1 /* Useful functions for dealing with collections of IP addresses */
23 uint32_t l
; /* Number of entries in list */
24 uint32_t a
; /* Allocated space in list */
28 extern struct subnet_list
*subnet_list_new(void);
29 extern void subnet_list_free(struct subnet_list
*a
);
30 extern void subnet_list_append(struct subnet_list
*a
, uint32_t prefix
,
33 static inline bool_t
subnet_match(struct subnet s
, uint32_t address
)
35 return (s
.prefix
==(address
&s
.mask
));
38 extern struct ipset
*ipset_new(void);
39 extern void ipset_free(struct ipset
*a
);
40 extern struct ipset
*ipset_from_subnet(struct subnet s
);
41 extern struct ipset
*ipset_from_subnet_list(struct subnet_list
*l
);
42 extern struct ipset
*ipset_union(struct ipset
*a
, struct ipset
*b
);
43 extern struct ipset
*ipset_intersection(struct ipset
*a
, struct ipset
*b
);
44 extern struct ipset
*ipset_complement(struct ipset
*a
);
45 extern struct ipset
*ipset_subtract(struct ipset
*a
, struct ipset
*b
);
46 extern bool_t
ipset_is_empty(struct ipset
*a
);
47 extern bool_t
ipset_contains_addr(struct ipset
*a
, uint32_t addr
);
48 extern bool_t
ipset_is_subset(struct ipset
*super
, struct ipset
*sub
);
49 extern struct subnet_list
*ipset_to_subnet_list(struct ipset
*is
);
51 extern string_t
ipaddr_to_string(uint32_t addr
);
52 extern string_t
subnet_to_string(struct subnet sn
);
54 extern struct ipset
*string_list_to_ipset(list_t
*l
,struct cloc loc
,
55 cstring_t module
, cstring_t param
);
57 extern uint32_t string_item_to_ipaddr(item_t
*i
, cstring_t desc
);