Skip to content

Commit

Permalink
chg: [pibs] fixed segfault in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
haegardev committed Oct 2, 2019
1 parent 5b2ddf2 commit c3f7c26
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
34 changes: 32 additions & 2 deletions bin/pibs-BGP-Ranking.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define __USE_XOPEN
#include <time.h>
#include "pibs.h"
#include <gmodule.h>

void usage(void)
{
Expand Down Expand Up @@ -69,13 +70,24 @@ struct ip* ipv4, struct tcphdr* tcp)
}
}

gint cmp_ips(gconstpointer a, gconstpointer b)
{
uint32_t* x;
uint32_t* y;
x = (uint32_t*)a;
y = (uint32_t*)b;
return *x<*y;
}

int main(int argc, char* argv[])
{
pibs_t* pibs;
int opt;


GTree *ip_tree;
pibs = init();
uint32_t *y;
ip_tree = NULL;

while ((opt = getopt(argc, argv, "hr:d:")) != -1) {
printf("%d\n", opt);
switch (opt) {
Expand All @@ -93,6 +105,24 @@ int main(int argc, char* argv[])
}
}

//sorted array insert operations -> o(n) not good if we have a lot of inserts
//Problem: memalloc per each ip address
//Problem: duplicates are added

// Gtree insert IP value several times

y = calloc(1,sizeof(uint32_t));
*y = 34;
// ip_list = g_list_insert_sorted_with_data (ip_list,y,&cmp_ips,NULL);
// y = calloc(1,sizeof(uint32_t));
// *y = 34;
// ip_list = g_list_insert_sorted_with_data (ip_list,y,&cmp_ips,NULL);
// y = calloc(1,sizeof(uint32_t));
// *y = 99;
// ip_list = g_list_insert_sorted_with_data (ip_list,y,&cmp_ips,NULL);


return EXIT_SUCCESS;
//Set call back function
pibs->synseen_callback = &frame_to_bgpr;

Expand Down
2 changes: 1 addition & 1 deletion bin/synseen.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
}
if (pibs->synseen_callback) {
synseen_callback = pibs->synseen_callback;
synseen_callback(pibs, wth, eth, ip, tcp);
synseen_callback(pibs, wth, eth, ipv4, tcp);
}
}

Expand Down

0 comments on commit c3f7c26

Please sign in to comment.