diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2002-06-05 19:41:28 +0000 |
---|---|---|
committer | Bart De Schuymer <bdschuym@pandora.be> | 2002-06-05 19:41:28 +0000 |
commit | ffebd1e6304e17bd63eaf7e988d5b62497914f17 (patch) | |
tree | 0693fea700fb68de55f448b9540ce6515ccaf9c8 /userspace/ebtables2/extensions | |
parent | b202119379e94eaf64fbb4b79f5689c285a49300 (diff) |
use ether_ntoa() and ether_aton() library functions
Diffstat (limited to 'userspace/ebtables2/extensions')
-rw-r--r-- | userspace/ebtables2/extensions/ebt_nat.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/userspace/ebtables2/extensions/ebt_nat.c b/userspace/ebtables2/extensions/ebt_nat.c index dbdb5a4..1f88ae2 100644 --- a/userspace/ebtables2/extensions/ebt_nat.c +++ b/userspace/ebtables2/extensions/ebt_nat.c @@ -3,6 +3,7 @@ #include <string.h> #include <sys/socket.h> #include <netinet/in.h> +#include <netinet/ether.h> #include <linux/netfilter_bridge/ebtables.h> #include <getopt.h> #include "../include/ebtables_u.h" @@ -74,13 +75,15 @@ static int parse_s(int c, char **argv, int argc, { int i; struct ebt_nat_info *natinfo = (struct ebt_nat_info *)(*target)->data; + struct ether_addr *addr; switch (c) { case NAT_S: check_option(flags, OPT_SNAT); to_source_supplied = 1; - if (getmac(optarg, natinfo->mac)) + if (!(addr = ether_aton(optarg))) print_error("Problem with specified to-source mac"); + memcpy(natinfo->mac, addr, ETH_ALEN); break; case NAT_S_TARGET: check_option(flags, OPT_SNAT_TARGET); @@ -106,14 +109,16 @@ static int parse_d(int c, char **argv, int argc, { int i; struct ebt_nat_info *natinfo = (struct ebt_nat_info *)(*target)->data; + struct ether_addr *addr; switch (c) { case NAT_D: check_option(flags, OPT_DNAT); to_dest_supplied = 1; - if (getmac(optarg, natinfo->mac)) + if (!(addr = ether_aton(optarg))) print_error("Problem with specified " "to-destination mac"); + memcpy(natinfo->mac, addr, ETH_ALEN); break; case NAT_D_TARGET: check_option(flags, OPT_DNAT_TARGET); @@ -155,12 +160,9 @@ static void print_s(const struct ebt_u_entry *entry, const struct ebt_entry_target *target) { struct ebt_nat_info *natinfo = (struct ebt_nat_info *)target->data; - int i; printf("snat - to: "); - for (i = 0; i < ETH_ALEN; i++) - printf("%02x%s", - natinfo->mac[i], (i == ETH_ALEN - 1) ? "" : ":"); + printf("%s", ether_ntoa((struct ether_addr *)natinfo->mac)); printf(" --snat-target %s", standard_targets[natinfo->target]); } @@ -168,12 +170,9 @@ static void print_d(const struct ebt_u_entry *entry, const struct ebt_entry_target *target) { struct ebt_nat_info *natinfo = (struct ebt_nat_info *)target->data; - int i; printf("dnat - to: "); - for (i = 0; i < ETH_ALEN; i++) - printf("%02x%s", - natinfo->mac[i], (i == ETH_ALEN - 1) ? "" : ":"); + printf("%s", ether_ntoa((struct ether_addr *)natinfo->mac)); printf(" --dnat-target %s", standard_targets[natinfo->target]); } |