-/* $OpenBSD: show.c,v 1.94 2013/07/19 20:10:23 guenther Exp $ */
+/* $OpenBSD: show.c,v 1.95 2014/04/17 15:35:35 claudio Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
char *link_print(struct sockaddr *);
char *label_print(struct sockaddr *);
-extern int nflag;
-extern int Fflag;
-extern int verbose;
-extern union sockunion so_label;
-
-#define PLEN (LONG_BIT / 4 + 2) /* XXX this is also defined in netstat.h */
-
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
if (needed == 0)
break;
if ((buf = realloc(buf, needed)) == NULL)
- err(1, "realloc");
+ err(1, NULL);
if (sysctl(mib, mcnt, buf, &needed, NULL, 0) == -1) {
if (errno == ENOMEM)
continue;
mib[2] = PF_KEY_V2;
mib[3] = NET_KEY_SPD_DUMP;
mib[4] = mib[5] = 0;
-
- if (sysctl(mib, 4, NULL, &needed, NULL, 0) == -1) {
- if (errno == ENOPROTOOPT)
- return;
- err(1, "spd-sysctl-estimate");
- }
- if (needed > 0) {
- if ((buf = malloc(needed)) == 0)
+ while (1) {
+ if (sysctl(mib, 4, NULL, &needed, NULL, 0) == -1) {
+ if (errno == ENOPROTOOPT)
+ return;
+ err(1, "spd-sysctl-estimate");
+ }
+ if (needed == 0)
+ break;
+ if ((buf = realloc(buf, needed)) == NULL)
err(1, NULL);
- if (sysctl(mib, 4, buf, &needed, NULL, 0) == -1)
+ if (sysctl(mib, 4, buf, &needed, NULL, 0) == -1) {
+ if (errno == ENOMEM)
+ continue;
err(1,"sysctl of spd");
+ }
lim = buf + needed;
+ break;
}
if (buf) {
-/* $OpenBSD: show.h,v 1.9 2010/10/11 11:45:00 claudio Exp $ */
+/* $OpenBSD: show.h,v 1.10 2014/04/17 15:35:35 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
char *netname(struct sockaddr *, struct sockaddr *);
char *mpls_op(u_int32_t);
+extern int nflag;
+extern int Fflag;
+extern int verbose;
+extern union sockunion so_label;
+
+#define PLEN (LONG_BIT / 4 + 2)
+
#endif /* __SHOW_H__ */