From 8898555fca8f6f042677c3d12745da8a898e1e23 Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 15 Jul 2019 23:03:30 +0200 Subject: [PATCH] chg: [pibs] consume dirname --- bin/pibs-BGP-Ranking.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/pibs-BGP-Ranking.c b/bin/pibs-BGP-Ranking.c index a87d3b6..2a2be19 100644 --- a/bin/pibs-BGP-Ranking.c +++ b/bin/pibs-BGP-Ranking.c @@ -48,16 +48,25 @@ char* create_path(pibs_t* pibs, uint16_t port, uint64_t ts) snprintf(s,32,"%ld",ts); if (strptime(s,"%s",&tm)){ strftime((char*)&s,32,"%Y-%m-%d", &tm); + //TODO use date sub-directory in case of too many files + snprintf(out, 2*FILENAME_MAX, "%s/%d/%s.txt",pibs->outputfile,port,s); + return out; } } //Something went wrong return NULL; } +//FIXME avoid mem allocation functions for each packet do them globaly per file void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth, struct ip* ipv4, struct tcphdr* tcp) { - create_path(pibs, ntohs(tcp->th_sport), wth->rec.ts.secs); + char *dirname; + dirname = create_path(pibs, ntohs(tcp->th_sport), wth->rec.ts.secs); + if (dirname) { + printf("%s\n", dirname); + free(dirname); + } } int main(int argc, char* argv[])