diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-10-08 07:33:39 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-10-08 07:33:39 +0000 |
commit | bb69c602cc2f10c794154716803997b4be82629b (patch) | |
tree | 2cde5c3c1bc187a00aeb76666582721b702642d7 /sys | |
parent | 041e9d82c7484cc50036fc56939903735506cdf5 (diff) |
Prototype & Stylistic fixes for high -W gcc levels
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/fil.c | 87 | ||||
-rw-r--r-- | sys/netinet/in_proto.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_fil.c | 178 | ||||
-rw-r--r-- | sys/netinet/ip_fil.h | 20 | ||||
-rw-r--r-- | sys/netinet/ip_fil_compat.h | 2 | ||||
-rw-r--r-- | sys/netinet/ip_frag.c | 41 | ||||
-rw-r--r-- | sys/netinet/ip_frag.h | 9 | ||||
-rw-r--r-- | sys/netinet/ip_nat.c | 83 | ||||
-rw-r--r-- | sys/netinet/ip_nat.h | 13 | ||||
-rw-r--r-- | sys/netinet/ip_state.c | 34 | ||||
-rw-r--r-- | sys/netinet/ip_state.h | 11 |
11 files changed, 304 insertions, 178 deletions
diff --git a/sys/netinet/fil.c b/sys/netinet/fil.c index 4cba4d8af2d..2c0f77c1cba 100644 --- a/sys/netinet/fil.c +++ b/sys/netinet/fil.c @@ -5,9 +5,11 @@ * provided that this notice is preserved and due credit is given * to the original author and the contributors. */ +#if 0 #ifndef lint static char sccsid[] = "@(#)fil.c 1.36 6/5/96 (C) 1993-1996 Darren Reed"; -static char rcsid[] = "$Id: fil.c,v 1.5 1996/07/18 05:00:55 dm Exp $"; +static char rcsid[] = "$OpenBSD: fil.c,v 1.6 1996/10/08 07:33:24 niklas Exp $"; +#endif #endif #include <sys/errno.h> @@ -45,8 +47,8 @@ static char rcsid[] = "$Id: fil.c,v 1.5 1996/07/18 05:00:55 dm Exp $"; #include <netinet/udp.h> #include <netinet/tcpip.h> #include <netinet/ip_icmp.h> -#include "ip_fil.h" #include "ip_fil_compat.h" +#include "ip_fil.h" #include "ip_nat.h" #include "ip_frag.h" #include "ip_state.h" @@ -72,7 +74,6 @@ extern void debug(), verbose(); #define FR_IFDEBUG(ex,second,verb_pr) ; #define FR_VERBOSE(verb_pr) #define FR_DEBUG(verb_pr) -extern int send_reset(); # if SOLARIS extern int icmp_error(); extern kmutex_t ipf_mutex; @@ -80,7 +81,7 @@ extern kmutex_t ipf_mutex; # else # define FR_SCANLIST(p, ip, fi, m) fr_scanlist(p, ip, fi, m) # endif -extern int ipl_unreach, ipllog(); +extern int ipl_unreach; #endif #if SOLARIS @@ -90,7 +91,8 @@ extern int ipl_unreach, ipllog(); icmp_error(b, ip, t, c, if, src) #else # define IPLLOG(fl, ip, fi, m) ipllog(fl, ip, fi, m) -# define SEND_RESET(ip, if, q) send_reset(ip) +# define SEND_RESET(ip, if, q) send_reset( \ + (struct tcpiphdr *)ip) # if BSD < 199103 # define ICMP_ERROR(b, ip, t, c, if, src) \ icmp_error(mtod(b, ip_t *), t, c, if, src) @@ -107,6 +109,13 @@ int fr_flags = 0, fr_active = 0; fr_info_t frcache[2]; +void fr_makefrip __P((int, ip_t *, fr_info_t *)); +int fr_tcpudpchk __P((frentry_t *, fr_info_t *)); +#if (defined(_KERNEL) || defined(KERNEL)) && !SOLARIS +int fr_scanlist __P((int, ip_t *, fr_info_t *, void *)); +#else +int fr_scanlist __P((int, ip_t *, fr_info_t *)); +#endif /* * bit values for identifying presence of individual IP options @@ -153,10 +162,11 @@ struct optlist secopt[8] = { * compact the IP header into a structure which contains just the info. * which is useful for comparing IP headers with. */ -void fr_makefrip(hlen, ip, fin) -int hlen; -ip_t *ip; -fr_info_t *fin; +void +fr_makefrip(hlen, ip, fin) + int hlen; + ip_t *ip; + fr_info_t *fin; { struct optlist *op; tcphdr_t *tcp; @@ -272,9 +282,10 @@ getports: /* * check an IP packet for TCP/UDP characteristics such as ports and flags. */ -int fr_tcpudpchk(fr, fin) -frentry_t *fr; -fr_info_t *fin; +int +fr_tcpudpchk(fr, fin) + frentry_t *fr; + fr_info_t *fin; { register u_short po, tup; register char i; @@ -365,11 +376,17 @@ fr_info_t *fin; * Could be per interface, but this gets real nasty when you don't have * kernel sauce. */ -int fr_scanlist(pass, ip, fin, m) -int pass; -ip_t *ip; -register fr_info_t *fin; -void *m; +int +fr_scanlist(pass, ip, fin +#if (defined(_KERNEL) || defined(KERNEL)) && !SOLARIS + , m) + void *m; +#else + ) +#endif + int pass; + ip_t *ip; + register fr_info_t *fin; { register struct frentry *fr; register fr_ip_t *fi = &fin->fin_fi; @@ -455,7 +472,7 @@ void *m; */ pass = fr->fr_flags; if ((pass & FR_CALLNOW) && fr->fr_func) - pass = (*fr->fr_func)(ip, fin); + pass = (*fr->fr_func)(pass, ip, fin); #ifdef IPFILTER_LOG if ((pass & FR_LOGMASK) == FR_LOG) { if (!IPLLOG(fr->fr_flags, ip, fin, m)) @@ -483,24 +500,25 @@ void *m; * check using source and destination addresses/pors in a packet whether * or not to pass it on or not. */ -int fr_check(ip, hlen, ifp, out +int +fr_check(ip, hlen, ifp, out #ifdef _KERNEL # if SOLARIS -, qif, q, mb) -qif_t *qif; -queue_t *q; -mblk_t *mb; + , qif, q, mb) + qif_t *qif; + queue_t *q; + mblk_t *mb; # else -, mp) -struct mbuf **mp; + , mp) + struct mbuf **mp; # endif #else -) + ) #endif -ip_t *ip; -int hlen; -struct ifnet *ifp; -int out; + ip_t *ip; + int hlen; + struct ifnet *ifp; + int out; { /* * The above really sucks, but short of writing a diff @@ -545,7 +563,14 @@ int out; if ((pass = ipfr_knownfrag(ip, fin))) { if ((pass & FR_KEEPSTATE)) { - if (fr_addstate(ip, hlen, pass) == -1) + /* + * XXX I don't know if changing hlen to fin is right, + * but at least that is typesafe. //niklas@appli.se + * + * old code was: + * if (fr_addstate(ip, hlen, pass) == -1) + */ + if (fr_addstate(ip, fin, pass) == -1) frstats[out].fr_bads++; else frstats[out].fr_ads++; diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 56387aaa7ca..295ca096960 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.5 1996/07/18 05:00:57 dm Exp $ */ +/* $OpenBSD: in_proto.c,v 1.6 1996/10/08 07:33:25 niklas Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -90,7 +90,7 @@ #endif /* MROUTING */ #ifdef IPFILTER -void iplinit(); +void iplinit __P((void)); #define ip_init iplinit #endif diff --git a/sys/netinet/ip_fil.c b/sys/netinet/ip_fil.c index 3296d114a42..e03aad0bc17 100644 --- a/sys/netinet/ip_fil.c +++ b/sys/netinet/ip_fil.c @@ -5,9 +5,11 @@ * provided that this notice is preserved and due credit is given * to the original author and the contributors. */ +#if 0 #ifndef lint static char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-1995 Darren Reed"; -static char rcsid[] = "$Id: ip_fil.c,v 1.5 1996/09/30 14:06:37 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ip_fil.c,v 1.6 1996/10/08 07:33:25 niklas Exp $"; +#endif #endif #ifndef linux @@ -39,8 +41,8 @@ static char rcsid[] = "$Id: ip_fil.c,v 1.5 1996/09/30 14:06:37 deraadt Exp $"; #include <netinet/ip_icmp.h> #include <syslog.h> #endif -#include "ip_fil.h" #include "ip_fil_compat.h" +#include "ip_fil.h" #include "ip_frag.h" #include "ip_nat.h" #include "ip_state.h" @@ -50,45 +52,37 @@ static char rcsid[] = "$Id: ip_fil.c,v 1.5 1996/09/30 14:06:37 deraadt Exp $"; extern fr_flags, fr_active; extern struct protosw inetsw[]; -extern int (*fr_checkp)(); +extern int (*fr_checkp) __P((ip_t *, int, struct ifnet *, int, + struct mbuf **)); #if BSD < 199306 -extern int ipfr_slowtimer(); -static int (*fr_saveslowtimo)(); +extern int ipfr_slowtimer __P((void)); +static int (*fr_saveslowtimo) __P((void)); extern int tcp_ttl; #else -extern void ipfr_slowtimer(); -static void (*fr_saveslowtimo)(); +extern void ipfr_slowtimer __P((void)); +static void (*fr_saveslowtimo) __P((void)); #endif int ipl_inited = 0; int ipl_unreach = ICMP_UNREACH_FILTER; -int send_reset(); #ifdef IPFILTER_LOG # define LOGSIZE 8192 -int ipllog(); static char iplbuf[LOGSIZE]; static caddr_t iplh = iplbuf, iplt = iplbuf; static int iplused = 0; #endif /* IPFILTER_LOG */ -static void frflush(); -static int frrequest(); static int iplbusy = 0; -static int (*fr_savep)(); +static int (*fr_savep) __P((ip_t *, int, struct ifnet *, int, + struct mbuf **)); #if _BSDI_VERSION >= 199510 # include <sys/device.h> # include <sys/conf.h> int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); -int iplopen __P((dev_t, int, int, struct proc *)); int iplclose __P((dev_t, int, int, struct proc *)); -# ifdef IPFILTER_LOG -int iplread __P((dev_t, struct uio *, int)); -# else -# define iplread noread -# endif -int iplioctl __P((dev_t, int, caddr_t, int, struct proc *)); +int iplopen __P((dev_t, int, int, struct proc *)); struct cfdriver iplcd = { NULL, "ipl", NULL, NULL, DV_DULL, 0 @@ -100,11 +94,41 @@ struct devsw iplsw = { nostrat, nodump, nopsize, 0, nostop }; +#else /* _BSDI_VERSION >= 199510 */ + +# ifndef linux +# ifdef IPFILTER_LOG +# if BSD >= 199306 +int iplread __P((dev_t, struct uio *, int)); +# else +int iplread __P((dev_t, struct uio *)); +# endif +# else +# define iplread noread +# endif +int iplclose __P((dev_t, int)); +int iplopen __P((dev_t, int)); +# endif /* linux */ +int iplioctl __P((dev_t, int, caddr_t, int)); + #endif /* _BSDI_VERSION >= 199510 */ +int iplattach __P((void)); +int ipldetach __P((void)); +void frzerostats __P((caddr_t)); +void frflush __P((caddr_t)); +int frrequest __P((int, caddr_t, int)); + +#ifndef IPFILTER_LKM +void iplinit __P((void)); +#endif /* !IPFILTER_LKM */ + #ifdef IPFILTER_LKM -int iplidentify(s) -char *s; +int iplidentify __P((char *)); + +int +iplidentify(s) + char *s; { if (strcmp(s, "ipl") == 0) return 1; @@ -113,7 +137,8 @@ char *s; #endif /* IPFILTER_LKM */ -int iplattach() +int +iplattach() { int s; @@ -133,7 +158,8 @@ int iplattach() } -int ipldetach() +int +ipldetach() { int s, i = FR_INQUE|FR_OUTQUE; @@ -163,8 +189,9 @@ int ipldetach() } -static void frzerostats(data) -caddr_t data; +void +frzerostats(data) + caddr_t data; { struct friostat fio; @@ -184,8 +211,9 @@ caddr_t data; } -static void frflush(data) -caddr_t data; +void +frflush(data) + caddr_t data; { struct frentry *f, **fp; int flags = *(int *)data, flushed = 0, set = fr_active; @@ -225,19 +253,20 @@ caddr_t data; /* * Filter ioctl interface. */ -int iplioctl(dev, cmd, data, mode +int +iplioctl(dev, cmd, data, mode #if _BSDI_VERSION >= 199510 -, p) -struct proc *p; + , p) + struct proc *p; #else -) + ) #endif -dev_t dev; -int cmd; -caddr_t data; -int mode; + dev_t dev; + int cmd; + caddr_t data; + int mode; { - int error = 0, s, unit, used; + int error = 0, s, unit; unit = minor(dev); if (unit != 0) @@ -366,9 +395,10 @@ int mode; } -static int frrequest(req, data, set) -int req, set; -caddr_t data; +int +frrequest(req, data, set) + int req, set; + caddr_t data; { register frentry_t *fp, *f, **fprev; register frentry_t **ftail; @@ -475,16 +505,17 @@ caddr_t data; /* * routines below for saving IP headers to buffer */ -int iplopen(dev, flags +int +iplopen(dev, flags #if _BSDI_VERSION >= 199510 -, devtype, p) -int devtype; -struct proc *p; + , devtype, p) + int devtype; + struct proc *p; #else -) + ) #endif -dev_t dev; -int flags; + dev_t dev; + int flags; { u_int min = minor(dev); @@ -494,16 +525,17 @@ int flags; } -int iplclose(dev, flags +int +iplclose(dev, flags #if _BSDI_VERSION >= 199510 -, devtype, p) -int devtype; -struct proc *p; + , devtype, p) + int devtype; + struct proc *p; #else -) + ) #endif -dev_t dev; -int flags; + dev_t dev; + int flags; { u_int min = minor(dev); @@ -520,13 +552,15 @@ int flags; * the filter lists. */ # if BSD >= 199306 -int iplread(dev, uio, ioflag) -int ioflag; +int +iplread(dev, uio, ioflag) + int ioflag; # else -int iplread(dev, uio) +int +iplread(dev, uio) # endif -dev_t dev; -register struct uio *uio; + dev_t dev; + register struct uio *uio; { register int ret, s; register size_t sz, sx; @@ -576,11 +610,12 @@ register struct uio *uio; #ifdef IPFILTER_LOG -int ipllog(flags, ip, fin, m) -u_int flags; -ip_t *ip; -register fr_info_t *fin; -struct mbuf *m; +int +ipllog(flags, ip, fin, m) + u_int flags; + ip_t *ip; + register fr_info_t *fin; + struct mbuf *m; { struct ipl_ci iplci; register size_t tail = 0; @@ -692,8 +727,9 @@ struct mbuf *m; * send_reset - this could conceivably be a call to tcp_respond(), but that * requires a large amount of setting up and isn't any more efficient. */ -int send_reset(ti) -struct tcpiphdr *ti; +int +send_reset(ti) + struct tcpiphdr *ti; { struct tcpiphdr *tp; struct ip *ip; @@ -753,6 +789,7 @@ struct tcpiphdr *ti; #ifndef IPFILTER_LKM +void iplinit() { /* (void) iplattach(); */ @@ -761,16 +798,17 @@ iplinit() #endif -void ipfr_fastroute(m0, fin, fdp) -struct mbuf *m0; -fr_info_t *fin; -frdest_t *fdp; +void +ipfr_fastroute(m0, fin, fdp) + struct mbuf *m0; + fr_info_t *fin; + frdest_t *fdp; { register struct ip *ip, *mhip; register struct mbuf *m = m0; register struct route *ro; struct ifnet *ifp = fdp->fd_ifp; - int len, off, error = 0, s; + int len, off, error = 0; int hlen = fin->fin_hlen; struct route iproute; struct sockaddr_in *dst; diff --git a/sys/netinet/ip_fil.h b/sys/netinet/ip_fil.h index c6a99edb2a0..031eb832254 100644 --- a/sys/netinet/ip_fil.h +++ b/sys/netinet/ip_fil.h @@ -6,7 +6,7 @@ * to the original author and the contributors. * * @(#)ip_fil.h 1.35 6/5/96 - * $Id: ip_fil.h,v 1.5 1996/09/30 14:06:38 deraadt Exp $ + * $OpenBSD: ip_fil.h,v 1.6 1996/10/08 07:33:26 niklas Exp $ */ #ifndef __IP_FIL_H__ @@ -148,7 +148,8 @@ typedef struct frentry { u_short fr_stop; /* top port for <> and >< */ u_short fr_dtop; /* top port for <> and >< */ u_long fr_flags; /* per-rule flags && options (see below) */ - int (*fr_func)(); /* call this function */ + int (*fr_func) __P((int, ip_t *, fr_info_t *)); + /* call this function */ char fr_icode; /* return ICMP code */ char fr_ifname[IFNAMSIZ]; struct frdest fr_tif; /* "to" interface */ @@ -328,15 +329,26 @@ typedef struct ipl_ci { #define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) -extern int fr_check(); extern fr_info_t frcache[]; #ifdef _KERNEL extern struct frentry *ipfilter[2][2], *ipacct[2][2]; extern struct filterstats frstats[]; + +#ifdef IPFILTER_LOG +extern int ipllog __P((u_int, ip_t *, fr_info_t *, struct mbuf *)); +#endif +extern int send_reset __P((struct tcpiphdr *)); +extern void ipfr_fastroute __P((struct mbuf *, fr_info_t *, frdest_t *)); # if SOLARIS +extern int fr_check(); extern int ipfsync(); -# endif +# else /* SOLARIS */ +extern int fr_check __P((ip_t *, int, struct ifnet *, int, + struct mbuf **)); +# endif /* SOLARIS */ +#else /* _KERNEL */ +extern int fr_check __P((ip_t *, int, struct ifnet *, int)); #endif /* _KERNEL */ #endif /* __IP_FIL_H__ */ diff --git a/sys/netinet/ip_fil_compat.h b/sys/netinet/ip_fil_compat.h index 70e30d11d8f..68caa3093c0 100644 --- a/sys/netinet/ip_fil_compat.h +++ b/sys/netinet/ip_fil_compat.h @@ -6,7 +6,7 @@ * to the original author and the contributors. * * @(#)ip_fil_compat.h 1.8 1/14/96 - * $Id: ip_fil_compat.h,v 1.1 1996/07/18 05:01:00 dm Exp $ + * $OpenBSD: ip_fil_compat.h,v 1.2 1996/10/08 07:33:26 niklas Exp $ */ #ifndef __IP_COMPAT_H_ diff --git a/sys/netinet/ip_frag.c b/sys/netinet/ip_frag.c index b193febd3e1..7c2514781d9 100644 --- a/sys/netinet/ip_frag.c +++ b/sys/netinet/ip_frag.c @@ -5,9 +5,11 @@ * provided that this notice is preserved and due credit is given * to the original author and the contributors. */ +#if 0 #ifndef lint static char sccsid[] = "@(#)ip_frag.c 1.11 3/24/96 (C) 1993-1995 Darren Reed"; -static char rcsid[] = "$Id: ip_frag.c,v 1.3 1996/07/18 05:01:02 dm Exp $"; +static char rcsid[] = "$OpenBSD: ip_frag.c,v 1.4 1996/10/08 07:33:27 niklas Exp $"; +#endif #endif #if !defined(_KERNEL) && !defined(KERNEL) @@ -16,6 +18,9 @@ static char rcsid[] = "$Id: ip_frag.c,v 1.3 1996/07/18 05:01:02 dm Exp $"; #endif #include <sys/errno.h> #include <sys/types.h> +#if defined(_KERNEL) || defined(KERNEL) +#include <sys/systm.h> +#endif #include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> @@ -46,8 +51,8 @@ static char rcsid[] = "$Id: ip_frag.c,v 1.3 1996/07/18 05:01:02 dm Exp $"; #include <netinet/tcpip.h> #include <netinet/ip_icmp.h> #include <syslog.h> -#include "ip_fil.h" #include "ip_fil_compat.h" +#include "ip_fil.h" #include "ip_frag.h" #include "ip_nat.h" #include "ip_state.h" @@ -67,8 +72,14 @@ extern kmutex_t ipf_frag; # endif #endif +# if BSD < 199306 +int ipfr_slowtimer __P((void)); +#else +void ipfr_slowtimer __P((void)); +#endif -ipfrstat_t *ipfr_fragstats() +ipfrstat_t * +ipfr_fragstats() { ipfr_stats.ifs_table = ipfr_heads; ipfr_stats.ifs_inuse = ipfr_inuse; @@ -80,10 +91,11 @@ ipfrstat_t *ipfr_fragstats() * add a new entry to the fragment cache, registering it as having come * through this box, with the result of the filter operation. */ -int ipfr_newfrag(ip, fin, pass) -ip_t *ip; -fr_info_t *fin; -int pass; +int +ipfr_newfrag(ip, fin, pass) + ip_t *ip; + fr_info_t *fin; + int pass; { ipfr_t **fp, *fr, frag; u_int idx; @@ -137,9 +149,10 @@ int pass; * check the fragment cache to see if there is already a record of this packet * with its filter result known. */ -int ipfr_knownfrag(ip, fin) -ip_t *ip; -fr_info_t *fin; +int +ipfr_knownfrag(ip, fin) + ip_t *ip; + fr_info_t *fin; { ipfr_t *f, frag; u_int idx; @@ -204,7 +217,8 @@ fr_info_t *fin; /* * Free memory in use by fragment state info. kept. */ -void ipfr_unload() +void +ipfr_unload() { ipfr_t **fp, *fr; int idx; @@ -230,10 +244,11 @@ void ipfr_unload() * of this being called twice per second. */ # if BSD < 199306 -int ipfr_slowtimer() +int #else -void ipfr_slowtimer() +void #endif +ipfr_slowtimer() { ipfr_t **fp, *fr; int s, idx; diff --git a/sys/netinet/ip_frag.h b/sys/netinet/ip_frag.h index 6780071aa6c..8ee30e677fe 100644 --- a/sys/netinet/ip_frag.h +++ b/sys/netinet/ip_frag.h @@ -6,7 +6,7 @@ * to the original author and the contributors. * * @(#)ip_frag.h 1.5 3/24/96 - * $Id: ip_frag.h,v 1.3 1996/07/18 05:01:03 dm Exp $ + * $OpenBSD: ip_frag.h,v 1.4 1996/10/08 07:33:27 niklas Exp $ */ #ifndef __IP_FRAG_H_ @@ -39,9 +39,10 @@ typedef struct ipfrstat { #define IPFR_CMPSZ (4 + 4 + 2 + 1 + 1) -extern ipfrstat_t *ipfr_fragstats(); -extern int ipfr_newfrag(), ipfr_knownfrag(); +extern ipfrstat_t *ipfr_fragstats __P((void)); +extern int ipfr_newfrag __P((ip_t *, fr_info_t *, int)); +extern int ipfr_knownfrag __P((ip_t *, fr_info_t *)); # ifdef _KERNEL -extern void ipfr_unload(); +extern void ipfr_unload __P((void)); # endif #endif /* __IP_FIL_H__ */ diff --git a/sys/netinet/ip_nat.c b/sys/netinet/ip_nat.c index b8b42874db4..56709cd0e69 100644 --- a/sys/netinet/ip_nat.c +++ b/sys/netinet/ip_nat.c @@ -21,9 +21,11 @@ * Missing from RFC 1631: ICMP header checksum recalculations. * */ +#if 0 #ifndef lint static char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed"; -static char rcsid[] = "$Id: ip_nat.c,v 1.4 1996/07/18 05:01:05 dm Exp $"; +static char rcsid[] = "$OpenBSD: ip_nat.c,v 1.5 1996/10/08 07:33:28 niklas Exp $"; +#endif #endif #if !defined(_KERNEL) && !defined(KERNEL) @@ -34,6 +36,9 @@ static char rcsid[] = "$Id: ip_nat.c,v 1.4 1996/07/18 05:01:05 dm Exp $"; #include <sys/errno.h> #include <sys/types.h> #include <sys/param.h> +#if defined(_KERNEL) || defined(KERNEL) +#include <sys/systm.h> +#endif #include <sys/file.h> #include <sys/ioctl.h> #include <sys/uio.h> @@ -63,8 +68,8 @@ static char rcsid[] = "$Id: ip_nat.c,v 1.4 1996/07/18 05:01:05 dm Exp $"; #include <netinet/tcpip.h> #include <netinet/ip_icmp.h> #include <syslog.h> -#include "ip_fil.h" #include "ip_fil_compat.h" +#include "ip_fil.h" #include "ip_nat.h" #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -83,6 +88,9 @@ extern kmutex_t ipf_nat; # endif #endif +int flush_nattable __P((void)); +int clear_natlist __P((void)); +nat_t *nat_new __P((ipnat_t *, ip_t *, int, u_short, int)); /* * How the NAT is organised and works. @@ -108,9 +116,10 @@ extern kmutex_t ipf_nat; /* * Handle ioctls which manipulate the NAT. */ -int nat_ioctl(data, cmd, mode) -caddr_t data; -int cmd, mode; +int +nat_ioctl(data, cmd, mode) + caddr_t data; + int cmd, mode; { register ipnat_t *nat, *n, **np; ipnat_t natd; @@ -215,7 +224,8 @@ int cmd, mode; /* * flush_nattable - clear the NAT table of all mapping entries. */ -int flush_nattable() +int +flush_nattable() { nat_t *nat, **natp; int i, j = 0; @@ -240,7 +250,8 @@ int flush_nattable() /* * clear_natlist - delete all entries in the active NAT mapping list. */ -int clear_natlist() +int +clear_natlist() { register ipnat_t *n, **np; int i = 0; @@ -256,12 +267,13 @@ int clear_natlist() /* * Create a new NAT table entry. */ -nat_t *nat_new(np, ip, hlen, flags, direction) -ipnat_t *np; -ip_t *ip; -int hlen; -u_short flags; -int direction; +nat_t * +nat_new(np, ip, hlen, flags, direction) + ipnat_t *np; + ip_t *ip; + int hlen; + u_short flags; + int direction; { register u_long sum1, sum2, sumd; u_short port = 0, sport = 0, dport = 0, nport = 0; @@ -412,8 +424,9 @@ int direction; * NB: these lookups don't lock access to the list, it assume it has already * been done! */ -nat_t *nat_lookupredir(np) -natlookup_t *np; +nat_t * +nat_lookupredir(np) + natlookup_t *np; { nat_t *nat; @@ -428,9 +441,10 @@ natlookup_t *np; } -nat_t *nat_lookupinip(ipaddr, sport) -struct in_addr ipaddr; -u_short sport; +nat_t * +nat_lookupinip(ipaddr, sport) + struct in_addr ipaddr; + u_short sport; { nat_t *nat; @@ -446,10 +460,11 @@ u_short sport; } -nat_t *nat_lookupoutip(np, ip, tcp) -register ipnat_t *np; -ip_t *ip; -tcphdr_t *tcp; +nat_t * +nat_lookupoutip(np, ip, tcp) + register ipnat_t *np; + ip_t *ip; + tcphdr_t *tcp; { struct in_addr ipaddr; u_short port = tcp->th_dport; @@ -478,10 +493,11 @@ tcphdr_t *tcp; * Packets going out on the external interface go through this. * Here, the source address requires alteration, if anything. */ -void ip_natout(ip, hlen, fin) -ip_t *ip; -int hlen; -fr_info_t *fin; +void +ip_natout(ip, hlen, fin) + ip_t *ip; + int hlen; + fr_info_t *fin; { register ipnat_t *np; register u_long ipa; @@ -589,10 +605,11 @@ fr_info_t *fin; * Packets coming in from the external interface go through this. * Here, the destination address requires alteration, if anything. */ -void ip_natin(ip, hlen, fin) -ip_t *ip; -int hlen; -fr_info_t *fin; +void +ip_natin(ip, hlen, fin) + ip_t *ip; + int hlen; + fr_info_t *fin; { register ipnat_t *np; register struct in_addr in; @@ -694,7 +711,8 @@ fr_info_t *fin; /* * Free all memory used by NAT structures allocated at runtime. */ -void ip_natunload() +void +ip_natunload() { register struct nat *nat, **natp; register struct ipnat *ipn, **ipnp; @@ -726,7 +744,8 @@ void ip_natunload() * Slowly expire held state for NAT entries. Timeouts are set in * expectation of this being called twice per second. */ -void ip_natexpire() +void +ip_natexpire() { register struct nat *nat, **natp; register int i; diff --git a/sys/netinet/ip_nat.h b/sys/netinet/ip_nat.h index 19ce04caa5a..fe5181ee5e7 100644 --- a/sys/netinet/ip_nat.h +++ b/sys/netinet/ip_nat.h @@ -6,7 +6,7 @@ * to the original author and the contributors. * * @(#)ip_nat.h 1.5 2/4/96 - * $Id: ip_nat.h,v 1.3 1996/07/18 05:01:06 dm Exp $ + * $Id: ip_nat.h,v 1.4 1996/10/08 07:33:29 niklas Exp $ */ #ifndef __IP_NAT_H_ @@ -98,7 +98,12 @@ typedef struct natstat { #define IPN_UDP 2 #define IPN_TCPUDP 3 -extern int nat_ioctl(); -extern nat_t *nat_lookupoutip(), *nat_lookupinip(), *nat_lookupredir(); -extern void ip_natout(), ip_natin(), ip_natunload(), ip_natexpire(); +extern int nat_ioctl __P((caddr_t, int, int)); +extern nat_t *nat_lookupoutip __P((ipnat_t *, ip_t *, tcphdr_t *)); +extern nat_t *nat_lookupinip __P((struct in_addr, u_short)); +extern nat_t *nat_lookupredir __P((natlookup_t *)); +extern void ip_natout __P((ip_t *, int, fr_info_t *)); +extern void ip_natin __P((ip_t *, int, fr_info_t *)); +extern void ip_natunload __P((void)); +extern void ip_natexpire __P((void)); #endif /* __IP_NAT_H__ */ diff --git a/sys/netinet/ip_state.c b/sys/netinet/ip_state.c index 946312cf4d7..52956b8c9e4 100644 --- a/sys/netinet/ip_state.c +++ b/sys/netinet/ip_state.c @@ -5,9 +5,11 @@ * provided that this notice is preserved and due credit is given * to the original author and the contributors. */ +#if 0 #ifndef lint static char sccsid[] = "@(#)ip_state.c 1.8 6/5/96 (C) 1993-1995 Darren Reed"; -static char rcsid[] = "$Id: ip_state.c,v 1.3 1996/07/18 05:01:08 dm Exp $"; +static char rcsid[] = "$OpenBSD: ip_state.c,v 1.4 1996/10/08 07:33:29 niklas Exp $"; +#endif #endif #if !defined(_KERNEL) && !defined(KERNEL) @@ -17,6 +19,9 @@ static char rcsid[] = "$Id: ip_state.c,v 1.3 1996/07/18 05:01:08 dm Exp $"; #ifndef linux #include <sys/errno.h> #include <sys/types.h> +#if defined(_KERNEL) || defined(KERNEL) +#include <sys/systm.h> +#endif #include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> @@ -48,8 +53,8 @@ static char rcsid[] = "$Id: ip_state.c,v 1.3 1996/07/18 05:01:08 dm Exp $"; #include <netinet/ip_icmp.h> #include <syslog.h> #endif -#include "ip_fil.h" #include "ip_fil_compat.h" +#include "ip_fil.h" #include "ip_state.h" #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -68,7 +73,8 @@ extern kmutex_t ipf_state; #endif -ips_stat_t *fr_statetstats() +ips_stat_t * +fr_statetstats() { ips_stats.iss_active = ips_num; ips_stats.iss_table = ips_table; @@ -84,10 +90,11 @@ ips_stat_t *fr_statetstats() /* * Create a new ipstate structure and hang it off the hash table. */ -int fr_addstate(ip, fin, pass) -ip_t *ip; -fr_info_t *fin; -u_int pass; +int +fr_addstate(ip, fin, pass) + ip_t *ip; + fr_info_t *fin; + u_int pass; { ipstate_t ips; register ipstate_t *is = &ips; @@ -189,9 +196,10 @@ u_int pass; /* * Check if a packet has a registered state. */ -int fr_checkstate(ip, fin) -ip_t *ip; -fr_info_t *fin; +int +fr_checkstate(ip, fin) + ip_t *ip; + fr_info_t *fin; { register struct in_addr dst, src; register ipstate_t *is, **isp; @@ -366,7 +374,8 @@ fr_info_t *fin; /* * Free memory in use by all state info. kept. */ -void fr_stateunload() +void +fr_stateunload() { register int i; register ipstate_t *is, **isp; @@ -385,7 +394,8 @@ void fr_stateunload() * Slowly expire held state for thingslike UDP and ICMP. Timeouts are set * in expectation of this being called twice per second. */ -void fr_timeoutstate() +void +fr_timeoutstate() { register int i; register ipstate_t *is, **isp; diff --git a/sys/netinet/ip_state.h b/sys/netinet/ip_state.h index b4aee7a4e14..5e0b34d3511 100644 --- a/sys/netinet/ip_state.h +++ b/sys/netinet/ip_state.h @@ -6,7 +6,7 @@ * to the original author and the contributors. * * @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed - * $Id: ip_state.h,v 1.2 1996/07/18 05:01:09 dm Exp $ + * $OpenBSD: ip_state.h,v 1.3 1996/10/08 07:33:30 niklas Exp $ */ #ifndef __IP_STATE_H__ #define __IP_STATE_H__ @@ -71,10 +71,11 @@ typedef struct ips_stat { ipstate_t **iss_table; } ips_stat_t; -extern ips_stat_t *fr_statetstats(); -extern int fr_addstate(), fr_checkstate(); -extern void fr_timeoutstate(); +extern ips_stat_t *fr_statetstats __P((void)); +extern int fr_addstate __P((ip_t *, fr_info_t *, u_int)); +extern int fr_checkstate __P((ip_t *, fr_info_t *)); +extern void fr_timeoutstate __P((void)); # ifdef _KERNEL -extern void fr_stateunload(); +extern void fr_stateunload __P((void)); # endif #endif /* __IP_STATE_H__ */ |