26 i =
fmt_ulong(s,(
unsigned long) (
unsigned char) ip[0]); len += i;
if (s) s += i;
27 if (s) { *s++ =
'.'; } ++len;
28 i =
fmt_ulong(s,(
unsigned long) (
unsigned char) ip[1]); len += i;
if (s) s += i;
29 if (s) { *s++ =
'.'; } ++len;
30 i =
fmt_ulong(s,(
unsigned long) (
unsigned char) ip[2]); len += i;
if (s) s += i;
31 if (s) { *s++ =
'.'; } ++len;
32 i =
fmt_ulong(s,(
unsigned long) (
unsigned char) ip[3]); len += i;
if (s) s += i;
49 i =
fmt_ulong(s,(
unsigned long) ip[3]); len += i;
if (s) s += i;
50 i =
fmt_str(s,
"."); len += i;
if (s) s += i;
51 i =
fmt_ulong(s,(
unsigned long) ip[2]); len += i;
if (s) s += i;
52 i =
fmt_str(s,
"."); len += i;
if (s) s += i;
53 i =
fmt_ulong(s,(
unsigned long) ip[1]); len += i;
if (s) s += i;
54 i =
fmt_str(s,
"."); len += i;
if (s) s += i;
55 i =
fmt_ulong(s,(
unsigned long) ip[0]); len += i;
if (s) s += i;
56 i =
fmt_str(s,
".in-addr.arpa."); len += i;
if (s) s += i;
75 i =
scan_ulong((
char *)s,&u);
if (!i) {
return 0; } ip[0] = u; s += i; len += i;
76 if (*s !=
'.') {
return 0; } ++s; ++len;
77 i =
scan_ulong((
char *)s,&u);
if (!i) {
return 0; } ip[1] = u; s += i; len += i;
78 if (*s !=
'.') {
return 0; } ++s; ++len;
79 i =
scan_ulong((
char *)s,&u);
if (!i) {
return 0; } ip[2] = u; s += i; len += i;
80 if (*s !=
'.') {
return 0; } ++s; ++len;
81 i =
scan_ulong((
char *)s,&u);
if (!i) {
return 0; } ip[3] = u; s += i; len += i;
96 if (*s !=
'[')
return 0;
99 if (s[len + 1] !=
']')
return 0;
111unsigned int ip4_cidr(
char *s,
char ip[4],
unsigned long *plen)
121 return ip4_scan((
const char *)s,ip);
134 unsigned char number;
139 for (i = 0; i < 4; i++) {
140 number = (
unsigned char) ip[i];
141 if (number > 255)
return -2;
143 for (j = 7; j >= 0; j--) {
144 if (number & (1 << j)) {
152 if (!prefix)
goto DONE;
unsigned int ip4_fmt(char *s, char ip[4])
ip4_fmt converts IPv4 address to dotted decimal string format
unsigned int ip4_cidr(char *s, char ip[4], unsigned long *plen)
ip4_cidr parse IPv4 address string concatinated with the prefix length: 192.168.1/24
unsigned int ip4_bytestring(stralloc *ipstring, char ip[4], int prefix)
ip4_bytestring parse IPv4 address and represent as char string with length prefix
unsigned int ip4_scanbracket(const char *s, char ip[4])
ip4_scanbracket parse IPv4 address string enclosed in brackets and convert to IP address array
unsigned int ia4_fmt(char *s, char ip[4])
ia4_fmt converts IPv4 address into DNS inverse nibble format
unsigned int ip4_scan(const char *s, char ip[4])
ip4_scan parse IPv4 address string and convert to IP address array
unsigned int scan_ulong(const char *, unsigned long *)
conversion function declarations
unsigned int fmt_ulong(char *, unsigned long)
unsigned int fmt_str(char *, const char *)
void byte_zero(void *, unsigned int)
unsigned int str_chr(const char *, int)
int stralloc_cats(stralloc *, const char *)
int stralloc_readyplus(stralloc *sa, size_t len)
int stralloc_copys(stralloc *, const char *)