ACCOUNT: use non-clashing function names

[jengelh: It is just impossible to set a breakpoint right on functions
if all modules call or/use the same symbol name.]
This commit is contained in:
Jan Rafaj
2009-09-01 19:52:48 +02:00
committed by Jan Engelhardt
parent 03363a528a
commit 47e002127c
2 changed files with 36 additions and 36 deletions

View File

@@ -13,7 +13,7 @@
#include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv4/ip_tables.h>
#include "xt_ACCOUNT.h" #include "xt_ACCOUNT.h"
static struct option opts[] = { static struct option account_tg_opts[] = {
{ .name = "addr", .has_arg = 1, .flag = 0, .val = 'a' }, { .name = "addr", .has_arg = 1, .flag = 0, .val = 'a' },
{ .name = "tname", .has_arg = 1, .flag = 0, .val = 't' }, { .name = "tname", .has_arg = 1, .flag = 0, .val = 't' },
{ .name = 0 } { .name = 0 }
@@ -25,18 +25,18 @@ static struct option opts[] = {
#endif #endif
/* Function which prints out usage message. */ /* Function which prints out usage message. */
static void help(void) static void account_tg_help(void)
{ {
printf( printf(
"ACCOUNT v%s options:\n" "ACCOUNT v%s options:\n"
" --%s ip/netmask\t\tBase network IP and netmask used for this table\n" " --%s ip/netmask\t\tBase network IP and netmask used for this table\n"
" --%s name\t\t\tTable name for the userspace library\n", " --%s name\t\t\tTable name for the userspace library\n",
XTABLES_VERSION, opts[0].name, opts[1].name); XTABLES_VERSION, account_tg_opts[0].name, account_tg_opts[1].name);
} }
/* Initialize the target. */ /* Initialize the target. */
static void static void
init(struct xt_entry_target *t) account_tg_init(struct xt_entry_target *t)
{ {
struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)t->data; struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)t->data;
@@ -49,7 +49,7 @@ init(struct xt_entry_target *t)
/* Function which parses command options; returns true if it /* Function which parses command options; returns true if it
ate an option */ ate an option */
static int parse(int c, char **argv, int invert, unsigned int *flags, static int account_tg_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target) const void *entry, struct xt_entry_target **target)
{ {
struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)(*target)->data; struct ipt_acc_info *accountinfo = (struct ipt_acc_info *)(*target)->data;
@@ -60,11 +60,11 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
case 'a': case 'a':
if (*flags & IPT_ACCOUNT_OPT_ADDR) if (*flags & IPT_ACCOUNT_OPT_ADDR)
xtables_error(PARAMETER_PROBLEM, "Can't specify --%s twice", xtables_error(PARAMETER_PROBLEM, "Can't specify --%s twice",
opts[0].name); account_tg_opts[0].name);
if (xtables_check_inverse(optarg, &invert, NULL, 0)) if (xtables_check_inverse(optarg, &invert, NULL, 0))
xtables_error(PARAMETER_PROBLEM, "Unexpected `!' after --%s", xtables_error(PARAMETER_PROBLEM, "Unexpected `!' after --%s",
opts[0].name); account_tg_opts[0].name);
#ifdef XTABLES_VERSION_CODE #ifdef XTABLES_VERSION_CODE
xtables_ipparse_any(optarg, &addrs, &mask, &naddrs); xtables_ipparse_any(optarg, &addrs, &mask, &naddrs);
@@ -84,16 +84,19 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
case 't': case 't':
if (*flags & IPT_ACCOUNT_OPT_TABLE) if (*flags & IPT_ACCOUNT_OPT_TABLE)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Can't specify --%s twice", opts[1].name); "Can't specify --%s twice",
account_tg_opts[1].name);
if (xtables_check_inverse(optarg, &invert, NULL, 0)) if (xtables_check_inverse(optarg, &invert, NULL, 0))
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Unexpected `!' after --%s", opts[1].name); "Unexpected `!' after --%s",
account_tg_opts[1].name);
if (strlen(optarg) > ACCOUNT_TABLE_NAME_LEN - 1) if (strlen(optarg) > ACCOUNT_TABLE_NAME_LEN - 1)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Maximum table name length %u for --%s", "Maximum table name length %u for --%s",
ACCOUNT_TABLE_NAME_LEN - 1, opts[1].name); ACCOUNT_TABLE_NAME_LEN - 1,
account_tg_opts[1].name);
strcpy(accountinfo->table_name, optarg); strcpy(accountinfo->table_name, optarg);
*flags |= IPT_ACCOUNT_OPT_TABLE; *flags |= IPT_ACCOUNT_OPT_TABLE;
@@ -105,12 +108,11 @@ static int parse(int c, char **argv, int invert, unsigned int *flags,
return 1; return 1;
} }
/* Final check; nothing. */ static void account_tg_check(unsigned int flags)
static void final_check(unsigned int flags)
{ {
if (!(flags & IPT_ACCOUNT_OPT_ADDR) || !(flags & IPT_ACCOUNT_OPT_TABLE)) if (!(flags & IPT_ACCOUNT_OPT_ADDR) || !(flags & IPT_ACCOUNT_OPT_TABLE))
xtables_error(PARAMETER_PROBLEM, "ACCOUNT: needs --%s and --%s", xtables_error(PARAMETER_PROBLEM, "ACCOUNT: needs --%s and --%s",
opts[0].name, opts[1].name); account_tg_opts[0].name, account_tg_opts[1].name);
} }
static const char *print_helper_ip(struct in_addr a) static const char *print_helper_ip(struct in_addr a)
@@ -131,7 +133,7 @@ static const char *print_helper_mask(struct in_addr a)
#endif #endif
} }
static void print_it(const void *ip, static void account_tg_print_it(const void *ip,
const struct xt_entry_target *target, char do_prefix) const struct xt_entry_target *target, char do_prefix)
{ {
const struct ipt_acc_info *accountinfo const struct ipt_acc_info *accountinfo
@@ -144,7 +146,7 @@ static void print_it(const void *ip,
// Network information // Network information
if (do_prefix) if (do_prefix)
printf("--"); printf("--");
printf("%s ", opts[0].name); printf("%s ", account_tg_opts[0].name);
a.s_addr = accountinfo->net_ip; a.s_addr = accountinfo->net_ip;
printf("%s", print_helper_ip(a)); printf("%s", print_helper_ip(a));
@@ -155,44 +157,42 @@ static void print_it(const void *ip,
if (do_prefix) if (do_prefix)
printf("--"); printf("--");
printf("%s %s", opts[1].name, accountinfo->table_name); printf("%s %s", account_tg_opts[1].name, accountinfo->table_name);
} }
static void static void
print(const void *ip, account_tg_print(const void *ip,
const struct xt_entry_target *target, const struct xt_entry_target *target,
int numeric) int numeric)
{ {
print_it(ip, target, 0); account_tg_print_it(ip, target, 0);
} }
/* Saves the union ipt_targinfo in parsable form to stdout. */ /* Saves the union ipt_targinfo in parsable form to stdout. */
static void static void
save(const void *ip, const struct xt_entry_target *target) account_tg_save(const void *ip, const struct xt_entry_target *target)
{ {
print_it(ip, target, 1); account_tg_print_it(ip, target, 1);
} }
static static struct xtables_target account_tg_reg = {
struct xtables_target account
= {
.next = NULL, .next = NULL,
.name = "ACCOUNT", .name = "ACCOUNT",
.family = AF_INET, .family = AF_INET,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct ipt_acc_info)), .size = XT_ALIGN(sizeof(struct ipt_acc_info)),
.userspacesize = offsetof(struct ipt_acc_info, table_nr), .userspacesize = offsetof(struct ipt_acc_info, table_nr),
.help = &help, .help = account_tg_help,
.init = &init, .init = account_tg_init,
.parse = &parse, .parse = account_tg_parse,
.final_check = &final_check, .final_check = account_tg_check,
.print = &print, .print = account_tg_print,
.save = &save, .save = account_tg_save,
.extra_opts = opts .extra_opts = account_tg_opts,
}; };
void _init(void) static __attribute__((constructor)) void account_tg_ldr(void)
{ {
xtables_register_target(&account); xtables_register_target(&account_tg_reg);
} }

View File

@@ -1037,7 +1037,7 @@ static struct nf_sockopt_ops ipt_acc_sockopts = {
.get = ipt_acc_get_ctl .get = ipt_acc_get_ctl
}; };
static int __init init(void) static int __init account_tg_init(void)
{ {
init_MUTEX(&ipt_acc_userspace_mutex); init_MUTEX(&ipt_acc_userspace_mutex);
@@ -1087,7 +1087,7 @@ error_cleanup:
return -EINVAL; return -EINVAL;
} }
static void __exit fini(void) static void __exit account_tg_exit(void)
{ {
xt_unregister_target(&xt_acc_reg); xt_unregister_target(&xt_acc_reg);
@@ -1098,6 +1098,6 @@ static void __exit fini(void)
free_page((unsigned long)ipt_acc_tmpbuf); free_page((unsigned long)ipt_acc_tmpbuf);
} }
module_init(init); module_init(account_tg_init);
module_exit(fini); module_exit(account_tg_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");