summaryrefslogtreecommitdiffstats
path: root/extensions/ebt_mark_m.c
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2002-07-21 15:18:30 +0000
committerBart De Schuymer <bdschuym@pandora.be>2002-07-21 15:18:30 +0000
commit2268250719338ccc6fccf9c2bc9382a90e9e4d8c (patch)
tree352848a27956e46a56efc08d48905037347802b0 /extensions/ebt_mark_m.c
parent8a8ca61d8e0a5fe454f23b2a05731885312e4328 (diff)
add "/mask"
Diffstat (limited to 'extensions/ebt_mark_m.c')
-rw-r--r--extensions/ebt_mark_m.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/extensions/ebt_mark_m.c b/extensions/ebt_mark_m.c
index 16caec5..5029738 100644
--- a/extensions/ebt_mark_m.c
+++ b/extensions/ebt_mark_m.c
@@ -18,7 +18,7 @@ static void print_help()
{
printf(
"mark option:\n"
-"--mark [!] value[/mask]: Match nfmask value with optional mask\n");
+"--mark [!] [value][/mask]: Match nfmask value (see man page)\n");
}
static void init(struct ebt_entry_match *match)
@@ -28,6 +28,7 @@ static void init(struct ebt_entry_match *match)
markinfo->mark = 0;
markinfo->mask = 0;
markinfo->invert = 0;
+ markinfo->bitmask = 0;
}
#define OPT_MARK 0x01
@@ -46,9 +47,12 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry,
if (optind > argc)
print_error("No mark specified");
markinfo->mark = strtoul(argv[optind - 1], &end, 0);
- if (*end == '/')
+ markinfo->bitmask = EBT_MARK_AND;
+ if (*end == '/') {
+ if (end == argv[optind - 1])
+ markinfo->bitmask = EBT_MARK_OR;
markinfo->mask = strtoul(end+1, &end, 0);
- else
+ } else
markinfo->mask = 0xffffffff;
if ( *end != '\0' || end == argv[optind - 1])
print_error("Bad mark value '%s'", argv[optind - 1]);
@@ -74,7 +78,9 @@ static void print(const struct ebt_u_entry *entry,
printf("--mark ");
if (markinfo->invert)
printf("! ");
- if(markinfo->mask != 0xffffffff)
+ if (markinfo->bitmask == EBT_MARK_OR)
+ printf("/0x%lx ", markinfo->mask);
+ else if(markinfo->mask != 0xffffffff)
printf("0x%lx/0x%lx ", markinfo->mark, markinfo->mask);
else
printf("0x%lx ", markinfo->mark);
@@ -92,6 +98,8 @@ static int compare(const struct ebt_entry_match *m1,
return 0;
if (markinfo1->mask != markinfo2->mask)
return 0;
+ if (markinfo1->bitmask != markinfo2->bitmask)
+ return 0;
return 1;
}