diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-04-22 17:00:42 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2010-04-22 17:00:42 +0200 |
commit | 5b20d409ef3062b24bbe7667f0daec34523446a6 (patch) | |
tree | 426e99a410b2b975460b5b0fb5a409d4381a16c8 /kernel/include/linux/netfilter/ip_set_ipmap.h | |
parent | 8e0608d31d988333ff04f3faaa6e851c0ecdbc6e (diff) |
Fifth stage to ipset-5
Rename files in kernel/ and get rid of old ones (2.4.x kernel tree support).
Diffstat (limited to 'kernel/include/linux/netfilter/ip_set_ipmap.h')
-rw-r--r-- | kernel/include/linux/netfilter/ip_set_ipmap.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/kernel/include/linux/netfilter/ip_set_ipmap.h b/kernel/include/linux/netfilter/ip_set_ipmap.h new file mode 100644 index 0000000..d16c0ae --- /dev/null +++ b/kernel/include/linux/netfilter/ip_set_ipmap.h @@ -0,0 +1,57 @@ +#ifndef __IP_SET_IPMAP_H +#define __IP_SET_IPMAP_H + +#include <linux/netfilter_ipv4/ip_set.h> +#include <linux/netfilter_ipv4/ip_set_bitmaps.h> + +#define SETTYPE_NAME "ipmap" + +struct ip_set_ipmap { + void *members; /* the ipmap proper */ + ip_set_ip_t first_ip; /* host byte order, included in range */ + ip_set_ip_t last_ip; /* host byte order, included in range */ + ip_set_ip_t netmask; /* subnet netmask */ + ip_set_ip_t sizeid; /* size of set in IPs */ + ip_set_ip_t hosts; /* number of hosts in a subnet */ + u_int32_t size; /* size of the ipmap proper */ +}; + +struct ip_set_req_ipmap_create { + ip_set_ip_t from; + ip_set_ip_t to; + ip_set_ip_t netmask; +}; + +struct ip_set_req_ipmap { + ip_set_ip_t ip; +}; + +static inline unsigned int +mask_to_bits(ip_set_ip_t mask) +{ + unsigned int bits = 32; + ip_set_ip_t maskaddr; + + if (mask == 0xFFFFFFFF) + return bits; + + maskaddr = 0xFFFFFFFE; + while (--bits > 0 && maskaddr != mask) + maskaddr <<= 1; + + return bits; +} + +static inline ip_set_ip_t +range_to_mask(ip_set_ip_t from, ip_set_ip_t to, unsigned int *bits) +{ + ip_set_ip_t mask = 0xFFFFFFFE; + + *bits = 32; + while (--(*bits) > 0 && mask && (to & mask) != from) + mask <<= 1; + + return mask; +} + +#endif /* __IP_SET_IPMAP_H */ |