1/* $OpenBSD: pfctl_parser.c,v 1.175 2003/09/18 20:27:58 cedric Exp $ */
2
3/*
4 * Copyright (c) 2001 Daniel Hartmeier
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 37 unchanged lines hidden (view full) ---
46#include <string.h>
47#include <ctype.h>
48#include <netdb.h>
49#include <stdarg.h>
50#include <errno.h>
51#include <err.h>
52#include <ifaddrs.h>
53
54#include "pfctl_parser.h"
55#include "pfctl.h"
56
57void print_op (u_int8_t, const char *, const char *);
58void print_port (u_int8_t, u_int16_t, u_int16_t, const char *);
59void print_ugid (u_int8_t, unsigned, unsigned, const char *, unsigned);
60void print_flags (u_int8_t);
61void print_fromto(struct pf_rule_addr *, pf_osfp_t,
--- 436 unchanged lines hidden (view full) ---
498 break;
499 case 2:
500 printf("%15s\n\n", "Debug: Misc");
501 break;
502 }
503 if (s->ifname[0] != 0) {
504 printf("Interface Stats for %-16s %5s %16s\n",
505 s->ifname, "IPv4", "IPv6");
506 printf(" %-25s %14llu %16llu\n", "Bytes In",
507 s->bcounters[0][0], s->bcounters[1][0]);
508 printf(" %-25s %14llu %16llu\n", "Bytes Out",
509 s->bcounters[0][1], s->bcounters[1][1]);
510 printf(" Packets In\n");
511 printf(" %-23s %14llu %16llu\n", "Passed",
512 s->pcounters[0][0][PF_PASS],
513 s->pcounters[1][0][PF_PASS]);
514 printf(" %-23s %14llu %16llu\n", "Blocked",
515 s->pcounters[0][0][PF_DROP],
516 s->pcounters[1][0][PF_DROP]);
517 printf(" Packets Out\n");
518 printf(" %-23s %14llu %16llu\n", "Passed",
519 s->pcounters[0][1][PF_PASS],
520 s->pcounters[1][1][PF_PASS]);
521 printf(" %-23s %14llu %16llu\n\n", "Blocked",
522 s->pcounters[0][1][PF_DROP],
523 s->pcounters[1][1][PF_DROP]);
524 }
525 printf("%-27s %14s %16s\n", "State Table", "Total", "Rate");
526 printf(" %-25s %14u %14s\n", "current entries", s->states, "");
527 for (i = 0; i < FCNT_MAX; i++) {
528 printf(" %-25s %14llu", pf_fcounters[i],
529 (unsigned long long)s->fcounters[i]);
530 if (runtime > 0)
531 printf("%14.1f/s\n",
532 (double)s->fcounters[i] / (double)runtime);
533 else
534 printf("%14s\n", "");
535 }
536 printf("Counters\n");
537 for (i = 0; i < PFRES_MAX; i++) {
538 printf(" %-25s %14llu ", pf_reasons[i],
539 (unsigned long long)s->counters[i]);
540 if (runtime > 0)
541 printf("%14.1f/s\n",
542 (double)s->counters[i] / (double)runtime);
543 else
544 printf("%14s\n", "");
545 }
546}
547
--- 571 unchanged lines hidden (view full) ---
1119 memset(&ina, 0, sizeof(struct in_addr));
1120 if ((bits = inet_net_pton(AF_INET, s, &ina, sizeof(ina))) > -1) {
1121 h = calloc(1, sizeof(struct node_host));
1122 if (h == NULL)
1123 err(1, "address: calloc");
1124 h->ifname = NULL;
1125 h->af = AF_INET;
1126 h->addr.v.a.addr.addr32[0] = ina.s_addr;
1127 set_ipmask(h, bits);
1128 h->next = NULL;
1129 h->tail = h;
1130 }
1131
1132 return (h);
1133}
1134
--- 152 unchanged lines hidden ---
2
3/*
4 * Copyright (c) 2001 Daniel Hartmeier
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 37 unchanged lines hidden (view full) ---
46#include <string.h>
47#include <ctype.h>
48#include <netdb.h>
49#include <stdarg.h>
50#include <errno.h>
51#include <err.h>
52#include <ifaddrs.h>
53
54#include "pfctl_parser.h"
55#include "pfctl.h"
56
57void print_op (u_int8_t, const char *, const char *);
58void print_port (u_int8_t, u_int16_t, u_int16_t, const char *);
59void print_ugid (u_int8_t, unsigned, unsigned, const char *, unsigned);
60void print_flags (u_int8_t);
61void print_fromto(struct pf_rule_addr *, pf_osfp_t,
--- 436 unchanged lines hidden (view full) ---
498 break;
499 case 2:
500 printf("%15s\n\n", "Debug: Misc");
501 break;
502 }
503 if (s->ifname[0] != 0) {
504 printf("Interface Stats for %-16s %5s %16s\n",
505 s->ifname, "IPv4", "IPv6");
506 printf(" %-25s %14llu %16llu\n", "Bytes In",
507 s->bcounters[0][0], s->bcounters[1][0]);
508 printf(" %-25s %14llu %16llu\n", "Bytes Out",
509 s->bcounters[0][1], s->bcounters[1][1]);
510 printf(" Packets In\n");
511 printf(" %-23s %14llu %16llu\n", "Passed",
512 s->pcounters[0][0][PF_PASS],
513 s->pcounters[1][0][PF_PASS]);
514 printf(" %-23s %14llu %16llu\n", "Blocked",
515 s->pcounters[0][0][PF_DROP],
516 s->pcounters[1][0][PF_DROP]);
517 printf(" Packets Out\n");
518 printf(" %-23s %14llu %16llu\n", "Passed",
519 s->pcounters[0][1][PF_PASS],
520 s->pcounters[1][1][PF_PASS]);
521 printf(" %-23s %14llu %16llu\n\n", "Blocked",
522 s->pcounters[0][1][PF_DROP],
523 s->pcounters[1][1][PF_DROP]);
524 }
525 printf("%-27s %14s %16s\n", "State Table", "Total", "Rate");
526 printf(" %-25s %14u %14s\n", "current entries", s->states, "");
527 for (i = 0; i < FCNT_MAX; i++) {
528 printf(" %-25s %14llu", pf_fcounters[i],
529 (unsigned long long)s->fcounters[i]);
530 if (runtime > 0)
531 printf("%14.1f/s\n",
532 (double)s->fcounters[i] / (double)runtime);
533 else
534 printf("%14s\n", "");
535 }
536 printf("Counters\n");
537 for (i = 0; i < PFRES_MAX; i++) {
538 printf(" %-25s %14llu ", pf_reasons[i],
539 (unsigned long long)s->counters[i]);
540 if (runtime > 0)
541 printf("%14.1f/s\n",
542 (double)s->counters[i] / (double)runtime);
543 else
544 printf("%14s\n", "");
545 }
546}
547
--- 571 unchanged lines hidden (view full) ---
1119 memset(&ina, 0, sizeof(struct in_addr));
1120 if ((bits = inet_net_pton(AF_INET, s, &ina, sizeof(ina))) > -1) {
1121 h = calloc(1, sizeof(struct node_host));
1122 if (h == NULL)
1123 err(1, "address: calloc");
1124 h->ifname = NULL;
1125 h->af = AF_INET;
1126 h->addr.v.a.addr.addr32[0] = ina.s_addr;
1127 set_ipmask(h, bits);
1128 h->next = NULL;
1129 h->tail = h;
1130 }
1131
1132 return (h);
1133}
1134
--- 152 unchanged lines hidden ---