Reduce packet_get_xxx() calls
This commit is contained in:
27
src/packet/udp_helpers.h
Normal file
27
src/packet/udp_helpers.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef _UDP_HELPERS_H
|
||||
#define _UDP_HELPERS_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#define __FAVOR_BSD 1
|
||||
#include <netinet/udp.h>
|
||||
|
||||
static inline uint16_t udp_hdr_get_sport(const struct udphdr *hdr)
|
||||
{
|
||||
return ntohs(hdr->uh_sport);
|
||||
}
|
||||
|
||||
static inline uint16_t udp_hdr_get_dport(const struct udphdr *hdr)
|
||||
{
|
||||
return ntohs(hdr->uh_dport);
|
||||
}
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user