PcapPlusPlus  Next
IpUtils.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #ifdef __linux__
5 # include <netinet/in.h>
6 # include <arpa/inet.h>
7 #endif
8 #if defined(__APPLE__)
9 # include <netinet/in.h>
10 # include <arpa/inet.h>
11 #endif
12 #if defined(_WIN32)
13 # include <ws2tcpip.h>
14 #endif
15 #if defined(__FreeBSD__)
16 # include <sys/socket.h>
17 # include <netinet/in.h>
18 # include <arpa/inet.h>
19 #endif
20 
22 
23 // Both Visual C++ Compiler and MinGW-w64 define inet_ntop() and inet_pton()
24 // Add compatibility functions for old MinGW (aka MinGW32)
25 // We use "__MINGW64_VERSION_MAJOR" and not __MINGW64__ to detect MinGW-w64 compiler
26 // because the second one is not defined for MinGW-w64 in 32bits mode
27 #if defined(_WIN32) && !defined(_MSC_VER) && (!defined(__MINGW64_VERSION_MAJOR) || (__MINGW64_VERSION_MAJOR < 8))
36 const char* inet_ntop(int af, const void* src, char* dst, size_t size);
37 
49 int inet_pton(int af, const char* src, void* dst);
50 #endif
51 
56 namespace pcpp
57 {
58  namespace internal
59  {
66  in_addr* sockaddr2in_addr(sockaddr* sa);
67 
73  in_addr* try_sockaddr2in_addr(sockaddr* sa);
74 
81  in6_addr* sockaddr2in6_addr(sockaddr* sa);
82 
88  in6_addr* try_sockaddr2in6_addr(sockaddr* sa);
89 
98  void sockaddr2string(sockaddr const* sa, char* resultString, size_t resultBufLen);
99 
105  uint32_t in_addr2int(in_addr inAddr);
106  } // namespace internal
107 } // namespace pcpp
const char * inet_ntop(int af, const void *src, char *dst, size_t size)
in_addr * sockaddr2in_addr(sockaddr *sa)
void sockaddr2string(sockaddr const *sa, char *resultString, size_t resultBufLen)
in_addr * try_sockaddr2in_addr(sockaddr *sa)
in6_addr * try_sockaddr2in6_addr(sockaddr *sa)
int inet_pton(int af, const char *src, void *dst)
in6_addr * sockaddr2in6_addr(sockaddr *sa)
uint32_t in_addr2int(in_addr inAddr)
The main namespace for the PcapPlusPlus lib.