Commit 594c26f8a7dbb83243a5168378a2164fa08d6dd8
1 parent
8b9c53221f
Exists in
master
and in
54 other branches
net: cosmetic: Un-typedef IP_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@ni.com>
Showing 15 changed files with 55 additions and 52 deletions Side-by-side Diff
drivers/net/netconsole.c
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 | /* send arp request */ |
70 | 70 | uchar *pkt; |
71 | 71 | NetSetHandler(nc_wait_arp_handler); |
72 | - pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE; | |
72 | + pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; | |
73 | 73 | memcpy(pkt, output_packet, output_packet_len); |
74 | 74 | NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port, |
75 | 75 | output_packet_len); |
... | ... | @@ -131,7 +131,7 @@ |
131 | 131 | return; |
132 | 132 | inited = 1; |
133 | 133 | } |
134 | - pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE; | |
134 | + pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; | |
135 | 135 | memcpy(pkt, buf, len); |
136 | 136 | ether = nc_ether; |
137 | 137 | ip = nc_ip; |
include/net.h
... | ... | @@ -194,9 +194,9 @@ |
194 | 194 | #define IPPROTO_UDP 17 /* User Datagram Protocol */ |
195 | 195 | |
196 | 196 | /* |
197 | - * Internet Protocol (IP) header. | |
197 | + * Internet Protocol (IP) + UDP header. | |
198 | 198 | */ |
199 | -typedef struct { | |
199 | +struct ip_udp_hdr { | |
200 | 200 | uchar ip_hl_v; /* header length and version */ |
201 | 201 | uchar ip_tos; /* type of service */ |
202 | 202 | ushort ip_len; /* total length */ |
... | ... | @@ -211,7 +211,7 @@ |
211 | 211 | ushort udp_dst; /* UDP destination port */ |
212 | 212 | ushort udp_len; /* Length of UDP packet */ |
213 | 213 | ushort udp_xsum; /* Checksum */ |
214 | -} IP_t; | |
214 | +}; | |
215 | 215 | |
216 | 216 | #define IP_OFFS 0x1fff /* ip offset *= 8 */ |
217 | 217 | #define IP_FLAGS 0xe000 /* first 3 bits */ |
218 | 218 | |
... | ... | @@ -219,9 +219,10 @@ |
219 | 219 | #define IP_FLAGS_DFRAG 0x4000 /* don't fragments */ |
220 | 220 | #define IP_FLAGS_MFRAG 0x2000 /* more fragments */ |
221 | 221 | |
222 | -#define IP_HDR_SIZE_NO_UDP (sizeof(IP_t) - 8) | |
223 | -#define IP_HDR_SIZE (sizeof(IP_t)) | |
222 | +#define IP_HDR_SIZE_NO_UDP (sizeof(struct ip_udp_hdr) - 8) | |
224 | 223 | |
224 | +#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr)) | |
225 | +#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE_NO_UDP) | |
225 | 226 | |
226 | 227 | /* |
227 | 228 | * Address Resolution Protocol (ARP) header. |
net/arp.c
net/arp.h
net/bootp.c
... | ... | @@ -622,7 +622,7 @@ |
622 | 622 | /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, |
623 | 623 | sizeof (struct Bootp_t)); */ |
624 | 624 | iphdr = pkt; /* We need this later for NetSetIP() */ |
625 | - pkt += IP_HDR_SIZE; | |
625 | + pkt += IP_UDP_HDR_SIZE; | |
626 | 626 | |
627 | 627 | bp = (struct Bootp_t *)pkt; |
628 | 628 | bp->bp_op = OP_BOOTREQUEST; |
... | ... | @@ -807,7 +807,7 @@ |
807 | 807 | pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); |
808 | 808 | |
809 | 809 | iphdr = pkt; /* We'll need this later to set proper pkt size */ |
810 | - pkt += IP_HDR_SIZE; | |
810 | + pkt += IP_UDP_HDR_SIZE; | |
811 | 811 | |
812 | 812 | bp = (struct Bootp_t *)pkt; |
813 | 813 | bp->bp_op = OP_BOOTREQUEST; |
net/bootp.h
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | }; |
53 | 53 | |
54 | 54 | #define BOOTP_HDR_SIZE sizeof(struct Bootp_t) |
55 | -#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE) | |
55 | +#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_UDP_HDR_SIZE + BOOTP_HDR_SIZE) | |
56 | 56 | |
57 | 57 | /**********************************************************************/ |
58 | 58 | /* |
net/dns.c
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | enum dns_query_type qtype = DNS_A_RECORD; |
46 | 46 | |
47 | 47 | name = NetDNSResolve; |
48 | - pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE); | |
48 | + pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE); | |
49 | 49 | |
50 | 50 | /* Prepare DNS packet header */ |
51 | 51 | header = (struct header *) pkt; |
net/net.c
... | ... | @@ -619,12 +619,13 @@ |
619 | 619 | pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP); |
620 | 620 | |
621 | 621 | NetSetIP(pkt, dest, dport, sport, len); |
622 | - memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket + | |
623 | - (pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len); | |
622 | + memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket + | |
623 | + (pkt - (uchar *)NetArpWaitTxPacket) + | |
624 | + IP_UDP_HDR_SIZE, len); | |
624 | 625 | |
625 | 626 | /* size of the waiting packet */ |
626 | 627 | NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + |
627 | - IP_HDR_SIZE + len; | |
628 | + IP_UDP_HDR_SIZE + len; | |
628 | 629 | |
629 | 630 | /* and do the ARP request */ |
630 | 631 | NetArpWaitTry = 1; |
... | ... | @@ -638,7 +639,7 @@ |
638 | 639 | pkt = (uchar *)NetTxPacket; |
639 | 640 | pkt += NetSetEther(pkt, ether, PROT_IP); |
640 | 641 | NetSetIP(pkt, dest, dport, sport, len); |
641 | - (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len); | |
642 | + eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + len); | |
642 | 643 | |
643 | 644 | return 0; /* transmitted */ |
644 | 645 | } |
645 | 646 | |
... | ... | @@ -676,12 +677,12 @@ |
676 | 677 | u16 unused; |
677 | 678 | }; |
678 | 679 | |
679 | -static IP_t *__NetDefragment(IP_t *ip, int *lenp) | |
680 | +static struct ip_udp_hdr *__NetDefragment(struct ip_udp_hdr *ip, int *lenp) | |
680 | 681 | { |
681 | 682 | static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN); |
682 | 683 | static u16 first_hole, total_len; |
683 | 684 | struct hole *payload, *thisfrag, *h, *newh; |
684 | - IP_t *localip = (IP_t *)pkt_buff; | |
685 | + struct ip_udp_hdr *localip = (struct ip_udp_hdr *)pkt_buff; | |
685 | 686 | uchar *indata = (uchar *)ip; |
686 | 687 | int offset8, start, len, done = 0; |
687 | 688 | u16 ip_off = ntohs(ip->ip_off); |
... | ... | @@ -796,7 +797,7 @@ |
796 | 797 | return localip; |
797 | 798 | } |
798 | 799 | |
799 | -static inline IP_t *NetDefragment(IP_t *ip, int *lenp) | |
800 | +static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp) | |
800 | 801 | { |
801 | 802 | u16 ip_off = ntohs(ip->ip_off); |
802 | 803 | if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG))) |
... | ... | @@ -806,7 +807,7 @@ |
806 | 807 | |
807 | 808 | #else /* !CONFIG_IP_DEFRAG */ |
808 | 809 | |
809 | -static inline IP_t *NetDefragment(IP_t *ip, int *lenp) | |
810 | +static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp) | |
810 | 811 | { |
811 | 812 | u16 ip_off = ntohs(ip->ip_off); |
812 | 813 | if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG))) |
... | ... | @@ -821,7 +822,8 @@ |
821 | 822 | * |
822 | 823 | * @parma ip IP packet containing the ICMP |
823 | 824 | */ |
824 | -static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et) | |
825 | +static void receive_icmp(struct ip_udp_hdr *ip, int len, | |
826 | + IPaddr_t src_ip, Ethernet_t *et) | |
825 | 827 | { |
826 | 828 | ICMP_t *icmph = (ICMP_t *)&ip->udp_src; |
827 | 829 | |
... | ... | @@ -850,7 +852,7 @@ |
850 | 852 | NetReceive(uchar *inpkt, int len) |
851 | 853 | { |
852 | 854 | Ethernet_t *et; |
853 | - IP_t *ip; | |
855 | + struct ip_udp_hdr *ip; | |
854 | 856 | IPaddr_t tmp; |
855 | 857 | IPaddr_t src_ip; |
856 | 858 | int x; |
857 | 859 | |
... | ... | @@ -898,11 +900,11 @@ |
898 | 900 | */ |
899 | 901 | x = ntohs(et->et_prot); |
900 | 902 | |
901 | - ip = (IP_t *)(inpkt + E802_HDR_SIZE); | |
903 | + ip = (struct ip_udp_hdr *)(inpkt + E802_HDR_SIZE); | |
902 | 904 | len -= E802_HDR_SIZE; |
903 | 905 | |
904 | 906 | } else if (x != PROT_VLAN) { /* normal packet */ |
905 | - ip = (IP_t *)(inpkt + ETHER_HDR_SIZE); | |
907 | + ip = (struct ip_udp_hdr *)(inpkt + ETHER_HDR_SIZE); | |
906 | 908 | len -= ETHER_HDR_SIZE; |
907 | 909 | |
908 | 910 | } else { /* VLAN packet */ |
... | ... | @@ -926,7 +928,7 @@ |
926 | 928 | vlanid = cti & VLAN_IDMASK; |
927 | 929 | x = ntohs(vet->vet_type); |
928 | 930 | |
929 | - ip = (IP_t *)(inpkt + VLAN_ETHER_HDR_SIZE); | |
931 | + ip = (struct ip_udp_hdr *)(inpkt + VLAN_ETHER_HDR_SIZE); | |
930 | 932 | len -= VLAN_ETHER_HDR_SIZE; |
931 | 933 | } |
932 | 934 | |
... | ... | @@ -961,8 +963,9 @@ |
961 | 963 | case PROT_IP: |
962 | 964 | debug("Got IP\n"); |
963 | 965 | /* Before we start poking the header, make sure it is there */ |
964 | - if (len < IP_HDR_SIZE) { | |
965 | - debug("len bad %d < %lu\n", len, (ulong)IP_HDR_SIZE); | |
966 | + if (len < IP_UDP_HDR_SIZE) { | |
967 | + debug("len bad %d < %lu\n", len, | |
968 | + (ulong)IP_UDP_HDR_SIZE); | |
966 | 969 | return; |
967 | 970 | } |
968 | 971 | /* Check the packet length */ |
969 | 972 | |
... | ... | @@ -1074,19 +1077,19 @@ |
1074 | 1077 | |
1075 | 1078 | |
1076 | 1079 | #ifdef CONFIG_NETCONSOLE |
1077 | - nc_input_packet((uchar *)ip + IP_HDR_SIZE, | |
1078 | - ntohs(ip->udp_dst), | |
1079 | - ntohs(ip->udp_src), | |
1080 | - ntohs(ip->udp_len) - 8); | |
1080 | + nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE, | |
1081 | + ntohs(ip->udp_dst), | |
1082 | + ntohs(ip->udp_src), | |
1083 | + ntohs(ip->udp_len) - UDP_HDR_SIZE); | |
1081 | 1084 | #endif |
1082 | 1085 | /* |
1083 | 1086 | * IP header OK. Pass the packet to the current handler. |
1084 | 1087 | */ |
1085 | - (*packetHandler)((uchar *)ip + IP_HDR_SIZE, | |
1086 | - ntohs(ip->udp_dst), | |
1087 | - src_ip, | |
1088 | - ntohs(ip->udp_src), | |
1089 | - ntohs(ip->udp_len) - 8); | |
1088 | + (*packetHandler)((uchar *)ip + IP_UDP_HDR_SIZE, | |
1089 | + ntohs(ip->udp_dst), | |
1090 | + src_ip, | |
1091 | + ntohs(ip->udp_src), | |
1092 | + ntohs(ip->udp_len) - UDP_HDR_SIZE); | |
1090 | 1093 | break; |
1091 | 1094 | } |
1092 | 1095 | } |
1093 | 1096 | |
... | ... | @@ -1237,10 +1240,9 @@ |
1237 | 1240 | } |
1238 | 1241 | } |
1239 | 1242 | |
1240 | -void | |
1241 | -NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len) | |
1243 | +void NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len) | |
1242 | 1244 | { |
1243 | - IP_t *ip = (IP_t *)xip; | |
1245 | + struct ip_udp_hdr *ip = (struct ip_udp_hdr *)xip; | |
1244 | 1246 | |
1245 | 1247 | /* |
1246 | 1248 | * If the data is an odd number of bytes, zero the |
... | ... | @@ -1248,7 +1250,7 @@ |
1248 | 1250 | * will work. |
1249 | 1251 | */ |
1250 | 1252 | if (len & 1) |
1251 | - xip[IP_HDR_SIZE + len] = 0; | |
1253 | + xip[IP_UDP_HDR_SIZE + len] = 0; | |
1252 | 1254 | |
1253 | 1255 | /* |
1254 | 1256 | * Construct an IP and UDP header. |
... | ... | @@ -1257,7 +1259,7 @@ |
1257 | 1259 | /* IP_HDR_SIZE / 4 (not including UDP) */ |
1258 | 1260 | ip->ip_hl_v = 0x45; |
1259 | 1261 | ip->ip_tos = 0; |
1260 | - ip->ip_len = htons(IP_HDR_SIZE + len); | |
1262 | + ip->ip_len = htons(IP_UDP_HDR_SIZE + len); | |
1261 | 1263 | ip->ip_id = htons(NetIPID++); |
1262 | 1264 | ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ |
1263 | 1265 | ip->ip_ttl = 255; |
... | ... | @@ -1269,7 +1271,7 @@ |
1269 | 1271 | NetCopyIP((void *)&ip->ip_dst, &dest); |
1270 | 1272 | ip->udp_src = htons(sport); |
1271 | 1273 | ip->udp_dst = htons(dport); |
1272 | - ip->udp_len = htons(8 + len); | |
1274 | + ip->udp_len = htons(UDP_HDR_SIZE + len); | |
1273 | 1275 | ip->udp_xsum = 0; |
1274 | 1276 | ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); |
1275 | 1277 | } |
net/nfs.c
... | ... | @@ -189,7 +189,7 @@ |
189 | 189 | |
190 | 190 | pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt; |
191 | 191 | |
192 | - memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, | |
192 | + memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE, | |
193 | 193 | (char *)&pkt, pktlen); |
194 | 194 | |
195 | 195 | if (rpc_prog == PROG_PORTMAP) |
net/ping.c
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | static int ping_send(void) |
20 | 20 | { |
21 | 21 | static uchar mac[6]; |
22 | - IP_t *ip; | |
22 | + struct ip_udp_hdr *ip; | |
23 | 23 | ushort *s; |
24 | 24 | uchar *pkt; |
25 | 25 | |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | pkt = NetArpWaitTxPacket; |
36 | 36 | pkt += NetSetEther(pkt, mac, PROT_IP); |
37 | 37 | |
38 | - ip = (IP_t *)pkt; | |
38 | + ip = (struct ip_udp_hdr *)pkt; | |
39 | 39 | |
40 | 40 | /* |
41 | 41 | * Construct an IP and ICMP header. |
... | ... | @@ -98,7 +98,7 @@ |
98 | 98 | ping_send(); |
99 | 99 | } |
100 | 100 | |
101 | -void ping_receive(Ethernet_t *et, IP_t *ip, int len) | |
101 | +void ping_receive(Ethernet_t *et, struct ip_udp_hdr *ip, int len) | |
102 | 102 | { |
103 | 103 | ICMP_t *icmph = (ICMP_t *)&(ip->udp_src); |
104 | 104 | IPaddr_t src_ip; |
net/ping.h
net/rarp.c
net/rarp.h
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | extern int RarpTry; |
37 | 37 | |
38 | 38 | /* Process the receipt of a RARP packet */ |
39 | -extern void rarp_receive(IP_t *ip, unsigned len); | |
39 | +extern void rarp_receive(struct ip_udp_hdr *ip, unsigned len); | |
40 | 40 | extern void RarpRequest(void); /* Send a RARP request */ |
41 | 41 | |
42 | 42 | /**********************************************************************/ |
net/sntp.c
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | pkt.vn = NTP_VERSION; |
32 | 32 | pkt.mode = NTP_MODE_CLIENT; |
33 | 33 | |
34 | - memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, | |
34 | + memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE, | |
35 | 35 | (char *)&pkt, pktlen); |
36 | 36 | |
37 | 37 | SntpOurPort = 10000 + (get_timer(0) % 4096); |
net/tftp.c
... | ... | @@ -322,7 +322,7 @@ |
322 | 322 | * We will always be sending some sort of packet, so |
323 | 323 | * cobble together the packet headers now. |
324 | 324 | */ |
325 | - pkt = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE); | |
325 | + pkt = NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE; | |
326 | 326 | |
327 | 327 | switch (TftpState) { |
328 | 328 | case STATE_SEND_RRQ: |