diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2004-01-14 20:05:27 +0000 |
---|---|---|
committer | Bart De Schuymer <bdschuym@pandora.be> | 2004-01-14 20:05:27 +0000 |
commit | 9c16370646dcac6ba9803ffea4c552014f7eee11 (patch) | |
tree | 6bf8e02c571f1502c20489248e36890d9e9b3291 /userspace/ebtables2/extensions | |
parent | 8c80b19bc2abf6f6cebc64018b0097a33548135d (diff) |
Make ebtables library functions
Diffstat (limited to 'userspace/ebtables2/extensions')
-rw-r--r-- | userspace/ebtables2/extensions/ebt_802_3.c | 10 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_among.c | 14 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_arp.c | 46 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_arpreply.c | 8 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_ip.c | 136 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_limit.c | 10 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_log.c | 12 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_mark.c | 6 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_mark_m.c | 6 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_nat.c | 16 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_pkttype.c | 6 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_redirect.c | 4 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_standard.c | 7 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_stp.c | 18 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebt_vlan.c | 10 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebtable_broute.c | 4 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebtable_filter.c | 4 | ||||
-rw-r--r-- | userspace/ebtables2/extensions/ebtable_nat.c | 4 |
18 files changed, 102 insertions, 219 deletions
diff --git a/userspace/ebtables2/extensions/ebt_802_3.c b/userspace/ebtables2/extensions/ebt_802_3.c index 52b05aa..f76b20a 100644 --- a/userspace/ebtables2/extensions/ebt_802_3.c +++ b/userspace/ebtables2/extensions/ebt_802_3.c @@ -43,8 +43,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case _802_3_SAP: - check_option(flags, _802_3_SAP); - if (check_inverse(optarg)) + ebt_check_option(flags, _802_3_SAP); + if (ebt_check_inverse(optarg)) info->invflags |= EBT_802_3_SAP; if (optind > argc) @@ -57,8 +57,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, info->bitmask |= EBT_802_3_SAP; break; case _802_3_TYPE: - check_option(flags, _802_3_TYPE); - if (check_inverse(optarg)) + ebt_check_option(flags, _802_3_TYPE); + if (ebt_check_inverse(optarg)) info->invflags |= EBT_802_3_TYPE; if (optind > argc) print_error("Missing 802.3-type argument"); @@ -141,5 +141,5 @@ static struct ebt_u_match _802_3_match = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_match(&_802_3_match); + ebt_register_match(&_802_3_match); } diff --git a/userspace/ebtables2/extensions/ebt_among.c b/userspace/ebtables2/extensions/ebt_among.c index b865ca2..9427038 100644 --- a/userspace/ebtables2/extensions/ebt_among.c +++ b/userspace/ebtables2/extensions/ebt_among.c @@ -41,8 +41,8 @@ static void print_help() { printf( "`among' options:\n" -"--among-dst [!] list : matches if ether dst is in list\n" -"--among-src [!] list : matches if ether src is in list\n" +"--among-dst [!] list : matches if ether dst is in list\n" +"--among-src [!] list : matches if ether src is in list\n" "list has form:\n" " xx:xx:xx:xx:xx:xx[=ip.ip.ip.ip],yy:yy:yy:yy:yy:yy[=ip.ip.ip.ip]" ",...,zz:zz:zz:zz:zz:zz[=ip.ip.ip.ip][,]\n" @@ -295,7 +295,7 @@ static int parse(int c, char **argv, int argc, switch (c) { case AMONG_DST: case AMONG_SRC: - if (check_inverse(optarg)) { + if (ebt_check_inverse(optarg)) { if (c == AMONG_DST) info->bitmask |= EBT_AMONG_DST_NEG; else @@ -314,11 +314,11 @@ static int parse(int c, char **argv, int argc, h->match_size = new_size - sizeof(struct ebt_entry_match); info = (struct ebt_among_info *) h->data; if (c == AMONG_DST) { - check_option(flags, OPT_DST); + ebt_check_option(flags, OPT_DST); info->wh_dst_ofs = old_size - sizeof(struct ebt_entry_match); } else { - check_option(flags, OPT_SRC); + ebt_check_option(flags, OPT_SRC); info->wh_src_ofs = old_size - sizeof(struct ebt_entry_match); } @@ -364,7 +364,7 @@ static void wormhash_printout(const struct ebt_mac_wormhash *wh) const struct ebt_mac_wormhash_tuple *p; p = (const struct ebt_mac_wormhash_tuple *)(&wh->pool[i]); - print_mac(((const char *) &p->cmp[0]) + 2); + ebt_print_mac(((const char *) &p->cmp[0]) + 2); if (p->ip) { ip = (unsigned char *) &p->ip; printf("=%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); @@ -439,5 +439,5 @@ static struct ebt_u_match among_match = { static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_match(&among_match); + ebt_register_match(&among_match); } diff --git a/userspace/ebtables2/extensions/ebt_arp.c b/userspace/ebtables2/extensions/ebt_arp.c index 7b00b78..a60d6a7 100644 --- a/userspace/ebtables2/extensions/ebt_arp.c +++ b/userspace/ebtables2/extensions/ebt_arp.c @@ -71,11 +71,6 @@ static void init(struct ebt_entry_match *match) arpinfo->bitmask = 0; } -/* defined in ebt_ip.c */ -void parse_ip_address(char *address, uint32_t *addr, uint32_t *msk); - -/* defined in ebtables.c */ -int get_mac_and_mask(char *from, char *to, char *mask); #define OPT_OPCODE 0x01 #define OPT_HTYPE 0x02 @@ -97,8 +92,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case ARP_OPCODE: - check_option(flags, OPT_OPCODE); - if (check_inverse(optarg)) + ebt_check_option(flags, OPT_OPCODE); + if (ebt_check_inverse(optarg)) arpinfo->invflags |= EBT_ARP_OPCODE; if (optind > argc) @@ -118,8 +113,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, break; case ARP_HTYPE: - check_option(flags, OPT_HTYPE); - if (check_inverse(optarg)) + ebt_check_option(flags, OPT_HTYPE); + if (ebt_check_inverse(optarg)) arpinfo->invflags |= EBT_ARP_HTYPE; if (optind > argc) @@ -140,8 +135,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, { uint16_t proto; - check_option(flags, OPT_PTYPE); - if (check_inverse(optarg)) + ebt_check_option(flags, OPT_PTYPE); + if (ebt_check_inverse(optarg)) arpinfo->invflags |= EBT_ARP_PTYPE; if (optind > argc) @@ -166,17 +161,17 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, case ARP_IP_S: case ARP_IP_D: if (c == ARP_IP_S) { - check_option(flags, OPT_IP_S); + ebt_check_option(flags, OPT_IP_S); addr = &arpinfo->saddr; mask = &arpinfo->smsk; arpinfo->bitmask |= EBT_ARP_SRC_IP; } else { - check_option(flags, OPT_IP_D); + ebt_check_option(flags, OPT_IP_D); addr = &arpinfo->daddr; mask = &arpinfo->dmsk; arpinfo->bitmask |= EBT_ARP_DST_IP; } - if (check_inverse(optarg)) { + if (ebt_check_inverse(optarg)) { if (c == ARP_IP_S) arpinfo->invflags |= EBT_ARP_SRC_IP; else @@ -184,23 +179,23 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, } if (optind > argc) print_error("Missing ARP IP address argument"); - parse_ip_address(argv[optind - 1], addr, mask); + ebt_parse_ip_address(argv[optind - 1], addr, mask); break; case ARP_MAC_S: case ARP_MAC_D: if (c == ARP_MAC_S) { - check_option(flags, OPT_MAC_S); + ebt_check_option(flags, OPT_MAC_S); maddr = arpinfo->smaddr; mmask = arpinfo->smmsk; arpinfo->bitmask |= EBT_ARP_SRC_MAC; } else { - check_option(flags, OPT_MAC_D); + ebt_check_option(flags, OPT_MAC_D); maddr = arpinfo->dmaddr; mmask = arpinfo->dmmsk; arpinfo->bitmask |= EBT_ARP_DST_MAC; } - if (check_inverse(optarg)) { + if (ebt_check_inverse(optarg)) { if (c == ARP_MAC_S) arpinfo->invflags |= EBT_ARP_SRC_MAC; else @@ -208,7 +203,7 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, } if (optind > argc) print_error("Missing ARP MAC address argument"); - if (get_mac_and_mask(argv[optind - 1], maddr, mmask)) + if (ebt_get_mac_and_mask(argv[optind - 1], maddr, mmask)) print_error("Problem with ARP MAC address argument"); break; @@ -228,9 +223,6 @@ static void final_check(const struct ebt_u_entry *entry, "specified as ARP or RARP"); } -/* defined in the ebt_ip.c */ -char *mask_to_dotted(uint32_t mask); - static void print(const struct ebt_u_entry *entry, const struct ebt_entry_match *match) { @@ -272,7 +264,7 @@ static void print(const struct ebt_u_entry *entry, for (i = 0; i < 4; i++) printf("%d%s", ((unsigned char *)&arpinfo->saddr)[i], (i == 3) ? "" : "."); - printf("%s ", mask_to_dotted(arpinfo->smsk)); + printf("%s ", ebt_mask_to_dotted(arpinfo->smsk)); } if (arpinfo->bitmask & EBT_ARP_DST_IP) { printf("--arp-ip-dst "); @@ -281,20 +273,20 @@ static void print(const struct ebt_u_entry *entry, for (i = 0; i < 4; i++) printf("%d%s", ((unsigned char *)&arpinfo->daddr)[i], (i == 3) ? "" : "."); - printf("%s ", mask_to_dotted(arpinfo->dmsk)); + printf("%s ", ebt_mask_to_dotted(arpinfo->dmsk)); } if (arpinfo->bitmask & EBT_ARP_SRC_MAC) { printf("--arp-mac-src "); if (arpinfo->invflags & EBT_ARP_SRC_MAC) printf("! "); - print_mac_and_mask(arpinfo->smaddr, arpinfo->smmsk); + ebt_print_mac_and_mask(arpinfo->smaddr, arpinfo->smmsk); printf(" "); } if (arpinfo->bitmask & EBT_ARP_DST_MAC) { printf("--arp-mac-dst "); if (arpinfo->invflags & EBT_ARP_DST_MAC) printf("! "); - print_mac_and_mask(arpinfo->dmaddr, arpinfo->dmmsk); + ebt_print_mac_and_mask(arpinfo->dmaddr, arpinfo->dmmsk); printf(" "); } } @@ -364,5 +356,5 @@ static struct ebt_u_match arp_match = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_match(&arp_match); + ebt_register_match(&arp_match); } diff --git a/userspace/ebtables2/extensions/ebt_arpreply.c b/userspace/ebtables2/extensions/ebt_arpreply.c index 7e5f113..d524253 100644 --- a/userspace/ebtables2/extensions/ebt_arpreply.c +++ b/userspace/ebtables2/extensions/ebt_arpreply.c @@ -48,7 +48,7 @@ static int parse(int c, char **argv, int argc, switch (c) { case REPLY_MAC: - check_option(flags, OPT_REPLY_MAC); + ebt_check_option(flags, OPT_REPLY_MAC); if (!(addr = ether_aton(optarg))) print_error("Problem with specified " "--arpreply-mac mac"); @@ -56,7 +56,7 @@ static int parse(int c, char **argv, int argc, mac_supplied = 1; break; case REPLY_TARGET: - check_option(flags, OPT_REPLY_TARGET); + ebt_check_option(flags, OPT_REPLY_TARGET); if (FILL_TARGET(optarg, replyinfo->target)) print_error("Illegal --arpreply-target target"); break; @@ -94,7 +94,7 @@ static void print(const struct ebt_u_entry *entry, (struct ebt_arpreply_info *)target->data; printf("--arpreply-mac "); - print_mac(replyinfo->mac); + ebt_print_mac(replyinfo->mac); if (replyinfo->target == EBT_DROP) return; printf(" --arpreply-target %s", TARGET_NAME(replyinfo->target)); @@ -128,5 +128,5 @@ static struct ebt_u_target arpreply_target = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_target(&arpreply_target); + ebt_register_target(&arpreply_target); } diff --git a/userspace/ebtables2/extensions/ebt_ip.c b/userspace/ebtables2/extensions/ebt_ip.c index b836bae..f93b8b9 100644 --- a/userspace/ebtables2/extensions/ebt_ip.c +++ b/userspace/ebtables2/extensions/ebt_ip.c @@ -57,111 +57,7 @@ static struct option opts[] = { 0 } }; -/* put the ip string into 4 bytes */ -static int undot_ip(char *ip, unsigned char *ip2) -{ - char *p, *q, *end; - long int onebyte; - int i; - char buf[20]; - - strncpy(buf, ip, sizeof(buf) - 1); - - p = buf; - for (i = 0; i < 3; i++) { - if ((q = strchr(p, '.')) == NULL) - return -1; - *q = '\0'; - onebyte = strtol(p, &end, 10); - if (*end != '\0' || onebyte > 255 || onebyte < 0) - return -1; - ip2[i] = (unsigned char)onebyte; - p = q + 1; - } - - onebyte = strtol(p, &end, 10); - if (*end != '\0' || onebyte > 255 || onebyte < 0) - return -1; - ip2[3] = (unsigned char)onebyte; - - return 0; -} - /* put the mask into 4 bytes */ -static int ip_mask(char *mask, unsigned char *mask2) -{ - char *end; - long int bits; - uint32_t mask22; - - if (undot_ip(mask, mask2)) { - /* not the /a.b.c.e format, maybe the /x format */ - bits = strtol(mask, &end, 10); - if (*end != '\0' || bits > 32 || bits < 0) - return -1; - if (bits != 0) { - mask22 = htonl(0xFFFFFFFF << (32 - bits)); - memcpy(mask2, &mask22, 4); - } else { - mask22 = 0xFFFFFFFF; - memcpy(mask2, &mask22, 4); - } - } - return 0; -} - -/* set the ip mask and ip address */ -void parse_ip_address(char *address, uint32_t *addr, uint32_t *msk) -{ - char *p; - - /* first the mask */ - if ((p = strrchr(address, '/')) != NULL) { - *p = '\0'; - if (ip_mask(p + 1, (unsigned char *)msk)) - print_error("Problem with the IP mask"); - } - else - *msk = 0xFFFFFFFF; - - if (undot_ip(address, (unsigned char *)addr)) - print_error("Problem with the IP address"); - *addr = *addr & *msk; -} - -/* transform the ip mask into a string ready for output */ -char *mask_to_dotted(uint32_t mask) -{ - int i; - static char buf[20]; - uint32_t maskaddr, bits; - - maskaddr = ntohl(mask); - - /* don't print /32 */ - if (mask == 0xFFFFFFFFL) { - *buf = '\0'; - return buf; - } - - i = 32; - bits = 0xFFFFFFFEL; /* case 0xFFFFFFFF has just been dealt with */ - while (--i >= 0 && maskaddr != bits) - bits <<= 1; - - if (i > 0) - sprintf(buf, "/%d", i); - else if (!i) - *buf = '\0'; - else - /* mask was not a decent combination of 1's and 0's */ - sprintf(buf, "/%d.%d.%d.%d", ((unsigned char *)&mask)[0], - ((unsigned char *)&mask)[1], ((unsigned char *)&mask)[2], - ((unsigned char *)&mask)[3]); - - return buf; -} - /* transform a protocol and service name into a port number */ static uint16_t parse_port(const char *protocol, const char *name) { @@ -247,15 +143,15 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case IP_SOURCE: - check_option(flags, OPT_SOURCE); + ebt_check_option(flags, OPT_SOURCE); ipinfo->bitmask |= EBT_IP_SOURCE; case IP_DEST: if (c == IP_DEST) { - check_option(flags, OPT_DEST); + ebt_check_option(flags, OPT_DEST); ipinfo->bitmask |= EBT_IP_DEST; } - if (check_inverse(optarg)) { + if (ebt_check_inverse(optarg)) { if (c == IP_SOURCE) ipinfo->invflags |= EBT_IP_SOURCE; else @@ -265,24 +161,24 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, if (optind > argc) print_error("Missing IP address argument"); if (c == IP_SOURCE) - parse_ip_address(argv[optind - 1], &ipinfo->saddr, + ebt_parse_ip_address(argv[optind - 1], &ipinfo->saddr, &ipinfo->smsk); else - parse_ip_address(argv[optind - 1], &ipinfo->daddr, + ebt_parse_ip_address(argv[optind - 1], &ipinfo->daddr, &ipinfo->dmsk); break; case IP_SPORT: case IP_DPORT: if (c == IP_SPORT) { - check_option(flags, OPT_SPORT); + ebt_check_option(flags, OPT_SPORT); ipinfo->bitmask |= EBT_IP_SPORT; - if (check_inverse(optarg)) + if (ebt_check_inverse(optarg)) ipinfo->invflags |= EBT_IP_SPORT; } else { - check_option(flags, OPT_DPORT); + ebt_check_option(flags, OPT_DPORT); ipinfo->bitmask |= EBT_IP_DPORT; - if (check_inverse(optarg)) + if (ebt_check_inverse(optarg)) ipinfo->invflags |= EBT_IP_DPORT; } if (optind > argc) @@ -294,8 +190,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, break; case IP_myTOS: - check_option(flags, OPT_TOS); - if (check_inverse(optarg)) + ebt_check_option(flags, OPT_TOS); + if (ebt_check_inverse(optarg)) ipinfo->invflags |= EBT_IP_TOS; if (optind > argc) @@ -308,8 +204,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, break; case IP_PROTO: - check_option(flags, OPT_PROTO); - if (check_inverse(optarg)) + ebt_check_option(flags, OPT_PROTO); + if (ebt_check_inverse(optarg)) ipinfo->invflags |= EBT_IP_PROTO; if (optind > argc) print_error("Missing IP protocol argument"); @@ -366,7 +262,7 @@ static void print(const struct ebt_u_entry *entry, for (j = 0; j < 4; j++) printf("%d%s",((unsigned char *)&ipinfo->saddr)[j], (j == 3) ? "" : "."); - printf("%s ", mask_to_dotted(ipinfo->smsk)); + printf("%s ", ebt_mask_to_dotted(ipinfo->smsk)); } if (ipinfo->bitmask & EBT_IP_DEST) { printf("--ip-dst "); @@ -375,7 +271,7 @@ static void print(const struct ebt_u_entry *entry, for (j = 0; j < 4; j++) printf("%d%s", ((unsigned char *)&ipinfo->daddr)[j], (j == 3) ? "" : "."); - printf("%s ", mask_to_dotted(ipinfo->dmsk)); + printf("%s ", ebt_mask_to_dotted(ipinfo->dmsk)); } if (ipinfo->bitmask & EBT_IP_TOS) { printf("--ip-tos "); @@ -471,5 +367,5 @@ static struct ebt_u_match ip_match = static void _init(void) __attribute((constructor)); static void _init(void) { - register_match(&ip_match); + ebt_register_match(&ip_match); } diff --git a/userspace/ebtables2/extensions/ebt_limit.c b/userspace/ebtables2/extensions/ebt_limit.c index bf322b8..490686d 100644 --- a/userspace/ebtables2/extensions/ebt_limit.c +++ b/userspace/ebtables2/extensions/ebt_limit.c @@ -120,16 +120,16 @@ static int parse(int c, char **argv, int argc, switch(c) { case ARG_LIMIT: - check_option(flags, FLAG_LIMIT); - if (check_inverse(optarg)) + ebt_check_option(flags, FLAG_LIMIT); + if (ebt_check_inverse(optarg)) print_error("Unexpected `!' after --limit"); if (!parse_rate(optarg, &r->avg)) print_error("bad rate `%s'", optarg); break; case ARG_LIMIT_BURST: - check_option(flags, FLAG_LIMIT_BURST); - if (check_inverse(optarg)) + ebt_check_option(flags, FLAG_LIMIT_BURST); + if (ebt_check_inverse(optarg)) print_error("Unexpected `!' after --limit-burst"); if (string_to_number(optarg, 0, 10000, &num) == -1) @@ -217,5 +217,5 @@ static struct ebt_u_match limit_match = static void _init(void) __attribute((constructor)); static void _init(void) { - register_match(&limit_match); + ebt_register_match(&limit_match); } diff --git a/userspace/ebtables2/extensions/ebt_log.c b/userspace/ebtables2/extensions/ebt_log.c index 2892348..953211e 100644 --- a/userspace/ebtables2/extensions/ebt_log.c +++ b/userspace/ebtables2/extensions/ebt_log.c @@ -103,14 +103,14 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case LOG_PREFIX: - check_option(flags, OPT_PREFIX); + ebt_check_option(flags, OPT_PREFIX); if (strlen(optarg) > sizeof(loginfo->prefix) - 1) print_error("Prefix too long"); strcpy(loginfo->prefix, optarg); break; case LOG_LEVEL: - check_option(flags, OPT_LEVEL); + ebt_check_option(flags, OPT_LEVEL); i = strtol(optarg, &end, 16); if (*end != '\0' || i < 0 || i > 7) loginfo->loglevel = name_to_loglevel(optarg); @@ -121,17 +121,17 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, break; case LOG_IP: - check_option(flags, OPT_IP); + ebt_check_option(flags, OPT_IP); loginfo->bitmask |= EBT_LOG_IP; break; case LOG_ARP: - check_option(flags, OPT_ARP); + ebt_check_option(flags, OPT_ARP); loginfo->bitmask |= EBT_LOG_ARP; break; case LOG_LOG: - check_option(flags, OPT_LOG); + ebt_check_option(flags, OPT_LOG); break; default: return 0; @@ -190,5 +190,5 @@ static struct ebt_u_watcher log_watcher = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_watcher(&log_watcher); + ebt_register_watcher(&log_watcher); } diff --git a/userspace/ebtables2/extensions/ebt_mark.c b/userspace/ebtables2/extensions/ebt_mark.c index 6fa26f8..c40b9fd 100644 --- a/userspace/ebtables2/extensions/ebt_mark.c +++ b/userspace/ebtables2/extensions/ebt_mark.c @@ -46,12 +46,12 @@ static int parse(int c, char **argv, int argc, switch (c) { case MARK_TARGET: - check_option(flags, OPT_MARK_TARGET); + ebt_check_option(flags, OPT_MARK_TARGET); if (FILL_TARGET(optarg, markinfo->target)) print_error("Illegal --mark-target target"); break; case MARK_SETMARK: - check_option(flags, OPT_MARK_SETMARK); + ebt_check_option(flags, OPT_MARK_SETMARK); markinfo->mark = strtoul(optarg, &end, 0); if (*end != '\0' || end == optarg) print_error("Bad MARK value '%s'", optarg); @@ -116,5 +116,5 @@ static struct ebt_u_target mark_target = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_target(&mark_target); + ebt_register_target(&mark_target); } diff --git a/userspace/ebtables2/extensions/ebt_mark_m.c b/userspace/ebtables2/extensions/ebt_mark_m.c index 0d14d76..1c18d9e 100644 --- a/userspace/ebtables2/extensions/ebt_mark_m.c +++ b/userspace/ebtables2/extensions/ebt_mark_m.c @@ -40,8 +40,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case MARK: - check_option(flags, MARK); - if (check_inverse(optarg)) + ebt_check_option(flags, MARK); + if (ebt_check_inverse(optarg)) markinfo->invert = 1; if (optind > argc) print_error("No mark specified"); @@ -118,5 +118,5 @@ static struct ebt_u_match mark_match = static void _init(void) __attribute((constructor)); static void _init(void) { - register_match(&mark_match); + ebt_register_match(&mark_match); } diff --git a/userspace/ebtables2/extensions/ebt_nat.c b/userspace/ebtables2/extensions/ebt_nat.c index 04c6f0f..16e1842 100644 --- a/userspace/ebtables2/extensions/ebt_nat.c +++ b/userspace/ebtables2/extensions/ebt_nat.c @@ -73,14 +73,14 @@ static int parse_s(int c, char **argv, int argc, switch (c) { case NAT_S: - check_option(flags, OPT_SNAT); + ebt_check_option(flags, OPT_SNAT); to_source_supplied = 1; 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); + ebt_check_option(flags, OPT_SNAT_TARGET); if (FILL_TARGET(optarg, natinfo->target)) print_error("Illegal --snat-target target"); break; @@ -101,7 +101,7 @@ static int parse_d(int c, char **argv, int argc, switch (c) { case NAT_D: - check_option(flags, OPT_DNAT); + ebt_check_option(flags, OPT_DNAT); to_dest_supplied = 1; if (!(addr = ether_aton(optarg))) print_error("Problem with specified " @@ -109,7 +109,7 @@ static int parse_d(int c, char **argv, int argc, memcpy(natinfo->mac, addr, ETH_ALEN); break; case NAT_D_TARGET: - check_option(flags, OPT_DNAT_TARGET); + ebt_check_option(flags, OPT_DNAT_TARGET); if (FILL_TARGET(optarg, natinfo->target)) print_error("Illegal --dnat-target target"); break; @@ -157,7 +157,7 @@ static void print_s(const struct ebt_u_entry *entry, struct ebt_nat_info *natinfo = (struct ebt_nat_info *)target->data; printf("--to-src "); - print_mac(natinfo->mac); + ebt_print_mac(natinfo->mac); printf(" --snat-target %s", TARGET_NAME(natinfo->target)); } @@ -167,7 +167,7 @@ static void print_d(const struct ebt_u_entry *entry, struct ebt_nat_info *natinfo = (struct ebt_nat_info *)target->data; printf("--to-dst "); - print_mac(natinfo->mac); + ebt_print_mac(natinfo->mac); printf(" --dnat-target %s", TARGET_NAME(natinfo->target)); } @@ -210,6 +210,6 @@ static struct ebt_u_target dnat_target = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_target(&snat_target); - register_target(&dnat_target); + ebt_register_target(&snat_target); + ebt_register_target(&dnat_target); } diff --git a/userspace/ebtables2/extensions/ebt_pkttype.c b/userspace/ebtables2/extensions/ebt_pkttype.c index 73f6e62..35bac29 100644 --- a/userspace/ebtables2/extensions/ebt_pkttype.c +++ b/userspace/ebtables2/extensions/ebt_pkttype.c @@ -57,8 +57,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, switch (c) { case '1': - check_option(flags, 1); - if (check_inverse(optarg)) + ebt_check_option(flags, 1); + if (ebt_check_inverse(optarg)) ptinfo->invert = 1; if (optind > argc) print_error("Missing pkttype class specification"); @@ -132,5 +132,5 @@ static struct ebt_u_match pkttype_match = static void _init(void) __attribute((constructor)); static void _init(void) { - register_match(&pkttype_match); + ebt_register_match(&pkttype_match); } diff --git a/userspace/ebtables2/extensions/ebt_redirect.c b/userspace/ebtables2/extensions/ebt_redirect.c index 432e58d..82feaa9 100644 --- a/userspace/ebtables2/extensions/ebt_redirect.c +++ b/userspace/ebtables2/extensions/ebt_redirect.c @@ -38,7 +38,7 @@ static int parse(int c, char **argv, int argc, switch (c) { case REDIRECT_TARGET: - check_option(flags, OPT_REDIRECT_TARGET); + ebt_check_option(flags, OPT_REDIRECT_TARGET); if (FILL_TARGET(optarg, redirectinfo->target)) print_error("Illegal --redirect-target target"); break; @@ -102,5 +102,5 @@ static struct ebt_u_target redirect_target = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_target(&redirect_target); + ebt_register_target(&redirect_target); } diff --git a/userspace/ebtables2/extensions/ebt_standard.c b/userspace/ebtables2/extensions/ebt_standard.c index 6a260eb..7ee454b 100644 --- a/userspace/ebtables2/extensions/ebt_standard.c +++ b/userspace/ebtables2/extensions/ebt_standard.c @@ -31,8 +31,6 @@ static void final_check(const struct ebt_u_entry *entry, { } -struct ebt_u_entries *nr_to_chain(int nr); - static void print(const struct ebt_u_entry *entry, const struct ebt_entry_target *target) { @@ -41,7 +39,8 @@ static void print(const struct ebt_u_entry *entry, if (verdict >= 0) { struct ebt_u_entries *entries; - entries = nr_to_chain(verdict + NF_BR_NUMHOOKS); + entries = ebt_nr_to_chain(entry->replace, + verdict + NF_BR_NUMHOOKS); printf("%s", entries->name); return; } @@ -81,5 +80,5 @@ static struct ebt_u_target standard = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_target(&standard); + ebt_register_target(&standard); } diff --git a/userspace/ebtables2/extensions/ebt_stp.c b/userspace/ebtables2/extensions/ebt_stp.c index 391b89e..60f2cc8 100644 --- a/userspace/ebtables2/extensions/ebt_stp.c +++ b/userspace/ebtables2/extensions/ebt_stp.c @@ -78,10 +78,6 @@ static void init(struct ebt_entry_match *match) stpinfo->bitmask = 0; } -/* defined in ebtables.c */ -int get_mac_and_mask(char *from, char *to, char *mask); -void print_mac_and_mask(const char *mac, const char *mask); - #define determine_value(p,s) \ { \ uint32_t _tmp2; \ @@ -135,8 +131,8 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, if (c < 'a' || c > ('a' + STP_NUMOPS - 1)) return 0; flag = 1 << (c - 'a'); - check_option(flags, flag); - if (check_inverse(optarg)) + ebt_check_option(flags, flag); + if (ebt_check_inverse(optarg)) stpinfo->invflags |= flag; if (optind > argc) print_error("Missing argument for --%s", opts[c-'a'].name); @@ -211,12 +207,12 @@ static int parse(int c, char **argv, int argc, const struct ebt_u_entry *entry, print_error("Bad STP config forward delay range"); break; case EBT_STP_ROOTADDR: - if (get_mac_and_mask(argv[optind-1], + if (ebt_get_mac_and_mask(argv[optind-1], stpinfo->config.root_addr, stpinfo->config.root_addrmsk)) print_error("Bad STP config root address"); break; case EBT_STP_SENDERADDR: - if (get_mac_and_mask(argv[optind-1], stpinfo->config.sender_addr, + if (ebt_get_mac_and_mask(argv[optind-1], stpinfo->config.sender_addr, stpinfo->config.sender_addrmsk)) print_error("Bad STP config sender address"); break; @@ -269,13 +265,13 @@ static void print(const struct ebt_u_entry *entry, } else if (EBT_STP_ROOTPRIO == (1 << i)) print_range(c->root_priol, c->root_priou); else if (EBT_STP_ROOTADDR == (1 << i)) - print_mac_and_mask(c->root_addr, c->root_addrmsk); + ebt_print_mac_and_mask(c->root_addr, c->root_addrmsk); else if (EBT_STP_ROOTCOST == (1 << i)) print_range(c->root_costl, c->root_costu); else if (EBT_STP_SENDERPRIO == (1 << i)) print_range(c->sender_priol, c->sender_priou); else if (EBT_STP_SENDERADDR == (1 << i)) - print_mac_and_mask(c->sender_addr, c->sender_addrmsk); + ebt_print_mac_and_mask(c->sender_addr, c->sender_addrmsk); else if (EBT_STP_PORT == (1 << i)) print_range(c->portl, c->portu); else if (EBT_STP_MSGAGE == (1 << i)) @@ -312,5 +308,5 @@ static struct ebt_u_match stp_match = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_match(&stp_match); + ebt_register_match(&stp_match); } diff --git a/userspace/ebtables2/extensions/ebt_vlan.c b/userspace/ebtables2/extensions/ebt_vlan.c index 198f537..5a8a912 100644 --- a/userspace/ebtables2/extensions/ebt_vlan.c +++ b/userspace/ebtables2/extensions/ebt_vlan.c @@ -45,7 +45,7 @@ #define SET_BITMASK(_MASK_) vlaninfo->bitmask |= _MASK_ #define INV_FLAG(_inv_flag_) (vlaninfo->invflags & _inv_flag_) ? "! " : "" #define CHECK_IF_MISSING_VALUE if (optind > argc) print_error ("Missing %s value", opts[c].name); -#define CHECK_INV_FLAG(_INDEX_) if (check_inverse (optarg)) vlaninfo->invflags |= _INDEX_; +#define CHECK_INV_FLAG(_INDEX_) if (ebt_check_inverse (optarg)) vlaninfo->invflags |= _INDEX_; #define CHECK_RANGE(_RANGE_) if (_RANGE_) print_error ("Invalid %s range", opts[c].name); #define NAME_VLAN_ID "id" @@ -138,7 +138,7 @@ parse(int c, switch (c) { case VLAN_ID: - check_option(flags, OPT_VLAN_ID); + ebt_check_option(flags, OPT_VLAN_ID); CHECK_INV_FLAG(EBT_VLAN_ID); CHECK_IF_MISSING_VALUE; (unsigned short) local.id = @@ -149,7 +149,7 @@ parse(int c, break; case VLAN_PRIO: - check_option(flags, OPT_VLAN_PRIO); + ebt_check_option(flags, OPT_VLAN_PRIO); CHECK_INV_FLAG(EBT_VLAN_PRIO); CHECK_IF_MISSING_VALUE; (unsigned char) local.prio = @@ -160,7 +160,7 @@ parse(int c, break; case VLAN_ENCAP: - check_option(flags, OPT_VLAN_ENCAP); + ebt_check_option(flags, OPT_VLAN_ENCAP); CHECK_INV_FLAG(EBT_VLAN_ENCAP); CHECK_IF_MISSING_VALUE; (unsigned short) local.encap = @@ -321,5 +321,5 @@ static struct ebt_u_match vlan_match = { static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_match(&vlan_match); + ebt_register_match(&vlan_match); } diff --git a/userspace/ebtables2/extensions/ebtable_broute.c b/userspace/ebtables2/extensions/ebtable_broute.c index 155d9ce..362183a 100644 --- a/userspace/ebtables2/extensions/ebtable_broute.c +++ b/userspace/ebtables2/extensions/ebtable_broute.c @@ -2,7 +2,7 @@ #include "../include/ebtables_u.h" -static void print_help(char **hn) +static void print_help(const char **hn) { printf("Supported chain for the broute table:\n"); printf("%s\n",hn[NF_BR_BROUTING]); @@ -18,5 +18,5 @@ ebt_u_table table = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_table(&table); + ebt_register_table(&table); } diff --git a/userspace/ebtables2/extensions/ebtable_filter.c b/userspace/ebtables2/extensions/ebtable_filter.c index 724198c..904a857 100644 --- a/userspace/ebtables2/extensions/ebtable_filter.c +++ b/userspace/ebtables2/extensions/ebtable_filter.c @@ -4,7 +4,7 @@ #define FILTER_VALID_HOOKS ((1 << NF_BR_LOCAL_IN) | (1 << NF_BR_FORWARD) | \ (1 << NF_BR_LOCAL_OUT)) -static void print_help(char **hn) +static void print_help(const char **hn) { int i; @@ -24,5 +24,5 @@ static struct ebt_u_table table = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_table(&table); + ebt_register_table(&table); } diff --git a/userspace/ebtables2/extensions/ebtable_nat.c b/userspace/ebtables2/extensions/ebtable_nat.c index 7998e7d..b151dc5 100644 --- a/userspace/ebtables2/extensions/ebtable_nat.c +++ b/userspace/ebtables2/extensions/ebtable_nat.c @@ -4,7 +4,7 @@ #define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \ (1 << NF_BR_POST_ROUTING)) -static void print_help(char **hn) +static void print_help(const char **hn) { int i; @@ -25,5 +25,5 @@ ebt_u_table table = static void _init(void) __attribute__ ((constructor)); static void _init(void) { - register_table(&table); + ebt_register_table(&table); } |