Skip to content

Commit 8898555

Browse files
committed
chg: [pibs] consume dirname
1 parent f24e3eb commit 8898555

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/pibs-BGP-Ranking.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,25 @@ char* create_path(pibs_t* pibs, uint16_t port, uint64_t ts)
4848
snprintf(s,32,"%ld",ts);
4949
if (strptime(s,"%s",&tm)){
5050
strftime((char*)&s,32,"%Y-%m-%d", &tm);
51+
//TODO use date sub-directory in case of too many files
52+
snprintf(out, 2*FILENAME_MAX, "%s/%d/%s.txt",pibs->outputfile,port,s);
53+
return out;
5154
}
5255
}
5356
//Something went wrong
5457
return NULL;
5558
}
5659

60+
//FIXME avoid mem allocation functions for each packet do them globaly per file
5761
void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth,
5862
struct ip* ipv4, struct tcphdr* tcp)
5963
{
60-
create_path(pibs, ntohs(tcp->th_sport), wth->rec.ts.secs);
64+
char *dirname;
65+
dirname = create_path(pibs, ntohs(tcp->th_sport), wth->rec.ts.secs);
66+
if (dirname) {
67+
printf("%s\n", dirname);
68+
free(dirname);
69+
}
6170
}
6271

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

0 commit comments

Comments
 (0)