From e565868eb40eb286fadc78d08779aefbf50bcb92 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Thu, 13 Apr 2023 23:36:55 +0800 Subject: [PATCH] udp: add udphdr definition adapts to third-party code compilation. in the process of porting ConnMan, we encounter some situations where the structure is not defined, or the returned data types do not match the expectations. Refer to the common implementation of other systems and add relevant definitions. Signed-off-by: zhanghongyu --- include/netinet/udp.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/netinet/udp.h b/include/netinet/udp.h index 756b8d26e90..36a9a80aecb 100644 --- a/include/netinet/udp.h +++ b/include/netinet/udp.h @@ -31,4 +31,27 @@ * Pre-processor Definitions ****************************************************************************/ +/* UDP header as specified by RFC 768, August 1980. */ + +struct udphdr +{ + union + { + struct + { + uint16_t uh_sport; /* source port */ + uint16_t uh_dport; /* destination port */ + uint16_t uh_ulen; /* udp length */ + uint16_t uh_sum; /* udp checksum */ + }; + struct + { + uint16_t source; + uint16_t dest; + uint16_t len; + uint16_t check; + }; + }; +}; + #endif /* __INCLUDE_NETINET_UDP_H */