ref: 13738d2aa200eeb5859525225ec1d7bec7e8134e
dir: /udp.c/
#include <stdio.h>
#include <stdint.h>
#include <pcap.h>
#include "common.h"
int
parseUdp(const u_char *pkt, Udp *udp)
{
udp->start = pos;
get(pkt, UDP_SRCPORT, &udp->src);
get(pkt, UDP_DSTPORT, &udp->dst);
get(pkt, UDP_LEN, &udp->len);
get(pkt, UDP_SUM, &udp->sum);
return 1;
}
void
printUdp(Udp udp)
{
printf("udp pkt:\n"
"\tsrcport: %d\tdstport: %d\n"
"\tlen: %d\tsum 0x%#x\n",
udp.src, udp.dst, udp.len, udp.sum);
}
Parser udpParser = {
.name = "udp",
.parse = parseUdp,
.print = printDns,
};