[U-Boot] [PATCH 09/28] net: cosmetic: Un-typedef variables in net

Joe Hershberger joe.hershberger at ni.com
Fri Jan 20 01:53:12 CET 2012


Un-typedef IP_t, Ethernet_t, VLAN_Ethernet_t, ARP_t, ICMP_t
Rename IP header related things to IP_UDP
The existing definition of IP_t includes UDP header, so name it to
accurately describe the structure

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
Cc: Wolfgang Denk <wd at denx.de>
---
 arch/powerpc/cpu/mpc8260/ether_fcc.c |   10 ++--
 drivers/net/netconsole.c             |    4 +-
 include/net.h                        |   30 ++++++-----
 net/arp.c                            |   12 ++--
 net/arp.h                            |    2 +-
 net/bootp.c                          |    8 ++--
 net/bootp.h                          |    2 +-
 net/cdp.c                            |    4 +-
 net/dns.c                            |    2 +-
 net/net.c                            |   87 +++++++++++++++++----------------
 net/nfs.c                            |    2 +-
 net/ping.c                           |   18 ++++----
 net/ping.h                           |    2 +-
 net/rarp.c                           |   10 ++--
 net/rarp.h                           |    2 +-
 net/sntp.c                           |    2 +-
 net/tftp.c                           |    2 +-
 17 files changed, 102 insertions(+), 97 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8260/ether_fcc.c b/arch/powerpc/cpu/mpc8260/ether_fcc.c
index 879ec0e..f59d9e1 100644
--- a/arch/powerpc/cpu/mpc8260/ether_fcc.c
+++ b/arch/powerpc/cpu/mpc8260/ether_fcc.c
@@ -1049,11 +1049,11 @@ eth_loopback_test (void)
 					}
 					else {
 						ushort datlen = bdp->cbd_datlen;
-						Ethernet_t *ehp;
+						struct Ethernet_t *ehp;
 						ushort prot;
 						int ours, tb, n, nbytes;
 
-						ehp = (Ethernet_t *) \
+						ehp = (struct Ethernet_t *) \
 							&ecp->rxbufs[i][0];
 
 						ours = memcmp (ehp->et_src, \
@@ -1064,9 +1064,9 @@ eth_loopback_test (void)
 						n = prot & 0x7fff;
 
 						nbytes = ELBT_BUFSZ - \
-							offsetof (Ethernet_t, \
-								et_dsap) - \
-							ELBT_CRCSZ;
+							offsetof(
+							struct Ethernet_t, \
+							et_dsap) - ELBT_CRCSZ;
 
 						/* check the frame is correct */
 						if (datlen != ELBT_BUFSZ)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 7acd5b0..ba02fd7 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -69,7 +69,7 @@ void NcStart(void)
 		/* send arp request */
 		uchar *pkt;
 		NetSetHandler(nc_wait_arp_handler);
-		pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
+		pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
 		memcpy(pkt, output_packet, output_packet_len);
 		NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
 			output_packet_len);
@@ -131,7 +131,7 @@ static void nc_send_packet(const char *buf, int len)
 			return;
 		inited = 1;
 	}
-	pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
+	pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
 	memcpy(pkt, buf, len);
 	ether = nc_ether;
 	ip = nc_ip;
diff --git a/include/net.h b/include/net.h
index 2d00233..9de1181 100644
--- a/include/net.h
+++ b/include/net.h
@@ -155,7 +155,7 @@ u32 ether_crc(size_t len, unsigned char const *p);
 /*
  *	Ethernet header
  */
