2 * Copyright (C) 2006 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: alist_new.c,v 1.1.2.3 2007/06/06 08:05:33 darrenr Exp $
12 alist_new(int v, char *host)
19 al = calloc(1, sizeof(*al));
21 fprintf(stderr, "alist_new out of memory\n");
26 slash = strchr(host, '/');
29 bits = atoi(slash + 1);
33 sscanf(host, "%d.%d.%d.%d", &a, &b, &c, &d);
35 if (bits > 0 && bits < 33) {
36 mask = 0xffffffff << (32 - bits);
55 if (gethost(host, &al->al_addr) == -1) {
58 fprintf(stderr, "Cannot parse hostname\n");
62 al->al_mask = htonl(mask);