NCBI C++ ToolKit
|
#include "../ncbi_ansi_ext.h"
#include "../ncbi_priv.h"
#include <connect/ncbi_socket.h>
#include <connect/ext/ncbi_localnet.h>
#include <stdlib.h>
#include <sys/types.h>
#include <netinet/in.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Macros | |
#define | INADDR_LOOPBACK 0x7F000001 |
#define | SizeOf(a) (sizeof(a) / sizeof((a)[0])) |
Functions | |
static int | x_IsPrivateIP (unsigned int addr) |
int | NcbiIsPrivateIP (unsigned int ip) |
Return non-zero (true) if the IP address (in network byte order) provided as an agrument, is a nonroutable private IP address (including loopback, multicast, and RFC1918); return zero (false) otherwise. More... | |
static int | x_IsAPIPA (unsigned int addr) |
int | NcbiIsAPIPA (unsigned int ip) |
Return non-zero (true) if the IP address (in network byte order) provided as an agrument, is an Automatic Private IP Address (APIPA); return zero (false) otherwise. More... | |
static int | s_IsPrivateIP (unsigned int ip) |
static const TNCBI_IPv6Addr * | x_StringToAddr (TNCBI_IPv6Addr *addr, const char *str) |
static const char * | s_SearchTrackingEnv (const char *name, const char *const *tracking_env) |
static const char * | s_SearchForwardedFor (TNCBI_IPv6Addr *addr, const char *const *tracking_env) |
TNCBI_IPv6Addr | NcbiGetCgiClientIPv6Ex (ECgiClientIP flag, char *buf, size_t buf_size, const char *const *tracking_env) |
Same as NcbiGetCgiClientIPEx but IPv6-aware. More... | |
TNCBI_IPv6Addr | NcbiGetCgiClientIPv6 (ECgiClientIP flag, const char *const *tracking_env) |
Same as NcbiGetCgiClientIPv6Ex(., NULL, 0, .) More... | |
unsigned int | NcbiGetCgiClientIPEx (ECgiClientIP flag, char *buf, size_t buf_size, const char *const *tracking_env) |
unsigned int | NcbiGetCgiClientIP (ECgiClientIP flag, const char *const *tracking_env) |
Same as NcbiGetCgiClientIPEx(., NULL, 0, .) More... | |
int | NcbiIsLocalCgiClient (const char *const *tracking_env) |
Return non-zero (true) if called from within a CGI that was invoked by an NCBI local client; zero otherwise. More... | |
#define INADDR_LOOPBACK 0x7F000001 |
Definition at line 45 of file ncbi_localnet.c.
INADDR_LOOPBACK
Definition at line 51 of file ncbi_localnet.c.
unsigned int NcbiGetCgiClientIP | ( | ECgiClientIP | flag, |
const char *const * | tracking_env | ||
) |
Same as NcbiGetCgiClientIPEx(., NULL, 0, .)
Definition at line 364 of file ncbi_localnet.c.
References NcbiGetCgiClientIPEx().
unsigned int NcbiGetCgiClientIPEx | ( | ECgiClientIP | flag, |
char * | buf, | ||
size_t | buf_size, | ||
const char *const * | tracking_env | ||
) |
Definition at line 353 of file ncbi_localnet.c.
References buf, NcbiGetCgiClientIPv6Ex(), and NcbiIPv6ToIPv4().
Referenced by NcbiGetCgiClientIP().
TNCBI_IPv6Addr NcbiGetCgiClientIPv6 | ( | ECgiClientIP | flag, |
const char *const * | tracking_env | ||
) |
Same as NcbiGetCgiClientIPv6Ex(., NULL, 0, .)
Definition at line 346 of file ncbi_localnet.c.
References NcbiGetCgiClientIPv6Ex().
Referenced by CHttpRequest::GetClientIP(), and NcbiIsLocalCgiClient().
TNCBI_IPv6Addr NcbiGetCgiClientIPv6Ex | ( | ECgiClientIP | flag, |
char * | buf, | ||
size_t | buf_size, | ||
const char *const * | tracking_env | ||
) |
Same as NcbiGetCgiClientIPEx but IPv6-aware.
IPv4 addresses packed as IPv6. Returns an empty IPv6 address when NcbiGetCgiClientIPEx() would return 0.
Definition at line 221 of file ncbi_localnet.c.
References assert, buf, CORE_LOG, eCgiClientIP_TryAll, eCgiClientIP_TryLeast, eLOG_Trace, free(), i, NcbiIPv6ToIPv4(), NcbiIsEmptyIPv6(), NcbiIsLocalIPEx, s_IsPrivateIP(), s_SearchForwardedFor(), s_SearchTrackingEnv(), SizeOf, and x_StringToAddr().
Referenced by NcbiGetCgiClientIPEx(), and NcbiGetCgiClientIPv6().
Return non-zero (true) if the IP address (in network byte order) provided as an agrument, is an Automatic Private IP Address (APIPA); return zero (false) otherwise.
Definition at line 104 of file ncbi_localnet.c.
References ip, SOCK_NetToHostLong, and x_IsAPIPA().
Referenced by NcbiGetHostIfConfEx().
Return non-zero (true) if called from within a CGI that was invoked by an NCBI local client; zero otherwise.
tracking_env | string array with the tracking environment, or if NULL then the process environment (as provided by the run-time library) is used |
Definition at line 371 of file ncbi_localnet.c.
References eCgiClientIP_TryAll, NcbiGetCgiClientIPv6(), NcbiIsLocalIPEx, and s_SearchTrackingEnv().
Return non-zero (true) if the IP address (in network byte order) provided as an agrument, is a nonroutable private IP address (including loopback, multicast, and RFC1918); return zero (false) otherwise.
Definition at line 89 of file ncbi_localnet.c.
References ip, SOCK_NetToHostLong, and x_IsPrivateIP().
Definition at line 113 of file ncbi_localnet.c.
References ip, SOCK_NetToHostLong, x_IsAPIPA(), and x_IsPrivateIP().
Referenced by NcbiGetCgiClientIPv6Ex(), and s_SearchForwardedFor().
|
static |
Definition at line 169 of file ncbi_localnet.c.
References assert, CORE_LOG, eLOG_Trace, f, free(), memmove, NcbiIPv6ToIPv4(), NcbiIsEmptyIPv6(), NcbiIsLocalIPEx, r(), s_IsPrivateIP(), s_SearchTrackingEnv(), strdup, and x_StringToAddr().
Referenced by NcbiGetCgiClientIPv6Ex().
|
static |
Definition at line 133 of file ncbi_localnet.c.
References CORE_LOGF, eLOG_Trace, len, result, str(), and strncasecmp.
Referenced by NcbiGetCgiClientIPv6Ex(), NcbiIsLocalCgiClient(), and s_SearchForwardedFor().
Definition at line 98 of file ncbi_localnet.c.
Referenced by NcbiIsAPIPA(), and s_IsPrivateIP().
Definition at line 61 of file ncbi_localnet.c.
References IN_LOOPBACKNET, and INADDR_LOOPBACK.
Referenced by NcbiIsPrivateIP(), and s_IsPrivateIP().
|
static |
Definition at line 121 of file ncbi_localnet.c.
References assert, NcbiIPv4ToIPv6(), NcbiStringToAddr(), SOCK_gethostbyname(), and str().
Referenced by NcbiGetCgiClientIPv6Ex(), and s_SearchForwardedFor().