-typedef struct {
+struct Ethernet_t {
 	uchar		et_dest[6];	/* Destination node		*/
 	uchar		et_src[6];	/* Source node			*/
 	ushort		et_protlen;	/* Protocol or length		*/
@@ -166,7 +166,7 @@ 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	*/
@@ -174,13 +174,13 @@ typedef struct {
 /*
  *	Ethernet header
  */
-typedef struct {
+struct VLAN_Ethernet_t {
 	uchar		vet_dest[6];	/* Destination node		*/
 	uchar		vet_src[6];	/* Source node			*/
 	ushort		vet_vlan_type;	/* PROT_VLAN			*/
 	ushort		vet_tag;	/* TAG of VLAN			*/
 	ushort		vet_type;	/* protocol type		*/
-} VLAN_Ethernet_t;
+};
 
 #define VLAN_ETHER_HDR_SIZE	18	/* VLAN Ethernet header size	*/
 
@@ -193,9 +193,9 @@ typedef struct {
 #define IPPROTO_UDP	17	/* User Datagram Protocol		*/
 
 /*
- *	Internet Protocol (IP) header.
+ *	Internet Protocol (IP) + UDP header.
  */
-typedef struct {
+struct IP_UDP_t {
 	uchar		ip_hl_v;	/* header length and version	*/
 	uchar		ip_tos;		/* type of service		*/
 	ushort		ip_len;		/* total length			*/
@@ -210,7 +210,7 @@ typedef struct {
 	ushort		udp_dst;	/* UDP destination port		*/
 	ushort		udp_len;	/* Length of UDP packet		*/
 	ushort		udp_xsum;	/* Checksum			*/
-} IP_t;
+};
 
 #define IP_OFFS		0x1fff /* ip offset *= 8 */
 #define IP_FLAGS	0xe000 /* first 3 bits */
@@ -218,15 +218,15 @@ typedef struct {
 #define IP_FLAGS_DFRAG	0x4000 /* don't fragments */
 #define IP_FLAGS_MFRAG	0x2000 /* more fragments */
 
-#define IP_HDR_SIZE_NO_UDP	(sizeof(IP_t) - 8)
-#define IP_HDR_SIZE		(sizeof(IP_t))
+#define UDP_HDR_SIZE		(sizeof(ushort) * 4)
+#define IP_HDR_SIZE		(sizeof(struct IP_UDP_t) - UDP_HDR_SIZE)
+#define IP_UDP_HDR_SIZE		(sizeof(struct IP_UDP_t))
 
 
 /*
  *	Address Resolution Protocol (ARP) header.
  */
-typedef struct
-{
+struct ARP_t {
 	ushort		ar_hrd;		/* Format of hardware address	*/
 #   define ARP_ETHER	    1		/* Ethernet  hardware address	*/
 	ushort		ar_pro;		/* Format of protocol address	*/
@@ -251,7 +251,7 @@ typedef struct
 	uchar		ar_tha[];	/* Target hardware address	*/
 	uchar		ar_tpa[];	/* Target protocol address	*/
 #endif /* 0 */
-} ARP_t;
+};
 
 #define ARP_HDR_SIZE	(8+20)		/* Size assuming ethernet	*/
 
@@ -270,7 +270,7 @@ typedef struct
 /* Codes for NOT_REACH */
 #define ICMP_NOT_REACH_PORT	3	/* Port unreachable		*/
 
-typedef struct icmphdr {
+struct ICMP_t {
 	uchar		type;
 	uchar		code;
 	ushort		checksum;
@@ -286,8 +286,10 @@ typedef struct icmphdr {
 		} frag;
 		uchar data[0];
 	} un;
-} ICMP_t;
+};
 
+#define ICMP_HDR_SIZE		(sizeof(struct ICMP_t))
+#define IP_ICMP_HDR_SIZE	(IP_HDR_SIZE + ICMP_HDR_SIZE)
 
 /*
  * Maximum packet size; used to allocate packet storage.
diff --git a/net/arp.c b/net/arp.c
index f75217c..96ffb85 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -51,7 +51,7 @@ void ArpInit(void)
 void ArpRequest(void)
 {
 	uchar *pkt;
-	ARP_t *arp;
+	struct ARP_t *arp;
 
 	debug("ARP broadcast %d\n", NetArpWaitTry);
 
@@ -59,7 +59,7 @@ void ArpRequest(void)
 
 	pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
 
-	arp = (ARP_t *) pkt;
+	arp = (struct ARP_t *) pkt;
 
 	arp->ar_hrd = htons(ARP_ETHER);
 	arp->ar_pro = htons(PROT_IP);
@@ -113,9 +113,9 @@ void ArpTimeoutCheck(void)
 	}
 }
 
-void ArpReceive(Ethernet_t *et, IP_t *ip, int len)
+void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len)
 {
-	ARP_t *arp;
+	struct ARP_t *arp;
 	IPaddr_t tmp;
 	uchar *pkt;
 
@@ -130,7 +130,7 @@ void ArpReceive(Ethernet_t *et, IP_t *ip, int len)
 	 */
 	debug("Got ARP\n");
 
-	arp = (ARP_t *)ip;
+	arp = (struct ARP_t *)ip;
 	if (len < ARP_HDR_SIZE) {
 		printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
 		return;
@@ -193,7 +193,7 @@ void ArpReceive(Ethernet_t *et, IP_t *ip, int len)
 			NetGetHandler()(0, 0, 0, 0, 0);
 #endif
 			/* modify header, and transmit it */
-			memcpy(((Ethernet_t *)NetArpWaitTxPacket)->
+			memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)->
 				et_dest, NetArpWaitPacketMAC, 6);
 			(void) eth_send(NetArpWaitTxPacket,
 					NetArpWaitTxPacketSize);
diff --git a/net/arp.h b/net/arp.h
index 09c763d..d9ce03d 100644
--- 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, IP_t *ip, int len);
+void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len);
 
 #endif /* __ARP_H__ */
diff --git a/net/bootp.c b/net/bootp.c
index 9824cd1..e95419f 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -105,7 +105,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_t *)NetRxPacket)->et_src, 6);
 #endif
 	if (strlen(bp->bp_file) > 0)
 		copy_filename(BootFile, bp->bp_file, sizeof(BootFile));
