Skip to content

Commit

Permalink
Better way of doing wildcards
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed May 31, 2014
1 parent c343f25 commit 9dee670
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/lib/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ int fr_pton4(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
*/
if ((value[0] == '*') && (value[1] == '\0')) {
out->ipaddr.ip4addr.s_addr = htonl(INADDR_ANY);
out->prefix = 0;
out->af = AF_INET;

return 0;
/*
* Convert things which are obviously integers to IP addresses
*
Expand Down Expand Up @@ -318,10 +314,6 @@ int fr_pton6(fr_ipaddr_t *out, char const *value, size_t inlen, bool resolve, bo
*/
if ((value[0] == '*') && (value[1] == '\0')) {
memset(&out->ipaddr.ip6addr.s6_addr, 0, sizeof(out->ipaddr.ip6addr.s6_addr));
out->prefix = 0;
out->af = AF_INET6;

return 0;
} else if (!resolve) {
if (inet_pton(AF_INET6, value, &(out->ipaddr.ip6addr.s6_addr)) <= 0) {
fr_strerror_printf("Failed to parse IPv6 address string \"%s\"", value);
Expand Down
5 changes: 5 additions & 0 deletions src/main/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ int client_add(RADCLIENT_LIST *clients, RADCLIENT *client)
return 0;
}

/*
* Hack to fixup wildcard clients
*/
if (is_wildcard(&client->ipaddr)) client->ipaddr.prefix = 0;

fr_ntop(buffer, sizeof(buffer), &client->ipaddr);
DEBUG3("Adding client %s (%s) to prefix tree %i", buffer, client->longname, client->ipaddr.prefix);

Expand Down
4 changes: 2 additions & 2 deletions src/main/conffile.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ static inline int fr_item_validate_ipaddr(CONF_SECTION *cs, char const *name, PW
case PW_TYPE_IP_ADDR:
switch (ipaddr->af) {
case AF_INET:
if (!is_wildcard(ipaddr) && (ipaddr->prefix != 32)) {
if (ipaddr->prefix != 32) {
ERROR("Invalid IPv4 mask length \"/%i\". Only \"/32\" permitted for non-prefix types",
ipaddr->prefix);

Expand All @@ -939,7 +939,7 @@ static inline int fr_item_validate_ipaddr(CONF_SECTION *cs, char const *name, PW
break;

case AF_INET6:
if (!is_wildcard(ipaddr) && (ipaddr->prefix != 128)) {
if (ipaddr->prefix != 128) {
ERROR("Invalid IPv6 mask length \"/%i\". Only \"/128\" permitted for non-prefix types",
ipaddr->prefix);

Expand Down

0 comments on commit 9dee670

Please sign in to comment.