Various cleanup, mostly by me, submitted by Ignatios Souvatzis.
This commit is contained in:
parent
3da4b2a160
commit
206addf62d
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_arcsubr.c,v 1.5 1995/07/12 08:27:26 cgd Exp $ */
|
||||
/* $NetBSD: if_arcsubr.c,v 1.6 1995/12/24 03:03:55 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Ignatios Souvatzis
|
||||
|
@ -43,9 +43,11 @@
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
|
||||
|
@ -65,8 +67,6 @@
|
|||
#define ARC_PHDSMTU 1500
|
||||
#endif
|
||||
|
||||
/* why isnt this in /sys/sys/mbuf.h?? */
|
||||
extern struct mbuf *m_split __P((struct mbuf *, int, int));
|
||||
static struct mbuf *arc_defrag __P((struct ifnet *, struct mbuf *));
|
||||
|
||||
/*
|
||||
|
@ -100,24 +100,22 @@ arc_output(ifp, m0, dst, rt0)
|
|||
struct rtentry *rt;
|
||||
struct arccom *ac;
|
||||
register struct arc_header *ah;
|
||||
int off, len;
|
||||
int s, error, newencoding;
|
||||
u_int8_t atype, adst;
|
||||
int tfrags, sflag, fsflag, rsflag;
|
||||
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
|
||||
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
|
||||
senderr(ENETDOWN);
|
||||
|
||||
error = newencoding = 0;
|
||||
ac = (struct arccom *)ifp;
|
||||
m = m0;
|
||||
len = m->m_pkthdr.len;
|
||||
mcopy = m1 = NULL;
|
||||
|
||||
ifp->if_lastchange = time;
|
||||
if (rt = rt0) {
|
||||
if ((rt = rt0)) {
|
||||
if ((rt->rt_flags & RTF_UP) == 0) {
|
||||
if (rt0 = rt = rtalloc1(dst, 1))
|
||||
if ((rt0 = rt = rtalloc1(dst, 1)))
|
||||
rt->rt_refcnt--;
|
||||
else
|
||||
senderr(EHOSTUNREACH);
|
||||
|
@ -153,7 +151,6 @@ arc_output(ifp, m0, dst, rt0)
|
|||
/* If broadcasting on a simplex interface, loopback a copy */
|
||||
if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
|
||||
mcopy = m_copy(m, 0, (int)M_COPYALL);
|
||||
off = m->m_pkthdr.len - m->m_len;
|
||||
if (ifp->if_flags & IFF_LINK0) {
|
||||
atype = ARCTYPE_IP;
|
||||
newencoding = 1;
|
||||
|
@ -191,8 +188,8 @@ arc_output(ifp, m0, dst, rt0)
|
|||
if (newencoding) {
|
||||
++ac->ac_seqid; /* make the seqid unique */
|
||||
|
||||
tfrags = (len + 503) / 504;
|
||||
fsflag = 2*tfrags-3;
|
||||
tfrags = (m->m_pkthdr.len + 503) / 504;
|
||||
fsflag = 2 * tfrags - 3;
|
||||
sflag = 0;
|
||||
rsflag = fsflag;
|
||||
|
||||
|
@ -205,10 +202,6 @@ arc_output(ifp, m0, dst, rt0)
|
|||
M_PREPEND(m, ARC_HDRNEWLEN, M_DONTWAIT);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
m = m_pullup(m,ARC_HDRNEWLEN);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
|
||||
ah = mtod(m, struct arc_header *);
|
||||
ah->arc_type = atype;
|
||||
ah->arc_dhost = adst;
|
||||
|
@ -226,16 +219,13 @@ arc_output(ifp, m0, dst, rt0)
|
|||
splx(s);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
ifp->if_obytes += m->m_pkthdr.len;
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
||||
(*ifp->if_start)(ifp);
|
||||
splx(s);
|
||||
|
||||
/* we don't count the hardwares lenght bytes here */
|
||||
ifp->if_obytes += 504 + ARC_HDRNEWLEN;
|
||||
|
||||
m = m1;
|
||||
len -= 504;
|
||||
sflag += 2;
|
||||
rsflag = sflag;
|
||||
}
|
||||
|
@ -244,80 +234,55 @@ arc_output(ifp, m0, dst, rt0)
|
|||
M_PREPEND(m, ARC_HDRNEWLEN, M_DONTWAIT);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
m = m_pullup(m, ARC_HDRNEWLEN);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
|
||||
ah = mtod(m, struct arc_header *);
|
||||
ah->arc_type = atype;
|
||||
ah->arc_flag = sflag;
|
||||
ah->arc_seqid= ac->ac_seqid;
|
||||
ah->arc_seqid = ac->ac_seqid;
|
||||
|
||||
/* here we can have small, especially forbidden packets */
|
||||
|
||||
if ((len >= ARC_MIN_FORBID_LEN - ARC_HDRNEWLEN + 2) &&
|
||||
(len <= ARC_MAX_FORBID_LEN - ARC_HDRNEWLEN + 2)) {
|
||||
|
||||
if ((m->m_pkthdr.len >= ARC_MIN_FORBID_LEN + 2) &&
|
||||
(m->m_pkthdr.len <= ARC_MAX_FORBID_LEN + 2)) {
|
||||
M_PREPEND(m, 4, M_DONTWAIT);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
|
||||
m = m_pullup(m, ARC_HDRNEWLEN);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
|
||||
ah = mtod(m, struct arc_header *);
|
||||
ah->arc_type = atype;
|
||||
ah->arc_flag = 0xFF;
|
||||
ah->arc_seqid= 0xFFFF;
|
||||
len += 4;
|
||||
ah->arc_seqid = 0xFFFF;
|
||||
}
|
||||
|
||||
ah->arc_dhost= adst;
|
||||
ah->arc_shost= ac->ac_anaddr;
|
||||
|
||||
s = splimp();
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
if (IF_QFULL(&ifp->if_snd)) {
|
||||
IF_DROP(&ifp->if_snd);
|
||||
splx(s);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
||||
(*ifp->if_start)(ifp);
|
||||
splx(s);
|
||||
|
||||
ifp->if_obytes += len + ARC_HDRNEWLEN;
|
||||
|
||||
ah->arc_dhost = adst;
|
||||
ah->arc_shost = ac->ac_anaddr;
|
||||
} else {
|
||||
M_PREPEND(m, ARC_HDRLEN, M_DONTWAIT);
|
||||
if (m == 0)
|
||||
senderr(ENOBUFS);
|
||||
ah = mtod(m, struct arc_header *);
|
||||
ah->arc_type = atype;
|
||||
ah->arc_dhost= adst;
|
||||
ah->arc_shost= ac->ac_anaddr;
|
||||
s = splimp();
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
if (IF_QFULL(&ifp->if_snd)) {
|
||||
IF_DROP(&ifp->if_snd);
|
||||
splx(s);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
||||
(*ifp->if_start)(ifp);
|
||||
splx(s);
|
||||
|
||||
ifp->if_obytes += len + ARC_HDRLEN;
|
||||
ah->arc_dhost = adst;
|
||||
ah->arc_shost = ac->ac_anaddr;
|
||||
}
|
||||
|
||||
s = splimp();
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
if (IF_QFULL(&ifp->if_snd)) {
|
||||
IF_DROP(&ifp->if_snd);
|
||||
splx(s);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
ifp->if_obytes += m->m_pkthdr.len;
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
if ((ifp->if_flags & IFF_OACTIVE) == 0)
|
||||
(*ifp->if_start)(ifp);
|
||||
splx(s);
|
||||
|
||||
return (error);
|
||||
|
||||
bad:
|
||||
|
@ -484,7 +449,7 @@ outofseq:
|
|||
*/
|
||||
int
|
||||
arc_isphds(type)
|
||||
int type;
|
||||
u_int8_t type;
|
||||
{
|
||||
return ((type != ARCTYPE_IP_OLD &&
|
||||
type != ARCTYPE_ARP_OLD));
|
||||
|
@ -529,13 +494,13 @@ arc_input(ifp, m)
|
|||
switch (atype) {
|
||||
#ifdef INET
|
||||
case ARCTYPE_IP:
|
||||
m_adj(m,ARC_HDRNEWLEN);
|
||||
m_adj(m, ARC_HDRNEWLEN);
|
||||
schednetisr(NETISR_IP);
|
||||
inq = &ipintrq;
|
||||
break;
|
||||
|
||||
case ARCTYPE_IP_OLD:
|
||||
m_adj(m,ARC_HDRLEN);
|
||||
m_adj(m, ARC_HDRLEN);
|
||||
schednetisr(NETISR_IP);
|
||||
inq = &ipintrq;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue