NCBI C++ ToolKit
|
Go to the source code of this file.
Go to the SVN repository for this file.
Enumerations | |
enum | ECgiClientIP { eCgiClientIP_TryAll = 0 , eCgiClientIP_TryMost = 1 , eCgiClientIP_TryLeast = 2 } |
Return IP address (in network byte order) of the CGI client, and optionally store the client hostname in a user-supplied buffer (if the size is not adequate to accomodate the result, then it is not stored). More... | |
Functions | |
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... | |
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... | |
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... | |
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... | |
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... | |
enum ECgiClientIP |
Return IP address (in network byte order) of the CGI client, and optionally store the client hostname in a user-supplied buffer (if the size is not adequate to accomodate the result, then it is not stored).
Return 0 if the IP address cannot be obtained; however, the text form of the host can still be stored in the provided buffer (check for '\0' at [0]).
flag | modifies the search algorithm: most users would want to specify eCgiClientIP_TryAll (and those who are absolutely sure that the requests cannot be coming from the older NI facility of the C Toolkit, would want to use eCgiClientIP_TryMost); eCgiClientIP_TryLeast causes the search to ignore the special "Client-Host:" tag that can indicate the real origin of the request (when this request is made on behalf of the indicated IP) |
buf | buffer where the client host (a hostname or textual representation of the network address as provided by the web-server) will be saved (may be NULL not to save) |
buf_size | the size of the buffer (must be large enough, truncation not allowed) |
tracking_env | string array with the tracking environment, or if NULL then the process environment (as provided by the run-time library) is used |
Enumerator | |
---|---|
eCgiClientIP_TryAll | Try all env.vars (NI_CLIENT_IPADDR incl.) |
eCgiClientIP_TryMost | Try most of known environment variables. |
eCgiClientIP_TryLeast | Try to detect caller's IP only,not origin. |
Definition at line 109 of file ncbi_localnet.h.
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().