diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2002-06-26 18:57:24 +0000 |
---|---|---|
committer | Bart De Schuymer <bdschuym@pandora.be> | 2002-06-26 18:57:24 +0000 |
commit | 28bf6f6b71a2ed1b096deeb75d0ad897eb9cc394 (patch) | |
tree | 1d485953b797e119de6dede7b12493c66943a8a4 /ebtables.c | |
parent | b909f9b5df3586298e3517545e7b0eefb9ab5af4 (diff) |
name_to_protocol()
Diffstat (limited to 'ebtables.c')
-rw-r--r-- | ebtables.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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" |