@@ -621,8 +621,8 @@ BootpRequest(void)
 	 */
 	/* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC,
 		sizeof (struct Bootp_t)); */
-	iphdr = pkt;	/* We need this later for NetSetIP() */
-	pkt += IP_HDR_SIZE;
+	iphdr = pkt;	/* We need this later for NetSetUDPHeader() */
+	pkt += IP_UDP_HDR_SIZE;
 
 	bp = (struct Bootp_t *)pkt;
 	bp->bp_op = OP_BOOTREQUEST;
@@ -807,7 +807,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
 	pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
 
 	iphdr = pkt;	/* We'll need this later to set proper pkt size */
-	pkt += IP_HDR_SIZE;
+	pkt += IP_UDP_HDR_SIZE;
 
 	bp = (struct Bootp_t *)pkt;
 	bp->bp_op = OP_BOOTREQUEST;
diff --git a/net/bootp.h b/net/bootp.h
index bf4e875..1cf9a02 100644
--- a/net/bootp.h
+++ b/net/bootp.h
@@ -52,7 +52,7 @@ struct Bootp_t {
 };
 
 #define BOOTP_HDR_SIZE	sizeof(struct Bootp_t)
-#define BOOTP_SIZE	(ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE)
+#define BOOTP_SIZE	(ETHER_HDR_SIZE + IP_UDP_HDR_SIZE + BOOTP_HDR_SIZE)
 
 /**********************************************************************/
 /*
diff --git a/net/cdp.c b/net/cdp.c
index c5e54b2..d617f18 100644
--- a/net/cdp.c
+++ b/net/cdp.c
@@ -108,7 +108,7 @@ CDPSendTrigger(void)
 	uchar *pkt;
 	ushort *s;
 	ushort *cp;
-	Ethernet_t *et;
+	struct Ethernet_t *et;
 	int len;
 	ushort chksum;
 #if	defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID)   || \
@@ -117,7 +117,7 @@ CDPSendTrigger(void)
 #endif
 
 	pkt = NetTxPacket;
-	et = (Ethernet_t *)pkt;
+	et = (struct Ethernet_t *)pkt;
 
 	/* NOTE: trigger sent not on any VLAN */
 
diff --git a/net/dns.c b/net/dns.c
index 7a3f1f9..cc7ed51 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -45,7 +45,7 @@ DnsSend(void)
 	enum dns_query_type qtype = DNS_A_RECORD;
 
 	name = NetDNSResolve;
-	pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE);
+	pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE);
 
 	/* Prepare DNS packet header */
 	header           = (struct header *) pkt;
diff --git a/net/net.c b/net/net.c
index fdc1ebe..023802d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -625,12 +625,13 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 		pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
 
 		NetSetIP(pkt, dest, dport, sport, len);
-		memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
-		       (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
+		memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket +
+		       (pkt - (uchar *)NetArpWaitTxPacket) +
+		       IP_UDP_HDR_SIZE, len);
 
 		/* size of the waiting packet */
 		NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) +
-			IP_HDR_SIZE + len;
+			IP_UDP_HDR_SIZE + len;
 
 		/* and do the ARP request */
 		NetArpWaitTry = 1;
@@ -644,7 +645,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 	pkt = (uchar *)NetTxPacket;
 	pkt += NetSetEther(pkt, ether, PROT_IP);
 	NetSetIP(pkt, dest, dport, sport, len);
