tcp - STL comparator for Session Management -
i trying find total number of session in captured *.pcap file structure
struct sessionmanager{ unsigned short int src_port; unsigned short int dest_port; unsigned char protocol; unsigned short int ip_ver; unsigned int srcip4addr; unsigned int destip4addr; char srcip6addr[16]; char destip6addr[16]; unsigned int seqnumber; };
and these wrote compare function
comparator
if(a->protocol <b->protocol) return true; else if(a->protocol==b->protocol) if(a->ip_ver<b->ip_ver) return true; else if(a->ip_ver==b->ip_ver) if(a->src_port<b->src_port) return true; else if(a->src_port==b->src_port) if(a->dest_port<b->dest_port) return true; else if(a->dest_port==b->dest_port) if((a->ip_ver==4)) { if((a->srcip4addr<b->srcip4addr)) return true; else if((a->srcip4addr==b->srcip4addr)) if(a->destip4addr<b->destip4addr) return true; } else if(a->ip_ver==6) { if(cmp(a->srcip6addr,b->srcip6addr)==-1) return true; else if(cmp(a->srcip6addr,b->srcip6addr)==0) { if(cmp(a->destip6addr,b->destip6addr)==-1) return true; else if(cmp(a->destip6addr,b->destip6addr)==0) if(a->src_port<b->src_port) return true; else if(a->src_port==b->src_port) if(a->dest_port<b->dest_port) return true; if(a->dest_port==b->dest_port) return false; } } return false;
its working fine ipv4 not working ipv6 i've created separate method string comparison
Comments
Post a Comment