I have a few thousand pcap files that I'm trying to parse as part of a research project. They are all named as xxx.xxx.xxx.xxx_yyy.yyy.yyy.yyy.pcap where the first IP address is the one I'm trying to use as a variable in my C++ program.
Parsing the pcap files themselves is not an issue. I am passing the filename to the function as a pointer and just don't quite know how to grab that first part of the filename.
As requested, here is a bit of code:
//program.cpp//
int main(int argc, char *argv[]){
char * inFile;
inFile = argv[1];
result = parsePkts(inFile);
return 0;
}
//functions.h//
int parsePkts(char *fn){
struct ip *ipHdr = NULL;
ipHdr = (struct ip *)(data + sizeof(struct ether_header));
if((ipHdr -> ip_dst.s_addr)) == xxx.xxx.xxx.xxx) {
do stuff
}
}
Obviously there is a lot more to the program but this is where I need to grab it. Thanks.