-	(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
+	eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + len);
 
 	return 0;	/* transmitted */
 }
@@ -668,7 +669,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 static struct rpc_t rpc_specimen;
 #define IP_PKTSIZE (CONFIG_NET_MAXDEFRAG + sizeof(rpc_specimen.u.reply))
 
-#define IP_MAXUDP (IP_PKTSIZE - IP_HDR_SIZE_NO_UDP)
+#define IP_MAXUDP (IP_PKTSIZE - IP_HDR_SIZE)
 
 /*
  * this is the packet being assembled, either data or frag control.
@@ -682,22 +683,22 @@ struct hole {
 	u16 unused;
 };
 
-static IP_t *__NetDefragment(IP_t *ip, int *lenp)
+static struct IP_UDP_t *__NetDefragment(struct IP_UDP_t *ip, int *lenp)
 {
 	static uchar pkt_buff[IP_PKTSIZE] __attribute__((aligned(PKTALIGN)));
 	static u16 first_hole, total_len;
 	struct hole *payload, *thisfrag, *h, *newh;
-	IP_t *localip = (IP_t *)pkt_buff;
+	struct IP_UDP_t *localip = (struct IP_UDP_t *)pkt_buff;
 	uchar *indata = (uchar *)ip;
 	int offset8, start, len, done = 0;
 	u16 ip_off = ntohs(ip->ip_off);
 
 	/* payload starts after IP header, this fragment is in there */
-	payload = (struct hole *)(pkt_buff + IP_HDR_SIZE_NO_UDP);
+	payload = (struct hole *)(pkt_buff + IP_HDR_SIZE);
 	offset8 =  (ip_off & IP_OFFS);
 	thisfrag = payload + offset8;
 	start = offset8 * 8;
-	len = ntohs(ip->ip_len) - IP_HDR_SIZE_NO_UDP;
+	len = ntohs(ip->ip_len) - IP_HDR_SIZE;
 
 	if (start + len > IP_MAXUDP) /* fragment extends too far */
 		return NULL;
@@ -710,7 +711,7 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
 		payload[0].prev_hole = 0;
 		first_hole = 0;
 		/* any IP header will work, copy the first we received */
-		memcpy(localip, ip, IP_HDR_SIZE_NO_UDP);
+		memcpy(localip, ip, IP_HDR_SIZE);
 	}
 
 	/*
@@ -793,16 +794,16 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
 	}
 
 	/* finally copy this fragment and possibly return whole packet */
-	memcpy((uchar *)thisfrag, indata + IP_HDR_SIZE_NO_UDP, len);
+	memcpy((uchar *)thisfrag, indata + IP_HDR_SIZE, len);
 	if (!done)
 		return NULL;
 
 	localip->ip_len = htons(total_len);
-	*lenp = total_len + IP_HDR_SIZE_NO_UDP;
+	*lenp = total_len + IP_HDR_SIZE;
 	return localip;
 }
 
