From a6e70c500fde8d432cc26f80b2c334b00a2644dc Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 15 Jul 2019 16:15:32 +0200 Subject: [PATCH] chg: [pibs] added callback mechansims for matched packets --- bin/pibs-BGP-Ranking.c | 8 ++++++++ bin/pibs.h | 5 +++++ bin/synseen.c | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/bin/pibs-BGP-Ranking.c b/bin/pibs-BGP-Ranking.c index 4303c89..82d9eb6 100644 --- a/bin/pibs-BGP-Ranking.c +++ b/bin/pibs-BGP-Ranking.c @@ -36,6 +36,11 @@ void usage(void) printf("/port/year/month/year-month-day.txt\n"); } +void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth, +struct ip* ipv4, struct tcphdr* tcp) +{ +} + int main(int argc, char* argv[]) { pibs_t* pibs; @@ -55,6 +60,9 @@ int main(int argc, char* argv[]) } } + //Set call back function + pibs->synseen_callback = &frame_to_bgpr; + if (pibs->filename[0]) { process_file(pibs); } diff --git a/bin/pibs.h b/bin/pibs.h index 0f2977b..94e248d 100644 --- a/bin/pibs.h +++ b/bin/pibs.h @@ -111,6 +111,7 @@ typedef struct pibs_s { pcap_dumper_t* dumper; pcap_t* outcap; uint32_t redisdb; + void* synseen_callback; } pibs_t; int load_shmid_file(pibs_t* pibs); @@ -127,4 +128,8 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth, struct ip* ipv4, struct tcphdr* tcp); int synseen_init(pibs_t* pibs); pibs_t* init(void); + +typedef void (* synseen_callback_t)(pibs_t* pibs, wtap *wth, uint8_t* eth, +struct ip* ipv4, struct tcphdr* tcp); + #endif diff --git a/bin/synseen.c b/bin/synseen.c index c8340fa..1c38b13 100644 --- a/bin/synseen.c +++ b/bin/synseen.c @@ -140,6 +140,7 @@ void pibs_dump_stats(pibs_t* pibs) void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth, struct ip* ipv4, struct tcphdr* tcp) { + synseen_callback_t synseen_callback; int_fast64_t lastseen; uint32_t ip; struct pcap_pkthdr pchdr; @@ -174,6 +175,10 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth, pchdr.len = wth->rec.rec_header.packet_header.len; pcap_dump((u_char*)pibs->dumper, &pchdr, eth); } + if (pibs->synseen_callback) { + synseen_callback = pibs->synseen_callback; + synseen_callback(pibs, wth, eth, ip, tcp); + } } int synseen_init(pibs_t* pibs)