diff options
author | peter <peter@pkgsrc.org> | 2004-11-05 15:08:33 +0000 |
---|---|---|
committer | peter <peter@pkgsrc.org> | 2004-11-05 15:08:33 +0000 |
commit | 6ad788ca7d730b97c6eae348df59cea5a5fe1e18 (patch) | |
tree | 231869d0095777caac607dc824e99cfad91df6d0 /sysutils/pftop | |
parent | 18bf35194170a3262ba86a0118e2a12dd69e88ea (diff) | |
download | pkgsrc-6ad788ca7d730b97c6eae348df59cea5a5fe1e18.tar.gz |
Initial import of pftop-0.4 into the NetBSD Packages Collection.
Pftop is a small, curses-based utility for real-time display of
active states and rule statistics for PF, the packet filter from OpenBSD.
Diffstat (limited to 'sysutils/pftop')
-rw-r--r-- | sysutils/pftop/DESCR | 2 | ||||
-rw-r--r-- | sysutils/pftop/Makefile | 22 | ||||
-rw-r--r-- | sysutils/pftop/PLIST | 3 | ||||
-rw-r--r-- | sysutils/pftop/distinfo | 6 | ||||
-rw-r--r-- | sysutils/pftop/patches/patch-aa | 15 | ||||
-rw-r--r-- | sysutils/pftop/patches/patch-ab | 417 |
6 files changed, 465 insertions, 0 deletions
diff --git a/sysutils/pftop/DESCR b/sysutils/pftop/DESCR new file mode 100644 index 00000000000..bce4a9d4cbc --- /dev/null +++ b/sysutils/pftop/DESCR @@ -0,0 +1,2 @@ +Pftop is a small, curses-based utility for real-time display of +active states and rule statistics for PF, the packet filter from OpenBSD. diff --git a/sysutils/pftop/Makefile b/sysutils/pftop/Makefile new file mode 100644 index 00000000000..d3072d50e13 --- /dev/null +++ b/sysutils/pftop/Makefile @@ -0,0 +1,22 @@ +# $NetBSD: Makefile,v 1.1.1.1 2004/11/05 15:08:33 peter Exp $ + +DISTNAME= pftop-0.4 +CATEGORIES= sysutils net +MASTER_SITES= http://www.eee.metu.edu.tr/~canacar/ + +MAINTAINER= peter@pointless.nl +HOMEPAGE= http://www.eee.metu.edu.tr/~canacar/pftop/ +COMMENT= Utility for real-time display of statistics for PF + +USE_BUILDLINK3= yes +NO_CONFIGURE= yes + +MAKE_ENV+= OSLEVEL=${_PF_VERSION:S/.//} +CFLAGS+= -I${PREFIX}/include + +do-install: + ${INSTALL_PROGRAM} ${WRKSRC}/pftop ${PREFIX}/sbin + ${INSTALL_MAN} ${WRKSRC}/pftop.8 ${PREFIX}/man/man8 + +.include "../../security/pflkm/buildlink3.mk" +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/pftop/PLIST b/sysutils/pftop/PLIST new file mode 100644 index 00000000000..5f497524b2e --- /dev/null +++ b/sysutils/pftop/PLIST @@ -0,0 +1,3 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2004/11/05 15:08:33 peter Exp $ +sbin/pftop +man/man8/pftop.8 diff --git a/sysutils/pftop/distinfo b/sysutils/pftop/distinfo new file mode 100644 index 00000000000..a946cbbe690 --- /dev/null +++ b/sysutils/pftop/distinfo @@ -0,0 +1,6 @@ +$NetBSD: distinfo,v 1.1.1.1 2004/11/05 15:08:33 peter Exp $ + +SHA1 (pftop-0.4.tar.gz) = 717d8a9527a412cf21c1a6b7e6fa054bf0298ab2 +Size (pftop-0.4.tar.gz) = 23631 bytes +SHA1 (patch-aa) = f8b273c9c81edf44b42d6379aa7ac92ceb1147f7 +SHA1 (patch-ab) = 7c3d45c2bfd1e8c24b6a442c5a4e8e3def9113b4 diff --git a/sysutils/pftop/patches/patch-aa b/sysutils/pftop/patches/patch-aa new file mode 100644 index 00000000000..c33f4881f2c --- /dev/null +++ b/sysutils/pftop/patches/patch-aa @@ -0,0 +1,15 @@ +$NetBSD: patch-aa,v 1.1.1.1 2004/11/05 15:08:33 peter Exp $ + +--- config.h.orig 2003-08-05 03:19:58.000000000 +0200 ++++ config.h 2004-10-25 13:20:55.000000000 +0200 +@@ -24,8 +24,8 @@ + #if OS_LEVEL > 32 + #define HAVE_ADDR_MASK + #define HAVE_ADDR_TYPE +-#define HAVE_ALTQ +-#define HAVE_RULE_ANCHOR ++/*#define HAVE_ALTQ*/ ++/*#define HAVE_RULE_ANCHOR*/ + #define HAVE_RULE_TOS + #endif + diff --git a/sysutils/pftop/patches/patch-ab b/sysutils/pftop/patches/patch-ab new file mode 100644 index 00000000000..d40db506f25 --- /dev/null +++ b/sysutils/pftop/patches/patch-ab @@ -0,0 +1,417 @@ +$NetBSD: patch-ab,v 1.1.1.1 2004/11/05 15:08:33 peter Exp $ + +This patch fixes the following: +* compile problem on NetBSD. +* compile problem on PF > 3.5. +* fixes at least two segfaults in batch mode. +* implements a better (less buggy) screen refresh method. +* changes some errx/warnx to err/warn for better errors. + +--- pftop.c.orig 2003-08-05 03:20:39.000000000 +0200 ++++ pftop.c 2004-10-27 00:21:10.000000000 +0200 +@@ -31,6 +31,11 @@ + */ + #include "config.h" + ++#ifdef __NetBSD__ ++#include <sys/param.h> ++#include <sys/syslimits.h> ++#endif ++ + #include <sys/types.h> + #include <sys/ioctl.h> + #include <sys/socket.h> +@@ -55,6 +60,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <netdb.h> ++#include <poll.h> + #include <signal.h> + #include <stdio.h> + #include <stdlib.h> +@@ -192,9 +198,6 @@ + + volatile sig_atomic_t gotsig_close = 0; + volatile sig_atomic_t gotsig_resize = 0; +-volatile sig_atomic_t gotsig_alarm = 0; +-int need_update = 0; +-int need_sort = 0; + + #define FLD_ALIGN_LEFT 0 + #define FLD_ALIGN_RIGHT 1 +@@ -506,7 +509,6 @@ + + int + tbprintf(char *format, ...) +- GCC_PRINTFLIKE(1,2) /* defined in curses.h */ + { + int len; + va_list arg; +@@ -758,7 +760,6 @@ + } + + if ((curr_view != NULL) && (curr_view->mgr != v->mgr)) { +- gotsig_alarm = 1; + if (v->mgr != NULL && v->mgr->select_fn != NULL) + v->mgr->select_fn(); + } +@@ -766,7 +767,6 @@ + curr_view = v; + curr_mgr = v->mgr; + field_setup(); +- need_update = 1; + } + + void +@@ -849,11 +849,9 @@ + if (cachestates) { + show_field(FLD_SI); + show_field(FLD_SP); +- gotsig_alarm = 1; + } else { + hide_field(FLD_SI); + hide_field(FLD_SP); +- need_update = 1; + } + field_setup(); + } +@@ -1212,7 +1210,7 @@ + ps.ps_buf = (char *) state_buf; + + if (ioctl(dev, DIOCGETSTATES, &ps) < 0) { +- errx(1, "DIOCGETSTATES"); ++ err(1, "DIOCGETSTATES"); + } + num_states = ps.ps_len / sizeof(struct pf_state); + +@@ -1303,7 +1301,7 @@ + tbprintf(" PAUSED"); + + if (rawmode) +- printf("\n\n%s\n", tmp_buf); ++ printf("\n%s", tmp_buf); + else + mvprintw(0, 0, "%s", tmp_buf); + +@@ -1319,7 +1317,10 @@ + len = columns - strlen(tmp_buf); + if (len < 0) + len = 0; +- mvprintw(0, len, "%s", tmp_buf); ++ if (rawmode) ++ printf(" %s\n", tmp_buf); ++ else ++ mvprintw(0, len, "%s", tmp_buf); + } + + tb_end(); +@@ -1645,7 +1646,7 @@ + dispstart = 0; + + if (ioctl(dev, DIOCGETSTATUS, &status)) { +- warnx("DIOCGETSTATUS"); ++ warn("DIOCGETSTATUS"); + return (-1); + } + +@@ -1681,7 +1682,7 @@ + + memset(&pr, 0, sizeof(pr)); + if (ioctl(dev, DIOCGETRULES, &pr)) { +- warnx("DIOCGETRULES"); ++ warn("DIOCGETRULES"); + return (-1); + } + +@@ -1704,7 +1705,7 @@ + for (nr = 0; nr < num_rules; ++nr) { + pr.nr = nr; + if (ioctl(dev, DIOCGETRULE, &pr)) { +- warnx("DIOCGETRULE"); ++ warn("DIOCGETRULE"); + return (-1); + } + rules[nr] = pr.rule; +@@ -1802,7 +1803,11 @@ + PF_AZERO(PT_MASK(src), AF_INET6)) + tbprintf("any "); + else { ++#if OS_LEVEL > 35 ++ if (src->neg) ++#else + if (src->not) ++#endif + tbprintf("! "); + #ifdef HAVE_ADDR_WRAP + tb_print_addrw(&src->addr, PT_MASK(src), af); +@@ -1823,7 +1828,11 @@ + PF_AZERO(PT_MASK(dst), AF_INET6)) + tbprintf("any "); + else { ++#if OS_LEVEL > 35 ++ if (dst->neg) ++#else + if (dst->not) ++#endif + tbprintf("! "); + #ifdef HAVE_ADDR_WRAP + tb_print_addrw(&dst->addr, PT_MASK(dst), af); +@@ -2486,12 +2495,6 @@ + } + + void +-sig_alarm(int signal) +-{ +- gotsig_alarm = 1; +-} +- +-void + usage() + { + extern char *__progname; +@@ -2544,7 +2547,9 @@ + line++; + mvprintw(line++, 6, "press any key to continue ..."); + ++ timeout(-1); + while (getch() == ERR); ++ timeout(0); + } + + void +@@ -2577,8 +2582,9 @@ + keypad(stdscr, TRUE); + intrflush(stdscr, FALSE); + +- halfdelay(10); ++ cbreak(); + noecho(); ++ timeout(0); + } + + if (maxstates == 0) +@@ -2597,7 +2603,6 @@ + cmdbuf[0] = 0; + } + curr_cmd = cmd; +- need_update = 1; + return prev; + } + +@@ -2618,10 +2623,8 @@ + { + int del; + del = atoi(cmdbuf); +- if (del > 0) { ++ if (del > 0) + delay = del; +- gotsig_alarm = 1; +- } + } + + void +@@ -2646,7 +2649,6 @@ + if (cmd_len < sizeof(cmdbuf) - 1) { + cmdbuf[cmd_len++] = ch; + cmdbuf[cmd_len] = 0; +- need_update = 1; + } else + beep(); + } +@@ -2663,10 +2665,9 @@ + case KEY_BACKSPACE: + case KEY_DC: + case CTRL_H: +- if (cmd_len > 0) { ++ if (cmd_len > 0) + cmdbuf[--cmd_len] = 0; +- need_update = 1; +- } else ++ else + beep(); + break; + default: +@@ -2687,9 +2688,6 @@ + } + + switch (ch) { +- case ' ': +- gotsig_alarm = 1; +- break; + case 'c': + cachestates = !cachestates; + update_cache(); +@@ -2698,25 +2696,21 @@ + /* FALLTHROUGH */ + case 'h': + show_help(); +- need_update = 1; + break; + case 'n': + command_set(&cm_count); + break; + case 'o': + next_order(); +- need_sort = 1; + break; + case 'p': + paused = !paused; +- gotsig_alarm = 1; + break; + case 'q': + gotsig_close = 1; + break; + case 'r': + sortdir *= -1; +- need_sort = 1; + break; + case 's': + command_set(&cm_delay); +@@ -2737,49 +2731,40 @@ + /* FALLTHROUGH */ + case CTRL_N: + dispstart++; +- need_update = 1; + break; + case KEY_UP: + /* FALLTHROUGH */ + case CTRL_P: + dispstart--; +- need_update = 1; + break; + case KEY_NPAGE: + /* FALLTHROUGH */ + case CTRL_V: + dispstart += maxprint; +- need_update = 1; + break; + case KEY_PPAGE: + /* FALLTHROUGH */ + case META_V: + dispstart -= maxprint; +- need_update = 1; + break; + case KEY_HOME: + /* FALLTHROUGH */ + case CTRL_A: + dispstart = 0; +- need_update = 1; + break; + case KEY_END: + /* FALLTHROUGH */ + case CTRL_E: + dispstart = num_disp; +- need_update = 1; + break; + case CTRL_L: + clear(); +- need_update = 1; + break; + default: + break; + } + +- if (set_order_hotkey(ch)) +- need_sort = 1; +- else ++ if (!set_order_hotkey(ch)) + set_view_hotkey(ch); + } + +@@ -2790,6 +2775,7 @@ + extern int optind; + + struct pf_status status; ++ struct pollfd set[1]; + + char *orderstr = NULL; + char *viewstr = NULL; +@@ -2872,7 +2858,6 @@ + signal(SIGINT, sig_close); + signal(SIGQUIT, sig_close); + signal(SIGWINCH, sig_resize); +- signal(SIGALRM, sig_alarm); + + #ifdef HAVE_DEVICE_RO + dev = open("/dev/pf", O_RDONLY); +@@ -2884,7 +2869,7 @@ + + /* preallocate existing states if possible */ + if (ioctl(dev, DIOCGETSTATUS, &status)) { +- warnx("DIOCGETSTATUS"); ++ warn("DIOCGETSTATUS"); + alloc_buf(0); + } else + alloc_buf(status.states); +@@ -2910,36 +2895,7 @@ + if (rawmode && countmax == 0) + countmax = 1; + +- gotsig_alarm = 1; + for (;;) { +- if (gotsig_alarm) { +- read_view(dev); +- need_sort = 1; +- gotsig_alarm = 0; +- alarm(delay); +- } +- +- if (need_sort) { +- sort_view(); +- need_sort = 0; +- need_update = 1; +- +- /* XXX if sort took too long */ +- if (gotsig_alarm) { +- gotsig_alarm = 0; +- alarm(delay); +- } +- } +- +- if (need_update) { +- erase(); +- disp_update(dev); +- end_page(); +- need_update = 0; +- if (countmax && ++count >= countmax) +- break; +- } +- + if (gotsig_close) + break; + if (gotsig_resize) { +@@ -2947,12 +2903,30 @@ + endwin(); + setup_term(maxstates); + gotsig_resize = 0; +- need_update = 1; + } + +- if (interactive && need_update == 0) +- keyboard(); +- else if (interactive == 0) ++ read_view(dev); ++ sort_view(); ++ ++ if (rawmode == 0) ++ erase(); ++ disp_update(dev); ++ end_page(); ++ ++ if (countmax && ++count >= countmax) ++ break; ++ ++ if (interactive) { ++ set[0].fd = STDIN_FILENO; ++ set[0].events = POLLIN; ++ if (poll(set, 1, delay * 1000) == -1) { ++ if (errno == EINTR) ++ continue; ++ break; ++ } ++ if ((set[0].revents & POLLIN) != 0) ++ keyboard(); ++ } else + sleep(delay); + } + |