-/* $NetBSD: bpf.c,v 1.23 1995/09/27 18:30:37 thorpej Exp $ */
+/* $OpenBSD: bpf.c,v 1.2 1996/03/03 21:07:00 niklas Exp $ */
+/* $NetBSD: bpf.c,v 1.24 1996/02/13 21:59:53 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
#include <net/bpf.h>
#include <net/bpfdesc.h>
+#include <net/net_conf.h>
#include <sys/errno.h>
static void bpf_ifname __P((struct ifnet *, struct ifreq *));
static void bpf_mcopy __P((const void *, void *, size_t));
static int bpf_movein __P((struct uio *, int,
- struct mbuf **, struct sockaddr *));
+ struct mbuf **, struct sockaddr *));
+static void bpf_attachd __P((struct bpf_d *, struct bpf_if *));
+static void bpf_detachd __P((struct bpf_d *));
static int bpf_setif __P((struct bpf_d *, struct ifreq *));
static int bpf_setif __P((struct bpf_d *, struct ifreq *));
+#if BSD >= 199103
+int bpfselect __P((dev_t, int, struct proc *));
+#endif
static __inline void
bpf_wakeup __P((struct bpf_d *));
-static void catchpacket __P((struct bpf_d *, u_char *, size_t,
- size_t, void (*)(const void *, void *, size_t)));
+static void catchpacket __P((struct bpf_d *, u_char *, size_t, size_t,
+ void (*)(const void *, void *, size_t)));
static void reset_d __P((struct bpf_d *));
static int
*/
/* ARGSUSED */
int
-bpfopen(dev, flag)
+bpfopen(dev, flag, mode, p)
dev_t dev;
int flag;
+ int mode;
+ struct proc *p;
{
register struct bpf_d *d;
*/
/* ARGSUSED */
int
-bpfclose(dev, flag)
+bpfclose(dev, flag, mode, p)
dev_t dev;
int flag;
+ int mode;
+ struct proc *p;
{
register struct bpf_d *d = &bpf_dtab[minor(dev)];
register int s;
* bpfread - read next chunk of packets from buffers
*/
int
-bpfread(dev, uio)
+bpfread(dev, uio, ioflag)
dev_t dev;
register struct uio *uio;
+ int ioflag;
{
register struct bpf_d *d = &bpf_dtab[minor(dev)];
int error;
if (d->bd_async && d->bd_sig)
if (d->bd_pgid > 0)
gsignal (d->bd_pgid, d->bd_sig);
- else if (p = pfind (-d->bd_pgid))
+ else if ((p = pfind (-d->bd_pgid)) != NULL)
psignal (p, d->bd_sig);
#if BSD >= 199103
}
int
-bpfwrite(dev, uio)
+bpfwrite(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
+ int ioflag;
{
register struct bpf_d *d = &bpf_dtab[minor(dev)];
struct ifnet *ifp;
*/
/* ARGSUSED */
int
-bpfioctl(dev, cmd, addr, flag)
+bpfioctl(dev, cmd, addr, flag, p)
dev_t dev;
u_long cmd;
caddr_t addr;
int flag;
+ struct proc *p;
{
register struct bpf_d *d = &bpf_dtab[minor(dev)];
int s, error = 0;
char *s = ifp->if_name;
char *d = ifr->ifr_name;
- while (*d++ = *s++)
+ while ((*d++ = *s++) != '\0')
continue;
- /* XXX Assume that unit number is less than 10. */
- *d++ = ifp->if_unit + '0';
- *d = '\0';
+ sprintf(d, "%d", ifp->if_unit);
}
/*
-/* $NetBSD: bpf.h,v 1.12 1995/09/27 18:30:40 thorpej Exp $ */
+/* $OpenBSD: bpf.h,v 1.2 1996/03/03 21:07:02 niklas Exp $ */
+/* $NetBSD: bpf.h,v 1.13 1996/02/13 21:59:58 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
#ifdef _KERNEL
int bpf_validate __P((struct bpf_insn *, int));
-int bpfopen __P((dev_t, int));
-int bpfclose __P((dev_t, int));
-int bpfread __P((dev_t, struct uio *));
-int bpfwrite __P((dev_t, struct uio *));
-int bpfioctl __P((dev_t, u_long, caddr_t, int));
-int bpf_select __P((dev_t, int, struct proc *));
void bpf_tap __P((caddr_t, u_char *, u_int));
void bpf_mtap __P((caddr_t, struct mbuf *));
void bpfattach __P((caddr_t *, struct ifnet *, u_int, u_int));
-/* $NetBSD: bpf_filter.c,v 1.11 1995/04/22 13:26:39 cgd Exp $ */
+/* $OpenBSD: bpf_filter.c,v 1.3 1996/03/03 21:07:02 niklas Exp $ */
+/* $NetBSD: bpf_filter.c,v 1.12 1996/02/13 22:00:00 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993
} \
}
+static int m_xword __P((struct mbuf *, int, int *));
+static int m_xhalf __P((struct mbuf *, int, int *));
+
static int
m_xword(m, k, err)
register struct mbuf *m;
u_int wirelen;
register u_int buflen;
{
- register u_int32_t A, X;
+ register u_int32_t A = 0, X = 0;
register int k;
int32_t mem[BPF_MEMWORDS];
* No filter means accept all.
*/
return (u_int)-1;
-#ifdef lint
- A = 0;
- X = 0;
-#endif
--pc;
while (1) {
++pc;
-/* $NetBSD: bsd-comp.c,v 1.1 1995/07/04 06:28:17 paulus Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.2 1996/03/03 21:07:03 niklas Exp $ */
+/* $NetBSD: bsd-comp.c,v 1.2 1996/02/13 22:00:03 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
*
/*
* This version is for use with mbufs on BSD-derived systems.
*
- * $Id: bsd-comp.c,v 1.1.1.1 1995/10/18 08:53:05 deraadt Exp $
+ * $Id: bsd-comp.c,v 1.2 1996/03/03 21:07:03 niklas Exp $
*/
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <net/if.h>
#define RATIO_SCALE (1<<RATIO_SCALE_LOG)
#define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
+static void bsd_clear __P((struct bsd_db *));
+static int bsd_check __P((struct bsd_db *));
+static void *bsd_alloc __P((u_char *, int, int));
+static int bsd_init __P((struct bsd_db *, u_char *, int, int, int, int,
+ int, int));
+
/*
* clear the dictionary
*/
|| options[1] != CILEN_BSD_COMPRESS
|| BSD_VERSION(options[2]) != BSD_CURRENT_VERSION
|| BSD_NBITS(options[2]) != db->maxbits
- || decomp && db->lens == NULL)
+ || (decomp && db->lens == NULL))
return 0;
if (decomp) {
struct bsd_dict *dictp;
u_char c;
int hval, disp, ent, ilen;
- struct mbuf *np;
u_char *rptr, *wptr;
u_char *cp_end;
int olen;
- struct mbuf *m, **mnp;
+ struct mbuf *m;
#define PUTBYTE(v) { \
++olen; \
struct mbuf *m, *dmp, *mret;
int adrs, ctrl, ilen;
int space, codelen, extra;
- struct mbuf *last;
/*
* Save the address/control from the PPP header
}
if (incode > max_ent + 2 || incode > db->maxmaxcode
- || incode > max_ent && oldcode == CLEAR) {
+ || (incode > max_ent && oldcode == CLEAR)) {
m_freem(mret);
if (db->debug) {
printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
-/* $NetBSD: if.c,v 1.23 1995/08/12 23:59:19 mycroft Exp $ */
+/* $OpenBSD: if.c,v 1.4 1996/03/03 21:07:04 niklas Exp $ */
+/* $NetBSD: if.c,v 1.24 1996/02/13 22:00:09 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
+#include <net/radix.h>
int ifqmaxlen = IFQ_MAXLEN;
void if_slowtimo __P((void *arg));
register struct sockaddr_dl *sdl;
register struct ifaddr *ifa;
static int if_indexlim = 8;
- extern void link_rtrequest();
if (if_index == 0)
TAILQ_INIT(&ifnet);
if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == 0) ||
((ifp = ifa->ifa_ifp) == 0) || ((dst = rt_key(rt)) == 0))
return;
- if (ifa = ifaof_ifpforaddr(dst, ifp)) {
+ if ((ifa = ifaof_ifpforaddr(dst, ifp)) != NULL) {
IFAFREE(rt->rt_ifa);
rt->rt_ifa = ifa;
ifa->ifa_refcnt++;
if_up(ifp)
register struct ifnet *ifp;
{
+#ifdef notyet
register struct ifaddr *ifa;
+#endif
ifp->if_flags |= IFF_UP;
#ifdef notyet
/* this has no effect on IP, and will kill all ISO connections XXX */
- for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next)
+ for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
+ ifa = ifa->ifa_list.tqe_next)
pfctlinput(PRC_IFUP, ifa->ifa_addr);
#endif
rt_ifmsg(ifp);
register struct mbuf *m, *n;
n = ifq->ifq_head;
- while (m = n) {
+ while ((m = n) != NULL) {
n = m->m_act;
m_freem(m);
}
break;
case SIOCSIFFLAGS:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (ifp->if_flags & IFF_UP && (ifr->ifr_flags & IFF_UP) == 0) {
int s = splimp();
break;
case SIOCSIFMETRIC:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
ifp->if_metric = ifr->ifr_metric;
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (ifp->if_ioctl == 0)
return (EOPNOTSUPP);
case OSIOCGIFNETMASK:
cmd = SIOCGIFNETMASK;
}
- error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
- cmd, data, ifp));
+ error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
+ (struct mbuf *) cmd,
+ (struct mbuf *) data,
+ (struct mbuf *) ifp));
switch (ocmd) {
case OSIOCGIFADDR:
-/* $NetBSD: if.h,v 1.19 1995/06/19 21:57:28 cgd Exp $ */
+/* $OpenBSD: if.h,v 1.2 1996/03/03 21:07:06 niklas Exp $ */
+/* $NetBSD: if.h,v 1.20 1996/02/13 22:00:12 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct ifnet *ifa_ifp; /* back-pointer to interface */
TAILQ_ENTRY(ifaddr) ifa_list; /* list of addresses for interface */
- void (*ifa_rtrequest)(); /* check or clean routes (+ or -)'d */
+ void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
+ __P((int, struct rtentry *, struct sockaddr *));
u_short ifa_flags; /* mostly rt_flags for cloning */
short ifa_refcnt; /* count of references */
int ifa_metric; /* cost of going out this interface */
-/* $NetBSD: if_ethersubr.c,v 1.17 1995/12/24 03:33:43 mycroft Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.3 1996/03/03 21:07:07 niklas Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.18 1996/02/13 22:00:14 christos Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
ifp->if_lastchange = time;
- if (rt = rt0) {
+ if ((rt = rt0) != NULL) {
if ((rt->rt_flags & RTF_UP) == 0) {
- if (rt0 = rt = rtalloc1(dst, 1))
+ if ((rt0 = rt = rtalloc1(dst, 1)) != NULL)
rt->rt_refcnt--;
else
senderr(EHOSTUNREACH);
if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen > 0) {
bcopy(LLADDR(sdl), (caddr_t)edst, sizeof(edst));
- } else if (error =
- iso_snparesolve(ifp, (struct sockaddr_iso *)dst,
- (char *)edst, &snpalen))
- goto bad; /* Not Resolved */
+ } else {
+ error = iso_snparesolve(ifp, (struct sockaddr_iso *)dst,
+ (char *)edst, &snpalen);
+ if (error)
+ goto bad; /* Not Resolved */
+ }
/* If broadcasting on a simplex interface, loopback a copy */
if (*edst & 1)
m->m_flags |= (M_BCAST|M_MCAST);
l = mtod(m, struct llc *);
l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
l->llc_control = LLC_UI;
- IFDEBUG(D_ETHER)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_ETHER]) {
int i;
printf("unoutput: sending pkt to: ");
for (i=0; i<6; i++)
printf("%x ", edst[i] & 0xff);
printf("\n");
- ENDDEBUG
+ }
+#endif
} break;
#endif /* ISO */
#ifdef LLC
struct mbuf *m;
{
register struct ifqueue *inq;
- register struct llc *l;
u_int16_t etype;
- struct arpcom *ac = (struct arpcom *)ifp;
int s;
+#if defined (ISO) || defined (LLC)
+ register struct llc *l;
+ struct arpcom *ac = (struct arpcom *)ifp;
+#endif
if ((ifp->if_flags & IFF_UP) == 0) {
m_freem(m);
if (m == 0)
return;
*mtod(m, struct ether_header *) = *eh;
- IFDEBUG(D_ETHER)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_ETHER])
printf("clnp packet");
- ENDDEBUG
+#endif
schednetisr(NETISR_ISO);
inq = &clnlintrq;
break;
register struct arpcom *ac;
{
register struct ether_multi *enm;
- register struct ether_multi **p;
struct sockaddr_in *sin;
u_char addrlo[6];
u_char addrhi[6];
-/* $NetBSD: if_ppp.c,v 1.24 1995/10/05 05:55:09 mycroft Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.4 1996/03/03 21:07:07 niklas Exp $ */
+/* $NetBSD: if_ppp.c,v 1.28 1996/02/13 22:00:18 christos Exp $ */
/*
* if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/kernel.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/ppp-comp.h>
#endif
-void pppattach __P((void));
-int pppioctl __P((struct ppp_softc *sc, u_long cmd, caddr_t data, int flag,
- struct proc *));
-int pppoutput __P((struct ifnet *ifp, struct mbuf *m0,
- struct sockaddr *dst, struct rtentry *rtp));
-int pppsioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data));
-void pppintr __P((void));
-
static void ppp_requeue __P((struct ppp_softc *));
static void ppp_outpkt __P((struct ppp_softc *));
-static int ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
+static void ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd));
static void ppp_ccp_closed __P((struct ppp_softc *));
static void ppp_inproc __P((struct ppp_softc *, struct mbuf *));
static void pppdumpm __P((struct mbuf *m0));
break;
case PPPIOCSFLAGS:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
flags = *(int *)data & SC_MASK;
s = splsoftnet();
break;
case PPPIOCSMRU:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
mru = *(int *)data;
if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
#ifdef VJC
case PPPIOCSMAXCID:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
s = splsoftnet();
sl_compress_init(&sc->sc_comp, *(int *)data);
#endif
case PPPIOCXFERUNIT:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
sc->sc_xfer = p->p_pid;
break;
#ifdef PPP_COMPRESS
case PPPIOCSCOMPRESS:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
odp = (struct ppp_option_data *) data;
nb = odp->length;
if (nb > sizeof(ccp_option))
nb = sizeof(ccp_option);
- if (error = copyin(odp->ptr, ccp_option, nb))
+ if ((error = copyin(odp->ptr, ccp_option, nb)) != 0)
return (error);
if (ccp_option[1] < 2) /* preliminary check on the length byte */
return (EINVAL);
if (cmd == PPPIOCGNPMODE) {
npi->mode = sc->sc_npmode[npx];
} else {
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (npi->mode != sc->sc_npmode[npx]) {
s = splsoftnet();
break;
case SIOCSIFMTU:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
break;
sc->sc_if.if_mtu = ifr->ifr_mtu;
break;
struct rtentry *rtp;
{
register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
- struct ppp_header *ph;
int protocol, address, control;
u_char *cp;
int s, error;
enum NPmode mode;
if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
- || (ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC) {
+ || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
error = ENETDOWN; /* sort of */
goto bad;
}
ppp_outpkt(sc)
struct ppp_softc *sc;
{
- int s;
struct mbuf *m, *mp;
u_char *cp;
int address, control, protocol;
- enum NPmode mode;
/*
* Grab a packet to send: first try the fast queue, then the
* Handle a CCP packet. `rcvd' is 1 if the packet was received,
* 0 if it is about to be transmitted.
*/
-static int
+static void
ppp_ccp(sc, m, rcvd)
struct ppp_softc *sc;
struct mbuf *m;
slen = CCP_LENGTH(dp);
if (dp + slen > ep) {
if (sc->sc_flags & SC_DEBUG)
- printf("if_ppp/ccp: not enough data in mbuf (%x+%x > %x+%x)\n",
+ printf("if_ppp/ccp: not enough data in mbuf (%p+%x > %p+%x)\n",
dp, slen, mtod(mp, u_char *), mp->m_len);
return;
}
{
struct ifnet *ifp = &sc->sc_if;
struct ifqueue *inq;
- int s, ilen, xlen, proto, rv;
+ int s, ilen = 0, xlen, proto, rv;
u_char *cp, adrs, ctrl;
struct mbuf *mp, *dmp;
u_char *iphdr;
ifp->if_lastchange = time;
if (sc->sc_flags & SC_LOG_INPKT) {
- printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen);
+ register int len = 0;
+ for (mp = m; mp != NULL; mp = mp->m_next)
+ len += mp->m_len;
+ printf("ppp%d: got %d bytes\n", ifp->if_unit, len);
pppdumpm(m);
}
-/* $NetBSD: if_ppp.h,v 1.9 1995/07/04 06:28:22 paulus Exp $ */
+/* $OpenBSD: if_ppp.h,v 1.2 1996/03/03 21:07:09 niklas Exp $ */
+/* $NetBSD: if_ppp.h,v 1.10 1996/02/13 22:00:21 christos Exp $ */
/*
* if_ppp.h - Point-to-Point Protocol definitions.
#if !defined(ifr_mtu)
#define ifr_mtu ifr_ifru.ifru_metric
#endif
-
+#ifdef _KERNEL
+void pppattach __P((void));
+struct ppp_softc *pppalloc __P((pid_t));
+void pppdealloc __P((struct ppp_softc *));
+int pppioctl __P((struct ppp_softc *, u_long, caddr_t, int, struct proc *));
+int pppsioctl __P((struct ifnet *, u_long, caddr_t));
+int pppoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
+ struct rtentry *));
+struct mbuf *ppp_dequeue __P((struct ppp_softc *));
+void pppintr __P((void));
+void ppppktin __P((struct ppp_softc *, struct mbuf *, int));
+#endif
#endif /* _IF_PPP_H_ */
-/* $NetBSD: if_sl.c,v 1.37 1995/08/12 23:59:22 mycroft Exp $ */
+/* $OpenBSD: if_sl.c,v 1.2 1996/03/03 21:07:10 niklas Exp $ */
+/* $NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
/*
* Copyright (c) 1987, 1989, 1992, 1993
#include <sys/tty.h>
#include <sys/kernel.h>
#include <sys/conf.h>
+#if __NetBSD__
+#include <sys/systm.h>
+#endif
#include <machine/cpu.h>
int s;
#endif
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if (tp->t_line == SLIPDISC)
struct mbuf *m2;
#if NBPFILTER > 0
u_char bpfbuf[SLMTU + SLIP_HDRLEN];
- register int len;
+ register int len = 0;
#endif
#ifndef NetBSD /* XXX - cgd */
extern int cfreecount;
bcopy(mtod(m1, caddr_t), cp, mlen);
cp += mlen;
len += mlen;
- } while (m1 = m1->m_next);
+ } while ((m1 = m1->m_next) != NULL);
}
#endif
if ((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP) {
#endif
sc->sc_if.if_lastchange = time;
-#ifndef NetBSD /* XXX - cgd */
+#ifndef __NetBSD__ /* XXX - cgd */
/*
* If system is getting low on clists, just flush our
* output queue (if the stuff was important, it'll get
sc->sc_if.if_collisions++;
continue;
}
-#endif /* !NetBSD */
+#endif /* !__NetBSD__ */
/*
* The extra FRAME_END will start up a new packet, and thus
* will flush any accumulated garbage. We do this whenever
* Put n characters at once
* into the tty output queue.
*/
-#ifdef NetBSD /* XXX - cgd */
+#ifdef __NetBSD__ /* XXX - cgd */
if (b_to_q((u_char *)bp, cp - bp,
#else
if (b_to_q((char *)bp, cp - bp,
-/* $OpenBSD: if_tun.c,v 1.4 1996/02/21 12:50:02 mickey Exp $ */
+/* $OpenBSD: if_tun.c,v 1.5 1996/03/03 21:07:11 niklas Exp $ */
+/* $NetBSD: if_tun.c,v 1.22 1996/02/13 22:00:26 christos Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
* in any changes that are made.
*
* This driver takes packets off the IP i/f and hands them up to a
- * user process to have it's wicked way with. This driver has it's
+ * user process to have its wicked way with. This driver has its
* roots in a similar driver written by Phil Cockcroft (formerly) at
* UCL. This driver is based much more on read/write/select mode of
* operation though.
#include <sys/file.h>
#include <sys/time.h>
#include <sys/device.h>
-#include <sys/conf.h>
#include <sys/vnode.h>
+#include <sys/signalvar.h>
#include <machine/cpu.h>
#endif
#include <net/if_tun.h>
+#include <net/net_conf.h>
#ifdef TUN_DEBUG
int tundebug = TUN_DEBUG;
extern int ifqmaxlen;
-int tunopen __P((dev_t, int, int, struct proc *));
-int tunclose __P((dev_t, int, int, struct proc *));
-int tunoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *,
- struct rtentry *rt));
-int tunread __P((dev_t, struct uio *, int));
-int tunwrite __P((dev_t, struct uio *, int));
-int tunioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
-int tunifioctl __P((struct ifnet *, u_long, caddr_t));
-int tunselect __P((dev_t, int, struct proc *));
-void tunattach __P((int));
+void tunattach __P((int));
+int tunopen __P((dev_t, int, int, struct proc *));
+int tunclose __P((dev_t, int, int, struct proc *));
+int tun_ioctl __P((struct ifnet *, u_long, caddr_t));
+int tun_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
+ struct rtentry *rt));
+int tunioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
+int tunread __P((dev_t, struct uio *, int));
+int tunwrite __P((dev_t, struct uio *, int));
+int tunselect __P((dev_t, int, struct proc *));
+
static int tuninit __P((int));
{
register int i;
struct ifnet *ifp;
- struct sockaddr_in *sin;
for (i = 0; i < NTUN; i++) {
tunctl[i].tun_flags = TUN_INITED;
ifp->if_unit = i;
ifp->if_name = "tun";
ifp->if_mtu = TUNMTU;
- ifp->if_ioctl = tunifioctl;
- ifp->if_output = tunoutput;
+ ifp->if_ioctl = tun_ioctl;
+ ifp->if_output = tun_output;
ifp->if_flags = IFF_POINTOPOINT;
ifp->if_type = IFT_PROPVIRTUAL;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
struct tun_softc *tp;
register int unit, error;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
if ((unit = minor(dev)) >= NTUN)
int
tunclose(dev, flag, mode, p)
dev_t dev;
- int flag,mode;
+ int flag;
+ int mode;
struct proc *p;
{
register int unit = minor(dev), s;
* Process an ioctl request.
*/
int
-tunifioctl(ifp, cmd, data)
+tun_ioctl(ifp, cmd, data)
struct ifnet *ifp;
u_long cmd;
caddr_t data;
{
- struct tun_softc *tp = &tunctl[ifp->if_unit];
int error = 0, s;
s = splimp();
}
/*
- * tunoutput - queue packets from higher level ready to put out.
+ * tun_output - queue packets from higher level ready to put out.
*/
int
-tunoutput(ifp, m0, dst, rt)
+tun_output(ifp, m0, dst, rt)
struct ifnet *ifp;
struct mbuf *m0;
struct sockaddr *dst;
struct proc *p;
int s;
- TUNDEBUG(("%s%d: tunoutput\n", ifp->if_name, ifp->if_unit));
+ TUNDEBUG(("%s%d: tun_output\n", ifp->if_name, ifp->if_unit));
if ((tp->tun_flags & TUN_READY) != TUN_READY) {
TUNDEBUG(("%s%d: not ready 0%o\n", ifp->if_name,
if (tp->tun_flags & TUN_ASYNC && tp->tun_pgrp) {
if (tp->tun_pgrp > 0)
gsignal(tp->tun_pgrp, SIGIO);
- else if (p = pfind(-tp->tun_pgrp))
+ else if ((p = pfind(-tp->tun_pgrp)) != NULL)
psignal(p, SIGIO);
}
selwakeup(&tp->tun_rsel);
* least as much of a packet as can be read.
*/
int
-tunread(dev, uio,flags)
+tunread(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
- int flags;
+ int ioflag;
{
int unit = minor(dev);
struct tun_softc *tp = &tunctl[unit];
do {
IF_DEQUEUE(&ifp->if_snd, m0);
if (m0 == 0) {
- if (tp->tun_flags & TUN_NBIO && flags & IO_NDELAY) {
+ if (tp->tun_flags & TUN_NBIO && ioflag & IO_NDELAY) {
splx(s);
return EWOULDBLOCK;
}
* the cdevsw write interface - an atomic write is a packet - or else!
*/
int
-tunwrite(dev, uio, flags)
+tunwrite(dev, uio, ioflag)
dev_t dev;
struct uio *uio;
- int flags;
+ int ioflag;
{
int unit = minor (dev);
struct ifnet *ifp = &tunctl[unit].tun_if;
*/
int
tunselect(dev, rw, p)
- dev_t dev;
+ dev_t dev;
int rw;
- struct proc *p;
+ struct proc *p;
{
int unit = minor(dev), s;
struct tun_softc *tp = &tunctl[unit];
--- /dev/null
+/* $OpenBSD: net_conf.h,v 1.1 1996/03/03 21:07:11 niklas Exp $ */
+/* $NetBSD: net_conf.h,v 1.1 1996/02/13 22:00:28 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/conf.h>
+
+#include "bpfilter.h"
+cdev_decl(bpf);
+
+#include "tun.h"
+cdev_decl(tun);
-/* $NetBSD: ppp_tty.c,v 1.3 1995/10/05 05:55:14 mycroft Exp $ */
+/* $OpenBSD: ppp_tty.c,v 1.2 1996/03/03 21:07:12 niklas Exp $ */
+/* $NetBSD: ppp_tty.c,v 1.4 1996/02/13 22:00:30 christos Exp $ */
/*
* ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/vnode.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/if_types.h>
{
struct proc *p = curproc; /* XXX */
register struct ppp_softc *sc;
- int error, s, i;
+ int error, s;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
s = spltty();
int flag;
{
register struct ppp_softc *sc;
- struct mbuf *m;
int s;
s = spltty();
splx(s);
for (m = m0; m && uio->uio_resid; m = m->m_next)
- if (error = uiomove(mtod(m, u_char *), m->m_len, uio))
+ if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0)
break;
m_freem(m0);
return (error);
len = M_TRAILINGSPACE(m);
if (len > uio->uio_resid)
len = uio->uio_resid;
- if (error = uiomove(mtod(m, u_char *), len, uio)) {
+ if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
m_freem(m0);
return (error);
}
error = 0;
switch (cmd) {
case PPPIOCSASYNCMAP:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
break;
sc->sc_asyncmap[0] = *(u_int *)data;
break;
break;
case PPPIOCSRASYNCMAP:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
break;
sc->sc_rasyncmap = *(u_int *)data;
break;
break;
case PPPIOCSXASYNCMAP:
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
break;
s = spltty();
bcopy(data, sc->sc_asyncmap, sizeof(sc->sc_asyncmap));
register struct mbuf *m;
register int len;
register u_char *start, *stop, *cp;
- int n, s, ndone, done, idle;
+ int n, ndone, done, idle;
struct mbuf *m2;
- if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0
+ if (((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
|| sc == NULL || tp != (struct tty *) sc->sc_devp) {
if (tp->t_oproc != NULL)
(*tp->t_oproc)(tp);
* abort sequence "}~".
*/
if (sc->sc_flags & (SC_FLUSH | SC_ESCAPED)
- || ilen > 0 && sc->sc_fcs != PPP_GOODFCS) {
+ || (ilen > 0 && sc->sc_fcs != PPP_GOODFCS)) {
sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
if (sc->sc_flags & SC_DEBUG)
if (c >= 0)
sc->sc_rawin[sc->sc_rawin_count++] = c;
if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
- || c < 0 && sc->sc_rawin_count > 0) {
+ || (c < 0 && sc->sc_rawin_count > 0)) {
printf("ppp%d input: ", sc->sc_if.if_unit);
pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
sc->sc_rawin_count = 0;
-/* $NetBSD: radix.c,v 1.9 1995/05/17 15:50:06 mycroft Exp $ */
+/* $OpenBSD: radix.c,v 1.2 1996/03/03 21:07:14 niklas Exp $ */
+/* $NetBSD: radix.c,v 1.10 1996/02/13 22:00:32 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1993
#define rn_masktop (mask_rnhead->rnh_treetop)
#undef Bcmp
#define Bcmp(a, b, l) (l == 0 ? 0 : bcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))
+
+
+static int rn_satsifies_leaf __P((char *, struct radix_node *, int));
+static int rn_lexobetter __P((void *, void *));
+static struct radix_mask *rn_new_radix_mask __P((struct radix_node *,
+ struct radix_mask *));
/*
* The data structure for the keys is a radix tree with one way
* branching removed. The index rn_b at an internal node n represents a bit
return x;
}
-static
+static int
rn_satsifies_leaf(trial, leaf, skip)
char *trial;
register struct radix_node *leaf;
do {
register struct radix_mask *m;
t = t->rn_p;
- if (m = t->rn_mklist) {
+ if ((m = t->rn_mklist) != NULL) {
/*
* If non-contiguous masks ever become important
* we can restore the masking and open coding of
if (x && rn_satsifies_leaf(v, x, off))
return x;
}
- } while (m = m->rm_mklist);
+ } while ((m = m->rm_mklist) != NULL);
}
} while (t != top);
return 0;
struct radix_node treenodes[2];
{
caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg;
- register struct radix_node *t, *x, *tt;
+ register struct radix_node *t, *x = NULL, *tt;
struct radix_node *saved_tt, *top = head->rnh_treetop;
- short b = 0, b_leaf;
+ short b = 0, b_leaf = 0;
int keyduplicated;
caddr_t mmask;
struct radix_mask *m, **mp;
if (x->rn_b < 0) {
for (mp = &t->rn_mklist; x; x = x->rn_dupedkey)
if (x->rn_mask && (x->rn_b >= b_leaf) && x->rn_mklist == 0) {
- if (*mp = m = rn_new_radix_mask(x, 0))
+ *mp = m = rn_new_radix_mask(x, 0);
+ if (m)
mp = &m->rm_mklist;
}
} else if (x->rn_mklist) {
/*
* Skip over masks whose index is > that of new node
*/
- for (mp = &x->rn_mklist; m = *mp; mp = &m->rm_mklist)
+ for (mp = &x->rn_mklist; (m = *mp) != NULL; mp = &m->rm_mklist)
if (m->rm_b >= b_leaf)
break;
t->rn_mklist = m; *mp = 0;
* Need same criteria as when sorting dupedkeys to avoid
* double loop on deletion.
*/
- for (mp = &x->rn_mklist; m = *mp; mp = &m->rm_mklist) {
+ for (mp = &x->rn_mklist; (m = *mp) != NULL; mp = &m->rm_mklist) {
if (m->rm_b < b_leaf)
continue;
if (m->rm_b > b_leaf)
x = t;
t = t->rn_p;
} while (b <= t->rn_b && x != top);
- for (mp = &x->rn_mklist; m = *mp; mp = &m->rm_mklist)
+ for (mp = &x->rn_mklist; (m = *mp) != NULL; mp = &m->rm_mklist)
if (m == saved_m) {
*mp = m->rm_mklist;
MKFree(m);
if (t) t->rn_ybro = tt->rn_ybro;
#endif
t = tt->rn_p;
- if (dupedkey = saved_tt->rn_dupedkey) {
+ if ((dupedkey = saved_tt->rn_dupedkey) != 0) {
if (tt == saved_tt) {
x = dupedkey; x->rn_p = t;
if (t->rn_l == tt) t->rn_l = x; else t->rn_r = x;
*/
if (t->rn_mklist) {
if (x->rn_b >= 0) {
- for (mp = &x->rn_mklist; m = *mp;)
+ for (mp = &x->rn_mklist; (m = *mp) != NULL;)
mp = &m->rm_mklist;
*mp = t->rn_mklist;
} else {
int
rn_walktree(h, f, w)
struct radix_node_head *h;
- register int (*f)();
+ register int (*f) __P((struct radix_node *, void *));
void *w;
{
int error;
rn = rn->rn_l;
next = rn;
/* Process leaves */
- while (rn = base) {
+ while ((rn = base) != NULL) {
base = rn->rn_dupedkey;
if (!(rn->rn_flags & RNF_ROOT) && (error = (*f)(rn, w)))
return (error);
-/* $NetBSD: radix.h,v 1.7 1995/05/17 15:50:08 mycroft Exp $ */
+/* $OpenBSD: radix.h,v 1.2 1996/03/03 21:07:15 niklas Exp $ */
+/* $NetBSD: radix.h,v 1.8 1996/02/13 22:00:37 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1993
struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */
__P((void *v, struct radix_node_head *head));
int (*rnh_walktree) /* traverse tree */
- __P((struct radix_node_head *head, int (*f)(), void *w));
+ __P((struct radix_node_head *,
+ int (*)(struct radix_node *, void *), void *));
struct radix_node rnh_nodes[3]; /* empty tree for common case */
};
void rn_init __P((void));
int rn_inithead __P((void **, int));
int rn_refines __P((void *, void *));
-int rn_walktree __P((struct radix_node_head *, int (*)(), void *));
+int rn_walktree __P((struct radix_node_head *,
+ int (*)(struct radix_node *, void *), void *));
struct radix_node
*rn_addmask __P((void *, int, int)),
*rn_addroute __P((void *, void *, struct radix_node_head *,
-/* $NetBSD: raw_cb.c,v 1.8 1995/06/12 00:46:53 mycroft Exp $ */
+/* $OpenBSD: raw_cb.c,v 1.2 1996/03/03 21:07:16 niklas Exp $ */
+/* $NetBSD: raw_cb.c,v 1.9 1996/02/13 22:00:39 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
*/
if (rp == 0)
return (ENOBUFS);
- if (error = soreserve(so, raw_sendspace, raw_recvspace))
+ if ((error = soreserve(so, raw_sendspace, raw_recvspace)) != 0)
return (error);
rp->rcb_socket = so;
rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
-/* $NetBSD: raw_cb.h,v 1.8 1995/06/12 00:46:54 mycroft Exp $ */
+/* $OpenBSD: raw_cb.h,v 1.2 1996/03/03 21:07:17 niklas Exp $ */
+/* $NetBSD: raw_cb.h,v 1.9 1996/02/13 22:00:41 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
LIST_HEAD(, rawcb) rawcb; /* head of list */
int raw_attach __P((struct socket *, int));
-void raw_ctlinput __P((int, struct sockaddr *));
+void *raw_ctlinput __P((int, struct sockaddr *, void *));
void raw_detach __P((struct rawcb *));
void raw_disconnect __P((struct rawcb *));
void raw_init __P((void));
-void raw_input __P((struct mbuf *,
- struct sockproto *, struct sockaddr *, struct sockaddr *));
+void raw_input __P((struct mbuf *, ...));
int raw_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
+
#endif /* _KERNEL */
-/* $NetBSD: raw_usrreq.c,v 1.10 1995/06/12 00:46:55 mycroft Exp $ */
+/* $OpenBSD: raw_usrreq.c,v 1.2 1996/03/03 21:07:18 niklas Exp $ */
+/* $NetBSD: raw_usrreq.c,v 1.11 1996/02/13 22:00:43 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/errno.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/route.h>
#include <net/netisr.h>
#include <net/raw_cb.h>
+#include <machine/stdarg.h>
/*
* Initialize raw connection block q.
*/
* Raw protocol interface.
*/
void
-raw_input(m0, proto, src, dst)
+#if __STDC__
+raw_input(struct mbuf *m0, ...)
+#else
+raw_input(m0, va_alist)
struct mbuf *m0;
- register struct sockproto *proto;
- struct sockaddr *src, *dst;
+ va_dcl
+#endif
{
register struct rawcb *rp;
register struct mbuf *m = m0;
register int sockets = 0;
struct socket *last;
+ va_list ap;
+ register struct sockproto *proto;
+ struct sockaddr *src, *dst;
+
+ va_start(ap, m0);
+ proto = va_arg(ap, struct sockproto *);
+ src = va_arg(ap, struct sockaddr *);
+ dst = va_arg(ap, struct sockaddr *);
+ va_end(ap);
last = 0;
for (rp = rawcb.lh_first; rp != 0; rp = rp->rcb_list.le_next) {
continue;
if (last) {
struct mbuf *n;
- if (n = m_copy(m, 0, (int)M_COPYALL)) {
+ if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
if (sbappendaddr(&last->so_rcv, src,
n, (struct mbuf *)0) == 0)
/* should notify about lost packet */
}
/*ARGSUSED*/
-void
-raw_ctlinput(cmd, arg)
+void *
+raw_ctlinput(cmd, arg, d)
int cmd;
struct sockaddr *arg;
+ void *d;
{
if (cmd < 0 || cmd > PRC_NCMDS)
- return;
+ return NULL;
+ return NULL;
/* INCOMPLETE */
}
-/* $NetBSD: route.c,v 1.13 1995/08/12 23:59:25 mycroft Exp $ */
+/* $OpenBSD: route.c,v 1.2 1996/03/03 21:07:19 niklas Exp $ */
+/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
panic ("rtfree 2");
rttrash--;
if (rt->rt_refcnt < 0) {
- printf("rtfree: %x not freed (neg refs)\n", rt);
+ printf("rtfree: %p not freed (neg refs)\n", rt);
return;
}
ifa = rt->rt_ifa;
*
* N.B.: must be called at splsoftnet
*/
-int
+void
rtredirect(dst, gateway, netmask, flags, src, rtp)
struct sockaddr *dst, *gateway, *netmask, *src;
int flags;
rt_maskedcopy(dst, deldst, ifa->ifa_netmask);
dst = deldst;
}
- if (rt = rtalloc1(dst, 0)) {
+ if ((rt = rtalloc1(dst, 0)) != NULL) {
rt->rt_refcnt--;
if (rt->rt_ifa != ifa) {
if (m)
if (cmd == RTM_ADD && error == 0 && (rt = nrt)) {
rt->rt_refcnt--;
if (rt->rt_ifa != ifa) {
- printf("rtinit: wrong ifa (%x) was (%x)\n", ifa,
- rt->rt_ifa);
+ printf("rtinit: wrong ifa (%p) was (%p)\n",
+ ifa, rt->rt_ifa);
if (rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, SA(0));
IFAFREE(rt->rt_ifa);
-/* $NetBSD: route.h,v 1.8 1995/03/26 20:30:19 jtc Exp $ */
+/* $OpenBSD: route.h,v 1.2 1996/03/03 21:07:20 niklas Exp $ */
+/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
struct socket;
void route_init __P((void));
-int route_output __P((struct mbuf *, struct socket *));
-int route_usrreq __P((struct socket *,
- int, struct mbuf *, struct mbuf *, struct mbuf *));
+int route_output __P((struct mbuf *, ...));
+int route_usrreq __P((struct socket *, int, struct mbuf *,
+ struct mbuf *, struct mbuf *));
void rt_ifmsg __P((struct ifnet *));
void rt_maskedcopy __P((struct sockaddr *,
struct sockaddr *, struct sockaddr *));
void rt_missmsg __P((int, struct rt_addrinfo *, int, int));
void rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));
-int rt_setgate __P((struct rtentry *,
- struct sockaddr *, struct sockaddr *));
+int rt_setgate __P((struct rtentry *, struct sockaddr *,
+ struct sockaddr *));
void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
void rtable_init __P((void **));
void rtalloc __P((struct route *));
void rtfree __P((struct rtentry *));
int rtinit __P((struct ifaddr *, int, int));
int rtioctl __P((u_long, caddr_t, struct proc *));
-int rtredirect __P((struct sockaddr *, struct sockaddr *,
- struct sockaddr *, int, struct sockaddr *, struct rtentry **));
+void rtredirect __P((struct sockaddr *, struct sockaddr *,
+ struct sockaddr *, int, struct sockaddr *,
+ struct rtentry **));
int rtrequest __P((int, struct sockaddr *,
- struct sockaddr *, struct sockaddr *, int, struct rtentry **));
+ struct sockaddr *, struct sockaddr *, int,
+ struct rtentry **));
#endif /* _KERNEL */
-/* $NetBSD: rtsock.c,v 1.16 1995/08/19 07:48:14 cgd Exp $ */
+/* $OpenBSD: rtsock.c,v 1.2 1996/03/03 21:07:21 niklas Exp $ */
+/* $NetBSD: rtsock.c,v 1.17 1996/02/13 22:00:52 christos Exp $ */
/*
* Copyright (c) 1988, 1991, 1993
#include <sys/domain.h>
#include <sys/protosw.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
+
#include <net/if.h>
#include <net/route.h>
#include <net/raw_cb.h>
+#include <machine/stdarg.h>
+
struct sockaddr route_dst = { 2, PF_ROUTE, };
struct sockaddr route_src = { 2, PF_ROUTE, };
struct sockproto route_proto = { PF_ROUTE, };
if (req == PRU_ATTACH) {
MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK);
- if (so->so_pcb = rp)
- bzero((caddr_t)so->so_pcb, sizeof(*rp));
+ if ((so->so_pcb = rp) != NULL)
+ bzero(so->so_pcb, sizeof(*rp));
}
if (req == PRU_DETACH && rp) {
/*ARGSUSED*/
int
-route_output(m, so)
- register struct mbuf *m;
- struct socket *so;
+#if __STDC__
+route_output(struct mbuf *m, ...)
+#else
+route_output(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
{
register struct rt_msghdr *rtm = 0;
register struct rtentry *rt = 0;
int len, error = 0;
struct ifnet *ifp = 0;
struct ifaddr *ifa = 0;
+ struct socket *so;
+ va_list ap;
+
+ va_start(ap, m);
+ so = va_arg(ap, struct socket *);
+ va_end(ap);
+
#define senderr(e) { error = e; goto flush;}
if (m == 0 || ((m->m_len < sizeof(int32_t)) &&
case RTM_LOCK:
if ((rnh = rt_tables[dst->sa_family]) == 0) {
senderr(EAFNOSUPPORT);
- } else if (rt = (struct rtentry *)
- rnh->rnh_lookup(dst, netmask, rnh))
+ } else if ((rt = (struct rtentry *)
+ rnh->rnh_lookup(dst, netmask, rnh)) != NULL)
rt->rt_refcnt++;
else
senderr(ESRCH);
netmask = rt_mask(rt);
genmask = rt->rt_genmask;
if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
- if (ifp = rt->rt_ifp) {
+ if ((ifp = rt->rt_ifp) != NULL) {
ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
ifaaddr = rt->rt_ifa->ifa_addr;
if (ifp->if_flags & IFF_POINTOPOINT)
default:
len = sizeof(struct rt_msghdr);
}
- if (cp0 = cp)
+ if ((cp0 = cp) != NULL)
cp += len;
for (i = 0; i < RTAX_MAX; i++) {
register struct sockaddr *sa;
if (rw->w_tmemsize < len) {
if (rw->w_tmem)
free(rw->w_tmem, M_RTABLE);
- if (rw->w_tmem = (caddr_t)
- malloc(len, M_RTABLE, M_NOWAIT))
+ rw->w_tmem = (caddr_t) malloc(len, M_RTABLE,
+ M_NOWAIT);
+ if (rw->w_tmem)
rw->w_tmemsize = len;
}
if (rw->w_tmem) {
register struct rtentry *rt;
{
struct rt_addrinfo info;
- struct sockaddr *sa;
+ struct sockaddr *sa = NULL;
int pass;
- struct mbuf *m;
+ struct mbuf *m = NULL;
struct ifnet *ifp = ifa->ifa_ifp;
if (route_cb.any_count == 0)
* This is used in dumping the kernel table via sysctl().
*/
int
-sysctl_dumpentry(rn, w)
+sysctl_dumpentry(rn, v)
struct radix_node *rn;
- register struct walkarg *w;
+ register void *v;
{
+ register struct walkarg *w = v;
register struct rtentry *rt = (struct rtentry *)rn;
int error = 0, size;
struct rt_addrinfo info;
rtm->rtm_index = rt->rt_ifp->if_index;
rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
rtm->rtm_addrs = info.rti_addrs;
- if (error = copyout((caddr_t)rtm, w->w_where, size))
+ if ((error = copyout((caddr_t)rtm, w->w_where, size)) != 0)
w->w_where = NULL;
else
w->w_where += size;
ifm->ifm_flags = ifp->if_flags;
ifm->ifm_data = ifp->if_data;
ifm->ifm_addrs = info.rti_addrs;
- if (error = copyout((caddr_t)ifm, w->w_where, len))
+ error = copyout((caddr_t)ifm, w->w_where, len);
+ if (error)
return (error);
w->w_where += len;
}
- while (ifa = ifa->ifa_list.tqe_next) {
+ while ((ifa = ifa->ifa_list.tqe_next) != NULL) {
if (af && af != ifa->ifa_addr->sa_family)
continue;
ifaaddr = ifa->ifa_addr;
ifam->ifam_flags = ifa->ifa_flags;
ifam->ifam_metric = ifa->ifa_metric;
ifam->ifam_addrs = info.rti_addrs;
- if (error = copyout(w->w_tmem, w->w_where, len))
+ error = copyout(w->w_tmem, w->w_where, len);
+ if (error)
return (error);
w->w_where += len;
}
int
sysctl_rtable(name, namelen, where, given, new, newlen)
int *name;
- int namelen;
- caddr_t where;
+ u_int namelen;
+ void *where;
size_t *given;
- caddr_t *new;
+ void *new;
size_t newlen;
{
register struct radix_node_head *rnh;
case NET_RT_FLAGS:
for (i = 1; i <= AF_MAX; i++)
if ((rnh = rt_tables[i]) && (af == 0 || af == i) &&
- (error = rnh->rnh_walktree(rnh,
- sysctl_dumpentry, &w)))
+ (error = (*rnh->rnh_walktree)(rnh,
+ sysctl_dumpentry,
+ &w)))
break;
break;
free(w.w_tmem, M_RTABLE);
w.w_needed += w.w_given;
if (where) {
- *given = w.w_where - where;
+ *given = w.w_where - (caddr_t) where;
if (*given < w.w_needed)
return (ENOMEM);
} else {
-/* $NetBSD: slcompress.c,v 1.13 1995/11/20 20:43:33 cgd Exp $ */
+/* $OpenBSD: slcompress.c,v 1.3 1996/03/03 21:07:22 niklas Exp $ */
+/* $NetBSD: slcompress.c,v 1.14 1996/02/13 22:00:55 christos Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
#include <sys/param.h>
#include <sys/mbuf.h>
+#include <sys/systm.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
* with it. */
goto uncompressed;
- if (deltaS = (u_int16_t)(ntohs(th->th_win) - ntohs(oth->th_win))) {
+ deltaS = (u_int16_t)(ntohs(th->th_win) - ntohs(oth->th_win));
+ if (deltaS) {
ENCODE(deltaS);
changes |= NEW_W;
}
- if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
+ deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack);
+ if (deltaA) {
if (deltaA > 0xffff)
goto uncompressed;
ENCODE(deltaA);
changes |= NEW_A;
}
- if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
+ deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq);
+ if (deltaS) {
if (deltaS > 0xffff)
goto uncompressed;
ENCODE(deltaS);