Skip to content

Commit 717234e

Browse files
temerkhanovsjg20
authored andcommitted
net: Convert protocol structures to use explicit sizes
Convert uchar/ushort to u8/u16 respectively. Signed-off-by: Radha Mohan Chintakuntla <[email protected]> Signed-off-by: Sergey Temerkhanov <[email protected]> Signed-off-by: Joe Hershberger <[email protected]> Acked-by: Simon Glass <[email protected]>
1 parent 5917e7d commit 717234e

File tree

2 files changed

+63
-63
lines changed

2 files changed

+63
-63
lines changed

include/net.h

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ u32 ether_crc(size_t len, unsigned char const *p);
259259
*/
260260

261261
struct ethernet_hdr {
262-
uchar et_dest[6]; /* Destination node */
263-
uchar et_src[6]; /* Source node */
264-
ushort et_protlen; /* Protocol or length */
262+
u8 et_dest[6]; /* Destination node */
263+
u8 et_src[6]; /* Source node */
264+
u16 et_protlen; /* Protocol or length */
265265
};
266266

267267
/* Ethernet header size */
@@ -270,16 +270,16 @@ struct ethernet_hdr {
270270
#define ETH_FCS_LEN 4 /* Octets in the FCS */
271271

272272
struct e802_hdr {
273-
uchar et_dest[6]; /* Destination node */
274-
uchar et_src[6]; /* Source node */
275-
ushort et_protlen; /* Protocol or length */
276-
uchar et_dsap; /* 802 DSAP */
277-
uchar et_ssap; /* 802 SSAP */
278-
uchar et_ctl; /* 802 control */
279-
uchar et_snap1; /* SNAP */
280-
uchar et_snap2;
281-
uchar et_snap3;
282-
ushort et_prot; /* 802 protocol */
273+
u8 et_dest[6]; /* Destination node */
274+
u8 et_src[6]; /* Source node */
275+
u16 et_protlen; /* Protocol or length */
276+
u8 et_dsap; /* 802 DSAP */
277+
u8 et_ssap; /* 802 SSAP */
278+
u8 et_ctl; /* 802 control */
279+
u8 et_snap1; /* SNAP */
280+
u8 et_snap2;
281+
u8 et_snap3;
282+
u16 et_prot; /* 802 protocol */
283283
};
284284

285285
/* 802 + SNAP + ethernet header size */
@@ -289,11 +289,11 @@ struct e802_hdr {
289289
* Virtual LAN Ethernet header
290290
*/
291291
struct vlan_ethernet_hdr {
292-
uchar vet_dest[6]; /* Destination node */
293-
uchar vet_src[6]; /* Source node */
294-
ushort vet_vlan_type; /* PROT_VLAN */
295-
ushort vet_tag; /* TAG of VLAN */
296-
ushort vet_type; /* protocol type */
292+
u8 vet_dest[6]; /* Destination node */
293+
u8 vet_src[6]; /* Source node */
294+
u16 vet_vlan_type; /* PROT_VLAN */
295+
u16 vet_tag; /* TAG of VLAN */
296+
u16 vet_type; /* protocol type */
297297
};
298298

299299
/* VLAN Ethernet header size */
@@ -311,14 +311,14 @@ struct vlan_ethernet_hdr {
311311
* Internet Protocol (IP) header.
312312
*/
313313
struct ip_hdr {
314-
uchar ip_hl_v; /* header length and version */
315-
uchar ip_tos; /* type of service */
316-
ushort ip_len; /* total length */
317-
ushort ip_id; /* identification */
318-
ushort ip_off; /* fragment offset field */
319-
uchar ip_ttl; /* time to live */
320-
uchar ip_p; /* protocol */
321-
ushort ip_sum; /* checksum */
314+
u8 ip_hl_v; /* header length and version */
315+
u8 ip_tos; /* type of service */
316+
u16 ip_len; /* total length */
317+
u16 ip_id; /* identification */
318+
u16 ip_off; /* fragment offset field */
319+
u8 ip_ttl; /* time to live */
320+
u8 ip_p; /* protocol */
321+
u16 ip_sum; /* checksum */
322322
struct in_addr ip_src; /* Source IP address */
323323
struct in_addr ip_dst; /* Destination IP address */
324324
};
@@ -335,20 +335,20 @@ struct ip_hdr {
335335
* Internet Protocol (IP) + UDP header.
336336
*/
337337
struct ip_udp_hdr {
338-
uchar ip_hl_v; /* header length and version */
339-
uchar ip_tos; /* type of service */
340-
ushort ip_len; /* total length */
341-
ushort ip_id; /* identification */
342-
ushort ip_off; /* fragment offset field */
343-
uchar ip_ttl; /* time to live */
344-
uchar ip_p; /* protocol */
345-
ushort ip_sum; /* checksum */
338+
u8 ip_hl_v; /* header length and version */
339+
u8 ip_tos; /* type of service */
340+
u16 ip_len; /* total length */
341+
u16 ip_id; /* identification */
342+
u16 ip_off; /* fragment offset field */
343+
u8 ip_ttl; /* time to live */
344+
u8 ip_p; /* protocol */
345+
u16 ip_sum; /* checksum */
346346
struct in_addr ip_src; /* Source IP address */
347347
struct in_addr ip_dst; /* Destination IP address */
348-
ushort udp_src; /* UDP source port */
349-
ushort udp_dst; /* UDP destination port */
350-
ushort udp_len; /* Length of UDP packet */
351-
ushort udp_xsum; /* Checksum */
348+
u16 udp_src; /* UDP source port */
349+
u16 udp_dst; /* UDP destination port */
350+
u16 udp_len; /* Length of UDP packet */
351+
u16 udp_xsum; /* Checksum */
352352
};
353353

354354
#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))
@@ -358,14 +358,14 @@ struct ip_udp_hdr {
358358
* Address Resolution Protocol (ARP) header.
359359
*/
360360
struct arp_hdr {
361-
ushort ar_hrd; /* Format of hardware address */
361+
u16 ar_hrd; /* Format of hardware address */
362362
# define ARP_ETHER 1 /* Ethernet hardware address */
363-
ushort ar_pro; /* Format of protocol address */
364-
uchar ar_hln; /* Length of hardware address */
363+
u16 ar_pro; /* Format of protocol address */
364+
u8 ar_hln; /* Length of hardware address */
365365
# define ARP_HLEN 6
366-
uchar ar_pln; /* Length of protocol address */
366+
u8 ar_pln; /* Length of protocol address */
367367
# define ARP_PLEN 4
368-
ushort ar_op; /* Operation */
368+
u16 ar_op; /* Operation */
369369
# define ARPOP_REQUEST 1 /* Request to resolve address */
370370
# define ARPOP_REPLY 2 /* Response to previous request */
371371

@@ -377,16 +377,16 @@ struct arp_hdr {
377377
* the sizes above, and are defined as appropriate for
378378
* specific hardware/protocol combinations.
379379
*/
380-
uchar ar_data[0];
380+
u8 ar_data[0];
381381
#define ar_sha ar_data[0]
382382
#define ar_spa ar_data[ARP_HLEN]
383383
#define ar_tha ar_data[ARP_HLEN + ARP_PLEN]
384384
#define ar_tpa ar_data[ARP_HLEN + ARP_PLEN + ARP_HLEN]
385385
#if 0
386-
uchar ar_sha[]; /* Sender hardware address */
387-
uchar ar_spa[]; /* Sender protocol address */
388-
uchar ar_tha[]; /* Target hardware address */
389-
uchar ar_tpa[]; /* Target protocol address */
386+
u8 ar_sha[]; /* Sender hardware address */
387+
u8 ar_spa[]; /* Sender protocol address */
388+
u8 ar_tha[]; /* Target hardware address */
389+
u8 ar_tpa[]; /* Target protocol address */
390390
#endif /* 0 */
391391
};
392392

@@ -408,20 +408,20 @@ struct arp_hdr {
408408
#define ICMP_NOT_REACH_PORT 3 /* Port unreachable */
409409

410410
struct icmp_hdr {
411-
uchar type;
412-
uchar code;
413-
ushort checksum;
411+
u8 type;
412+
u8 code;
413+
u16 checksum;
414414
union {
415415
struct {
416-
ushort id;
417-
ushort sequence;
416+
u16 id;
417+
u16 sequence;
418418
} echo;
419419
u32 gateway;
420420
struct {
421-
ushort unused;
422-
ushort mtu;
421+
u16 unused;
422+
u16 mtu;
423423
} frag;
424-
uchar data[0];
424+
u8 data[0];
425425
} un;
426426
};
427427

net/bootp.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */
3030
#endif
3131

3232
struct bootp_hdr {
33-
uchar bp_op; /* Operation */
33+
u8 bp_op; /* Operation */
3434
# define OP_BOOTREQUEST 1
3535
# define OP_BOOTREPLY 2
36-
uchar bp_htype; /* Hardware type */
36+
u8 bp_htype; /* Hardware type */
3737
# define HWT_ETHER 1
38-
uchar bp_hlen; /* Hardware address length */
38+
u8 bp_hlen; /* Hardware address length */
3939
# define HWL_ETHER 6
40-
uchar bp_hops; /* Hop count (gateway thing) */
40+
u8 bp_hops; /* Hop count (gateway thing) */
4141
u32 bp_id; /* Transaction ID */
42-
ushort bp_secs; /* Seconds since boot */
43-
ushort bp_spare1; /* Alignment */
42+
u16 bp_secs; /* Seconds since boot */
43+
u16 bp_spare1; /* Alignment */
4444
struct in_addr bp_ciaddr; /* Client IP address */
4545
struct in_addr bp_yiaddr; /* Your (client) IP address */
4646
struct in_addr bp_siaddr; /* Server IP address */
4747
struct in_addr bp_giaddr; /* Gateway IP address */
48-
uchar bp_chaddr[16]; /* Client hardware address */
48+
u8 bp_chaddr[16]; /* Client hardware address */
4949
char bp_sname[64]; /* Server host name */
5050
char bp_file[128]; /* Boot file name */
5151
char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */

0 commit comments

Comments
 (0)