-static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
+static inline struct IP_UDP_t *NetDefragment(struct IP_UDP_t *ip, int *lenp)
 {
 	u16 ip_off = ntohs(ip->ip_off);
 	if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
@@ -812,7 +813,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
 
 #else /* !CONFIG_IP_DEFRAG */
 
-static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
+static inline struct IP_UDP_t *NetDefragment(struct IP_UDP_t *ip, int *lenp)
 {
 	u16 ip_off = ntohs(ip->ip_off);
 	if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
@@ -827,9 +828,10 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
  *
  * @parma ip	IP packet containing the ICMP
  */
-static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
+static void receive_icmp(struct IP_UDP_t *ip, int len,
+			IPaddr_t src_ip, struct Ethernet_t *et)
 {
-	ICMP_t *icmph = (ICMP_t *)&ip->udp_src;
+	struct ICMP_t *icmph = (struct ICMP_t *)&(ip->udp_src);
 
 	switch (icmph->type) {
 	case ICMP_REDIRECT:
@@ -855,8 +857,8 @@ static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
 void
 NetReceive(volatile uchar *inpkt, int len)
 {
-	Ethernet_t *et;
-	IP_t	*ip;
+	struct Ethernet_t *et;
+	struct IP_UDP_t	*ip;
 	IPaddr_t tmp;
 	IPaddr_t src_ip;
 	int	x;
@@ -869,7 +871,7 @@ NetReceive(volatile uchar *inpkt, int len)
 
 	NetRxPacket = (uchar *)inpkt;
 	NetRxPacketLen = len;
-	et = (Ethernet_t *)NetRxPacket;
+	et = (struct Ethernet_t *)NetRxPacket;
 
 	/* too small packet? */
 	if (len < ETHER_HDR_SIZE)
@@ -904,15 +906,15 @@ NetReceive(volatile uchar *inpkt, int len)
 		 */
 		x = ntohs(et->et_prot);
 
-		ip = (IP_t *)(NetRxPacket + E802_HDR_SIZE);
+		ip = (struct IP_UDP_t *)(NetRxPacket + E802_HDR_SIZE);
 		len -= E802_HDR_SIZE;
 
 	} else if (x != PROT_VLAN) {	/* normal packet */
-		ip = (IP_t *)(NetRxPacket + ETHER_HDR_SIZE);
+		ip = (struct IP_UDP_t *)(NetRxPacket + ETHER_HDR_SIZE);
 		len -= ETHER_HDR_SIZE;
 
 	} else {			/* VLAN packet */
-		VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)et;
+		struct VLAN_Ethernet_t *vet = (struct VLAN_Ethernet_t *)et;
 
 		debug("VLAN packet received\n");
 
@@ -932,7 +934,7 @@ NetReceive(volatile uchar *inpkt, int len)
 		vlanid = cti & VLAN_IDMASK;
 		x = ntohs(vet->vet_type);
 
-		ip = (IP_t *)(NetRxPacket + VLAN_ETHER_HDR_SIZE);
+		ip = (struct IP_UDP_t *)(NetRxPacket + VLAN_ETHER_HDR_SIZE);
 		len -= VLAN_ETHER_HDR_SIZE;
 	}
 
@@ -967,8 +969,9 @@ NetReceive(volatile uchar *inpkt, int len)
 	case PROT_IP:
 		debug("Got IP\n");
 		/* Before we start poking the header, make sure it is there */
-		if (len < IP_HDR_SIZE) {
-			debug("len bad %d < %lu\n", len, (ulong)IP_HDR_SIZE);
+		if (len < IP_UDP_HDR_SIZE) {
+			debug("len bad %d < %lu\n", len,
+				(ulong)IP_UDP_HDR_SIZE);
 			return;
 		}
 		/* Check the packet length */
@@ -986,7 +989,7 @@ NetReceive(volatile uchar *inpkt, int len)
 		if ((ip->ip_hl_v & 0x0f) > 0x05)
 			return;
 		/* Check the Checksum of the header */
-		if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
+		if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE / 2)) {
 			puts("checksum bad\n");
 			return;
 		}
@@ -1080,19 +1083,19 @@ NetReceive(volatile uchar *inpkt, int len)
 
 
 #ifdef CONFIG_NETCONSOLE
-		nc_input_packet((uchar *)ip + IP_HDR_SIZE,
-						ntohs(ip->udp_dst),
-						ntohs(ip->udp_src),
-						ntohs(ip->udp_len) - 8);
+		nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE,
+					ntohs(ip->udp_dst),
+					ntohs(ip->udp_src),
+					ntohs(ip->udp_len) - UDP_HDR_SIZE);
 #endif
 		/*
 		 *	IP header OK.  Pass the packet to the current handler.
 		 */
-		(*packetHandler)((uchar *)ip + IP_HDR_SIZE,
-						ntohs(ip->udp_dst),
-						src_ip,
-						ntohs(ip->udp_src),
-						ntohs(ip->udp_len) - 8);
+		(*packetHandler)((uchar *)ip + IP_UDP_HDR_SIZE,
+					ntohs(ip->udp_dst),
+					src_ip,
+					ntohs(ip->udp_src),
+					ntohs(ip->udp_len) - UDP_HDR_SIZE);
 		break;
 	}
 }
@@ -1221,7 +1224,7 @@ NetEthHdrSize(void)
 int
 NetSetEther(uchar *xet, uchar * addr, uint prot)
 {
-	Ethernet_t *et = (Ethernet_t *)xet;
+	struct Ethernet_t *et = (struct Ethernet_t *)xet;
 	ushort myvlanid;
 
 	myvlanid = ntohs(NetOurVLAN);
@@ -1234,7 +1237,7 @@ NetSetEther(uchar *xet, uchar * addr, uint prot)
 		et->et_protlen = htons(prot);
 		return ETHER_HDR_SIZE;
 	} else {
-		VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)xet;
+		struct VLAN_Ethernet_t *vet = (struct VLAN_Ethernet_t *)xet;
 
 		vet->vet_vlan_type = htons(PROT_VLAN);
 		vet->vet_tag = htons((0 << 5) | (myvlanid & VLAN_IDMASK));
