<s> """<STR_LIT>""" <EOL> from construct import * <EOL> from ipv4 import IpAddress <EOL> echo_payload = Struct ( "<STR_LIT>" , <EOL> UBInt16 ( "<STR_LIT>" ) , <EOL> UBInt16 ( "<STR_LIT>" ) , <EOL> Bytes ( "<STR_LIT:data>" , <NUM_LIT:32> ) , <EOL> ) <EOL> dest_unreachable_payload = Struct ( "<STR_LIT>" , <EOL> Padding ( <NUM_LIT:2> ) , <EOL> UBInt16 ( "<STR_LIT>" ) , <EOL> IpAddress ( "<STR_LIT:host>" ) , <EOL> Bytes ( "<STR_LIT>" , <NUM_LIT:8> ) , <EOL> ) <EOL> dest_unreachable_code = Enum ( Byte ( "<STR_LIT:code>" ) , <EOL> Network_unreachable_error = <NUM_LIT:0> , <EOL> Host_unreachable_error = <NUM_LIT:1> , <EOL> Protocol_unreachable_error = <NUM_LIT:2> , <EOL> Port_unreachable_error = <NUM_LIT:3> , <EOL> The_datagram_is_too_big = <NUM_LIT:4> , <EOL> Source_route_failed_error = <NUM_LIT:5> , <EOL> Destination_network_unknown_error = <NUM_LIT:6> , <EOL> Destination_host_unknown_error = <NUM_LIT:7> , <EOL> Source_host_isolated_error = <NUM_LIT:8> , <EOL> Desination_administratively_prohibited = <NUM_LIT:9> , <EOL> Host_administratively_prohibited2 = <NUM_LIT:10> , <EOL> Network_TOS_unreachable = <NUM_LIT:11> , <EOL> Host_TOS_unreachable = <NUM_LIT:12> , <EOL> ) <EOL> icmp_header = Struct ( "<STR_LIT>" , <EOL> Enum ( Byte ( "<STR_LIT:type>" ) , <EOL> Echo_reply = <NUM_LIT:0> , <EOL> Destination_unreachable = <NUM_LIT:3> , <EOL> Source_quench = <NUM_LIT:4> , <EOL> Redirect = <NUM_LIT:5> , <EOL> Alternate_host_address = <NUM_LIT:6> , <EOL> Echo_request = <NUM_LIT:8> , <EOL> Router_advertisement = <NUM_LIT:9> , <EOL> Router_solicitation = <NUM_LIT:10> , <EOL> Time_exceeded = <NUM_LIT:11> , <EOL> Parameter_problem = <NUM_LIT:12> , <EOL> Timestamp_request = <NUM_LIT> , <EOL> Timestamp_reply = <NUM_LIT> , <EOL> Information_request = <NUM_LIT:15> , <EOL> Information_reply = <NUM_LIT:16> , <EOL> Address_mask_request = <NUM_LIT> , <EOL> Address_mask_reply = <NUM_LIT> , <EOL> _default_ = Pass , <EOL> ) , <EOL> Switch ( "<STR_LIT:code>" , lambda ctx : ctx . type , <EOL> { <EOL> "<STR_LIT>" : dest_unreachable_code , <EOL> } , <EOL> default = Byte ( "<STR_LIT:code>" ) , <EOL> ) , <EOL> UBInt16 ( "<STR_LIT>" ) , <EOL> Switch ( "<STR_LIT>" , lambda ctx : ctx . type , <EOL> { <EOL> "<STR_LIT>" : echo_payload , <EOL> "<STR_LIT>" : echo_payload , <EOL> "<STR_LIT>" : dest_unreachable_payload , <EOL> } , <EOL> default = Pass <EOL> ) <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> cap1 = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) . decode ( "<STR_LIT>" ) <EOL> cap2 = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) . decode ( "<STR_LIT>" ) <EOL> cap3 = ( "<STR_LIT>" ) . decode ( "<STR_LIT>" ) <EOL> print icmp_header . parse ( cap1 ) <EOL> print icmp_header . parse ( cap2 ) <EOL> print icmp_header . parse ( cap3 ) </s>
