chg: [pibs] consume dirname

master
Gerard Wagener 2019-07-15 23:03:30 +02:00
parent f24e3eb6df
commit 8898555fca
1 changed files with 10 additions and 1 deletions

View File

@ -48,16 +48,25 @@ char* create_path(pibs_t* pibs, uint16_t port, uint64_t ts)
snprintf(s,32,"%ld",ts); snprintf(s,32,"%ld",ts);
if (strptime(s,"%s",&tm)){ if (strptime(s,"%s",&tm)){
strftime((char*)&s,32,"%Y-%m-%d", &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 //Something went wrong
return NULL; 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, void frame_to_bgpr(pibs_t* pibs, wtap *wth, uint8_t* eth,
struct ip* ipv4, struct tcphdr* tcp) 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[]) int main(int argc, char* argv[])