#include #include #include #include #include "xshared.h" /* * Print out any special helps. A user might like to be able to add a --help * to the commandline, and see expected results. So we call help for all * specified matches and targets. */ void print_extension_helps(const struct xtables_target *t, const struct xtables_rule_match *m) { for (; t != NULL; t = t->next) { if (t->used) { printf("\n"); if (t->help == NULL) printf("%s does not take any options\n", t->name); else t->help(); } } for (; m != NULL; m = m->next) { printf("\n"); if (m->match->help == NULL) printf("%s does not take any options\n", m->match->name); else m->match->help(); } } const char * proto_to_name(uint8_t proto, int nolookup) { unsigned int i; if (proto && !nolookup) { struct protoent *pent = getprotobynumber(proto); if (pent) return pent->p_name; } for (i = 0; xtables_chain_protos[i].name != NULL; ++i) if (xtables_chain_protos[i].num == proto) return xtables_chain_protos[i].name; return NULL; } struct xtables_match * find_proto(const char *pname, enum xtables_tryload tryload, int nolookup, struct xtables_rule_match **matches) { unsigned int proto; if (xtables_strtoui(pname, NULL, &proto, 0, UINT8_MAX)) { const char *protoname = proto_to_name(proto, nolookup); if (protoname) return xtables_find_match(protoname, tryload, matches); } else return xtables_find_match(pname, tryload, matches); return NULL; }