Skip to content

Commit a6e70c5

Browse files
committed
chg: [pibs] added callback mechansims for matched packets
1 parent 4770c2f commit a6e70c5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

bin/pibs-BGP-Ranking.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ void usage(void)
3636
printf("<directory>/port/year/month/year-month-day.txt\n");
3737
}
3838

39+
void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth,
40+
struct ip* ipv4, struct tcphdr* tcp)
41+
{
42+
}
43+
3944
int main(int argc, char* argv[])
4045
{
4146
pibs_t* pibs;
@@ -55,6 +60,9 @@ int main(int argc, char* argv[])
5560
}
5661
}
5762

63+
//Set call back function
64+
pibs->synseen_callback = &frame_to_bgpr;
65+
5866
if (pibs->filename[0]) {
5967
process_file(pibs);
6068
}

bin/pibs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ typedef struct pibs_s {
111111
pcap_dumper_t* dumper;
112112
pcap_t* outcap;
113113
uint32_t redisdb;
114+
void* synseen_callback;
114115
} pibs_t;
115116

116117
int load_shmid_file(pibs_t* pibs);
@@ -127,4 +128,8 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
127128
struct ip* ipv4, struct tcphdr* tcp);
128129
int synseen_init(pibs_t* pibs);
129130
pibs_t* init(void);
131+
132+
typedef void (* synseen_callback_t)(pibs_t* pibs, wtap *wth, uint8_t* eth,
133+
struct ip* ipv4, struct tcphdr* tcp);
134+
130135
#endif

bin/synseen.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ void pibs_dump_stats(pibs_t* pibs)
140140
void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
141141
struct ip* ipv4, struct tcphdr* tcp)
142142
{
143+
synseen_callback_t synseen_callback;
143144
int_fast64_t lastseen;
144145
uint32_t ip;
145146
struct pcap_pkthdr pchdr;
@@ -174,6 +175,10 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
174175
pchdr.len = wth->rec.rec_header.packet_header.len;
175176
pcap_dump((u_char*)pibs->dumper, &pchdr, eth);
176177
}
178+
if (pibs->synseen_callback) {
179+
synseen_callback = pibs->synseen_callback;
180+
synseen_callback(pibs, wth, eth, ip, tcp);
181+
}
177182
}
178183

179184
int synseen_init(pibs_t* pibs)

0 commit comments

Comments
 (0)