Skip to content

Commit 459102f

Browse files
committed
add: [pibs] timestamp parsing
1 parent a6e70c5 commit 459102f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bin/pibs-BGP-Ranking.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121
#include <stdio.h>
22+
#define __USE_XOPEN
23+
#include <time.h>
2224
#include "pibs.h"
2325

2426
void usage(void)
@@ -36,9 +38,26 @@ void usage(void)
3638
printf("<directory>/port/year/month/year-month-day.txt\n");
3739
}
3840

41+
char* create_path(pibs_t* pibs, uint16_t port, uint64_t ts)
42+
{
43+
struct tm tm;
44+
char s[32];
45+
char *out;
46+
out = calloc(1,FILENAME_MAX);
47+
if (out) {
48+
snprintf(s,32,"%ld",ts);
49+
if (strptime(s,"%s",&tm)){
50+
strftime((char*)&s,32,"%Y-%m-%d", &tm);
51+
}
52+
}
53+
//Something went wrong
54+
return NULL;
55+
}
56+
3957
void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth,
4058
struct ip* ipv4, struct tcphdr* tcp)
4159
{
60+
create_path(pibs, ntohs(tcp->th_sport), wth->rec.ts.secs);
4261
}
4362

4463
int main(int argc, char* argv[])

0 commit comments

Comments
 (0)