Index: lc_register_var.3.in ================================================================== --- lc_register_var.3.in +++ lc_register_var.3.in @@ -81,14 +81,17 @@ .TP LC_VAR_CIDR This type of variable accepts a CIDR format netmask and IP. This is not yet implemented. (XXX) .TP LC_VAR_IP -This type of variable accepts an IP address in decimal-dot format. The value is stored in a uint32_t. +This type of variable accepts an IP address in decimal-dot format. The value is stored in a uint32_t in network byte order. +.TP +LC_VAR_HOSTNAME +This type of variable accepts an address in hostname format. The value is stored in a uint32_t in network byte order. .TP LC_VAR_ADDR -This type of variable accepts an address in either host or decimal-dot format. The value is stored in a uint32_t. This is not yet implemented. (XXX) +This type of variable accepts an address in either hostname or decimal-dot format. The value is stored in a uint32_t in network byte order. .SH "RETURN VALUE" On success 0 is returned, otherwise -1 is returned. .SH EXAMPLE Index: libconfig.c ================================================================== --- libconfig.c +++ libconfig.c @@ -73,15 +73,17 @@ } if (ghbn_ret->h_length != 4) { return(-1); } + + if (ghbn_ret->h_addr_list[0] == 0) { + return(-1); + } memcpy(data, ghbn_ret->h_addr_list[0], sizeof(*data)); - *data = ntohl(*data); - return(0); } static int lc_process_var_hostname6(void *data, const char *value, const char **endptr) { return(-1); @@ -105,18 +107,17 @@ if (curr_ipval > 255) { retval = -1; break; } - ipval <<= 8; - ipval |= curr_ipval; - curr_ipval = 0; - /* For lists */ if (*valptr == ',') { break; } + + ipval |= curr_ipval << ((dotcount - 1) * 8); + curr_ipval = 0; continue; } else { retval = -1; break; @@ -124,15 +125,17 @@ } curr_ipval *= 10; curr_ipval += *valptr - '0'; } + + if (curr_ipval > 255) { + retval = -1; + } if (retval == 0) { - ipval <<= 8; - ipval |= curr_ipval; - + ipval |= curr_ipval << 24; *data = ipval; } return(retval); }