diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py index 769c3966934ad709c2fbdb3ef15fd0d76f3ee449..15897eb2d32b28428253e2f31f77f761c3db3210 100644 --- a/scapy/layers/inet.py +++ b/scapy/layers/inet.py @@ -517,10 +517,37 @@ icmptypes = { 0 : "echo-reply", 17 : "address-mask-request", 18 : "address-mask-reply" } +icmpcodes = { 3 : { 0 : "network-unreachable", + 1 : "host-unreachable", + 2 : "protocol-unreachable", + 3 : "port-unreachable", + 4 : "fragmentation-needed", + 5 : "source-route-failed", + 6 : "network-unknown", + 7 : "host-unknown", + 9 : "network-prohibited", + 10 : "host-prohibited", + 11 : "TOS-network-unreachable", + 12 : "TOS-host-unreachable", + 13 : "communication-prohibited", + 14 : "host-precedence-violation", + 15 : "precedence-cutoff", }, + 5 : { 0 : "network-redirect", + 1 : "host-redirect", + 2 : "TOS-network-redirect", + 3 : "TOS-host-redirect", }, + 11 : { 0 : "ttl-zero-during-transit", + 1 : "ttl-zero-during-reassembly", }, + 12 : { 0 : "ip-header-bad", + 1 : "required-option-missing", }, } + + + + class ICMP(Packet): name = "ICMP" fields_desc = [ ByteEnumField("type",8, icmptypes), - ByteField("code",0), + MultiEnumField("code",0, icmpcodes, depends_on=lambda pkt:pkt.type,fmt="B"), XShortField("chksum", None), ConditionalField(XShortField("id",0), lambda pkt:pkt.type in [0,8,13,14,15,16,17,18]), ConditionalField(XShortField("seq",0), lambda pkt:pkt.type in [0,8,13,14,15,16,17,18]),