Message ID | 1447054736-27658-6-git-send-email-judge.packham@gmail.com |
---|---|
State | RFC |
Delegated to: | Joe Hershberger |
Headers | show |
On Mon, Nov 9, 2015 at 1:38 AM, Chris Packham <judge.packham@gmail.com> wrote: > UDP is the same over IPv4 as it is over other protocols (i.e. IPv6) add > a definition of just the UDP header independent of the IPv4 header that > it may or may not be combined with. > > Signed-off-by: Chris Packham <judge.packham@gmail.com> > --- > Ideally struct ip_udp_hdr would be defined as > > struct ip_udp_hdr { > struct ip_hdr ip; > struct udp_hdr udp; > }; > > Implementing this touches more code that I really want to at this > point. Some of the code that currently uses struct ip_udp_hdr could > probably just use struct ip_hdr instead but some care would need to be > taken to much such a change. Sounds reasonable. > Changes in v2: None > > include/net.h | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/include/net.h b/include/net.h > index ebed29a..e8bd2b7 100644 > --- a/include/net.h > +++ b/include/net.h > @@ -348,6 +348,18 @@ struct ip_hdr { > #define IP_HDR_SIZE (sizeof(struct ip_hdr)) > > /* > + * UDP header. > + */ > +struct udp_hdr { > + __be16 udp_src; /* UDP source port */ > + __be16 udp_dst; /* UDP destination port */ > + __be16 udp_len; /* Length of UDP packet */ > + __be16 udp_xsum; /* Checksum */ > +}; > + > +#define UDP_HDR_SIZE (sizeof(struct udp_hdr)) > + > +/* > * Internet Protocol (IP) + UDP header. > */ > struct ip_udp_hdr { > @@ -368,7 +380,6 @@ struct ip_udp_hdr { > }; > > #define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr)) > -#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE) > > /* > * Address Resolution Protocol (ARP) header. > -- > 2.5.3 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot
diff --git a/include/net.h b/include/net.h index ebed29a..e8bd2b7 100644 --- a/include/net.h +++ b/include/net.h @@ -348,6 +348,18 @@ struct ip_hdr { #define IP_HDR_SIZE (sizeof(struct ip_hdr)) /* + * UDP header. + */ +struct udp_hdr { + __be16 udp_src; /* UDP source port */ + __be16 udp_dst; /* UDP destination port */ + __be16 udp_len; /* Length of UDP packet */ + __be16 udp_xsum; /* Checksum */ +}; + +#define UDP_HDR_SIZE (sizeof(struct udp_hdr)) + +/* * Internet Protocol (IP) + UDP header. */ struct ip_udp_hdr { @@ -368,7 +380,6 @@ struct ip_udp_hdr { }; #define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr)) -#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE) /* * Address Resolution Protocol (ARP) header.
UDP is the same over IPv4 as it is over other protocols (i.e. IPv6) add a definition of just the UDP header independent of the IPv4 header that it may or may not be combined with. Signed-off-by: Chris Packham <judge.packham@gmail.com> --- Ideally struct ip_udp_hdr would be defined as struct ip_udp_hdr { struct ip_hdr ip; struct udp_hdr udp; }; Implementing this touches more code that I really want to at this point. Some of the code that currently uses struct ip_udp_hdr could probably just use struct ip_hdr instead but some care would need to be taken to much such a change. Changes in v2: None include/net.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)