Add IP proto utils function

This commit is contained in:
luwenpeng
2024-06-02 00:36:50 +08:00
parent 18fe1e2e41
commit eb1056b4f9
5 changed files with 119 additions and 79 deletions

View File

@@ -81,7 +81,7 @@ static inline void udp_hdr_set_checksum(struct udphdr *hdr, uint16_t sum)
static inline int udp_hdr_to_str(const struct udphdr *hdr, char *buf, size_t size)
{
memset(buf, 0, size);
return snprintf(buf, size, "UDP: src_port=%u dst_port=%u total_len=%u checksum=%u",
return snprintf(buf, size, "UDP: src_port=%u dst_port=%u total_len=%u checksum=0x%x",
udp_hdr_get_src_port(hdr), udp_hdr_get_dst_port(hdr),
udp_hdr_get_total_len(hdr), udp_hdr_get_checksum(hdr));
}