@@ -1246,7 +1249,7 @@ NetSetEther(uchar *xet, uchar * addr, uint prot)
 void
 NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 {
-	IP_t *ip = (IP_t *)xip;
+	struct IP_UDP_t *ip = (struct IP_UDP_t *)xip;
 
 	/*
 	 *	If the data is an odd number of bytes, zero the
@@ -1254,7 +1257,7 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 	 *	will work.
 	 */
 	if (len & 1)
-		xip[IP_HDR_SIZE + len] = 0;
+		xip[IP_UDP_HDR_SIZE + len] = 0;
 
 	/*
 	 *	Construct an IP and UDP header.
@@ -1263,7 +1266,7 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 	/* IP_HDR_SIZE / 4 (not including UDP) */
 	ip->ip_hl_v  = 0x45;
 	ip->ip_tos   = 0;
-	ip->ip_len   = htons(IP_HDR_SIZE + len);
+	ip->ip_len   = htons(IP_UDP_HDR_SIZE + len);
 	ip->ip_id    = htons(NetIPID++);
 	ip->ip_off   = htons(IP_FLAGS_DFRAG);	/* Don't fragment */
 	ip->ip_ttl   = 255;
@@ -1275,9 +1278,9 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
 	NetCopyIP((void *)&ip->ip_dst, &dest);
 	ip->udp_src  = htons(sport);
 	ip->udp_dst  = htons(dport);
-	ip->udp_len  = htons(8 + len);
+	ip->udp_len  = htons(UDP_HDR_SIZE + len);
 	ip->udp_xsum = 0;
-	ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
+	ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE / 2);
 }
 
 void copy_filename(char *dst, const char *src, int size)
diff --git a/net/nfs.c b/net/nfs.c
index 54f56c4..b6188fe 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -189,7 +189,7 @@ rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
 
 	pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
 
-	memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
+	memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
 		(char *)&pkt, pktlen);
 
 	if (rpc_prog == PROG_PORTMAP)
diff --git a/net/ping.c b/net/ping.c
index 4a66b8d..34e287c 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -19,7 +19,7 @@ IPaddr_t NetPingIP;
 static int PingSend(void)
 {
 	static uchar mac[6];
-	IP_t *ip;
+	struct IP_UDP_t *ip;
 	ushort *s;
 	uchar *pkt;
 
@@ -35,7 +35,7 @@ static int PingSend(void)
 	pkt = NetArpWaitTxPacket;
 	pkt += NetSetEther(pkt, mac, PROT_IP);
 
-	ip = (IP_t *)pkt;
+	ip = (struct IP_UDP_t *)pkt;
 
 	/*
 	 * Construct an IP and ICMP header.
@@ -44,7 +44,7 @@ static int PingSend(void)
 	/* IP_HDR_SIZE / 4 (not including UDP) */
 	ip->ip_hl_v  = 0x45;
 	ip->ip_tos   = 0;
-	ip->ip_len   = htons(IP_HDR_SIZE_NO_UDP + 8);
+	ip->ip_len   = htons(IP_HDR_SIZE + 8);
 	ip->ip_id    = htons(NetIPID++);
 	ip->ip_off   = htons(IP_FLAGS_DFRAG);	/* Don't fragment */
 	ip->ip_ttl   = 255;
@@ -54,7 +54,7 @@ static int PingSend(void)
 	NetCopyIP((void *)&ip->ip_src, &NetOurIP);
 	/* - "" - */
 	NetCopyIP((void *)&ip->ip_dst, &NetPingIP);
-	ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
+	ip->ip_sum   = ~NetCksum((uchar *)ip, IP_HDR_SIZE / 2);
 
 	s = &ip->udp_src;		/* XXX ICMP starts here */
 	s[0] = htons(0x0800);		/* echo-request, code */
@@ -65,7 +65,7 @@ static int PingSend(void)
 
 	/* size of the waiting packet */
 	NetArpWaitTxPacketSize =
-		(pkt - NetArpWaitTxPacket) + IP_HDR_SIZE_NO_UDP + 8;
+		(pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + 8;
 
 	/* and do the ARP request */
 	NetArpWaitTry = 1;
@@ -101,9 +101,9 @@ PingStart(void)
 	PingSend();
 }
 
-void PingReceive(Ethernet_t *et, IP_t *ip, int len)
+void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len)
 {
-	ICMP_t *icmph = (ICMP_t *)&(ip->udp_src);
+	struct ICMP_t *icmph = (struct ICMP_t *)&(ip->udp_src);
 	IPaddr_t src_ip;
 
 	switch (icmph->type) {
@@ -128,12 +128,12 @@ void PingReceive(Ethernet_t *et, IP_t *ip, int len)
 		NetCopyIP((void *)&ip->ip_dst, &ip->ip_src);
 		NetCopyIP((void *)&ip->ip_src, &NetOurIP);
 		ip->ip_sum = ~NetCksum((uchar *)ip,
-				       IP_HDR_SIZE_NO_UDP >> 1);
+				       IP_HDR_SIZE >> 1);
 
 		icmph->type = ICMP_ECHO_REPLY;
 		icmph->checksum = 0;
 		icmph->checksum = ~NetCksum((uchar *)icmph,
-			(len - IP_HDR_SIZE_NO_UDP) >> 1);
+			(len - IP_HDR_SIZE) >> 1);
 		(void) eth_send((uchar *)et,
 				ETHER_HDR_SIZE + len);
 		return;
