net: cosmetic: Un-typedef Ethernet_t
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 07:58:06 +0000 (07:58 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 22:46:14 +0000 (17:46 -0500)
Separate the Ethernet header from the 802 header.
Base the size constants on the structs.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
arch/powerpc/cpu/mpc8260/ether_fcc.c
include/net.h
net/arp.c
net/arp.h
net/bootp.c
net/cdp.c
net/net.c
net/ping.c
net/ping.h

index eed0a4babe7b79d43154715e41aee53aee15175e..18534516a4cd6860c4a58be9ed7b72368b74b964 100644 (file)
@@ -1049,11 +1049,11 @@ eth_loopback_test (void)
                                        }
                                        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, \
@@ -1063,9 +1063,8 @@ eth_loopback_test (void)
                                                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 */
@@ -1080,10 +1079,10 @@ eth_loopback_test (void)
                                                                patwords[n];
                                                        uint nbb;
 
-                                                       nbb = badbits ( \
-                                                               &ehp->et_dsap, \
-                                                               nbytes, \
-                                                               patword);
+                                                       nbb = badbits(
+                                                           ((uchar *)&ehp) +
+                                                           ETHER_HDR_SIZE,
+                                                           nbytes, patword);
 
                                                        ecp->rxeacc.badbit += \
                                                                nbb;
index 7692153b309487b25eb0aa0279b12afb75d665c3..2551516032458ea6fac134c4ca400453dc6a8516 100644 (file)
@@ -156,7 +156,17 @@ u32 ether_crc(size_t len, unsigned char const *p);
 /*
  *     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           */
@@ -167,10 +177,10 @@ typedef struct {
        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
index 03272adf5744b97c5f9cd2e774b913f0b36962d0..c3def633b649e98c51037e90f6d2df46f33af15c 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
@@ -113,7 +113,7 @@ 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)
 {
        ARP_t *arp;
        IPaddr_t tmp;
@@ -193,7 +193,7 @@ void ArpReceive(Ethernet_t *et, struct ip_udp_hdr *ip, int len)
                        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);
index b59fbdd2edab30124a463fdf507a5d081c235b69..b7a1ac97d43306ea1aee52889afe1548cf37d717 100644 (file)
--- a/net/arp.h
+++ b/net/arp.h
@@ -25,6 +25,6 @@ extern int NetArpWaitTry;
 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__ */
index b8d27606761ea4916930714b4fc62b324fb5bf5f..32852500d97e9f522a33e416a5851bb450d2081b 100644 (file)
@@ -103,7 +103,7 @@ static void BootpCopyNetParams(struct Bootp_t *bp)
        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));
index 004aae2ff2ab82fb1281289c99966be6ee8f641e..63be570584fd30e37a822c6a4a0999769cc6968a 100644 (file)
--- a/net/cdp.c
+++ b/net/cdp.c
@@ -109,7 +109,7 @@ CDPSendTrigger(void)
        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)   || \
@@ -118,7 +118,7 @@ CDPSendTrigger(void)
 #endif
 
        pkt = NetTxPacket;
-       et = (Ethernet_t *)pkt;
+       et = (struct ethernet_hdr *)pkt;
 
        /* NOTE: trigger sent not on any VLAN */
 
index 2bf5631f0d4de9f3cf5b195b4e92959fec4f9e9b..33de3996830ac6e7199aa63bc147e38e72ffb56a 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -823,7 +823,7 @@ static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp)
  * @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;
 
@@ -851,7 +851,7 @@ static void receive_icmp(struct ip_udp_hdr *ip, int len,
 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;
@@ -865,7 +865,7 @@ NetReceive(uchar *inpkt, int len)
 
        NetRxPacket = inpkt;
        NetRxPacketLen = len;
-       et = (Ethernet_t *)inpkt;
+       et = (struct ethernet_hdr *)inpkt;
 
        /* too small packet? */
        if (len < ETHER_HDR_SIZE)
@@ -895,10 +895,11 @@ NetReceive(uchar *inpkt, int len)
        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;
@@ -1218,7 +1219,7 @@ NetEthHdrSize(void)
 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);
index 8542e2299b4b1d597f94330673fd655df60c293a..04a594cf53ae9944576fdc7ce525beb1dfa44d6b 100644 (file)
@@ -98,7 +98,7 @@ void ping_start(void)
        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;
index 0a2d7d179763018bb72f595a5e218d1e71cdbe0a..fd8d8d9778b94b658b15c4e0c0c3f98abf00f5a3 100644 (file)
@@ -28,7 +28,7 @@ void ping_start(void);
  * @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