[iptstate-commit] iptstate iptstate.cc,1.17,1.17.2.1
Brought to you by:
jaymzh
|
From: Phil D. <ja...@us...> - 2009-10-23 15:57:36
|
Update of /cvsroot/iptstate/iptstate In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32087 Modified Files: Tag: cpp_ification_branch iptstate.cc Log Message: - Move our defines to enums - Start pulling in ID so we can handle cursor-jumps better one day Index: iptstate.cc =================================================================== RCS file: /cvsroot/iptstate/iptstate/iptstate.cc,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -d -r1.17 -r1.17.2.1 --- iptstate.cc 19 Sep 2009 21:07:02 -0000 1.17 +++ iptstate.cc 23 Oct 2009 15:57:24 -0000 1.17.2.1 @@ -63,7 +63,7 @@ #include <unistd.h> using namespace std; -#define VERSION "2.2.2" +static const char *VERSION = "2.2.2"; /* * MAXCONS is set to 16k, the default number of states in iptables. Generally * speaking the ncurses pad is this many lines long, but since ncurses @@ -73,36 +73,41 @@ #define MAXCONS 16384 #define MAXLINES 32767 #if MAXCONS < MAXLINES - #define NLINES MAXCONS +static const size_t NLINES = MAXCONS; #else - #define NLINES MAXLINES +static const size_t NLINES = MAXLINES; #endif -#define MAXFIELDS 20 +static const int MAXFIELDS = 20; // This is the default format string if we don't dynamically determine it -#define DEFAULT_FORMAT "%-21s %-21s %-7s %-12s %-9s\n" +static const char *DEFAULT_FORMAT = "%-21s %-21s %-7s %-12s %-9s\n"; // The following MUST be the same as the above -#define DEFAULT_SRC 21 -#define DEFAULT_DST 21 -#define DEFAULT_PROTO 7 -#define DEFAULT_STATE 12 -#define DEFAULT_TTL 9 +static const int DEFAULT_SRC = 21; +static const int DEFAULT_DST = 21; +static const int DEFAULT_PROTO = 7; +static const int DEFAULT_STATE = 12; +static const int DEFAULT_TTL = 9; // This is the format string for the "totals" line, always. -#define TOTALS_FORMAT \ - "Total States: %i -- TCP: %i UDP: %i ICMP: %i Other: %i (Filtered: %i)\n" +static const char *TOTALS_FORMAT = + "Total States: %i -- TCP: %i UDP: %i ICMP: %i Other: %i (Filtered: %i)\n"; // Options for truncating from the front or the back -#define TRUNC_FRONT 0 -#define TRUNC_END 1 +enum { + TRUNK_FRONT, + TRUNK_END +}; + // Sorting options -#define SORT_SRC 0 -#define SORT_SRC_PT 1 -#define SORT_DST 2 -#define SORT_DST_PT 3 -#define SORT_PROTO 4 -#define SORT_STATE 5 -#define SORT_TTL 6 -#define SORT_BYTES 7 -#define SORT_PACKETS 8 -#define SORT_MAX 8 +enum { + SORT_SRC, + SORT_SRC_PT, + SORT_DST, + SORT_DST_PT, + SORT_PROTO, + SORT_STATE, + SORT_TTL, + SORT_BYTES, + SORT_PACKETS, + SORT_MAX +}; /* * GLOBAL CONSTANTS @@ -137,6 +142,7 @@ string proto, state, ttl, sname, dname, spname, dpname; in_addr src, dst; int srcpt, dstpt, bytes, packets; + unsigned int id; }; // x/y of the terminal window struct screensize_t { @@ -939,6 +945,12 @@ entry.proto = ""; entry.ttl = ""; entry.state = ""; + entry.id = 0; + + /* + * Get the ID + */ + entry.id = nfct_get_attr_u32(ct, ATTR_ID); /* * First, we read stuff into the array that's always the @@ -2475,7 +2487,7 @@ sort_factor = -sort_factor; break; case 'b': - if (sortby < SORT_MAX) { + if (sortby < SORT_MAX - 1) { sortby++; if (!flags.counters && sortby >= SORT_BYTES) |