From 459102f9b12c6eb8898f0b5ed7e4f62696a2406a Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 15 Jul 2019 22:18:14 +0200 Subject: [PATCH] add: [pibs] timestamp parsing --- bin/pibs-BGP-Ranking.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/pibs-BGP-Ranking.c b/bin/pibs-BGP-Ranking.c index 82d9eb6..dab817c 100644 --- a/bin/pibs-BGP-Ranking.c +++ b/bin/pibs-BGP-Ranking.c @@ -19,6 +19,8 @@ * along with this program. If not, see . */ #include +#define __USE_XOPEN +#include #include "pibs.h" void usage(void) @@ -36,9 +38,26 @@ void usage(void) printf("/port/year/month/year-month-day.txt\n"); } +char* create_path(pibs_t* pibs, uint16_t port, uint64_t ts) +{ + struct tm tm; + char s[32]; + char *out; + out = calloc(1,FILENAME_MAX); + if (out) { + snprintf(s,32,"%ld",ts); + if (strptime(s,"%s",&tm)){ + strftime((char*)&s,32,"%Y-%m-%d", &tm); + } + } + //Something went wrong + return NULL; +} + 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); } int main(int argc, char* argv[])