summaryrefslogtreecommitdiffstats
path: root/userspace
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2002-11-20 19:41:54 +0000
committerBart De Schuymer <bdschuym@pandora.be>2002-11-20 19:41:54 +0000
commit2b47248ff3d4982b5355434884cfe284a0dddf78 (patch)
treedfbc27822122680495487d898141eef67f14acfa /userspace
parentadcae4d5f0dc5cbf3a3f120a15d54bd222c94718 (diff)
use getethertype.c
Diffstat (limited to 'userspace')
-rw-r--r--userspace/ebtables2/extensions/ebt_arp.c16
-rw-r--r--userspace/ebtables2/extensions/ebt_vlan.c25
2 files changed, 27 insertions, 14 deletions
diff --git a/userspace/ebtables2/extensions/ebt_arp.c b/userspace/ebtables2/extensions/ebt_arp.c
index da3d9d6..b517068 100644
--- a/userspace/ebtables2/extensions/ebt_arp.c
+++ b/userspace/ebtables2/extensions/ebt_arp.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <getopt.h>
#include "../include/ebtables_u.h"
+#include "../include/ethernetdb.h"
#include <linux/netfilter_bridge/ebt_arp.h>
#define ARP_OPCODE '1'
@@ -133,9 +134,14 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry,
print_error("Missing ARP protocol type argument");
i = strtol(argv[optind - 1], &end, 16);
if (i < 0 || i >= (0x1 << 16) || *end !='\0') {
- if (name_to_number (argv[optind - 1], &proto) == -1)
+ struct ethertypeent *ent;
+
+ ent = getethertypebyname(argv[optind - 1]);
+ if (!ent)
print_error("Problem with specified ARP "
"protocol type");
+ proto = ent->e_ethertype;
+
} else
proto = i;
arpinfo->ptype = htons(proto);
@@ -190,7 +196,6 @@ static void print(const struct ebt_u_entry *entry,
{
struct ebt_arp_info *arpinfo = (struct ebt_arp_info *)match->data;
int i;
- char name[21];
if (arpinfo->bitmask & EBT_ARP_OPCODE) {
int opcode = ntohs(arpinfo->opcode);
@@ -209,13 +214,16 @@ static void print(const struct ebt_u_entry *entry,
printf("%d ", ntohs(arpinfo->htype));
}
if (arpinfo->bitmask & EBT_ARP_PTYPE) {
+ struct ethertypeent *ent;
+
printf("--arp-ptype ");
if (arpinfo->invflags & EBT_ARP_PTYPE)
printf("! ");
- if (number_to_name(ntohs(arpinfo->ptype), name))
+ ent = getethertypebynumber(ntohs(arpinfo->ptype));
+ if (!ent)
printf("0x%x ", ntohs(arpinfo->ptype));
else
- printf("%s ", name);
+ printf("%s ", ent->e_name);
}
if (arpinfo->bitmask & EBT_ARP_SRC_IP) {
printf("--arp-ip-src ");
diff --git a/userspace/ebtables2/extensions/ebt_vlan.c b/userspace/ebtables2/extensions/ebt_vlan.c
index 297b61b..ab2ce09 100644
--- a/userspace/ebtables2/extensions/ebt_vlan.c
+++ b/userspace/ebtables2/extensions/ebt_vlan.c
@@ -35,6 +35,7 @@
#include <string.h>
#include <getopt.h>
#include "../include/ebtables_u.h"
+#include "../include/ethernetdb.h"
#include <linux/netfilter_bridge/ebt_vlan.h>
#define GET_BITMASK(_MASK_) vlaninfo->bitmask & _MASK_
@@ -189,17 +190,22 @@ parse (int c,
if (*end == '\0' && (encap < ETH_ZLEN || encap > 0xFFFF))
print_error
("Specified encapsulated frame type is out of range");
- if (*end != '\0')
- if (name_to_number (argv[optind - 1], &encap) == -1)
+ if (*end != '\0') {
+ struct ethertypeent *ent;
+
+ ent = getethertypebyname(argv[optind - 1]);
+ if (!ent)
print_error
("Problem with the specified encapsulated"
"protocol");
+ encap = ent->e_ethertype;
+ }
/*
* Set up parameter value (network notation)
*/
vlaninfo->encap = htons (encap);
/*
- * Set up parameter presence flag
+ * Set up parameter presence flag
*/
SET_BITMASK (EBT_VLAN_ENCAP);
break;
@@ -258,7 +264,6 @@ print (const struct ebt_u_entry *entry,
struct ebt_vlan_info *vlaninfo =
(struct ebt_vlan_info *) match->data;
- char ethertype_name[21];
/*
* Print VLAN ID if they are specified
*/
@@ -279,15 +284,15 @@ print (const struct ebt_u_entry *entry,
* Print encapsulated frame type if they are specified
*/
if (GET_BITMASK (EBT_VLAN_ENCAP)) {
+ struct ethertypeent *ent;
+
printf ("--%s %s",
opts[VLAN_ENCAP].name, INV_FLAG (EBT_VLAN_ENCAP));
- bzero (ethertype_name, 21);
- if (!number_to_name
- (ntohs (vlaninfo->encap), ethertype_name)) {
- printf ("%s ", ethertype_name);
- } else {
+ ent = getethertypebynumber(ntohs(vlaninfo->encap));
+ if (!ent)
printf ("%2.4X ", ntohs (vlaninfo->encap));
- }
+ else
+ printf ("%s ", ent->e_name);
}
}