summaryrefslogtreecommitdiffstats
path: root/ipset_macipmap.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-20 10:00:26 +0000
committer/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-20 10:00:26 +0000
commita96e4fca10506462df4ee4035f0f86f09bd9dc34 (patch)
tree103bed0a7ae3608675f371d2ac91f3fa7f3a58cc /ipset_macipmap.c
parentbc2ddd2d8da1252e78a1f25bd91c1e3cd8016ead (diff)
ipset 2.4 release
userspace changes: - Added KBUILD_OUTPUT support (Sven Wegener) - Fix memory leak in ipset_iptreemap (Sven Wegener) - Fix multiple compiler warnings (Sven Wegener) - ipportiphash, ipportnethash and setlist types added - binding marked as deprecated functionality - element separator token changed to ',' in anticipating IPv6 addresses, old separator tokens are still supported - unnecessary includes removed - ipset does not try to resolve IP addresses when listing the content of sets (default changed) - manpage updated - ChangeLog forked for kernel part kernel part changes: - ipportiphash, ipportnethash and setlist types added - set type modules reworked to avoid code duplication as much as possible, code unification macros - expand_macros Makefile target added to help debugging code unification macros - ip_set_addip_kernel and ip_set_delip_kernel changed from void to int, __ip_set_get_byname and __ip_set_put_byid added for the sake of setlist type - unnecessary includes removed - compatibility fix for kernels >= 2.6.27: semaphore.h was moved from asm/ to linux/ (James King) - ChangeLog forked for kernel part
Diffstat (limited to 'ipset_macipmap.c')
-rw-r--r--ipset_macipmap.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/ipset_macipmap.c b/ipset_macipmap.c
index a243dc4..7345f8b 100644
--- a/ipset_macipmap.c
+++ b/ipset_macipmap.c
@@ -21,8 +21,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
@@ -51,8 +49,7 @@ create_init(void *data)
static int
create_parse(int c, char *argv[], void *data, unsigned *flags)
{
- struct ip_set_req_macipmap_create *mydata =
- (struct ip_set_req_macipmap_create *) data;
+ struct ip_set_req_macipmap_create *mydata = data;
DP("create_parse");
@@ -112,8 +109,7 @@ create_parse(int c, char *argv[], void *data, unsigned *flags)
static void
create_final(void *data, unsigned int flags)
{
- struct ip_set_req_macipmap_create *mydata =
- (struct ip_set_req_macipmap_create *) data;
+ struct ip_set_req_macipmap_create *mydata = data;
if (flags == 0)
exit_error(PARAMETER_PROBLEM,
@@ -182,14 +178,18 @@ parse_mac(const char *mac, unsigned char *ethernet)
static ip_set_ip_t
adt_parser(unsigned cmd, const char *optarg, void *data)
{
- struct ip_set_req_macipmap *mydata =
- (struct ip_set_req_macipmap *) data;
+ struct ip_set_req_macipmap *mydata = data;
char *saved = ipset_strdup(optarg);
char *ptr, *tmp = saved;
DP("macipmap: %p %p", optarg, data);
+
+ if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
+ fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
+ "Next release won't support it.\n",
+ ptr);
- ptr = strsep(&tmp, ":%");
+ ptr = strsep(&tmp, ":%,");
parse_ip(ptr, &mydata->ip);
if (tmp)
@@ -208,10 +208,8 @@ adt_parser(unsigned cmd, const char *optarg, void *data)
static void
initheader(struct set *set, const void *data)
{
- struct ip_set_req_macipmap_create *header =
- (struct ip_set_req_macipmap_create *) data;
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->settype->header;
+ const struct ip_set_req_macipmap_create *header = data;
+ struct ip_set_macipmap *map = set->settype->header;
memset(map, 0, sizeof(struct ip_set_macipmap));
map->first_ip = header->from;
@@ -222,8 +220,7 @@ initheader(struct set *set, const void *data)
static void
printheader(struct set *set, unsigned options)
{
- struct ip_set_macipmap *mysetdata =
- (struct ip_set_macipmap *) set->settype->header;
+ struct ip_set_macipmap *mysetdata = set->settype->header;
printf(" from: %s", ip_tostring(mysetdata->first_ip, options));
printf(" to: %s", ip_tostring(mysetdata->last_ip, options));
@@ -246,10 +243,8 @@ print_mac(unsigned char macaddress[ETH_ALEN])
static void
printips_sorted(struct set *set, void *data, size_t len, unsigned options)
{
- struct ip_set_macipmap *mysetdata =
- (struct ip_set_macipmap *) set->settype->header;
- struct ip_set_macip *table =
- (struct ip_set_macip *) data;
+ struct ip_set_macipmap *mysetdata = set->settype->header;
+ struct ip_set_macip *table = data;
u_int32_t addr = mysetdata->first_ip;
while (addr <= mysetdata->last_ip) {
@@ -267,8 +262,7 @@ printips_sorted(struct set *set, void *data, size_t len, unsigned options)
static void
saveheader(struct set *set, unsigned options)
{
- struct ip_set_macipmap *mysetdata =
- (struct ip_set_macipmap *) set->settype->header;
+ struct ip_set_macipmap *mysetdata = set->settype->header;
printf("-N %s %s --from %s",
set->name, set->settype->typename,
@@ -283,16 +277,14 @@ saveheader(struct set *set, unsigned options)
static void
saveips(struct set *set, void *data, size_t len, unsigned options)
{
- struct ip_set_macipmap *mysetdata =
- (struct ip_set_macipmap *) set->settype->header;
- struct ip_set_macip *table =
- (struct ip_set_macip *) data;
+ struct ip_set_macipmap *mysetdata = set->settype->header;
+ struct ip_set_macip *table = data;
u_int32_t addr = mysetdata->first_ip;
while (addr <= mysetdata->last_ip) {
if (test_bit(IPSET_MACIP_ISSET,
(void *)&table[addr - mysetdata->first_ip].flags)) {
- printf("-A %s %s:",
+ printf("-A %s %s,",
set->name, ip_tostring(addr, options));
print_mac(table[addr - mysetdata->first_ip].
ethernet);
@@ -307,9 +299,9 @@ static void usage(void)
printf
("-N set macipmap --from IP --to IP [--matchunset]\n"
"-N set macipmap --network IP/mask [--matchunset]\n"
- "-A set IP:MAC\n"
- "-D set IP[:MAC]\n"
- "-T set IP[:MAC]\n");
+ "-A set IP[,MAC]\n"
+ "-D set IP[,MAC]\n"
+ "-T set IP[,MAC]\n");
}
static struct settype settype_macipmap = {