,
b,
ip;
49 switch(range->
type) {
53 return!memcmp(&range->
a,
addr,
sizeof(range->
a));
63 return a<=
ip&&
ip<=
b;
76 return!((
ip&
b) ^
a);
99memset(&retval, 0,
sizeof(retval));
108retval.
a= range->
a;
115retval.
a= range->
a;
116retval.
b= range->
b;
126retval.
a= range->
a;
127retval.
b=
a| ~range->
b;
138 static size_t x_size(
const char* dst,
size_t len,
const char* ptr)
140 return len> (size_t)(ptr - dst) ?
len- (size_t)(ptr - dst) : 0;
163 switch(range->
type) {
166memcpy(s,
"Host", 4);
172memcpy(s,
"Range", 5);
177memcpy(s,
"Network", 7);
188 assert(memcmp(&temp, range,
sizeof(temp)) == 0);
193sprintf(s,
"/%u", temp.
b);
195 assert(memcmp(&temp.
a, &range->
a,
sizeof(temp.
a)) == 0);
210strcpy(
result,
"None");
218 unsigned int addr, temp;
225 if(!range || !
str)
229memset(range, 0,
sizeof(*range));
242 if(*p++ ==
'/'&& !
isspace((
unsigned char)(*p))) {
244d = strtol(p, &e, 10);
245 if(!errno && p != e && !*e && d > 0) {
247 if(ipv4 && d <= 32) {
254temp = (
unsigned int)(~0UL << (32 - d));
259&& (
size_t) d <= (
sizeof(range->
a.
octet) << 3)) {
260 if(!d || (
size_t) d == (
sizeof(range->
a.
octet) << 3)) {
267range->
b= (
unsigned int) d;
269d = (long)(
sizeof(range->
a.
octet) << 3) - d;
271 for(
n=
sizeof(range->
a.
octet);
n> 0; --
n) {
273 if(range->
a.
octet[
n- 1] & ~0)
277 if(range->
a.
octet[
n- 1] & ~(~0 << d))
304d = strtol(p, &e, 10);
305 if(errno || p == e || e - p > 3 || d < 0 || 255 < d
306|| sprintf(s,
"%u", (
unsigned int) d) != (
int)(e - p)) {
310}
else if(!*++p && dots) {
311temp = (
unsigned int)((4 - dots) << 3);
319 switch(range->
type) {
324 addr<<= (3 - dots) << 3;
336}
else if(++dots <= 3) {
351 return!(temp & (temp + 1)) &&
addr&& !(
addr& temp);
355temp = dots > 0 ?
addr: 0;
356temp &= (
unsigned int)(~((1UL << ((4 - dots) << 3)) - 1));
357temp |= (
unsigned int) (d << ((3 - dots) << 3));
358temp |= (
unsigned int) ((1U << ((3 - dots) << 3)) - 1);
376temp = (
unsigned int)(~0UL << (32 - d));
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
int SOCK_isipEx(const char *host, int fullquad)
Check whether a given string represents a valid bare IPv4 address.
unsigned int SOCK_HostToNetLong(unsigned int value)
See man for the BSDisms, htonl() and htons().
#define SOCK_NetToHostLong
unsigned int SOCK_gethostbyname(const char *hostname)
Same as SOCK_gethostbynameEx(,<current API data logging>)
int SOCK_ntoa(unsigned int addr, char *buf, size_t bufsize)
Convert IP address to a string in dotted notation.
int SOCK_isip(const char *host)
Equivalent of SOCK_isip(host, 0)
unsigned int
A callback function used to compare two keys in a database.
char * strncpy0(char *s1, const char *s2, size_t n)
Copy not more than "n" characters from string "s2" into "s1", and return the result,...
SIPRange NcbiTrueIPRange(const SIPRange *range)
int NcbiIsInIPRange(const SIPRange *range, const TNCBI_IPv6Addr *addr)
const char * NcbiDumpIPRange(const SIPRange *range, char *buf, size_t bufsize)
static size_t x_size(const char *dst, size_t len, const char *ptr)
int NcbiParseIPRange(SIPRange *range, const char *str)
Acceptable forms (netmasked IPv4s may omit trailing .0s before '/'): 4 quad full IP: 123....
int NcbiIsEmptyIPv6(const TNCBI_IPv6Addr *addr)
Return non-zero if the address is empty (either as NULL or IPv6 or IPv4); return zero otherwise.
const char * NcbiDNSIPToAddr(TNCBI_IPv6Addr *addr, const char *str, size_t len)
Convert into an IPv6 address, the first "len" (or "strlen(str)" if "len" is 0) bytes of "str",...
unsigned int NcbiIPv6ToIPv4(const TNCBI_IPv6Addr *addr, size_t pfxlen)
Extract and return a network byte order IPv4 embedded address from an IPv6 address,...
TNCBI_IPv6Addr * NcbiIPv4ToIPv6(TNCBI_IPv6Addr *addr, unsigned int ipv4, size_t pfxlen)
Embed a passed network byte order IPv4 address into an IPv6 address using the specified prefix length...
char * NcbiIPv6ToString(char *buf, size_t bufsize, const TNCBI_IPv6Addr *addr)
Convert an IPv6 address into a hex colon-separated text form and store the result in the "buf" of siz...
int NcbiIsIPv4(const TNCBI_IPv6Addr *addr)
Return non-zero(true) if the address is a true IPv4 address (a mapped IPv4 address),...
const char * NcbiStringToIPv4(unsigned int *addr, const char *str, size_t len)
Convert into a network byte order IPv4 address, the first "len" (or "strlen(str)" if "len" is 0) byte...
int NcbiIsInIPv6Network(const TNCBI_IPv6Addr *base, unsigned int bits, const TNCBI_IPv6Addr *addr)
Return non-zero(true) if "addr" belongs to the network specified as CIDR "base/bits"; return a zero(f...
const char * NcbiIPToAddr(TNCBI_IPv6Addr *addr, const char *str, size_t len)
Convert into an IPv6 address, the first "len" (or "strlen(str)" if "len" is 0) bytes of "str" from ei...
static PCRE2_SIZE bufsize
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4