PcapPlusPlus  20.08
IpUtils.h
Go to the documentation of this file.
1 #ifndef PCAPPP_IP_UTILS
2 #define PCAPPP_IP_UTILS
3 
4 #include <stdint.h>
5 #ifdef LINUX
6 #include <in.h>
7 #include <arpa/inet.h>
8 #endif
9 #ifdef MAC_OS_X
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
12 #endif
13 #if defined(WIN32) || defined(WINx64) || defined(PCAPPP_MINGW_ENV)
14 #include <winsock2.h>
15 #include <ws2tcpip.h>
16 #endif
17 #ifdef FREEBSD
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
21 #endif
22 
24 
25 #if defined(WIN32) && !defined(_MSC_VER)
26 
34 const char* inet_ntop(int af, const void* src, char* dst, size_t size);
35 
47 int inet_pton(int af, const char* src, void* dst);
48 #endif
49 
50 
55 namespace pcpp
56 {
57 
63  in_addr* sockaddr2in_addr(struct sockaddr *sa);
64 
70  in6_addr* sockaddr2in6_addr(struct sockaddr *sa);
71 
77  void sockaddr2string(struct sockaddr *sa, char* resultString);
78 
84  uint32_t in_addr2int(in_addr inAddr);
85 
89  template<typename T>
90  struct ScalarBuffer
91  {
95  T* buffer;
96 
100  size_t len;
101  };
102 
109  uint16_t compute_checksum(ScalarBuffer<uint16_t> vec[], size_t vecSize);
110 
118  uint32_t fnv_hash(ScalarBuffer<uint8_t> vec[], size_t vecSize);
119 
126  uint32_t fnv_hash(uint8_t* buffer, size_t bufSize);
127 
128 } // namespace pcpp
129 #endif
inet_pton
int inet_pton(int af, const char *src, void *dst)
pcpp::in_addr2int
uint32_t in_addr2int(in_addr inAddr)
pcpp::ScalarBuffer::len
size_t len
Definition: IpUtils.h:100
pcpp::ScalarBuffer
Definition: IpUtils.h:90
pcpp::fnv_hash
uint32_t fnv_hash(ScalarBuffer< uint8_t > vec[], size_t vecSize)
pcpp::sockaddr2string
void sockaddr2string(struct sockaddr *sa, char *resultString)
pcpp::compute_checksum
uint16_t compute_checksum(ScalarBuffer< uint16_t > vec[], size_t vecSize)
pcpp::sockaddr2in6_addr
in6_addr * sockaddr2in6_addr(struct sockaddr *sa)
inet_ntop
const char * inet_ntop(int af, const void *src, char *dst, size_t size)
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::ScalarBuffer::buffer
T * buffer
Definition: IpUtils.h:95
pcpp::sockaddr2in_addr
in_addr * sockaddr2in_addr(struct sockaddr *sa)