uint16_t Packet::get_icmp_time_exceed_ipid() { if(!is_icmp()) { return 0; } if(icmp_hdr->type != 11 || icmp_hdr->code != 0 || get_icmp_payload_len()==0) { return 0; } struct ip* ip_hdr = (struct ip*)(payload); return ntohs(ip_hdr->ip_id); }
bool Packet::is_icmp_ttl_exceeded() { if (!is_icmp()) { return false; } else { if (icmp_hdr->type != 11) { return false; } else { return true; } } }
/* for constructing a packet that is captured */ void Packet::build_pkt(const uint8_t *b, uint16_t len) { reset(); memcpy(buf_, b, len); payload = buf_; ip_hdr = (struct ip*)buf_; if(is_tcp()) { tcp_hdr = (struct tcphdr*)((uint8_t *)(ip_hdr) + get_ip_hdr_len()); set_payload((uint8_t *)((uint8_t *)(tcp_hdr) + get_tcp_hdr_len())); } else if (is_icmp()) { icmp_hdr = (struct icmphdr*)((uint8_t *)(ip_hdr) + get_ip_hdr_len()); set_payload((uint8_t *)((uint8_t *)(icmp_hdr) + ICMP_H)); } else { logger->PrintErr("[%s:%d] Only support TCP/ICMP/IP now!\n", __FILE__, __LINE__); } }
static bool pred_is_icmp(arguments_t args, SkBuff b) { return is_icmp(b); }