i want to parse some information from pcap file to my project. I'm creating analizer that can find errors in sip calls. I created the class that can hold such information (not all of them for now). I use Windows and Codeblocks c++ and have installed the pcap library for windows. What is the easiest way to achieve this ?
class Messege
{
private:
int number;
string cseq;
string method;
string callId;
string source;
string destination;
string request;
public:
//set
void setCseq (string newCseq){cseq=newCseq;};
void setNumber (int newNumber){number=newNumber;};
void setMethod (string newMethod){method=newMethod;};
void setSource (string newSource){source=newSource;};
void setDestination (string newDestination){destination = newDestination;};
void setCallId (string newCallId){callId = newCallId;};
void setRequest (string newRequest){request = newRequest;};
//get
int getNumber (){return number;};
string getCseq (){return cseq;};
string getMethod (){return method;};
string getSource (){return source;};
string getDestination () {return destination;};
string getCallId (){return callId;};
string getRequest (){return request;};
};
Your might want to check out libpcap. You can parse a pcap file with:
pcap_t *pcap = pcap_open_offline(pcap_filename, errbuf);
int link_layer_type = pcap_datalink(pcap);
pcap_loop(pcap, -1, pcap_handler, NULL);
pcap_close(pcap);
where pcap_handler is your call back function:
typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes);
Find details here.