X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fipaccess.c;h=1bbd085fc2ee69b16384cd4f69d5515f13c629c9;hb=d775f3ca9c8619bc1f0d2f98a9518fed60fe6658;hp=51d9eb586fe8e1859394b19ea02f78ec2d4b7193;hpb=cad27e97e6370f96903d42aaf345c099af0a03bd;p=libucw.git diff --git a/lib/ipaccess.c b/lib/ipaccess.c index 51d9eb58..1bbd085f 100644 --- a/lib/ipaccess.c +++ b/lib/ipaccess.c @@ -36,33 +36,10 @@ ipaccess_init(void) return l; } -static byte * -parse_ip(byte *x, u32 *a) -{ - uns i, q; - u32 z = 0; - - for(i=0; i<4; i++) - { - q = 0; - while (Cdigit(*x)) - { - q = q*10 + *x++ - '0'; - if (q > 255) - return "Invalid IP address"; - } - if (*x++ != ((i == 3) ? 0 : '.')) - return "Invalid IP address"; - z = (z << 8) | q; - } - *a = z; - return NULL; -} - byte * ipaccess_parse(struct ipaccess_list *l, byte *c, int is_allow) { - char *p = strchr(c, '/'); + byte *p = strchr(c, '/'); char *q; struct ipaccess_entry *a = cfg_malloc(sizeof(struct ipaccess_entry)); unsigned long pxlen; @@ -78,11 +55,11 @@ ipaccess_parse(struct ipaccess_list *l, byte *c, int is_allow) if (pxlen != 32) a->mask = ~(~0U >> (uns) pxlen); } - else if (q = parse_ip(p, &a->mask)) + else if (q = cf_parse_ip(&p, &a->mask)) return q; } add_tail(&l->l, &a->n); - return parse_ip(c, &a->addr); + return cf_parse_ip(&c, &a->addr); } int