summaryrefslogtreecommitdiffstats
path: root/userspace
diff options
context:
space:
mode:
Diffstat (limited to 'userspace')
-rw-r--r--userspace/ebtables2/ebtables.c18
-rw-r--r--userspace/ebtables2/include/ebtables_u.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/userspace/ebtables2/ebtables.c b/userspace/ebtables2/ebtables.c
index e00106a..b2a1262 100644
--- a/userspace/ebtables2/ebtables.c
+++ b/userspace/ebtables2/ebtables.c
@@ -1395,15 +1395,17 @@ static void allowdb(char yorn)
exit(0);
}
-// set ethproto
-int name_to_protocol(char *name)
+// 0 == success
+// 1 == success, but for the special 'protocol' LENGTH
+// -1 == failure
+int name_to_number(char *name, __u16 *proto)
{
FILE *ifp;
char buffer[21], value[5], *bfr;
unsigned short i;
if (!strcasecmp("LENGTH", name)) {
- new_entry->ethproto = 0;
+ *proto = 0;
new_entry->bitmask |= EBT_802_3;
return 1;
}
@@ -1416,7 +1418,7 @@ int name_to_protocol(char *name)
i = (unsigned short) strtol(value, &bfr, 16);
if (*bfr != '\0')
return -1;
- new_entry->ethproto = i;
+ *proto = i;
fclose(ifp);
return 0;
}
@@ -1990,10 +1992,14 @@ int main(int argc, char *argv[])
print_error("Problem with the specified "
"protocol");
new_entry->ethproto = i;
- if (*buffer != '\0')
- if (name_to_protocol(argv[optind - 1]) == -1)
+ if (*buffer != '\0') {
+ if ((i = name_to_number(argv[optind - 1],
+ &new_entry->ethproto)) == -1)
print_error("Problem with the specified"
" protocol");
+ if (i == 1)
+ new_entry->bitmask |= EBT_802_3;
+ }
if (new_entry->ethproto < 1536 &&
!(new_entry->bitmask & EBT_802_3))
print_error("Sorry, protocols have values above"
diff --git a/userspace/ebtables2/include/ebtables_u.h b/userspace/ebtables2/include/ebtables_u.h
index c08e72a..4debe25 100644
--- a/userspace/ebtables2/include/ebtables_u.h
+++ b/userspace/ebtables2/include/ebtables_u.h
@@ -197,7 +197,7 @@ void deliver_table(struct ebt_u_replace *repl);
void get_dbinfo(struct brdb_dbinfo *nr);
void get_db(int len, struct brdb_dbentry *db);
void deliver_allowdb(__u16 *decision);
-int name_to_protocol(char *name);
+int name_to_number(char *name, __u16 *proto);
int number_to_name(unsigned short proto, char *name);
void check_option(unsigned int *flags, unsigned int mask);
int check_inverse(const char option[]);