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