ipsec.c (153809) | ipsec.c (160787) |
---|---|
1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 153809 2005-12-28 20:36:55Z kbyanc $ */ | 1/* $FreeBSD: head/usr.bin/netstat/ipsec.c 160787 2006-07-28 16:09:19Z yar $ */ |
2/* $KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $ */ 3 4/* 5 * Copyright (c) 2005 NTT Multimedia Communications Laboratories, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 81 unchanged lines hidden (view full) --- 91 92#if 0 93#ifndef lint 94static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; 95#endif /* not lint */ 96#endif 97 98#include <sys/cdefs.h> | 2/* $KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $ */ 3 4/* 5 * Copyright (c) 2005 NTT Multimedia Communications Laboratories, Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 81 unchanged lines hidden (view full) --- 91 92#if 0 93#ifndef lint 94static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; 95#endif /* not lint */ 96#endif 97 98#include <sys/cdefs.h> |
99__FBSDID("$FreeBSD: head/usr.bin/netstat/ipsec.c 153809 2005-12-28 20:36:55Z kbyanc $"); | 99__FBSDID("$FreeBSD: head/usr.bin/netstat/ipsec.c 160787 2006-07-28 16:09:19Z yar $"); |
100 101#include <sys/param.h> 102#include <sys/queue.h> 103#include <sys/socket.h> 104 105#include <netinet/in.h> 106 107#if defined(IPSEC) && !defined(FAST_IPSEC) 108#include <netinet6/ipsec.h> 109#endif 110 111#ifdef FAST_IPSEC 112#include <netipsec/ipsec.h> 113#include <netipsec/ah_var.h> 114#include <netipsec/esp_var.h> 115#include <netipsec/ipcomp_var.h> 116#endif 117 | 100 101#include <sys/param.h> 102#include <sys/queue.h> 103#include <sys/socket.h> 104 105#include <netinet/in.h> 106 107#if defined(IPSEC) && !defined(FAST_IPSEC) 108#include <netinet6/ipsec.h> 109#endif 110 111#ifdef FAST_IPSEC 112#include <netipsec/ipsec.h> 113#include <netipsec/ah_var.h> 114#include <netipsec/esp_var.h> 115#include <netipsec/ipcomp_var.h> 116#endif 117 |
118#include <stdint.h> |
|
118#include <stdio.h> 119#include <string.h> 120#include <unistd.h> 121#include "netstat.h" 122 123#ifdef IPSEC 124struct val2str { 125 int val; --- 73 unchanged lines hidden (view full) --- 199 printf("\t%s histogram:\n", title); 200 first = 0; 201 } 202 for (p = name; p && p->str; p++) { 203 if (p->val == (int)proto) 204 break; 205 } 206 if (p && p->str) { | 119#include <stdio.h> 120#include <string.h> 121#include <unistd.h> 122#include "netstat.h" 123 124#ifdef IPSEC 125struct val2str { 126 int val; --- 73 unchanged lines hidden (view full) --- 200 printf("\t%s histogram:\n", title); 201 first = 0; 202 } 203 for (p = name; p && p->str; p++) { 204 if (p->val == (int)proto) 205 break; 206 } 207 if (p && p->str) { |
207 printf("\t\t%s: %llu\n", p->str, (unsigned long long)hist[proto]); | 208 printf("\t\t%s: %ju\n", p->str, (uintmax_t)hist[proto]); |
208 } else { | 209 } else { |
209 printf("\t\t#%ld: %llu\n", (long)proto, 210 (unsigned long long)hist[proto]); | 210 printf("\t\t#%ld: %ju\n", (long)proto, 211 (uintmax_t)hist[proto]); |
211 } 212 } 213} 214 215static void 216print_ipsecstats(const struct ipsecstat *ipsecstat) 217{ 218#define p(f, m) if (ipsecstat->f || sflag <= 1) \ | 212 } 213 } 214} 215 216static void 217print_ipsecstats(const struct ipsecstat *ipsecstat) 218{ 219#define p(f, m) if (ipsecstat->f || sflag <= 1) \ |
219 printf(m, (unsigned long long)ipsecstat->f, plural(ipsecstat->f)) | 220 printf(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f)) |
220#define pes(f, m) if (ipsecstat->f || sflag <= 1) \ | 221#define pes(f, m) if (ipsecstat->f || sflag <= 1) \ |
221 printf(m, (unsigned long long)ipsecstat->f, plurales(ipsecstat->f)) | 222 printf(m, (uintmax_t)ipsecstat->f, plurales(ipsecstat->f)) |
222#define hist(f, n, t) \ 223 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t)); 224 | 223#define hist(f, n, t) \ 224 ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t)); 225 |
225 p(in_success, "\t%llu inbound packet%s processed successfully\n"); 226 p(in_polvio, "\t%llu inbound packet%s violated process security " | 226 p(in_success, "\t%ju inbound packet%s processed successfully\n"); 227 p(in_polvio, "\t%ju inbound packet%s violated process security " |
227 "policy\n"); | 228 "policy\n"); |
228 p(in_nosa, "\t%llu inbound packet%s with no SA available\n"); 229 p(in_inval, "\t%llu invalid inbound packet%s\n"); 230 p(in_nomem, "\t%llu inbound packet%s failed due to insufficient memory\n"); 231 p(in_badspi, "\t%llu inbound packet%s failed getting SPI\n"); 232 p(in_ahreplay, "\t%llu inbound packet%s failed on AH replay check\n"); 233 p(in_espreplay, "\t%llu inbound packet%s failed on ESP replay check\n"); 234 p(in_ahauthsucc, "\t%llu inbound packet%s considered authentic\n"); 235 p(in_ahauthfail, "\t%llu inbound packet%s failed on authentication\n"); | 229 p(in_nosa, "\t%ju inbound packet%s with no SA available\n"); 230 p(in_inval, "\t%ju invalid inbound packet%s\n"); 231 p(in_nomem, "\t%ju inbound packet%s failed due to insufficient memory\n"); 232 p(in_badspi, "\t%ju inbound packet%s failed getting SPI\n"); 233 p(in_ahreplay, "\t%ju inbound packet%s failed on AH replay check\n"); 234 p(in_espreplay, "\t%ju inbound packet%s failed on ESP replay check\n"); 235 p(in_ahauthsucc, "\t%ju inbound packet%s considered authentic\n"); 236 p(in_ahauthfail, "\t%ju inbound packet%s failed on authentication\n"); |
236 hist(ipsecstat->in_ahhist, ipsec_ahnames, "AH input"); 237 hist(ipsecstat->in_esphist, ipsec_espnames, "ESP input"); 238 hist(ipsecstat->in_comphist, ipsec_compnames, "IPComp input"); 239 | 237 hist(ipsecstat->in_ahhist, ipsec_ahnames, "AH input"); 238 hist(ipsecstat->in_esphist, ipsec_espnames, "ESP input"); 239 hist(ipsecstat->in_comphist, ipsec_compnames, "IPComp input"); 240 |
240 p(out_success, "\t%llu outbound packet%s processed successfully\n"); 241 p(out_polvio, "\t%llu outbound packet%s violated process security " | 241 p(out_success, "\t%ju outbound packet%s processed successfully\n"); 242 p(out_polvio, "\t%ju outbound packet%s violated process security " |
242 "policy\n"); | 243 "policy\n"); |
243 p(out_nosa, "\t%llu outbound packet%s with no SA available\n"); 244 p(out_inval, "\t%llu invalid outbound packet%s\n"); 245 p(out_nomem, "\t%llu outbound packet%s failed due to insufficient memory\n"); 246 p(out_noroute, "\t%llu outbound packet%s with no route\n"); | 244 p(out_nosa, "\t%ju outbound packet%s with no SA available\n"); 245 p(out_inval, "\t%ju invalid outbound packet%s\n"); 246 p(out_nomem, "\t%ju outbound packet%s failed due to insufficient memory\n"); 247 p(out_noroute, "\t%ju outbound packet%s with no route\n"); |
247 hist(ipsecstat->out_ahhist, ipsec_ahnames, "AH output"); 248 hist(ipsecstat->out_esphist, ipsec_espnames, "ESP output"); 249 hist(ipsecstat->out_comphist, ipsec_compnames, "IPComp output"); | 248 hist(ipsecstat->out_ahhist, ipsec_ahnames, "AH output"); 249 hist(ipsecstat->out_esphist, ipsec_espnames, "ESP output"); 250 hist(ipsecstat->out_comphist, ipsec_compnames, "IPComp output"); |
250 p(spdcachelookup, "\t%llu SPD cache lookup%s\n"); 251 pes(spdcachemiss, "\t%llu SPD cache miss%s\n"); | 251 p(spdcachelookup, "\t%ju SPD cache lookup%s\n"); 252 pes(spdcachemiss, "\t%ju SPD cache miss%s\n"); |
252#undef p 253#undef pes 254#undef hist 255} 256 257void 258ipsec_stats(u_long off, const char *name, int af1 __unused) 259{ --- 87 unchanged lines hidden (view full) --- 347} 348 349static void 350print_ahstats(const struct ahstat *ahstat) 351{ 352#define p32(f, m) if (ahstat->f || sflag <= 1) \ 353 printf("\t%u" m, (unsigned int)ahstat->f, plural(ahstat->f)) 354#define p64(f, m) if (ahstat->f || sflag <= 1) \ | 253#undef p 254#undef pes 255#undef hist 256} 257 258void 259ipsec_stats(u_long off, const char *name, int af1 __unused) 260{ --- 87 unchanged lines hidden (view full) --- 348} 349 350static void 351print_ahstats(const struct ahstat *ahstat) 352{ 353#define p32(f, m) if (ahstat->f || sflag <= 1) \ 354 printf("\t%u" m, (unsigned int)ahstat->f, plural(ahstat->f)) 355#define p64(f, m) if (ahstat->f || sflag <= 1) \ |
355 printf("\t%llu" m, (unsigned long long)ahstat->f, plural(ahstat->f)) | 356 printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f)) |
356#define hist(f, n, t) \ 357 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 358 359 p32(ahs_hdrops, " packet%s shorter than header shows\n"); 360 p32(ahs_nopf, " packet%s dropped; protocol family not supported\n"); 361 p32(ahs_notdb, " packet%s dropped; no TDB\n"); 362 p32(ahs_badkcr, " packet%s dropped; bad KCR\n"); 363 p32(ahs_qfull, " packet%s dropped; queue full\n"); --- 32 unchanged lines hidden (view full) --- 396} 397 398static void 399print_espstats(const struct espstat *espstat) 400{ 401#define p32(f, m) if (espstat->f || sflag <= 1) \ 402 printf("\t%u" m, (unsigned int)espstat->f, plural(espstat->f)) 403#define p64(f, m) if (espstat->f || sflag <= 1) \ | 357#define hist(f, n, t) \ 358 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 359 360 p32(ahs_hdrops, " packet%s shorter than header shows\n"); 361 p32(ahs_nopf, " packet%s dropped; protocol family not supported\n"); 362 p32(ahs_notdb, " packet%s dropped; no TDB\n"); 363 p32(ahs_badkcr, " packet%s dropped; bad KCR\n"); 364 p32(ahs_qfull, " packet%s dropped; queue full\n"); --- 32 unchanged lines hidden (view full) --- 397} 398 399static void 400print_espstats(const struct espstat *espstat) 401{ 402#define p32(f, m) if (espstat->f || sflag <= 1) \ 403 printf("\t%u" m, (unsigned int)espstat->f, plural(espstat->f)) 404#define p64(f, m) if (espstat->f || sflag <= 1) \ |
404 printf("\t%llu" m, (unsigned long long)espstat->f, plural(espstat->f)) | 405 printf("\t%ju" m, (uintmax_t)espstat->f, plural(espstat->f)) |
405#define hist(f, n, t) \ 406 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 407 408 p32(esps_hdrops, " packet%s shorter than header shows\n"); 409 p32(esps_nopf, " packet%s dropped; protocol family not supported\n"); 410 p32(esps_notdb, " packet%s dropped; no TDB\n"); 411 p32(esps_badkcr, " packet%s dropped; bad KCR\n"); 412 p32(esps_qfull, " packet%s dropped; queue full\n"); --- 33 unchanged lines hidden (view full) --- 446} 447 448static void 449print_ipcompstats(const struct ipcompstat *ipcompstat) 450{ 451#define p32(f, m) if (ipcompstat->f || sflag <= 1) \ 452 printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f)) 453#define p64(f, m) if (ipcompstat->f || sflag <= 1) \ | 406#define hist(f, n, t) \ 407 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 408 409 p32(esps_hdrops, " packet%s shorter than header shows\n"); 410 p32(esps_nopf, " packet%s dropped; protocol family not supported\n"); 411 p32(esps_notdb, " packet%s dropped; no TDB\n"); 412 p32(esps_badkcr, " packet%s dropped; bad KCR\n"); 413 p32(esps_qfull, " packet%s dropped; queue full\n"); --- 33 unchanged lines hidden (view full) --- 447} 448 449static void 450print_ipcompstats(const struct ipcompstat *ipcompstat) 451{ 452#define p32(f, m) if (ipcompstat->f || sflag <= 1) \ 453 printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f)) 454#define p64(f, m) if (ipcompstat->f || sflag <= 1) \ |
454 printf("\t%llu" m, (unsigned long long)ipcompstat->f, plural(ipcompstat->f)) | 455 printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f)) |
455#define hist(f, n, t) \ 456 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 457 458 p32(ipcomps_hdrops, " packet%s shorter than header shows\n"); 459 p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n"); 460 p32(ipcomps_notdb, " packet%s dropped; no TDB\n"); 461 p32(ipcomps_badkcr, " packet%s dropped; bad KCR\n"); 462 p32(ipcomps_qfull, " packet%s dropped; queue full\n"); --- 32 unchanged lines hidden --- | 456#define hist(f, n, t) \ 457 ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); 458 459 p32(ipcomps_hdrops, " packet%s shorter than header shows\n"); 460 p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n"); 461 p32(ipcomps_notdb, " packet%s dropped; no TDB\n"); 462 p32(ipcomps_badkcr, " packet%s dropped; bad KCR\n"); 463 p32(ipcomps_qfull, " packet%s dropped; queue full\n"); --- 32 unchanged lines hidden --- |