PcapPlusPlus  22.11
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 <netinet/in.h>
7 #include <arpa/inet.h>
8 #endif
9 #if defined(__APPLE__)
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
12 #endif
13 #if defined(_WIN32)
14 #include <ws2tcpip.h>
15 #endif
16 #if defined(__FreeBSD__)
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #endif
21 
23 
24 // Both Visual C++ Compiler and MinGW-w64 define inet_ntop() and inet_pton()
25 // Add compatibility functions for old MinGW (aka MinGW32)
26 // We use "__MINGW64_VERSION_MAJOR" and not __MINGW64__ to detect MinGW-w64 compiler
27 // because the second one is not defined for MinGW-w64 in 32bits mode
28 #if defined(_WIN32) && !defined(_MSC_VER) && (!defined(__MINGW64_VERSION_MAJOR) || (__MINGW64_VERSION_MAJOR < 8))
29 
37 const char* inet_ntop(int af, const void* src, char* dst, size_t size);
38 
50 int inet_pton(int af, const char* src, void* dst);
51 #endif
52 
53 
58 namespace pcpp
59 {
60  namespace internal
61  {
67  in_addr* sockaddr2in_addr(struct sockaddr *sa);
68 
74  in6_addr* sockaddr2in6_addr(struct sockaddr *sa);
75 
81  void sockaddr2string(struct sockaddr *sa, char* resultString);
82 
88  uint32_t in_addr2int(in_addr inAddr);
89  } // namespace internal
90 } // namespace pcpp
91 #endif
The main namespace for the PcapPlusPlus lib.
in_addr * sockaddr2in_addr(struct sockaddr *sa)
const char * inet_ntop(int af, const void *src, char *dst, size_t size)
void sockaddr2string(struct sockaddr *sa, char *resultString)
in6_addr * sockaddr2in6_addr(struct sockaddr *sa)
uint32_t in_addr2int(in_addr inAddr)
int inet_pton(int af, const char *src, void *dst)