Separate the Ethernet header from the 802 header.
Base the size constants on the structs.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
}
else {
ushort datlen = bdp->cbd_datlen;
- Ethernet_t *ehp;
+ struct ethernet_hdr *ehp;
ushort prot;
int ours, tb, n, nbytes;
- ehp = (Ethernet_t *) \
+ ehp = (struct ethernet_hdr *) \
&ecp->rxbufs[i][0];
ours = memcmp (ehp->et_src, \
tb = prot & 0x8000;
n = prot & 0x7fff;
- nbytes = ELBT_BUFSZ - \
- offsetof (Ethernet_t, \
- et_dsap) - \
+ nbytes = ELBT_BUFSZ -
+ ETHER_HDR_SIZE -
ELBT_CRCSZ;
/* check the frame is correct */
patwords[n];
uint nbb;
- nbb = badbits ( \
- &ehp->et_dsap, \
- nbytes, \
- patword);
+ nbb = badbits(
+ ((uchar *)&ehp) +
+ ETHER_HDR_SIZE,
+ nbytes, patword);
ecp->rxeacc.badbit += \
nbb;
/*
* Ethernet header
*/
-typedef struct {
+
+struct ethernet_hdr {
+ uchar et_dest[6]; /* Destination node */
+ uchar et_src[6]; /* Source node */
+ ushort et_protlen; /* Protocol or length */
+};
+
+/* Ethernet header size */
+#define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr))
+
+struct e802_hdr {
uchar et_dest[6]; /* Destination node */
uchar et_src[6]; /* Source node */
ushort et_protlen; /* Protocol or length */
uchar et_snap2;
uchar et_snap3;
ushort et_prot; /* 802 protocol */
-} Ethernet_t;
+};
-#define ETHER_HDR_SIZE 14 /* Ethernet header size */
-#define E802_HDR_SIZE 22 /* 802 ethernet header size */
+/* 802 ethernet header size */
+#define E802_HDR_SIZE (sizeof(struct e802_hdr))
/*
* Ethernet header
}
}
-void ArpReceive(Ethernet_t *et, struct ip_udp_hdr *ip, int len)
+void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
{
ARP_t *arp;
IPaddr_t tmp;
NetGetHandler()(0, 0, 0, 0, 0);
#endif
/* modify header, and transmit it */
- memcpy(((Ethernet_t *)NetArpWaitTxPacket)->
+ memcpy(((struct ethernet_hdr *)NetArpWaitTxPacket)->
et_dest, NetArpWaitPacketMAC, 6);
(void) eth_send(NetArpWaitTxPacket,
NetArpWaitTxPacketSize);
void ArpInit(void);
void ArpRequest(void);
void ArpTimeoutCheck(void);
-void ArpReceive(Ethernet_t *et, struct ip_udp_hdr *ip, int len);
+void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
#endif /* __ARP_H__ */
NetCopyIP(&tmp_ip, &bp->bp_siaddr);
if (tmp_ip != 0)
NetCopyIP(&NetServerIP, &bp->bp_siaddr);
- memcpy(NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
+ memcpy(NetServerEther, ((struct ethernet_hdr *)NetRxPacket)->et_src, 6);
#endif
if (strlen(bp->bp_file) > 0)
copy_filename(BootFile, bp->bp_file, sizeof(BootFile));
uchar *pkt;
ushort *s;
ushort *cp;
- Ethernet_t *et;
+ struct ethernet_hdr *et;
int len;
ushort chksum;
#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
#endif
pkt = NetTxPacket;
- et = (Ethernet_t *)pkt;
+ et = (struct ethernet_hdr *)pkt;
/* NOTE: trigger sent not on any VLAN */
* @parma ip IP packet containing the ICMP
*/
static void receive_icmp(struct ip_udp_hdr *ip, int len,
- IPaddr_t src_ip, Ethernet_t *et)
+ IPaddr_t src_ip, struct ethernet_hdr *et)
{
ICMP_t *icmph = (ICMP_t *)&ip->udp_src;
void
NetReceive(uchar *inpkt, int len)
{
- Ethernet_t *et;
+ struct ethernet_hdr *et;
struct ip_udp_hdr *ip;
IPaddr_t tmp;
IPaddr_t src_ip;
NetRxPacket = inpkt;
NetRxPacketLen = len;
- et = (Ethernet_t *)inpkt;
+ et = (struct ethernet_hdr *)inpkt;
/* too small packet? */
if (len < ETHER_HDR_SIZE)
debug("packet received\n");
if (x < 1514) {
+ struct e802_hdr *et802 = (struct e802_hdr *)et;
/*
* Got a 802 packet. Check the other protocol field.
*/
- x = ntohs(et->et_prot);
+ x = ntohs(et802->et_prot);
ip = (struct ip_udp_hdr *)(inpkt + E802_HDR_SIZE);
len -= E802_HDR_SIZE;
int
NetSetEther(uchar *xet, uchar * addr, uint prot)
{
- Ethernet_t *et = (Ethernet_t *)xet;
+ struct ethernet_hdr *et = (struct ethernet_hdr *)xet;
ushort myvlanid;
myvlanid = ntohs(NetOurVLAN);
ping_send();
}
-void ping_receive(Ethernet_t *et, struct ip_udp_hdr *ip, int len)
+void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
{
ICMP_t *icmph = (ICMP_t *)&(ip->udp_src);
IPaddr_t src_ip;
* @param ip IP header in the same packet
* @param len Packet length
*/
-void ping_receive(Ethernet_t *et, struct ip_udp_hdr *ip, int len);
+void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
#endif /* __PING_H__ */
#endif