[MINOR] standard: str2mask: string to netmask converter

This function converts a dotted or CIDR value to a netmask.
This commit is contained in:
Willy Tarreau
2010-01-26 17:36:17 +01:00
parent 1a51b6342e
commit 2937c0dd20
2 changed files with 32 additions and 15 deletions

View File

@@ -162,6 +162,12 @@ struct sockaddr_in *str2sa(char *str);
*/
struct sockaddr_in *str2sa_range(char *str, int *low, int *high);
/* converts <str> to a struct in_addr containing a network mask. It can be
* passed in dotted form (255.255.255.0) or in CIDR form (24). It returns 1
* if the conversion succeeds otherwise non-zero.
*/
int str2mask(const char *str, struct in_addr *mask);
/*
* converts <str> to two struct in_addr* which must be pre-allocated.
* The format is "addr[/mask]", where "addr" cannot be empty, and mask