X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=ipaddr.h;h=54f10d434367988a596f526c6fb1f267b75fe544;hp=8c262bfb3a899cb092cdf422761052e5b543f57e;hb=HEAD;hpb=794f2398b8fe84bf398bb10d6eeca6fe6737f65f diff --git a/ipaddr.h b/ipaddr.h index 8c262bf..d8bc9fa 100644 --- a/ipaddr.h +++ b/ipaddr.h @@ -1,4 +1,22 @@ /* Useful functions for dealing with collections of IP addresses */ +/* + * This file is part of secnet. + * See README for full list of copyright holders. + * + * secnet is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * secnet is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with secnet; if not, see + * https://www.gnu.org/licenses/gpl.html. + */ #ifndef ipaddr_h #define ipaddr_h @@ -6,12 +24,12 @@ struct subnet { uint32_t prefix; uint32_t mask; - uint32_t len; + int len; }; struct subnet_list { - uint32_t entries; - uint32_t alloc; + int32_t entries; + int32_t alloc; struct subnet *list; }; @@ -20,15 +38,14 @@ struct iprange { }; struct ipset { - uint32_t l; /* Number of entries in list */ - uint32_t a; /* Allocated space in list */ + int32_t l; /* Number of entries in list */ + int32_t a; /* Allocated space in list */ struct iprange *d; }; extern struct subnet_list *subnet_list_new(void); extern void subnet_list_free(struct subnet_list *a); -extern void subnet_list_append(struct subnet_list *a, uint32_t prefix, - uint32_t len); +extern void subnet_list_append(struct subnet_list *a, uint32_t prefix, int len); static inline bool_t subnet_match(struct subnet s, uint32_t address) { @@ -52,8 +69,8 @@ extern string_t ipaddr_to_string(uint32_t addr); extern string_t subnet_to_string(struct subnet sn); extern struct ipset *string_list_to_ipset(list_t *l,struct cloc loc, - string_t module,string_t param); + cstring_t module, cstring_t param); -extern uint32_t string_item_to_ipaddr(item_t *i, string_t desc); +extern uint32_t string_item_to_ipaddr(const item_t *i, cstring_t desc); #endif /* ipaddr_h */