if.c (6a068746777241722b2b32c5d0bc443a2a64d80b) if.c (d6d3f01e0a3395c1fae34a3c4be7b051cb2d7581)
1/*-
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 67 unchanged lines hidden (view full) ---

76
77static void sidewaysintpr(int, u_long);
78static void catchalarm(int);
79
80#ifdef INET6
81static char addr_buf[NI_MAXHOST]; /* for getnameinfo() */
82#endif
83
1/*-
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 67 unchanged lines hidden (view full) ---

76
77static void sidewaysintpr(int, u_long);
78static void catchalarm(int);
79
80#ifdef INET6
81static char addr_buf[NI_MAXHOST]; /* for getnameinfo() */
82#endif
83
84static const char* pfsyncacts[] = {
85 /* PFSYNC_ACT_CLR */ "clear all request",
86 /* PFSYNC_ACT_INS */ "state insert",
87 /* PFSYNC_ACT_INS_ACK */ "state inserted ack",
88 /* PFSYNC_ACT_UPD */ "state update",
89 /* PFSYNC_ACT_UPD_C */ "compressed state update",
90 /* PFSYNC_ACT_UPD_REQ */ "uncompressed state request",
91 /* PFSYNC_ACT_DEL */ "state delete",
92 /* PFSYNC_ACT_DEL_C */ "compressed state delete",
93 /* PFSYNC_ACT_INS_F */ "fragment insert",
94 /* PFSYNC_ACT_DEL_F */ "fragment delete",
95 /* PFSYNC_ACT_BUS */ "bulk update mark",
96 /* PFSYNC_ACT_TDB */ "TDB replay counter update",
97 /* PFSYNC_ACT_EOF */ "end of frame mark",
98};
99
100static void
101pfsync_acts_stats(const char *fmt, uint64_t *a)
102{
103 int i;
104
105 for (i = 0; i < PFSYNC_ACT_MAX; i++, a++)
106 if (*a || sflag <= 1)
107 printf(fmt, *a, pfsyncacts[i], plural(*a));
108}
109
84/*
85 * Dump pfsync statistics structure.
86 */
87void
88pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
89{
90 struct pfsyncstats pfsyncstat, zerostat;
91 size_t len = sizeof(struct pfsyncstats);

--- 9 unchanged lines hidden (view full) ---

101 }
102 } else
103 kread(off, &pfsyncstat, len);
104
105 printf("%s:\n", name);
106
107#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
108 printf(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
110/*
111 * Dump pfsync statistics structure.
112 */
113void
114pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
115{
116 struct pfsyncstats pfsyncstat, zerostat;
117 size_t len = sizeof(struct pfsyncstats);

--- 9 unchanged lines hidden (view full) ---

127 }
128 } else
129 kread(off, &pfsyncstat, len);
130
131 printf("%s:\n", name);
132
133#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
134 printf(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
109#define p2(f, m) if (pfsyncstat.f || sflag <= 1) \
110 printf(m, (uintmax_t)pfsyncstat.f)
111
112 p(pfsyncs_ipackets, "\t%ju packet%s received (IPv4)\n");
113 p(pfsyncs_ipackets6, "\t%ju packet%s received (IPv6)\n");
135
136 p(pfsyncs_ipackets, "\t%ju packet%s received (IPv4)\n");
137 p(pfsyncs_ipackets6, "\t%ju packet%s received (IPv6)\n");
138 pfsync_acts_stats("\t %ju %s%s received\n",
139 &pfsyncstat.pfsyncs_iacts[0]);
114 p(pfsyncs_badif, "\t\t%ju packet%s discarded for bad interface\n");
115 p(pfsyncs_badttl, "\t\t%ju packet%s discarded for bad ttl\n");
116 p(pfsyncs_hdrops, "\t\t%ju packet%s shorter than header\n");
117 p(pfsyncs_badver, "\t\t%ju packet%s discarded for bad version\n");
118 p(pfsyncs_badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
119 p(pfsyncs_badact,"\t\t%ju packet%s discarded for bad action\n");
120 p(pfsyncs_badlen, "\t\t%ju packet%s discarded for short packet\n");
121 p(pfsyncs_badval, "\t\t%ju state%s discarded for bad values\n");
122 p(pfsyncs_stale, "\t\t%ju stale state%s\n");
123 p(pfsyncs_badstate, "\t\t%ju failed state lookup/insert%s\n");
124 p(pfsyncs_opackets, "\t%ju packet%s sent (IPv4)\n");
125 p(pfsyncs_opackets6, "\t%ju packet%s sent (IPv6)\n");
140 p(pfsyncs_badif, "\t\t%ju packet%s discarded for bad interface\n");
141 p(pfsyncs_badttl, "\t\t%ju packet%s discarded for bad ttl\n");
142 p(pfsyncs_hdrops, "\t\t%ju packet%s shorter than header\n");
143 p(pfsyncs_badver, "\t\t%ju packet%s discarded for bad version\n");
144 p(pfsyncs_badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
145 p(pfsyncs_badact,"\t\t%ju packet%s discarded for bad action\n");
146 p(pfsyncs_badlen, "\t\t%ju packet%s discarded for short packet\n");
147 p(pfsyncs_badval, "\t\t%ju state%s discarded for bad values\n");
148 p(pfsyncs_stale, "\t\t%ju stale state%s\n");
149 p(pfsyncs_badstate, "\t\t%ju failed state lookup/insert%s\n");
150 p(pfsyncs_opackets, "\t%ju packet%s sent (IPv4)\n");
151 p(pfsyncs_opackets6, "\t%ju packet%s sent (IPv6)\n");
126 p2(pfsyncs_onomem, "\t\t%ju send failed due to mbuf memory error\n");
127 p2(pfsyncs_oerrors, "\t\t%ju send error\n");
152 pfsync_acts_stats("\t %ju %s%s sent\n",
153 &pfsyncstat.pfsyncs_oacts[0]);
154 p(pfsyncs_onomem, "\t\t%ju failure%s due to mbuf memory error\n");
155 p(pfsyncs_oerrors, "\t\t%ju send error%s\n");
128#undef p
156#undef p
129#undef p2
130}
131
132/*
133 * Display a formatted value, or a '-' in the same space.
134 */
135static void
136show_stat(const char *fmt, int width, u_long value, short showvalue)
137{

--- 568 unchanged lines hidden ---
157}
158
159/*
160 * Display a formatted value, or a '-' in the same space.
161 */
162static void
163show_stat(const char *fmt, int width, u_long value, short showvalue)
164{

--- 568 unchanged lines hidden ---