pfctl_parser.c (126354) | pfctl_parser.c (126355) |
---|---|
1/* $FreeBSD: head/contrib/pf/pfctl/pfctl_parser.c 126355 2004-02-28 17:32:53Z mlaier $ */ |
|
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 | 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 |
|
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"); | 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"); |
506 printf(" %-25s %14llu %16llu\n", "Bytes In", | 514 printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes In", |
507 s->bcounters[0][0], s->bcounters[1][0]); | 515 s->bcounters[0][0], s->bcounters[1][0]); |
508 printf(" %-25s %14llu %16llu\n", "Bytes Out", | 516 printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes Out", |
509 s->bcounters[0][1], s->bcounters[1][1]); 510 printf(" Packets In\n"); | 517 s->bcounters[0][1], s->bcounters[1][1]); 518 printf(" Packets In\n"); |
511 printf(" %-23s %14llu %16llu\n", "Passed", | 519 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", |
512 s->pcounters[0][0][PF_PASS], 513 s->pcounters[1][0][PF_PASS]); | 520 s->pcounters[0][0][PF_PASS], 521 s->pcounters[1][0][PF_PASS]); |
514 printf(" %-23s %14llu %16llu\n", "Blocked", | 522 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Blocked", |
515 s->pcounters[0][0][PF_DROP], 516 s->pcounters[1][0][PF_DROP]); 517 printf(" Packets Out\n"); | 523 s->pcounters[0][0][PF_DROP], 524 s->pcounters[1][0][PF_DROP]); 525 printf(" Packets Out\n"); |
518 printf(" %-23s %14llu %16llu\n", "Passed", | 526 printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", |
519 s->pcounters[0][1][PF_PASS], 520 s->pcounters[1][1][PF_PASS]); | 527 s->pcounters[0][1][PF_PASS], 528 s->pcounters[1][1][PF_PASS]); |
521 printf(" %-23s %14llu %16llu\n\n", "Blocked", | 529 printf(" %-23s %14"PRIu64" %16"PRIu64"\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++) { | 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++) { |
528 printf(" %-25s %14llu", pf_fcounters[i], 529 (unsigned long long)s->fcounters[i]); | 536 printf(" %-25s %14"PRIu64" ", pf_fcounters[i], 537 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 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++) { |
538 printf(" %-25s %14llu ", pf_reasons[i], 539 (unsigned long long)s->counters[i]); | 546 printf(" %-25s %14"PRIu64" ", pf_reasons[i], 547 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; | 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 |
|
1127 set_ipmask(h, bits); 1128 h->next = NULL; 1129 h->tail = h; 1130 } 1131 1132 return (h); 1133} 1134 --- 152 unchanged lines hidden --- | 1141 set_ipmask(h, bits); 1142 h->next = NULL; 1143 h->tail = h; 1144 } 1145 1146 return (h); 1147} 1148 --- 152 unchanged lines hidden --- |