version 1.1.1.3, 2013/07/22 10:46:12
|
version 1.1.1.4, 2014/06/15 16:12:54
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 2010-2012 Todd C. Miller <Todd.Miller@courtesan.com> | * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 51
|
Line 51
|
# define INADDR_NONE ((unsigned int)-1) |
# define INADDR_NONE ((unsigned int)-1) |
#endif |
#endif |
|
|
static struct interface *interfaces; | static struct interface_list interfaces; |
|
|
/* |
/* |
* Parse a space-delimited list of IP address/netmask pairs and |
* Parse a space-delimited list of IP address/netmask pairs and |
Line 87 set_interfaces(const char *ai)
|
Line 87 set_interfaces(const char *ai)
|
} else { |
} else { |
/* IPv4 */ |
/* IPv4 */ |
ifp->family = AF_INET; |
ifp->family = AF_INET; |
ifp->addr.ip4.s_addr = inet_addr(addr); | if (inet_pton(AF_INET, addr, &ifp->addr.ip4) != 1 || |
ifp->netmask.ip4.s_addr = inet_addr(mask); | inet_pton(AF_INET, mask, &ifp->netmask.ip4) != 1) { |
if (ifp->addr.ip4.s_addr == INADDR_NONE || | |
ifp->netmask.ip4.s_addr == INADDR_NONE) { | |
efree(ifp); |
efree(ifp); |
continue; |
continue; |
} |
} |
} |
} |
ifp->next = interfaces; | SLIST_INSERT_HEAD(&interfaces, ifp, entries); |
interfaces = ifp; | |
} |
} |
efree(addrinfo); |
efree(addrinfo); |
debug_return; |
debug_return; |
} |
} |
|
|
struct interface * | struct interface_list * |
get_interfaces(void) |
get_interfaces(void) |
{ |
{ |
return interfaces; | return &interfaces; |
} |
} |
|
|
void |
void |