nat64stl.c (f76e5f2087e097d7eb612d831801082262533d2d) nat64stl.c (c5e85276aca64be6b5b6d0a2388db5a47bb36637)
1/*-
2 * Copyright (c) 2015-2016 Yandex LLC
3 * Copyright (c) 2015-2016 Andrey V. Elsukov <ae@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

31#include <sys/types.h>
32#include <sys/socket.h>
33
34#include "ipfw2.h"
35
36#include <ctype.h>
37#include <err.h>
38#include <errno.h>
1/*-
2 * Copyright (c) 2015-2016 Yandex LLC
3 * Copyright (c) 2015-2016 Andrey V. Elsukov <ae@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

31#include <sys/types.h>
32#include <sys/socket.h>
33
34#include "ipfw2.h"
35
36#include <ctype.h>
37#include <err.h>
38#include <errno.h>
39#include <inttypes.h>
39#include <netdb.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43#include <sysexits.h>
44
45#include <net/if.h>
46#include <netinet/in.h>

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

381 memcpy(stats, oc + 1, sizeof(*stats));
382 free(oh);
383 return (0);
384 }
385 free(oh);
386 return (-1);
387}
388
40#include <netdb.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44#include <sysexits.h>
45
46#include <net/if.h>
47#include <netinet/in.h>

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

382 memcpy(stats, oc + 1, sizeof(*stats));
383 free(oh);
384 return (0);
385 }
386 free(oh);
387 return (-1);
388}
389
389#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f)
390static void
391nat64stl_stats(const char *name, uint8_t set)
392{
393 struct ipfw_nat64stl_stats stats;
394
395 if (nat64stl_get_stats(name, set, &stats) != 0)
396 err(EX_OSERR, "Error retrieving stats");
397
390static void
391nat64stl_stats(const char *name, uint8_t set)
392{
393 struct ipfw_nat64stl_stats stats;
394
395 if (nat64stl_get_stats(name, set, &stats) != 0)
396 err(EX_OSERR, "Error retrieving stats");
397
398 _P_STAT(stats, opcnt64);
399 _P_STAT(stats, opcnt46);
400 _P_STAT(stats, ofrags);
401 _P_STAT(stats, ifrags);
402 _P_STAT(stats, oerrors);
403 _P_STAT(stats, noroute4);
404 _P_STAT(stats, noroute6);
405 _P_STAT(stats, noproto);
406 _P_STAT(stats, nomem);
407 _P_STAT(stats, dropped);
398 if (co.use_set != 0 || set != 0)
399 printf("set %u ", set);
400 printf("nat64stl %s\n", name);
401
402 printf("\t%ju packets translated from IPv6 to IPv4\n",
403 (uintmax_t)stats.opcnt64);
404 printf("\t%ju packets translated from IPv4 to IPv6\n",
405 (uintmax_t)stats.opcnt46);
406 printf("\t%ju IPv6 fragments created\n",
407 (uintmax_t)stats.ofrags);
408 printf("\t%ju IPv4 fragments received\n",
409 (uintmax_t)stats.ifrags);
410 printf("\t%ju output packets dropped due to no bufs, etc.\n",
411 (uintmax_t)stats.oerrors);
412 printf("\t%ju output packets discarded due to no IPv4 route\n",
413 (uintmax_t)stats.noroute4);
414 printf("\t%ju output packets discarded due to no IPv6 route\n",
415 (uintmax_t)stats.noroute6);
416 printf("\t%ju packets discarded due to unsupported protocol\n",
417 (uintmax_t)stats.noproto);
418 printf("\t%ju packets discarded due to memory allocation problems\n",
419 (uintmax_t)stats.nomem);
420 printf("\t%ju packets discarded due to some errors\n",
421 (uintmax_t)stats.dropped);
408}
409
410/*
411 * Reset nat64stl instance statistics specified by @oh->ntlv.
412 * Request: [ ipfw_obj_header ]
413 */
414static void
415nat64stl_reset_stats(const char *name, uint8_t set)

--- 106 unchanged lines hidden ---
422}
423
424/*
425 * Reset nat64stl instance statistics specified by @oh->ntlv.
426 * Request: [ ipfw_obj_header ]
427 */
428static void
429nat64stl_reset_stats(const char *name, uint8_t set)

--- 106 unchanged lines hidden ---