Skip to content

Commit 9854962

Browse files
committed
chg: [pibs] Split up inititalization process
1 parent 969e6e6 commit 9854962

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

bin/pibs.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,14 @@ pibs_t* init(void)
9292

9393
wtap_init(FALSE);
9494
pibs=calloc(sizeof(pibs_t),1);
95+
//TODO error handling
9596
//TODO check if size is correct
96-
pibs->data_size = sizeof(pibs_header_t) + NBINSCALE * NBINS * SZBIN * NBINITEMS * sizeof(item_t);
97-
pibs->data = calloc(pibs->data_size,1);
9897
pibs->filename = calloc(FILENAME_MAX,1);
9998
pibs->uuid = calloc(SZUUID,1);
10099
pibs->key = calloc(SZKEY,1);
101100
pibs->server = calloc(SZSERVER,1);
102-
printf("#Internal look up structure size in bytes: %ld\n", pibs->data_size);
103-
// Build header
104-
pibs->data[0]='P';
105-
pibs->data[1] = 'I';
106-
pibs->data[2] = 'B';
107-
pibs->data[3] = 'S';
108-
pibs->data[4] = 1; //version 1
109-
pibs->next_block = sizeof(pibs_header_t);
110-
pibs->bin_offset = pibs->next_block;
111-
printf("#data address is %p\n",pibs->data);
112-
pibs->bin_table = (uint32_t*)(pibs->data+pibs->bin_offset);
113-
printf("#bin_table address is %p\n", pibs->bin_table);
114-
// Create bins
115-
pibs->next_block+=SZBIN * NBINS;
116-
printf("#next block %d\n", pibs->next_block);
117-
pibs->items = (item_t*)(pibs->data+pibs->next_block);
118-
pibs->next_item = 0;
119-
printf("#items are address %p\n", pibs->items);
120-
pibs->max_item = NBINS * NBINITEMS;
121-
printf("#max_item: %d\n", pibs->max_item);
101+
// Initialize the various processors
102+
synseen_init(pibs);
122103
return pibs;
123104
}
124105

bin/pibs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ void pibs_dump_stats(pibs_t* pibs);
125125
void process_redis_list(pibs_t* pibs);
126126
void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
127127
struct ip* ipv4, struct tcphdr* tcp);
128-
128+
int synseen_init(pibs_t* pibs);
129129
#endif

bin/synseen.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,31 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
175175
pcap_dump((u_char*)pibs->dumper, &pchdr, eth);
176176
}
177177
}
178+
179+
int synseen_init(pibs_t* pibs)
180+
{
181+
pibs->data_size = sizeof(pibs_header_t) + NBINSCALE * NBINS * SZBIN * NBINITEMS * sizeof(item_t);
182+
pibs->data = calloc(pibs->data_size,1);
183+
printf("#Internal look up structure size in bytes: %ld\n", pibs->data_size);
184+
// Build header
185+
pibs->data[0]='P';
186+
pibs->data[1] = 'I';
187+
pibs->data[2] = 'B';
188+
pibs->data[3] = 'S';
189+
pibs->data[4] = 1; //version 1
190+
191+
pibs->next_block = sizeof(pibs_header_t);
192+
pibs->bin_offset = pibs->next_block;
193+
printf("#data address is %p\n",pibs->data);
194+
pibs->bin_table = (uint32_t*)(pibs->data+pibs->bin_offset);
195+
printf("#bin_table address is %p\n", pibs->bin_table);
196+
// Create bins
197+
pibs->next_block+=SZBIN * NBINS;
198+
printf("#next block %d\n", pibs->next_block);
199+
pibs->items = (item_t*)(pibs->data+pibs->next_block);
200+
pibs->next_item = 0;
201+
printf("#items are address %p\n", pibs->items);
202+
pibs->max_item = NBINS * NBINITEMS;
203+
printf("#max_item: %d\n", pibs->max_item);
204+
return 1;
205+
}

0 commit comments

Comments
 (0)