- fw3_pr("-%s", s);
- }
- else
- {
- inet_ntop(dest->family == FW3_FAMILY_V4 ? AF_INET : AF_INET6,
- &dest->address.v4, s, sizeof(s));
-
- fw3_pr(" %s-d %s/%u", dest->invert ? "! " : "", s, dest->mask);
- }
- }
-}
-
-void
-fw3_format_sport_dport(struct fw3_port *sp, struct fw3_port *dp)
-{
- if (sp && sp->set)
- {
- if (sp->port_min == sp->port_max)
- fw3_pr(" %s--sport %u", sp->invert ? "! " : "", sp->port_min);
- else
- fw3_pr(" %s--sport %u:%u",
- sp->invert ? "! " : "", sp->port_min, sp->port_max);
- }
-
- if (dp && dp->set)
- {
- if (dp->port_min == dp->port_max)
- fw3_pr(" %s--dport %u", dp->invert ? "! " : "", dp->port_min);
- else
- fw3_pr(" %s--dport %u:%u",
- dp->invert ? "! " : "", dp->port_min, dp->port_max);
- }
-}
-
-void
-fw3_format_mac(struct fw3_mac *mac)
-{
- if (!mac)
- return;
-
- fw3_pr(" -m mac %s--mac-source %s",
- mac->invert ? "! " : "", ether_ntoa(&mac->mac));
-}
-
-void
-fw3_format_protocol(struct fw3_protocol *proto, enum fw3_family family)
-{
- uint16_t pr;
-
- if (!proto)
- return;
-
- pr = proto->protocol;
-
- if (pr == 1 && family == FW3_FAMILY_V6)
- pr = 58;
-
- if (proto->any)
- fw3_pr(" -p all");
- else
- fw3_pr(" %s-p %u", proto->invert ? "! " : "", pr);
-}
-
-void
-fw3_format_icmptype(struct fw3_icmptype *icmp, enum fw3_family family)
-{
- if (!icmp)
- return;
-
- if (family != FW3_FAMILY_V6)
- {
- if (icmp->code_min == 0 && icmp->code_max == 0xFF)
- fw3_pr(" %s--icmp-type %u", icmp->invert ? "! " : "", icmp->type);
- else
- fw3_pr(" %s--icmp-type %u/%u",
- icmp->invert ? "! " : "", icmp->type, icmp->code_min);
- }
- else
- {
- if (icmp->code6_min == 0 && icmp->code6_max == 0xFF)
- fw3_pr(" %s--icmpv6-type %u", icmp->invert ? "! " : "", icmp->type6);
- else
- fw3_pr(" %s--icmpv6-type %u/%u",
- icmp->invert ? "! " : "", icmp->type6, icmp->code6_min);