ProNET_Token_Ring = 4, Chaos = 5, IEEE_802 = 6, ARCNET = 7, Hyperchannel = 8, Lanstar = 9, ), Byte("hardware_address_length"), Byte("hop_count"), UBInt32("transaction_id"), UBInt16("elapsed_time"), BitStruct("flags", Flag("boardcast"), Padding(15), ), IpAddress("client_addr"), IpAddress("your_addr"), IpAddress("server_addr"), IpAddress("gateway_addr"), IpAddress("client_addr"), Bytes("client_hardware_addr", 16), Bytes("server_host_name", 64), Bytes("boot_filename", 128), # BOOTP/DHCP options # "The first four bytes contain the (decimal) values 99, 130, 83 and 99" Const(Bytes("magic", 4), six.b("\x63\x82\x53\x63")), Rename("options", OptionalGreedyRange(dhcp_option)), ) if __name__ == "__main__":
from construct import * from ipv4 import IpAddress echo_payload = Struct( "echo_payload", UBInt16("identifier"), UBInt16("sequence"), Bytes("data", 32), # length is implementation dependent... # is anyone using more than 32 bytes? ) dest_unreachable_payload = Struct( "dest_unreachable_payload", Padding(2), UBInt16("next_hop_mtu"), IpAddress("host"), Bytes("echo", 8), ) dest_unreachable_code = Enum( Byte("code"), Network_unreachable_error=0, Host_unreachable_error=1, Protocol_unreachable_error=2, Port_unreachable_error=3, The_datagram_is_too_big=4, Source_route_failed_error=5, Destination_network_unknown_error=6, Destination_host_unknown_error=7, Source_host_isolated_error=8, Desination_administratively_prohibited=9,
Chaos=5, IEEE_802=6, ARCNET=7, Hyperchannel=8, Lanstar=9, ), Byte("hardware_address_length"), Byte("hop_count"), UBInt32("transaction_id"), UBInt16("elapsed_time"), BitStruct( "flags", Flag("boardcast"), Padding(15), ), IpAddress("client_addr"), IpAddress("your_addr"), IpAddress("server_addr"), IpAddress("relay_addr"), Bytes("client_hardware_addr", 16), Bytes("server_host_name", 64), Bytes("boot_filename", 128), # BOOTP/DHCP options # "The first four bytes contain the (decimal) values 99, 130, 83 and 99" Const(Bytes("magic", 4), b"\x63\x82\x53\x63"), Rename("options", OptionalGreedyRange(dhcp_option)), ) if __name__ == "__main__": test = unhexlify( six.b("0101060167c05f5a00000000"