Index: iptables-save.c =================================================================== RCS file: /cvspublic/iptables/iptables-save.c,v retrieving revision 1.27 diff -u -r1.27 iptables-save.c --- iptables-save.c 21 Feb 2004 09:20:34 -0000 1.27 +++ iptables-save.c 18 Mar 2004 18:53:54 -0000 @@ -62,36 +62,18 @@ printf(" "); } -/* These are hardcoded backups in iptables.c, so they are safe */ -struct pprot { - char *name; - u_int8_t num; -}; - -/* FIXME: why don't we use /etc/protocols ? */ -static const struct pprot chain_protos[] = { - { "tcp", IPPROTO_TCP }, - { "udp", IPPROTO_UDP }, - { "icmp", IPPROTO_ICMP }, - { "esp", IPPROTO_ESP }, - { "ah", IPPROTO_AH }, - { "sctp", IPPROTO_SCTP }, -}; - static void print_proto(u_int16_t proto, int invert) { if (proto) { - unsigned int i; const char *invertstr = invert ? "! " : ""; - for (i = 0; i < sizeof(chain_protos)/sizeof(struct pprot); i++) - if (chain_protos[i].num == proto) { - printf("-p %s%s ", - invertstr, chain_protos[i].name); - return; - } - - printf("-p %s%u ", invertstr, proto); + struct protoent* pent = getprotobynumber(proto) + if (proto) { + printf("-p %s%s ", invertstr, pent->p_name); + } + else { + printf("-p %s%u", invertstr, proto); + } } }