2020#include "sn_resolv.h"
2121
2222/*** extern stuff ********/
23- extern char * SHARED , * connection_data , * running_connections ,
24- * logged_connections ;
23+ extern char * SHARED , * connection_data , * logged_connections ;
24+ extern struct shared_conn_data * running_connections ;
2525extern int * LISTlength , * DATAlength , memory_id ;
2626extern unsigned int * TCP_nr_of_packets , * ICMP_nr_of_packets , * UDP_nr_of_packets ; unsigned int * IP_nr_of_packets ;
2727extern unsigned long * TCP_bytes_in_packets , * UDP_bytes_in_packets ;
@@ -133,12 +133,10 @@ doupdate();
133133
134134static void data_window (struct box_window * Win , struct box_window * P_Win ,
135135 int num_lines , int num_cols , int begy ,int begx ,
136- char * buffer , int listitem )
136+ struct shared_conn_data * conn , int listitem )
137137{
138138int i = 0 , j = 0 ;
139- struct shared_conn_data * conn ;
140139
141- conn = (struct shared_conn_data * ) buffer ;
142140while ((j < listitem )&& (i < (CONNECTION_CAPACITY + 1 )))
143141 {
144142 if (conn [i ].connection [0 ]!= 0 )
@@ -169,12 +167,10 @@ wnoutrefresh(Win->main_window);wnoutrefresh(Win->work_window);
169167doupdate ();
170168}
171169
172- static void data_device (char * buffer , int listitem )
170+ static void data_device (struct shared_conn_data * conn , int listitem )
173171{
174172int i = 0 , j = 0 ;
175- struct shared_conn_data * conn ;
176173
177- conn = (struct shared_conn_data * ) buffer ;
178174while ((j < listitem )&& (i < (CONNECTION_CAPACITY + 1 )))
179175 {
180176 if (conn [i ].connection [0 ]!= 0 )
@@ -235,14 +231,12 @@ wnoutrefresh(Work_win->work_window);
235231doupdate ();
236232}
237233
238- static void fill_box_window (struct box_window * Work_win , char * buffer ,
234+ static void fill_box_window (struct box_window * Work_win , struct shared_conn_data * conn ,
239235 int begin_item , int boxlen , int rowlen )
240236 /* 0 is the first item */
241237{
242238int i = 0 , j = 0 , line = 0 ;
243- struct shared_conn_data * conn ;
244239
245- conn = (struct shared_conn_data * ) buffer ;
246240while ((j < begin_item )&& (i < (CONNECTION_CAPACITY + 1 )))
247241 {
248242 if (conn [i ].connection [0 ]!= 0 )
@@ -286,18 +280,15 @@ for(i=line;i<boxlen;i++)
286280wnoutrefresh (Work_win -> work_window );
287281}
288282
289- static void point_item (struct box_window * Work_win , char * buffer ,
283+ static void point_item (struct box_window * Work_win , struct shared_conn_data * conn ,
290284 int item , int begin_item , int boxlen , int rowlen )
291285{
292286int i = 0 , j = 0 ;
293- struct shared_conn_data * conn ;
294-
295287
296288if (item < 0 ) return ; /* POINTpos 0 = first item -1 = no items */
297289 /* LISTlength 0 = 1 -1 = no items */
298290 /* DANGER - there should always be >= */
299291 /* connections than 'item' */
300- conn = (struct shared_conn_data * ) buffer ;
301292while ((j < item )&& (i < (CONNECTION_CAPACITY + 1 )))
302293 {
303294 if (conn [i ].connection [0 ] != 0 )
@@ -468,11 +459,10 @@ sigaction(signum,&new_sigusr,NULL);
468459static void interaction (int sig ) /* invoked when data arrives */
469460{
470461int i ;
471- struct shared_conn_data * conn ;
462+ struct shared_conn_data * conn = running_connections ;
472463
473464
474465/* timeout increase */
475- conn = (struct shared_conn_data * ) running_connections ;
476466for (i = 0 ;i < CONNECTION_CAPACITY ;i ++ )
477467 if (conn [i ].connection [0 ]!= 0 )
478468 conn [i ].timeout += 1 ;
@@ -566,14 +556,12 @@ delwin(packets_box.work_window), delwin(packets_box.main_window);
566556forced_refresh ();
567557}
568558
569- int add_itemlist (char * buffer , char * string , char * desc )
559+ int add_itemlist (struct shared_conn_data * conn , char * string , char * desc )
570560{
571561int i , to_help , to_item ;
572- struct shared_conn_data * conn ;
573562
574563/*invoked every time a packet comes in */
575564
576- conn = (struct shared_conn_data * ) buffer ;
577565for (i = 0 ;i < CONNECTION_CAPACITY ;i ++ )
578566 if (strcmp ( conn [i ].connection , string )== 0 )
579567 {
@@ -606,12 +594,10 @@ conn[to_item].timeout=0;
606594return to_item ;
607595}
608596
609- int del_itemlist (char * buffer , char * string )
597+ int del_itemlist (struct shared_conn_data * conn , char * string )
610598{
611599int i ;
612- struct shared_conn_data * conn ;
613600
614- conn = (struct shared_conn_data * ) buffer ;
615601for (i = 0 ;i < CONNECTION_CAPACITY ;i ++ )
616602 if (strcmp ( conn [i ].connection , string )== 0 )
617603 {
@@ -632,7 +618,7 @@ void clear_shared_mem(char mode)
632618 /* keep packet count */
633619{
634620int i ;
635- struct shared_conn_data * conn ;
621+ struct shared_conn_data * conn = running_connections ;
636622
637623* DATAlength = 0 ;
638624* LISTlength = -1 ;
@@ -646,7 +632,6 @@ if(mode==0)
646632 }
647633
648634log_conn -> log_enter [0 ]= 0 ;
649- conn = (struct shared_conn_data * ) running_connections ;
650635for (i = 0 ;i < CONNECTION_CAPACITY ;i ++ )
651636 {
652637 conn [i ].connection [0 ]= 0 ;
@@ -656,14 +641,12 @@ for(i=0;i<CONNECTION_CAPACITY;i++)
656641};
657642
658643static void create_arguments (char * esource , char * es_port , char * edest ,
659- char * ed_port , char * buffer , int item )
644+ char * ed_port , struct shared_conn_data * conn , int item )
660645{
661646char e_dummy [CONN_NAMELEN ];
662647int i = 0 , j = 0 ;
663- struct shared_conn_data * conn ;
664648
665649if (item < 0 ) return ;
666- conn = (struct shared_conn_data * ) buffer ;
667650while ((j < item )&& (i < (CONNECTION_CAPACITY + 1 )))
668651 {
669652 if (conn [i ].connection [0 ] != 0 )
0 commit comments