~ubuntu-branches/ubuntu/hardy/nast/hardy

« back to all changes in this revision

Viewing changes to ncurses/n_nast.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2004-02-17 22:14:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040217221421-f1h39tzviblbp2lh
Tags: upstream-0.2.0
ImportĀ upstreamĀ versionĀ 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    nast
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify
 
5
    it under the terms of the GNU General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or
 
7
    (at your option) any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
    GNU General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License
 
15
    along with this program; if not, write to the Free Software
 
16
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 
 
18
*/
 
19
 
 
20
#include "../include/nast.h"
 
21
 
 
22
#ifdef HAVE_LIBNCURSES          /*don't compile if we haven't ncurses*/
 
23
 
 
24
# include <menu.h>
 
25
 
 
26
# define SAFE_WREFRESH(x)   do { wrefresh(x); } while(0)
 
27
 
 
28
# define SAFE_WIN_REFRESH(x)   do { wrefresh(x->win); } while(0)
 
29
# define SAFE_FREE(x) do{ if(x) { free(x); x = NULL; } }while(0)
 
30
 
 
31
# define SAFE_SCROLL_REFRESH(sx) do {  \
 
32
   pnoutrefresh(sx->win, sx->y_scroll, 0, sx->y + 1, sx->x + 1, sx->y + sx->lines - 2, sx->cols - 1 ); \
 
33
   wnoutrefresh(sx->out);              \
 
34
   doupdate();                         \
 
35
} while(0)
 
36
 
 
37
# define POLL_WGETCH(x, y)   do {    \
 
38
   struct pollfd poll_fd = {        \
 
39
      .fd = 0,                      \
 
40
      .events = POLLIN,             \
 
41
   };                               \
 
42
   poll(&poll_fd, 1, 1);            \
 
43
   if (poll_fd.revents & POLLIN)    \
 
44
      x = wgetch(y);                \
 
45
   else                             \
 
46
      usleep(1000);                 \
 
47
} while(0)
 
48
 
 
49
struct scrolling_window
 
50
{
 
51
   WINDOW *win;
 
52
   WINDOW *out;
 
53
   int y_scroll;
 
54
   int y_max;
 
55
   int lines;
 
56
   int cols;
 
57
   int x;
 
58
   int y;
 
59
   char *title;
 
60
};
 
61
typedef struct scrolling_window N_SCROLLWIN;
 
62
 
 
63
N_SCROLLWIN *newscrollwin(int lines, int cols, int y, int x, char *title, int maxlines);
 
64
void redrawscrollwin(N_SCROLLWIN *win, int focus);
 
65
void drawscroller(N_SCROLLWIN *win);
 
66
void winscroll(N_SCROLLWIN *win, int delta);
 
67
void delscrollwin(N_SCROLLWIN **win);
 
68
 
 
69
void nmenu(void);
 
70
int sniffer_menu(void);
 
71
int analyzer_menu(void);
 
72
int options_menu(void);
 
73
void pop_up_win(void);
 
74
void *conn_db(void *threadarg);
 
75
void *conn_db_r(void *threadarg);
 
76
int connection(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport);
 
77
int rst_connection_db(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport);
 
78
int reset_conn(char *dev,u_long s_ip, u_long d_ip, u_short s_port, u_short d_port,u_long seq, u_long ack);
 
79
int streamg (char *dev,char *sfilter);
 
80
void data_sniffo_stream (char *data_info, u_int len);
 
81
void init_scr(void);
 
82
int reset(char *dev, char *sfilter);
 
83
int check_pthread(void);
 
84
int shutdown_thread(void);
 
85
void help_win(void);
 
86
 
 
87
WINDOW *query;
 
88
WINDOW *werror;
 
89
WINDOW *help;
 
90
N_SCROLLWIN *princ;
 
91
N_SCROLLWIN *winfo;
 
92
N_SCROLLWIN *wstream;
 
93
N_SCROLLWIN *wconn;
 
94
 
 
95
MENU *my_nmenu;
 
96
ITEM *curr_item;
 
97
WINDOW *my_nmenu_win;
 
98
WINDOW *pop_up;
 
99
 
 
100
u_short mvar;
 
101
u_short promisc,hex,ascii,ld,f,lr,l;
 
102
u_short flg;
 
103
int linm;
 
104
int fileds;
 
105
char dev[10];
 
106
char n_filter[60];
 
107
char ldfile[50];
 
108
char tcpdfile[50];
 
109
char reportl[50];
 
110
char logfile[50];
 
111
/*descriptor for stream*/
 
112
pcap_t* str;
 
113
pcap_dumper_t *dumper;
 
114
 
 
115
/* thread for database connections */
 
116
pthread_t thID[6];
 
117
 
 
118
struct thread_conn
 
119
{
 
120
   char device[30];
 
121
   u_long ip_src;
 
122
   u_long ip_dst;
 
123
   u_short sport;
 
124
   u_short dport;
 
125
   int thread_id;
 
126
};
 
127
 
 
128
struct thread_arp
 
129
{
 
130
   char device[30];
 
131
   int lr;
 
132
};
 
133
 
 
134
struct thread_conn_rst
 
135
{
 
136
   char device[30];
 
137
   u_long ip_src;
 
138
   u_long ip_dst;
 
139
   u_short sport;
 
140
   u_short dport;
 
141
   int thread_id;
 
142
};
 
143
 
 
144
struct thread_conn th_data[1];
 
145
struct thread_conn_rst th_r_data[1];
 
146
struct thread_arp th_arp_data[1];
 
147
 
 
148
struct connections
 
149
{
 
150
   unsigned long s_ip;
 
151
   unsigned long d_ip;
 
152
   unsigned short s_port;
 
153
   unsigned short d_port;
 
154
   u_long seq;
 
155
   u_long ack;
 
156
   int lin;
 
157
   int pr;
 
158
   int set;
 
159
 
 
160
}
 
161
c_inf[30];
 
162
 
 
163
/* connection struct */
 
164
struct cnn
 
165
{
 
166
   char string[200];
 
167
   /*filter for tcp stream*/
 
168
   char sfilter[200];
 
169
   u_long seq;
 
170
   u_long ack;
 
171
   u_long ip_src;
 
172
   u_long ip_dst;
 
173
   u_short s_port;
 
174
   u_short d_port;
 
175
   int cont;
 
176
}
 
177
sf[30];
 
178
 
 
179
/* num max of db connections */
 
180
int nmax;
 
181
 
 
182
#endif
 
183