void handle_packet(u_char *args,const struct pcap_pkthdr* pkthdr,const u_char* packet) { u_int16_t type = handle_ethernet(args,pkthdr,packet); if(type == ETHERTYPE_IP) { handle_IP(args,pkthdr,packet); } }
void process_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet) { pkt_count++; u_int16_t type = handle_ethernet(args, header, packet); if (type != ETHERTYPE_IP) return; handle_IP(args, header, packet); }
/* looking at ethernet headers */ void my_callback(u_char *args,const struct pcap_pkthdr* pkthdr,const u_char* packet){ u_int16_t type = handle_ethernet(args,pkthdr,packet); if(type == ETHERTYPE_IP) { /* handle IP packet */ handle_IP(args,pkthdr,packet); }else if(type == ETHERTYPE_ARP) { /* handle arp packet */ }else if(type == ETHERTYPE_REVARP){ /* handle reverse arp packet */ }else { /* handle_ethernet returned -1 */ } }
/* looking at ernet headers */ void my_callback(u_char *args,const struct pcap_pkthdr* pkthdr,const u_char* packet) { printf("---- start packet\n"); u_int16_t type = handle_ethernet(args,pkthdr,packet); if(type == ETHERTYPE_IP) {/* handle IP packet */ handle_IP(args,pkthdr,packet); }else if(type == ETHERTYPE_ARP) {/* handle arp packet */ } else if(type == ETHERTYPE_REVARP) {/* handle reverse arp packet */ } printf("---- end packet\n"); }
void my_callback(u_char *args,const struct pcap_pkthdr *hdr, const u_char *packet){ uint16_t type = handle_ethernet(args,hdr,packet); uint16_t ipproto = -1; uint16_t pld_l =0; printf("type eth: %d\n",type); if(type == ETHERTYPE_IP){ ipproto = handle_IP(args,hdr,packet); } else if (type == ETHERTYPE_ARP) { printf("ARP\n"); } if(ipproto == 17) pld_l = handle_UDP(args,hdr,packet); else if(ipproto == 6){ //pld_l = handle_TCP(args,hdr,packet); } printf("length pld: %d\n",pld_l); if(pld_l > 0) handle_PLD(args,hdr,packet); }