7 */ 8 9#include "ipf.h" 10 11alist_t * 12alist_new(int v, char *host) 13{ 14 int a, b, c, d, bits; 15 char *slash; 16 alist_t *al; 17 u_int mask; 18 19 al = calloc(1, sizeof(*al)); 20 if (al == NULL) { 21 fprintf(stderr, "alist_new out of memory\n"); 22 return NULL; 23 } 24 25 bits = -1; 26 slash = strchr(host, '/'); 27 if (slash != NULL) { 28 *slash = '\0'; 29 bits = atoi(slash + 1); 30 } 31 32 a = b = c = d = -1; 33 sscanf(host, "%d.%d.%d.%d", &a, &b, &c, &d); 34 35 if (bits > 0 && bits < 33) { 36 mask = 0xffffffff << (32 - bits); 37 } else if (b == -1) { 38 mask = 0xff000000; 39 b = c = d = 0; 40 } else if (c == -1) { 41 mask = 0xffff0000; 42 c = d = 0; 43 } else if (d == -1) { 44 mask = 0xffffff00; 45 d = 0; 46 } else { 47 mask = 0xffffffff; 48 } 49 50 if (*host == '!') { 51 al->al_not = 1; 52 host++; 53 } 54 55 if (gethost(host, &al->al_addr) == -1) {
| 7 */ 8 9#include "ipf.h" 10 11alist_t * 12alist_new(int v, char *host) 13{ 14 int a, b, c, d, bits; 15 char *slash; 16 alist_t *al; 17 u_int mask; 18 19 al = calloc(1, sizeof(*al)); 20 if (al == NULL) { 21 fprintf(stderr, "alist_new out of memory\n"); 22 return NULL; 23 } 24 25 bits = -1; 26 slash = strchr(host, '/'); 27 if (slash != NULL) { 28 *slash = '\0'; 29 bits = atoi(slash + 1); 30 } 31 32 a = b = c = d = -1; 33 sscanf(host, "%d.%d.%d.%d", &a, &b, &c, &d); 34 35 if (bits > 0 && bits < 33) { 36 mask = 0xffffffff << (32 - bits); 37 } else if (b == -1) { 38 mask = 0xff000000; 39 b = c = d = 0; 40 } else if (c == -1) { 41 mask = 0xffff0000; 42 c = d = 0; 43 } else if (d == -1) { 44 mask = 0xffffff00; 45 d = 0; 46 } else { 47 mask = 0xffffffff; 48 } 49 50 if (*host == '!') { 51 al->al_not = 1; 52 host++; 53 } 54 55 if (gethost(host, &al->al_addr) == -1) {
|