1/* $FreeBSD: head/contrib/pf/pfctl/pfctl_parser.c 126355 2004-02-28 17:32:53Z mlaier $ */ |
2/* $OpenBSD: pfctl_parser.c,v 1.175 2003/09/18 20:27:58 cedric Exp $ */ 3 4/* 5 * Copyright (c) 2001 Daniel Hartmeier 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 --- 37 unchanged lines hidden (view full) --- 47#include <string.h> 48#include <ctype.h> 49#include <netdb.h> 50#include <stdarg.h> 51#include <errno.h> 52#include <err.h> 53#include <ifaddrs.h> 54 |
55#if defined(__FreeBSD__) 56#include <inttypes.h> 57#else 58#define PRIu64 "llu" 59#define PRId64 "lld" 60#endif 61 |
62#include "pfctl_parser.h" 63#include "pfctl.h" 64 65void print_op (u_int8_t, const char *, const char *); 66void print_port (u_int8_t, u_int16_t, u_int16_t, const char *); 67void print_ugid (u_int8_t, unsigned, unsigned, const char *, unsigned); 68void print_flags (u_int8_t); 69void print_fromto(struct pf_rule_addr *, pf_osfp_t, --- 436 unchanged lines hidden (view full) --- 506 break; 507 case 2: 508 printf("%15s\n\n", "Debug: Misc"); 509 break; 510 } 511 if (s->ifname[0] != 0) { 512 printf("Interface Stats for %-16s %5s %16s\n", 513 s->ifname, "IPv4", "IPv6"); |
514 printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes In", |
515 s->bcounters[0][0], s->bcounters[1][0]); |
516 printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes Out", |
517 s->bcounters[0][1], s->bcounters[1][1]); 518 printf(" Packets In\n"); |
519 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", |
520 s->pcounters[0][0][PF_PASS], 521 s->pcounters[1][0][PF_PASS]); |
522 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Blocked", |
523 s->pcounters[0][0][PF_DROP], 524 s->pcounters[1][0][PF_DROP]); 525 printf(" Packets Out\n"); |
526 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", |
527 s->pcounters[0][1][PF_PASS], 528 s->pcounters[1][1][PF_PASS]); |
529 printf(" %-23s %14"PRIu64" %16"PRIu64"\n\n", "Blocked", |
530 s->pcounters[0][1][PF_DROP], 531 s->pcounters[1][1][PF_DROP]); 532 } 533 printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); 534 printf(" %-25s %14u %14s\n", "current entries", s->states, ""); 535 for (i = 0; i < FCNT_MAX; i++) { |
536 printf(" %-25s %14"PRIu64" ", pf_fcounters[i], 537 s->fcounters[i]); |
538 if (runtime > 0) 539 printf("%14.1f/s\n", 540 (double)s->fcounters[i] / (double)runtime); 541 else 542 printf("%14s\n", ""); 543 } 544 printf("Counters\n"); 545 for (i = 0; i < PFRES_MAX; i++) { |
546 printf(" %-25s %14"PRIu64" ", pf_reasons[i], 547 s->counters[i]); |
548 if (runtime > 0) 549 printf("%14.1f/s\n", 550 (double)s->counters[i] / (double)runtime); 551 else 552 printf("%14s\n", ""); 553 } 554} 555 --- 571 unchanged lines hidden (view full) --- 1127 memset(&ina, 0, sizeof(struct in_addr)); 1128 if ((bits = inet_net_pton(AF_INET, s, &ina, sizeof(ina))) > -1) { 1129 h = calloc(1, sizeof(struct node_host)); 1130 if (h == NULL) 1131 err(1, "address: calloc"); 1132 h->ifname = NULL; 1133 h->af = AF_INET; 1134 h->addr.v.a.addr.addr32[0] = ina.s_addr; |
1135#if defined(__FreeBSD__) && (__FreeBSD_version <= 501106) 1136 /* inet_net_pton acts strange w/ multicast addresses, RFC1112 */ 1137 if (mask == -1 && h->addr.v.a.addr.addr8[0] >= 224 && 1138 h->addr.v.a.addr.addr8[0] < 240) 1139 bits = 32; 1140#endif |
1141 set_ipmask(h, bits); 1142 h->next = NULL; 1143 h->tail = h; 1144 } 1145 1146 return (h); 1147} 1148 --- 152 unchanged lines hidden --- |