-/* $OpenBSD: pf_print_state.c,v 1.64 2015/01/21 21:50:33 deraadt Exp $ */
+/* $OpenBSD: pf_print_state.c,v 1.65 2018/07/24 09:48:04 kn Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
printf("<%s>", addr->v.tblname);
return;
case PF_ADDR_RANGE: {
- char buf[48];
-
- if (inet_ntop(af, &addr->v.a.addr, buf, sizeof(buf)) == NULL)
- printf("?");
- else
- printf("%s", buf);
- if (inet_ntop(af, &addr->v.a.mask, buf, sizeof(buf)) == NULL)
- printf(" - ?");
- else
- printf(" - %s", buf);
+ print_addr_str(af, &addr->v.a.addr);
+ printf(" - ");
+ print_addr_str(af, &addr->v.a.mask);
break;
}
case PF_ADDR_ADDRMASK:
if (PF_AZERO(&addr->v.a.addr, AF_INET6) &&
PF_AZERO(&addr->v.a.mask, AF_INET6))
printf("any");
- else {
- char buf[48];
-
- if (inet_ntop(af, &addr->v.a.addr, buf,
- sizeof(buf)) == NULL)
- printf("?");
- else
- printf("%s", buf);
- }
+ else
+ print_addr_str(af, &addr->v.a.addr);
break;
case PF_ADDR_NOROUTE:
printf("no-route");
}
}
+void
+print_addr_str(sa_family_t af, struct pf_addr *addr)
+{
+ static char buf[48];
+
+ if (inet_ntop(af, addr, buf, sizeof(buf)) == NULL)
+ printf("?");
+ else
+ printf("%s", buf);
+}
+
void
print_name(struct pf_addr *addr, sa_family_t af)
{
-/* $OpenBSD: pfctl.h,v 1.55 2017/08/11 22:30:38 benno Exp $ */
+/* $OpenBSD: pfctl.h,v 1.56 2018/07/24 09:48:04 kn Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
};
void print_addr(struct pf_addr_wrap *, sa_family_t, int);
+void print_addr_str(sa_family_t, struct pf_addr *);
void print_host(struct pf_addr *, u_int16_t p, sa_family_t, u_int16_t, const char *, int);
void print_seq(struct pfsync_state_peer *);
void print_state(struct pfsync_state *, int);
-/* $OpenBSD: pfctl_parser.c,v 1.322 2018/07/24 09:38:21 kn Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.323 2018/07/24 09:48:04 kn Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
case PF_DIVERT_NONE:
break;
case PF_DIVERT_TO: {
- /* XXX cut&paste from print_addr */
- char buf[48];
-
printf(" divert-to ");
- if (inet_ntop(r->af, &r->divert.addr, buf, sizeof(buf)) == NULL)
- printf("?");
- else
- printf("%s", buf);
+ print_addr_str(r->af, &r->divert.addr);
printf(" port %u", ntohs(r->divert.port));
break;
}