void hidp_dump(int level, struct frame *frm) { uint8_t hdr; char *param; hdr = p_get_u8(frm); switch (hdr & 0xf0) { case 0x00: param = result2str(hdr); break; case 0x10: param = operation2str(hdr); break; case 0x60: case 0x70: param = protocol2str(hdr); break; case 0x40: case 0x50: case 0xa0: case 0xb0: param = report2str(hdr); break; default: param = ""; break; } p_indent(level, frm); printf("HIDP: %s: %s\n", type2str(hdr), param); raw_dump(level, frm); }
void decode_packet(void *packet_data) { struct ip *ip_hdr = (struct ip *)packet_data; // hd short int // hhd char printf("%d] " "IPv%hd HL:%hhd TOS:%s TL:%hu ID:%hu Off:%hu TTL:%hhu %s\n" "Sum:%hu ", get_stack_id(), (short)ip_hdr->ip_v, (short)ip_hdr->ip_hl, tos2str(ip_hdr->ip_tos), ntohs(ip_hdr->ip_len), ntohs(ip_hdr->ip_id), ntohs(ip_hdr->ip_off), ip_hdr->ip_ttl, protocol2str(ip_hdr->ip_p), ntohs(ip_hdr->ip_sum) ); printf("%s -> ", inet_ntoa(ip_hdr->ip_src)); printf("%s\n", inet_ntoa(ip_hdr->ip_dst)); if(ip_hdr->ip_p == 6) decode_tcp((unsigned char *)packet_data + (ip_hdr->ip_hl * 4), ntohs(ip_hdr->ip_len) - (ip_hdr->ip_hl * 4)); }