mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 08:22:44 +00:00
Moved conversion of ether_type to host byte order out of ethernet drivers
and into ether_input(). It was silly to have bpf want this one way and ether_input want it another way. Ripped out trailer support from the few remaining drivers that still had it.
This commit is contained in:
parent
63281ad752
commit
307d80be7a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4796
@ -21,7 +21,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_de.c,v 1.6 1994/11/13 12:39:38 davidg Exp $
|
||||
* $Id: if_de.c,v 1.7 1994/11/22 09:47:31 davidg Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -394,7 +394,6 @@ tulip_rx_intr(
|
||||
}
|
||||
#endif
|
||||
eh = *(struct ether_header *) bufaddr;
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
#if NBPFILTER > 0
|
||||
if (sc->tulip_bpf != NULL) {
|
||||
bpf_tap(sc->tulip_bpf, bufaddr, total_len);
|
||||
|
@ -13,7 +13,7 @@
|
||||
* the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
|
||||
* and a variety of similar clones.
|
||||
*
|
||||
* $Id: if_ed.c,v 1.55 1994/11/13 07:17:46 davidg Exp $
|
||||
* $Id: if_ed.c,v 1.56 1994/11/17 14:42:27 davidg Exp $
|
||||
*/
|
||||
|
||||
#include "ed.h"
|
||||
@ -2110,8 +2110,7 @@ ed_get_packet(sc, buf, len, multicast)
|
||||
len -= sizeof(struct ether_header);
|
||||
|
||||
/*
|
||||
* Pull packet off interface. Or if this was a trailer packet, the
|
||||
* data portion is appended.
|
||||
* Pull packet off interface.
|
||||
*/
|
||||
if (ed_ring_to_mbuf(sc, buf, m, len) == NULL) {
|
||||
m_freem(m);
|
||||
@ -2146,11 +2145,6 @@ ed_get_packet(sc, buf, len, multicast)
|
||||
*/
|
||||
m_adj(m, sizeof(struct ether_header));
|
||||
|
||||
/*
|
||||
* silly ether_input routine needs 'type' in host byte order
|
||||
*/
|
||||
eh->ether_type = ntohs(eh->ether_type);
|
||||
|
||||
ether_input(&sc->arpcom.ac_if, eh, m);
|
||||
return;
|
||||
}
|
||||
|
@ -52,10 +52,6 @@
|
||||
* used while working on this driver and the program that displays this
|
||||
* information (epstat).
|
||||
*
|
||||
* NB 2: About trailers, I didn't care if this implementation was OK, I just
|
||||
* adapted it to have the same behaviour as in the original driver (donne
|
||||
* just for epread()).
|
||||
*
|
||||
*
|
||||
* Some driver statistics can be viewed with the epstat utility. In order to
|
||||
* use this, you have to compile if_ep.c with
|
||||
@ -812,62 +808,7 @@ startagain:
|
||||
|
||||
#if NBPFILTER > 0
|
||||
if (sc->bpf) {
|
||||
u_short etype;
|
||||
int off, datasize, resid;
|
||||
struct ether_header *eh;
|
||||
struct trailer_header {
|
||||
u_short ether_type;
|
||||
u_short ether_residual;
|
||||
} trailer_header;
|
||||
char ether_packet[ETHER_MAX_LEN];
|
||||
char *ep;
|
||||
|
||||
ep = ether_packet;
|
||||
|
||||
/*
|
||||
* We handle trailers below: Copy ether header first, then residual
|
||||
* data, then data. Put all this in a temporary buffer 'ether_packet'
|
||||
* and send off to bpf. Since the system has generated this packet,
|
||||
* we assume that all of the offsets in the packet are correct; if
|
||||
* they're not, the system will almost certainly crash in m_copydata.
|
||||
* We make no assumptions about how the data is arranged in the mbuf
|
||||
* chain (i.e. how much data is in each mbuf, if mbuf clusters are
|
||||
* used, etc.), which is why we use m_copydata to get the ether
|
||||
* header rather than assume that this is located in the first mbuf.
|
||||
*/
|
||||
/* copy ether header */
|
||||
m_copydata(top, 0, sizeof(struct ether_header), ep);
|
||||
eh = (struct ether_header *) ep;
|
||||
ep += sizeof(struct ether_header);
|
||||
eh->ether_type = etype = ntohs(eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) {
|
||||
datasize = ((etype - ETHERTYPE_TRAIL) << 9);
|
||||
off = datasize + sizeof(struct ether_header);
|
||||
|
||||
/* copy trailer_header into a data structure */
|
||||
m_copydata(top, off, sizeof(struct trailer_header),
|
||||
(caddr_t) & trailer_header.ether_type);
|
||||
|
||||
/* copy residual data */
|
||||
resid = trailer_header.ether_residual -
|
||||
sizeof(struct trailer_header);
|
||||
resid = ntohs(resid);
|
||||
m_copydata(top, off + sizeof(struct trailer_header),
|
||||
resid, ep);
|
||||
ep += resid;
|
||||
|
||||
/* copy data */
|
||||
m_copydata(top, sizeof(struct ether_header),
|
||||
datasize, ep);
|
||||
ep += datasize;
|
||||
|
||||
/* restore original ether packet type */
|
||||
eh->ether_type = trailer_header.ether_type;
|
||||
|
||||
bpf_tap(sc->bpf, ether_packet, ep - ether_packet);
|
||||
} else
|
||||
bpf_mtap(sc->bpf, top);
|
||||
bpf_mtap(sc->bpf, top);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -998,12 +939,7 @@ epread(sc)
|
||||
short rx_fifo2, status;
|
||||
register short delta;
|
||||
register short rx_fifo;
|
||||
u_short etype;
|
||||
|
||||
/*
|
||||
* XXX I have just adapted the code for the protocol trailing processing
|
||||
* as programed in the original driver. FreeBSD 1.1.5.1 release
|
||||
*/
|
||||
status = inw(BASE + EP_W1_RX_STATUS);
|
||||
|
||||
read_again:
|
||||
@ -1050,34 +986,6 @@ read_again:
|
||||
top->m_len = sizeof(struct ether_header);
|
||||
rx_fifo -= sizeof(struct ether_header);
|
||||
sc->cur_len = rx_fifo2;
|
||||
|
||||
/*
|
||||
* Test for trailers.
|
||||
* I didn't care if this implementation was OK, I just adapted it to
|
||||
* have the same behaviour as in the original driver
|
||||
*/
|
||||
eh = mtod(top, struct ether_header *);
|
||||
etype = eh->ether_type = ntohs((u_short) eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) {
|
||||
if ((etype - ETHERTYPE_TRAIL) * 512 >= ETHERMTU)
|
||||
goto out;
|
||||
m->m_data = m->m_dat; /* Convert back to regular mbuf. */
|
||||
m->m_flags = 0; /* This sucks but non-trailers are the norm */
|
||||
m->m_data += 2 * sizeof(u_short); /* Get rid of type & len */
|
||||
|
||||
sc->cur_len = sizeof(struct ether_header);
|
||||
ep_fset(F_RX_TRAILER);
|
||||
|
||||
/* in the case of trailers, we prefer to have the packet complete */
|
||||
if (status & ERR_RX_INCOMPLETE) {
|
||||
ep_frst(F_RX_FIRST);
|
||||
outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 2032); /* disable */
|
||||
return;
|
||||
} else
|
||||
/* We don't read the trailer, next we are reading the data */
|
||||
rx_fifo -= sizeof(struct ether_header);
|
||||
}
|
||||
} else {
|
||||
/* come here if we didn't have a complete packet last time */
|
||||
top = sc->top;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_ie.c,v 1.17 1994/10/23 21:27:20 wollman Exp $
|
||||
* $Id: if_ie.c,v 1.18 1994/10/26 00:16:17 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1231,8 +1231,6 @@ static void ie_readframe(unit, ie, num)
|
||||
* as a multicast router or when using BPF.
|
||||
*/
|
||||
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
|
||||
/*
|
||||
* Finally pass this packet up to higher layers.
|
||||
*/
|
||||
|
@ -454,7 +454,6 @@ lnc_rint(int unit)
|
||||
head->m_pkthdr.rcvif = &sc->arpcom.ac_if;
|
||||
head->m_pkthdr.len = pkt_len - sizeof(*eh);
|
||||
eh = (struct ether_header *) head->m_data;
|
||||
eh->ether_type = ntohs(eh->ether_type);
|
||||
head->m_data += sizeof *eh;
|
||||
head->m_len -= sizeof *eh;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
|
||||
* and a variety of similar clones.
|
||||
*
|
||||
* $Id: if_ed.c,v 1.55 1994/11/13 07:17:46 davidg Exp $
|
||||
* $Id: if_ed.c,v 1.56 1994/11/17 14:42:27 davidg Exp $
|
||||
*/
|
||||
|
||||
#include "ed.h"
|
||||
@ -2110,8 +2110,7 @@ ed_get_packet(sc, buf, len, multicast)
|
||||
len -= sizeof(struct ether_header);
|
||||
|
||||
/*
|
||||
* Pull packet off interface. Or if this was a trailer packet, the
|
||||
* data portion is appended.
|
||||
* Pull packet off interface.
|
||||
*/
|
||||
if (ed_ring_to_mbuf(sc, buf, m, len) == NULL) {
|
||||
m_freem(m);
|
||||
@ -2146,11 +2145,6 @@ ed_get_packet(sc, buf, len, multicast)
|
||||
*/
|
||||
m_adj(m, sizeof(struct ether_header));
|
||||
|
||||
/*
|
||||
* silly ether_input routine needs 'type' in host byte order
|
||||
*/
|
||||
eh->ether_type = ntohs(eh->ether_type);
|
||||
|
||||
ether_input(&sc->arpcom.ac_if, eh, m);
|
||||
return;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Questions, comments, bug reports and fixes to kimmel@cs.umass.edu.
|
||||
*
|
||||
* $Id: if_el.c,v 1.7 1994/10/21 01:19:06 wollman Exp $
|
||||
* $Id: if_el.c,v 1.8 1994/10/23 21:27:17 wollman Exp $
|
||||
*/
|
||||
/* Except of course for the portions of code lifted from other FreeBSD
|
||||
* drivers (mainly elread, elget and el_ioctl)
|
||||
@ -562,47 +562,21 @@ void elintr(int unit)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pass a packet up to the higher levels. Deal with trailer protocol. */
|
||||
/* Pass a packet up to the higher levels. */
|
||||
static inline void elread(struct el_softc *sc,caddr_t buf,int len)
|
||||
{
|
||||
register struct ether_header *eh;
|
||||
struct mbuf *m;
|
||||
int off, resid;
|
||||
|
||||
/* Deal with trailer protocol: if type is trailer type
|
||||
* get true type from first 16-bit word past data.
|
||||
* Remember that type was trailer by setting off.
|
||||
*/
|
||||
eh = (struct ether_header *)buf;
|
||||
eh->ether_type = ntohs((u_short)eh->ether_type);
|
||||
#define eldataaddr(eh,off,type) ((type)(((caddr_t)((eh)+1)+(off))))
|
||||
if(eh->ether_type >= ETHERTYPE_TRAIL &&
|
||||
eh->ether_type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
|
||||
off = (eh->ether_type - ETHERTYPE_TRAIL) * 512;
|
||||
if(off >= ETHERMTU)
|
||||
return;
|
||||
eh->ether_type = ntohs(*eldataaddr(eh,off,u_short *));
|
||||
resid = ntohs(*(eldataaddr(eh,off+2,u_short *)));
|
||||
if((off+resid) > len)
|
||||
return;
|
||||
len = off + resid;
|
||||
}
|
||||
else
|
||||
off = 0;
|
||||
|
||||
if(len <= 0)
|
||||
return;
|
||||
|
||||
#if NBPFILTER > 0
|
||||
/*
|
||||
* Check if there's a bpf filter listening on this interface.
|
||||
* If so, hand off the raw packet to bpf, which must deal with
|
||||
* trailers in its own way.
|
||||
* If so, hand off the raw packet to bpf.
|
||||
*/
|
||||
if(sc->bpf) {
|
||||
eh->ether_type = htons((u_short)eh->ether_type);
|
||||
bpf_tap(sc->bpf,buf,len+sizeof(struct ether_header));
|
||||
eh->ether_type = ntohs((u_short)eh->ether_type);
|
||||
|
||||
/*
|
||||
* Note that the interface cannot be in promiscuous mode if
|
||||
@ -621,12 +595,9 @@ static inline void elread(struct el_softc *sc,caddr_t buf,int len)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pull packet off interface. Off is nonzero if packet
|
||||
* has trailing header; neget will then force this header
|
||||
* information to be at the front, but we still have to drop
|
||||
* the type and length which are at the front of any trailer data.
|
||||
* Pull packet off interface.
|
||||
*/
|
||||
m = elget(buf,len,off,&sc->arpcom.ac_if);
|
||||
m = elget(buf,len,0,&sc->arpcom.ac_if);
|
||||
if(m == 0)
|
||||
return;
|
||||
|
||||
@ -636,11 +607,6 @@ static inline void elread(struct el_softc *sc,caddr_t buf,int len)
|
||||
/*
|
||||
* Pull read data off a interface.
|
||||
* Len is length of data, with local net header stripped.
|
||||
* Off is non-zero if a trailer protocol was used, and
|
||||
* gives the offset of the trailer information.
|
||||
* We copy the trailer information and then all the normal
|
||||
* data into mbufs. When full cluster sized units are present
|
||||
* we copy into clusters.
|
||||
*/
|
||||
struct mbuf *
|
||||
elget(buf, totlen, off0, ifp)
|
||||
|
@ -52,10 +52,6 @@
|
||||
* used while working on this driver and the program that displays this
|
||||
* information (epstat).
|
||||
*
|
||||
* NB 2: About trailers, I didn't care if this implementation was OK, I just
|
||||
* adapted it to have the same behaviour as in the original driver (donne
|
||||
* just for epread()).
|
||||
*
|
||||
*
|
||||
* Some driver statistics can be viewed with the epstat utility. In order to
|
||||
* use this, you have to compile if_ep.c with
|
||||
@ -812,62 +808,7 @@ startagain:
|
||||
|
||||
#if NBPFILTER > 0
|
||||
if (sc->bpf) {
|
||||
u_short etype;
|
||||
int off, datasize, resid;
|
||||
struct ether_header *eh;
|
||||
struct trailer_header {
|
||||
u_short ether_type;
|
||||
u_short ether_residual;
|
||||
} trailer_header;
|
||||
char ether_packet[ETHER_MAX_LEN];
|
||||
char *ep;
|
||||
|
||||
ep = ether_packet;
|
||||
|
||||
/*
|
||||
* We handle trailers below: Copy ether header first, then residual
|
||||
* data, then data. Put all this in a temporary buffer 'ether_packet'
|
||||
* and send off to bpf. Since the system has generated this packet,
|
||||
* we assume that all of the offsets in the packet are correct; if
|
||||
* they're not, the system will almost certainly crash in m_copydata.
|
||||
* We make no assumptions about how the data is arranged in the mbuf
|
||||
* chain (i.e. how much data is in each mbuf, if mbuf clusters are
|
||||
* used, etc.), which is why we use m_copydata to get the ether
|
||||
* header rather than assume that this is located in the first mbuf.
|
||||
*/
|
||||
/* copy ether header */
|
||||
m_copydata(top, 0, sizeof(struct ether_header), ep);
|
||||
eh = (struct ether_header *) ep;
|
||||
ep += sizeof(struct ether_header);
|
||||
eh->ether_type = etype = ntohs(eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) {
|
||||
datasize = ((etype - ETHERTYPE_TRAIL) << 9);
|
||||
off = datasize + sizeof(struct ether_header);
|
||||
|
||||
/* copy trailer_header into a data structure */
|
||||
m_copydata(top, off, sizeof(struct trailer_header),
|
||||
(caddr_t) & trailer_header.ether_type);
|
||||
|
||||
/* copy residual data */
|
||||
resid = trailer_header.ether_residual -
|
||||
sizeof(struct trailer_header);
|
||||
resid = ntohs(resid);
|
||||
m_copydata(top, off + sizeof(struct trailer_header),
|
||||
resid, ep);
|
||||
ep += resid;
|
||||
|
||||
/* copy data */
|
||||
m_copydata(top, sizeof(struct ether_header),
|
||||
datasize, ep);
|
||||
ep += datasize;
|
||||
|
||||
/* restore original ether packet type */
|
||||
eh->ether_type = trailer_header.ether_type;
|
||||
|
||||
bpf_tap(sc->bpf, ether_packet, ep - ether_packet);
|
||||
} else
|
||||
bpf_mtap(sc->bpf, top);
|
||||
bpf_mtap(sc->bpf, top);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -998,12 +939,7 @@ epread(sc)
|
||||
short rx_fifo2, status;
|
||||
register short delta;
|
||||
register short rx_fifo;
|
||||
u_short etype;
|
||||
|
||||
/*
|
||||
* XXX I have just adapted the code for the protocol trailing processing
|
||||
* as programed in the original driver. FreeBSD 1.1.5.1 release
|
||||
*/
|
||||
status = inw(BASE + EP_W1_RX_STATUS);
|
||||
|
||||
read_again:
|
||||
@ -1050,34 +986,6 @@ read_again:
|
||||
top->m_len = sizeof(struct ether_header);
|
||||
rx_fifo -= sizeof(struct ether_header);
|
||||
sc->cur_len = rx_fifo2;
|
||||
|
||||
/*
|
||||
* Test for trailers.
|
||||
* I didn't care if this implementation was OK, I just adapted it to
|
||||
* have the same behaviour as in the original driver
|
||||
*/
|
||||
eh = mtod(top, struct ether_header *);
|
||||
etype = eh->ether_type = ntohs((u_short) eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) {
|
||||
if ((etype - ETHERTYPE_TRAIL) * 512 >= ETHERMTU)
|
||||
goto out;
|
||||
m->m_data = m->m_dat; /* Convert back to regular mbuf. */
|
||||
m->m_flags = 0; /* This sucks but non-trailers are the norm */
|
||||
m->m_data += 2 * sizeof(u_short); /* Get rid of type & len */
|
||||
|
||||
sc->cur_len = sizeof(struct ether_header);
|
||||
ep_fset(F_RX_TRAILER);
|
||||
|
||||
/* in the case of trailers, we prefer to have the packet complete */
|
||||
if (status & ERR_RX_INCOMPLETE) {
|
||||
ep_frst(F_RX_FIRST);
|
||||
outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | 2032); /* disable */
|
||||
return;
|
||||
} else
|
||||
/* We don't read the trailer, next we are reading the data */
|
||||
rx_fifo -= sizeof(struct ether_header);
|
||||
}
|
||||
} else {
|
||||
/* come here if we didn't have a complete packet last time */
|
||||
top = sc->top;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_ie.c,v 1.17 1994/10/23 21:27:20 wollman Exp $
|
||||
* $Id: if_ie.c,v 1.18 1994/10/26 00:16:17 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1231,8 +1231,6 @@ static void ie_readframe(unit, ie, num)
|
||||
* as a multicast router or when using BPF.
|
||||
*/
|
||||
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
|
||||
/*
|
||||
* Finally pass this packet up to higher layers.
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@
|
||||
* of this software, nor does the author assume any responsibility
|
||||
* for damages incurred with its use.
|
||||
*
|
||||
* $Id: if_is.c,v 1.30 1994/10/26 00:16:19 phk Exp $
|
||||
* $Id: if_is.c,v 1.31 1994/10/29 10:19:32 phk Exp $
|
||||
*/
|
||||
|
||||
/* TODO
|
||||
@ -598,69 +598,9 @@ is_start(ifp)
|
||||
len += m->m_len;
|
||||
}
|
||||
#if NBPFILTER > 0
|
||||
if (is->bpf) {
|
||||
u_short etype;
|
||||
int off, datasize, resid;
|
||||
struct ether_header *eh;
|
||||
struct trailer_header {
|
||||
u_short ether_type;
|
||||
u_short ether_residual;
|
||||
} trailer_header;
|
||||
char ether_packet[ETHER_MAX_LEN];
|
||||
char *ep;
|
||||
|
||||
ep = ether_packet;
|
||||
|
||||
/*
|
||||
* We handle trailers below:
|
||||
* Copy ether header first, then residual data,
|
||||
* then data. Put all this in a temporary buffer
|
||||
* 'ether_packet' and send off to bpf. Since the
|
||||
* system has generated this packet, we assume
|
||||
* that all of the offsets in the packet are
|
||||
* correct; if they're not, the system will almost
|
||||
* certainly crash in m_copydata.
|
||||
* We make no assumptions about how the data is
|
||||
* arranged in the mbuf chain (i.e. how much
|
||||
* data is in each mbuf, if mbuf clusters are
|
||||
* used, etc.), which is why we use m_copydata
|
||||
* to get the ether header rather than assume
|
||||
* that this is located in the first mbuf.
|
||||
*/
|
||||
/* copy ether header */
|
||||
m_copydata(m0, 0, sizeof(struct ether_header), ep);
|
||||
eh = (struct ether_header *) ep;
|
||||
ep += sizeof(struct ether_header);
|
||||
etype = ntohs(eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
|
||||
datasize = ((etype - ETHERTYPE_TRAIL) << 9);
|
||||
off = datasize + sizeof(struct ether_header);
|
||||
|
||||
/* copy trailer_header into a data structure */
|
||||
m_copydata(m0, off, sizeof(struct trailer_header),
|
||||
(caddr_t)&trailer_header.ether_type);
|
||||
|
||||
/* copy residual data */
|
||||
resid = trailer_header.ether_residual -
|
||||
sizeof(struct trailer_header);
|
||||
resid = ntohs(resid);
|
||||
m_copydata(m0, off+sizeof(struct trailer_header),
|
||||
resid, ep);
|
||||
ep += resid;
|
||||
|
||||
/* copy data */
|
||||
m_copydata(m0, sizeof(struct ether_header),
|
||||
datasize, ep);
|
||||
ep += datasize;
|
||||
|
||||
/* restore original ether packet type */
|
||||
eh->ether_type = trailer_header.ether_type;
|
||||
|
||||
bpf_tap(is->bpf, ether_packet, ep - ether_packet);
|
||||
} else
|
||||
bpf_mtap(is->bpf, m0);
|
||||
}
|
||||
if (is->bpf) {
|
||||
bpf_mtap(is->bpf, m0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -853,26 +793,9 @@ isread(struct is_softc *is, unsigned char *buf, int len)
|
||||
{
|
||||
register struct ether_header *eh;
|
||||
struct mbuf *m;
|
||||
int off, resid;
|
||||
|
||||
/*
|
||||
* Deal with trailer protocol: if type is trailer type
|
||||
* get true type from first 16-bit word past data.
|
||||
* Remember that type was trailer by setting off.
|
||||
*/
|
||||
eh = (struct ether_header *)buf;
|
||||
eh->ether_type = ntohs((u_short)eh->ether_type);
|
||||
len = len - sizeof(struct ether_header) - 4;
|
||||
#define nedataaddr(eh, off, type) ((type)(((caddr_t)((eh)+1)+(off))))
|
||||
if (eh->ether_type >= ETHERTYPE_TRAIL &&
|
||||
eh->ether_type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
|
||||
off = (eh->ether_type - ETHERTYPE_TRAIL) * 512;
|
||||
if (off >= ETHERMTU) return; /* sanity */
|
||||
eh->ether_type = ntohs(*nedataaddr(eh, off, u_short *));
|
||||
resid = ntohs(*(nedataaddr(eh, off+2, u_short *)));
|
||||
if (off + resid > len) return; /* sanity */
|
||||
len = off + resid;
|
||||
} else off = 0;
|
||||
|
||||
if (len == 0) return;
|
||||
|
||||
@ -882,7 +805,7 @@ isread(struct is_softc *is, unsigned char *buf, int len)
|
||||
* information to be at the front, but we still have to drop
|
||||
* the type and length which are at the front of any trailer data.
|
||||
*/
|
||||
m = isget(buf, len, off, &is->arpcom.ac_if);
|
||||
m = isget(buf, len, 0, &is->arpcom.ac_if);
|
||||
if (m == 0) return;
|
||||
#if NBPFILTER > 0
|
||||
/*
|
||||
|
@ -21,9 +21,22 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_le.c,v 1.8 1994/10/19 01:59:03 wollman Exp $
|
||||
* $Id: if_le.c,v 1.9 1994/10/23 21:27:22 wollman Exp $
|
||||
*
|
||||
* $Log: if_le.c,v $
|
||||
* Revision 1.9 1994/10/23 21:27:22 wollman
|
||||
* Finished device configuration database work for all ISA devices (except `ze')
|
||||
* and all SCSI devices (except that it's not done quite the way I want). New
|
||||
* information added includes:
|
||||
*
|
||||
* - A text description of the device
|
||||
* - A ``state''---unknown, unconfigured, idle, or busy
|
||||
* - A generic parent device (with support in the m.i. code)
|
||||
* - An interrupt mask type field (which will hopefully go away) so that
|
||||
* . ``doconfig'' can be written
|
||||
*
|
||||
* This requires a new version of the `lsdev' program as well (next commit).
|
||||
*
|
||||
* Revision 1.8 1994/10/19 01:59:03 wollman
|
||||
* Add support for devconf to a large number of device drivers, and do
|
||||
* the right thing in dev_goawayall() when kdc_goaway is null.
|
||||
@ -476,7 +489,6 @@ le_input(
|
||||
return;
|
||||
}
|
||||
MEMCPY(&eh, seg1, sizeof(eh));
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
|
||||
#if NBPFILTER > 0
|
||||
if (sc->le_bpf != NULL && seg2 == NULL) {
|
||||
|
@ -454,7 +454,6 @@ lnc_rint(int unit)
|
||||
head->m_pkthdr.rcvif = &sc->arpcom.ac_if;
|
||||
head->m_pkthdr.len = pkt_len - sizeof(*eh);
|
||||
eh = (struct ether_header *) head->m_data;
|
||||
eh->ether_type = ntohs(eh->ether_type);
|
||||
head->m_data += sizeof *eh;
|
||||
head->m_len -= sizeof *eh;
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
* $Id: if_ze.c,v 1.8 1994/10/23 21:27:25 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "ze.h"
|
||||
@ -1283,70 +1283,10 @@ outloop:
|
||||
ze_xmit(ifp);
|
||||
/*
|
||||
* If there is BPF support in the configuration, tap off here.
|
||||
* The following has support for converting trailer packets
|
||||
* back to normal.
|
||||
*/
|
||||
#if NBPFILTER > 0
|
||||
if (sc->bpf) {
|
||||
u_short etype;
|
||||
int off, datasize, resid;
|
||||
struct ether_header *eh;
|
||||
struct trailer_header {
|
||||
u_short ether_type;
|
||||
u_short ether_residual;
|
||||
} trailer_header;
|
||||
char ether_packet[ETHER_MAX_LEN];
|
||||
char *ep;
|
||||
|
||||
ep = ether_packet;
|
||||
|
||||
/*
|
||||
* We handle trailers below:
|
||||
* Copy ether header first, then residual data,
|
||||
* then data. Put all this in a temporary buffer
|
||||
* 'ether_packet' and send off to bpf. Since the
|
||||
* system has generated this packet, we assume
|
||||
* that all of the offsets in the packet are
|
||||
* correct; if they're not, the system will almost
|
||||
* certainly crash in m_copydata.
|
||||
* We make no assumptions about how the data is
|
||||
* arranged in the mbuf chain (i.e. how much
|
||||
* data is in each mbuf, if mbuf clusters are
|
||||
* used, etc.), which is why we use m_copydata
|
||||
* to get the ether header rather than assume
|
||||
* that this is located in the first mbuf.
|
||||
*/
|
||||
/* copy ether header */
|
||||
m_copydata(m0, 0, sizeof(struct ether_header), ep);
|
||||
eh = (struct ether_header *) ep;
|
||||
ep += sizeof(struct ether_header);
|
||||
etype = ntohs(eh->ether_type);
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
|
||||
datasize = ((etype - ETHERTYPE_TRAIL) << 9);
|
||||
off = datasize + sizeof(struct ether_header);
|
||||
|
||||
/* copy trailer_header into a data structure */
|
||||
m_copydata(m0, off, sizeof(struct trailer_header),
|
||||
&trailer_header.ether_type);
|
||||
|
||||
/* copy residual data */
|
||||
m_copydata(m0, off+sizeof(struct trailer_header),
|
||||
resid = ntohs(trailer_header.ether_residual) -
|
||||
sizeof(struct trailer_header), ep);
|
||||
ep += resid;
|
||||
|
||||
/* copy data */
|
||||
m_copydata(m0, sizeof(struct ether_header),
|
||||
datasize, ep);
|
||||
ep += datasize;
|
||||
|
||||
/* restore original ether packet type */
|
||||
eh->ether_type = trailer_header.ether_type;
|
||||
|
||||
bpf_tap(sc->bpf, ether_packet, ep - ether_packet);
|
||||
} else
|
||||
bpf_mtap(sc->bpf, m0);
|
||||
bpf_mtap(sc->bpf, m0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1850,38 +1790,6 @@ ze_get_packet(sc, buf, len)
|
||||
head->m_len += sizeof(struct ether_header);
|
||||
len -= sizeof(struct ether_header);
|
||||
|
||||
etype = ntohs((u_short)eh->ether_type);
|
||||
|
||||
/*
|
||||
* Deal with trailer protocol:
|
||||
* If trailer protocol, calculate the datasize as 'off',
|
||||
* which is also the offset to the trailer header.
|
||||
* Set resid to the amount of packet data following the
|
||||
* trailer header.
|
||||
* Finally, copy residual data into mbuf chain.
|
||||
*/
|
||||
if (etype >= ETHERTYPE_TRAIL &&
|
||||
etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
|
||||
|
||||
off = (etype - ETHERTYPE_TRAIL) << 9;
|
||||
if ((off + sizeof(struct trailer_header)) > len)
|
||||
goto bad; /* insanity */
|
||||
|
||||
eh->ether_type = *ringoffset(sc, buf, off, u_short *);
|
||||
resid = ntohs(*ringoffset(sc, buf, off+2, u_short *));
|
||||
|
||||
if ((off + resid) > len) goto bad; /* insanity */
|
||||
|
||||
resid -= sizeof(struct trailer_header);
|
||||
if (resid < 0) goto bad; /* insanity */
|
||||
|
||||
m = ze_ring_to_mbuf(sc, ringoffset(sc, buf, off+4, char *), head, resid);
|
||||
if (m == NULL) goto bad;
|
||||
|
||||
len = off;
|
||||
head->m_pkthdr.len -= 4; /* subtract trailer header */
|
||||
}
|
||||
|
||||
/*
|
||||
* Pull packet off interface. Or if this was a trailer packet,
|
||||
* the data portion is appended.
|
||||
@ -1921,11 +1829,6 @@ ze_get_packet(sc, buf, len)
|
||||
*/
|
||||
m_adj(head, sizeof(struct ether_header));
|
||||
|
||||
/*
|
||||
* silly ether_input routine needs 'type' in host byte order
|
||||
*/
|
||||
eh->ether_type = ntohs(eh->ether_type);
|
||||
|
||||
ether_input(&sc->arpcom.ac_if, eh, head);
|
||||
return;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_de.c,v 1.6 1994/11/13 12:39:38 davidg Exp $
|
||||
* $Id: if_de.c,v 1.7 1994/11/22 09:47:31 davidg Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -394,7 +394,6 @@ tulip_rx_intr(
|
||||
}
|
||||
#endif
|
||||
eh = *(struct ether_header *) bufaddr;
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
#if NBPFILTER > 0
|
||||
if (sc->tulip_bpf != NULL) {
|
||||
bpf_tap(sc->tulip_bpf, bufaddr, total_len);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: if_ethersubr.c,v 1.2 1994/08/02 07:46:14 davidg Exp $
|
||||
* $Id: if_ethersubr.c,v 1.3 1994/10/11 23:16:24 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -311,6 +311,7 @@ ether_input(ifp, eh, m)
|
||||
register struct ifqueue *inq;
|
||||
register struct llc *l;
|
||||
struct arpcom *ac = (struct arpcom *)ifp;
|
||||
u_short ether_type;
|
||||
int s;
|
||||
|
||||
if ((ifp->if_flags & IFF_UP) == 0) {
|
||||
@ -327,7 +328,9 @@ ether_input(ifp, eh, m)
|
||||
if (m->m_flags & (M_BCAST|M_MCAST))
|
||||
ifp->if_imcasts++;
|
||||
|
||||
switch (eh->ether_type) {
|
||||
ether_type = ntohs(eh->ether_type);
|
||||
|
||||
switch (ether_type) {
|
||||
#ifdef INET
|
||||
case ETHERTYPE_IP:
|
||||
schednetisr(NETISR_IP);
|
||||
@ -348,7 +351,7 @@ ether_input(ifp, eh, m)
|
||||
#endif
|
||||
default:
|
||||
#if defined (ISO) || defined (LLC)
|
||||
if (eh->ether_type > ETHERMTU)
|
||||
if (ether_type > ETHERMTU)
|
||||
goto dropanyway;
|
||||
l = mtod(m, struct llc *);
|
||||
switch (l->llc_dsap) {
|
||||
@ -360,8 +363,8 @@ ether_input(ifp, eh, m)
|
||||
if ((l->llc_dsap == LLC_ISO_LSAP) &&
|
||||
(l->llc_ssap == LLC_ISO_LSAP)) {
|
||||
/* LSAP for ISO */
|
||||
if (m->m_pkthdr.len > eh->ether_type)
|
||||
m_adj(m, eh->ether_type - m->m_pkthdr.len);
|
||||
if (m->m_pkthdr.len > ether_type)
|
||||
m_adj(m, ether_type - m->m_pkthdr.len);
|
||||
m->m_data += 3; /* XXX */
|
||||
m->m_len -= 3; /* XXX */
|
||||
m->m_pkthdr.len -= 3; /* XXX */
|
||||
@ -421,8 +424,8 @@ ether_input(ifp, eh, m)
|
||||
#ifdef LLC
|
||||
case LLC_X25_LSAP:
|
||||
{
|
||||
if (m->m_pkthdr.len > eh->ether_type)
|
||||
m_adj(m, eh->ether_type - m->m_pkthdr.len);
|
||||
if (m->m_pkthdr.len > ether_type)
|
||||
m_adj(m, ether_type - m->m_pkthdr.len);
|
||||
M_PREPEND(m, sizeof(struct sdl_hdr) , M_DONTWAIT);
|
||||
if (m == 0)
|
||||
return;
|
||||
@ -430,7 +433,7 @@ ether_input(ifp, eh, m)
|
||||
eh->ether_dhost, LLC_X25_LSAP, 6,
|
||||
mtod(m, struct sdl_hdr *)))
|
||||
panic("ETHER cons addr failure");
|
||||
mtod(m, struct sdl_hdr *)->sdlhdr_len = eh->ether_type;
|
||||
mtod(m, struct sdl_hdr *)->sdlhdr_len = ether_type;
|
||||
#ifdef LLC_DEBUG
|
||||
printf("llc packet\n");
|
||||
#endif /* LLC_DEBUG */
|
||||
|
@ -21,7 +21,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: if_de.c,v 1.6 1994/11/13 12:39:38 davidg Exp $
|
||||
* $Id: if_de.c,v 1.7 1994/11/22 09:47:31 davidg Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -394,7 +394,6 @@ tulip_rx_intr(
|
||||
}
|
||||
#endif
|
||||
eh = *(struct ether_header *) bufaddr;
|
||||
eh.ether_type = ntohs(eh.ether_type);
|
||||
#if NBPFILTER > 0
|
||||
if (sc->tulip_bpf != NULL) {
|
||||
bpf_tap(sc->tulip_bpf, bufaddr, total_len);
|
||||
|
Loading…
Reference in New Issue
Block a user