diff --git a/net/ping.h b/net/ping.h
index 56aad43..4671909 100644
--- a/net/ping.h
+++ b/net/ping.h
@@ -15,6 +15,6 @@
 #include <net.h>
 
 void PingStart(void);
-void PingReceive(Ethernet_t *et, IP_t *ip, int len);
+void PingReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len);
 
 #endif /* __PING_H__ */
diff --git a/net/rarp.c b/net/rarp.c
index 761560c..305b0a4 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -42,12 +42,12 @@ int		RarpTry;
  *	Handle a RARP received packet.
  */
 void
-RarpReceive(IP_t *ip, unsigned len)
+RarpReceive(struct IP_UDP_t *ip, unsigned len)
 {
-	ARP_t *arp;
+	struct ARP_t *arp;
 
 	debug("Got RARP\n");
-	arp = (ARP_t *)ip;
+	arp = (struct ARP_t *)ip;
 	if (len < ARP_HDR_SIZE) {
 		printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
 		return;
@@ -90,14 +90,14 @@ void
 RarpRequest(void)
 {
 	uchar *pkt;
-	ARP_t *rarp;
+	struct ARP_t *rarp;
 
 	printf("RARP broadcast %d\n", ++RarpTry);
 	pkt = NetTxPacket;
 
 	pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP);
 
-	rarp = (ARP_t *)pkt;
+	rarp = (struct ARP_t *)pkt;
 
 	rarp->ar_hrd = htons(ARP_ETHER);
 	rarp->ar_pro = htons(PROT_IP);
diff --git a/net/rarp.h b/net/rarp.h
index 0d728dc..8723dd3 100644
--- a/net/rarp.h
+++ b/net/rarp.h
@@ -37,7 +37,7 @@
 
 extern int RarpTry;
 
-extern void RarpReceive(IP_t *ip, unsigned len);
+extern void RarpReceive(struct IP_UDP_t *ip, unsigned len);
 extern void RarpRequest(void);	/* Send a RARP request */
 
 /**********************************************************************/
diff --git a/net/sntp.c b/net/sntp.c
index 6dd0dbd..7997f98 100644
--- a/net/sntp.c
+++ b/net/sntp.c
@@ -31,7 +31,7 @@ SntpSend(void)
 	pkt.vn = NTP_VERSION;
 	pkt.mode = NTP_MODE_CLIENT;
 
-	memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
+	memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
 		(char *)&pkt, pktlen);
 
 	SntpOurPort = 10000 + (get_timer(0) % 4096);
diff --git a/net/tftp.c b/net/tftp.c
index bc7fe05..a04a832 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -322,7 +322,7 @@ TftpSend(void)
 	 *	We will always be sending some sort of packet, so
 	 *	cobble together the packet headers now.
 	 */
-	pkt = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE);
+	pkt = NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
 
 	switch (TftpState) {
 	case STATE_SEND_RRQ:
-- 
1.6.0.2



More information about the U-Boot mailing list