- 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);
- }
-}
-
-void
-fw3_format_limit(struct fw3_limit *limit)
-{
- if (!limit)
- return;
-
- if (limit->rate > 0)
- {
- fw3_pr(" -m limit %s--limit %u/%s",
- limit->invert ? "! " : "",
- limit->rate, limit_units[limit->unit]);
-
- if (limit->burst > 0)
- fw3_pr(" --limit-burst %u", limit->burst);
- }
-}
-
-void
-fw3_format_ipset(struct fw3_ipset *ipset, bool invert)
-{
- bool first = true;
- const char *name = NULL;
- struct fw3_ipset_datatype *type;
-
- if (!ipset)
- return;
-
- if (ipset->external && *ipset->external)
- name = ipset->external;
- else
- name = ipset->name;
-
- fw3_pr(" -m set %s--match-set %s", invert ? "! " : "", name);
-
- list_for_each_entry(type, &ipset->datatypes, list)
- {
- fw3_pr("%c%s", first ? ' ' : ',', type->dest ? "dst" : "src");
- first = false;
- }
-}
-
-void
-fw3_format_time(struct fw3_time *time)
-{
- int i;
- struct tm empty = { 0 };
- char buf[sizeof("9999-99-99T23:59:59\0")];
- bool d1 = memcmp(&time->datestart, &empty, sizeof(empty));
- bool d2 = memcmp(&time->datestop, &empty, sizeof(empty));
- bool first;
-
- if (!d1 && !d2 && !time->timestart && !time->timestop &&
- !(time->monthdays & 0xFFFFFFFE) && !(time->weekdays & 0xFE))
- {
- return;
- }
-
- fw3_pr(" -m time");
-
- if (time->utc)
- fw3_pr(" --utc");
-
- if (d1)
- {
- strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &time->datestart);
- fw3_pr(" --datestart %s", buf);
- }
-
- if (d2)
- {
- strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &time->datestop);
- fw3_pr(" --datestop %s", buf);
- }
-
- if (time->timestart)
- {
- fw3_pr(" --timestart %02d:%02d:%02d",
- time->timestart / 3600,
- time->timestart % 3600 / 60,
- time->timestart % 60);
- }
-
- if (time->timestop)