in the function ofp_match::from_packet():
...............
...............
else if (nwproto() == ip::proto::ICMP)
{
const icmp_header* icmp = cast_check(packet);
if (!icmp)
return;
packet = packet + sizeof(icmp_header);
tp_src(ntohs(icmp->icmp_type));
tp_dst(ntohs(icmp->icmp_code));
}
..............
the type of "icmp->icmp_type" and "icmp->icmp_code" are uint8_t, they shoud not be converted to host byte order by calling "ntohs". simply fix it like that:
tp_src(icmp->icmp_type);
tp_dst(icmp->icmp_code);
in the function ofp_match::from_packet(): ............... ............... else if (nwproto() == ip::proto::ICMP) { const icmp_header* icmp = cast_check(packet);
if (!icmp)
return;
packet = packet + sizeof(icmp_header);
tp_src(ntohs(icmp->icmp_type));
tp_dst(ntohs(icmp->icmp_code));
}
..............
the type of "icmp->icmp_type" and "icmp->icmp_code" are uint8_t, they shoud not be converted to host byte order by calling "ntohs". simply fix it like that:
tp_src(icmp->icmp_type);
tp_dst(icmp->icmp_code);