class SCTPChunkParamIPv6Addr(_SCTPChunkParam, Packet): fields_desc = [ ShortEnumField("type", 6, sctpchunkparamtypes), ShortField("len", 20), IP6Field("addr", "::1"), ]
def any2i(self, pkt, x): return IP6Field.any2i(self, pkt, x)
class _SDOption_IP6(_SDOption): fields_desc = [ _SDOption_Header, IP6Field("addr", "2001:cdba:0000:0000:0000:0000:3257:9652"), _SDOption_Tail ]
class LLTDAttributeIPv6Address(LLTDAttribute): name = "LLTD Attribute - IPv6 Address" fields_desc = [ ByteField("len", 16), IP6Field("ipv6", "::"), ]
class SAPMS(Packet): """SAP Message Server packet This packet is used for the Message Server protocol. """ name = "SAP Message Server" fields_desc = [ StrFixedLenField("eyecatcher", "**MESSAGE**\x00", 12), ByteField("version", 0x04), ByteEnumKeysField("errorno", 0x00, ms_errorno_values), StrFixedLenField("toname", "-" + " " * 39, 40), FlagsField("msgtype", 0, 8, ["DIA", "UPD", "ENQ", "BTC", "SPO", "UP2", "ATP", "ICM"]), ByteField("reserved", 0x00), ByteEnumKeysField("domain", 0x00, ms_domain_values), ByteField("reserved", 0x00), StrFixedLenField("key", "\x00" * 8, 8), ByteEnumKeysField("flag", 0x01, ms_flag_values), ByteEnumKeysField("iflag", 0x01, ms_iflag_values), StrFixedLenField("fromname", "-" + " " * 39, 40), ShortField("padd", 0x0000), # OpCode fields ConditionalField(ByteEnumKeysField("opcode", 0x00, ms_opcode_values), lambda pkt: pkt.iflag in [0x00, 0x01]), ConditionalField( ByteEnumKeysField("opcode_error", 0x00, ms_opcode_error_values), lambda pkt: pkt.iflag in [0x00, 0x01]), ConditionalField(ByteField("opcode_version", 0x01), lambda pkt: pkt.iflag in [0x00, 0x01]), ConditionalField(ByteField("opcode_charset", 0x03), lambda pkt: pkt.iflag in [0x00, 0x01]), ConditionalField( StrField("opcode_value", ""), lambda pkt: pkt.iflag in [0x00, 0x01] and pkt.opcode not in [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x11, 0x1c, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2f, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4a ]), # Adm OpCode fields ConditionalField( StrFixedLenField("adm_eyecatcher", "AD-EYECATCH\x00", 12), lambda pkt: pkt.iflag == 0x05), ConditionalField(ByteField("adm_version", 0x01), lambda pkt: pkt.iflag == 0x05), ConditionalField( ByteEnumKeysField("adm_type", 0x01, ms_adm_type_values), lambda pkt: pkt.iflag == 0x05), ConditionalField(IntToStrField("adm_recsize", 104, 11), lambda pkt: pkt.iflag == 0x05), ConditionalField(IntToStrField("adm_recno", 1, 11), lambda pkt: pkt.iflag == 0x05), ConditionalField(PacketListField("adm_records", None, SAPMSAdmRecord), lambda pkt: pkt.iflag == 0x05), # Server List fields ConditionalField( PacketListField("clients", None, SAPMSClient1), lambda pkt: pkt. opcode in [0x02, 0x03, 0x04, 0x05] and pkt.opcode_version == 0x01), ConditionalField( PacketListField("clients", None, SAPMSClient2), lambda pkt: pkt. opcode in [0x02, 0x03, 0x04, 0x05] and pkt.opcode_version == 0x02), ConditionalField( PacketListField("clients", None, SAPMSClient3), lambda pkt: pkt. opcode in [0x02, 0x03, 0x04, 0x05] and pkt.opcode_version == 0x03), ConditionalField( PacketListField("clients", None, SAPMSClient4), lambda pkt: pkt. opcode in [0x02, 0x03, 0x04, 0x05] and pkt.opcode_version == 0x04), # Change IP fields ConditionalField(IPField("change_ip_addressv4", "0.0.0.0"), lambda pkt: pkt.opcode == 0x06), ConditionalField( IP6Field("change_ip_addressv6", "::"), lambda pkt: pkt.opcode == 0x06 and pkt.opcode_version == 0x02), # Get/Set Text fields ConditionalField(StrFixedLenField("text_name", "", 40), lambda pkt: pkt.opcode in [0x22, 0x23]), ConditionalField( FieldLenField("text_length", None, length_of="text_value", fmt="!I"), lambda pkt: pkt.opcode in [0x22, 0x23]), ConditionalField( StrFixedLenField("text_value", "", length_from=lambda pkt: pkt.text_length or 80), lambda pkt: pkt.opcode in [0x22, 0x23]), # Counter fields ConditionalField( PacketField("counter", None, SAPMSCounter), lambda pkt: pkt.opcode in [0x24, 0x25, 0x26, 0x27, 0x28, 0x29]), ConditionalField(PacketListField("counters", None, SAPMSCounter), lambda pkt: pkt.opcode in [0x2a]), # Security Key 1 fields ConditionalField(StrFixedLenField("security_name", None, 40), lambda pkt: pkt.opcode in [0x07, 0x08]), ConditionalField(StrFixedLenField("security_key", None, 256), lambda pkt: pkt.opcode in [0x07, 0x08]), # Security Key 2 fields ConditionalField(IPField("security2_addressv4", "0.0.0.0"), lambda pkt: pkt.opcode == 0x09), ConditionalField(ShortField("security2_port", 0), lambda pkt: pkt.opcode == 0x09), ConditionalField(StrFixedLenField("security2_key", None, 256), lambda pkt: pkt.opcode == 0x09), ConditionalField(IP6Field("security2_addressv6", "::"), lambda pkt: pkt.opcode == 0x09), # Hardware ID field ConditionalField(StrNullFixedLenField("hwid", "", length=99), lambda pkt: pkt.opcode == 0x0a), # Statistics ConditionalField(PacketField("stats", None, SAPMSStat3), lambda pkt: pkt.opcode == 0x11 and pkt.flag == 0x03), # Codepage ConditionalField(IntField("codepage", 0), lambda pkt: pkt.opcode == 0x1c and pkt.flag == 0x03), # Dump Info Request fields ConditionalField(ByteField("dump_dest", 0x02), lambda pkt: pkt.opcode == 0x1E and pkt.flag == 0x02), ConditionalField(StrFixedLenField("dump_filler", "\x00\x00\x00", 3), lambda pkt: pkt.opcode == 0x1E and pkt.flag == 0x02), ConditionalField(ShortField("dump_index", 0x00), lambda pkt: pkt.opcode == 0x1E and pkt.flag == 0x02), ConditionalField( ShortEnumKeysField("dump_command", 0x01, ms_dump_command_values), lambda pkt: pkt.opcode == 0x1E and pkt.flag == 0x02), ConditionalField(StrFixedLenField("dump_name", "\x00" * 40, 40), lambda pkt: pkt.opcode == 0x1E and pkt.flag == 0x02), # File Reload fields ConditionalField( ByteEnumKeysField("file_reload", 0, ms_file_reload_values), lambda pkt: pkt.opcode == 0x1f), ConditionalField(StrFixedLenField("file_filler", "\x00\x00\x00", 3), lambda pkt: pkt.opcode == 0x1f), # Get/Set/Del Logon fields ConditionalField(PacketField("logon", None, SAPMSLogon), lambda pkt: pkt.opcode in [0x2b, 0x2c, 0x2d]), # Server Disconnect/Shutdown fields ConditionalField(PacketField("shutdown_client", None, SAPMSClient3), lambda pkt: pkt.opcode in [0x2e, 0x2f, 0x30, 0x4a]), ConditionalField( FieldLenField("shutdown_reason_length", None, length_of="shutdown_reason", fmt="!H"), lambda pkt: pkt.opcode in [0x2e, 0x2f, 0x30, 0x4a]), ConditionalField( StrLenField("shutdown_reason", "", length_from=lambda pkt: pkt.shutdown_reason_length), lambda pkt: pkt.opcode in [0x2e, 0x2f, 0x30, 0x4a]), # Get/Set Property fields ConditionalField(PacketField("property", None, SAPMSProperty), lambda pkt: pkt.opcode in [0x43, 0x44, 0x45]), # IP/Port to name fields ConditionalField( IPField("ip_to_name_address4", "0.0.0.0"), lambda pkt: pkt.opcode == 0x46 and pkt.opcode_version == 0x01), ConditionalField( IP6Field("ip_to_name_address6", "::"), lambda pkt: pkt.opcode == 0x46 and pkt.opcode_version == 0x02), ConditionalField(ShortField("ip_to_name_port", 0), lambda pkt: pkt.opcode == 0x46), ConditionalField( FieldLenField("ip_to_name_length", None, length_of="ip_to_name", fmt="!I"), lambda pkt: pkt.opcode == 0x46), ConditionalField( StrLenField("ip_to_name", "", length_from=lambda pkt: pkt.logonname_length), lambda pkt: pkt.opcode == 0x46), # Check ACL fields ConditionalField(ShortField("error_code", 0), lambda pkt: pkt.opcode == 0x47), ConditionalField(StrFixedLenField("acl", "", 46), lambda pkt: pkt.opcode == 0x47), ]
def __init__(self, name, default, length_of=None): IP6Field.__init__(self, name, default) self.length_of = length_of
class SAPRFC(Packet): """SAP Remote Function Call packet This packet is used for the Remote Function Call (RFC) protocol. """ name = "SAP Remote Function Call" fields_desc = [ ByteField( "version", 3 ), # If the version is 3, the packet has a size > 88h, versions 1 and 2 are 40h ByteEnumKeysField("req_type", 0, rfc_req_type_values), # Normal client fields (GW_NORMAL_CLIENT) ConditionalField(IPField("address", "0.0.0.0"), lambda pkt: pkt.req_type == 0x03), ConditionalField(IntField("padd1", 0), lambda pkt: pkt.req_type == 0x03), ConditionalField(StrFixedLenPaddedField("service", "", length=10), lambda pkt: pkt.req_type == 0x03), ConditionalField(StrFixedLenField("codepage", "1100", length=4), lambda pkt: pkt.req_type == 0x03), ConditionalField(StrFixedLenField("padd2", "\x00" * 6, length=6), lambda pkt: pkt.req_type == 0x03), ConditionalField(StrFixedLenPaddedField("lu", "", length=8), lambda pkt: pkt.req_type == 0x03), ConditionalField(StrFixedLenPaddedField("tp", "", length=8), lambda pkt: pkt.req_type == 0x03), ConditionalField( StrFixedLenPaddedField("conversation_id", "", length=8), lambda pkt: pkt.req_type == 0x03), ConditionalField(ByteField("appc_header_version", 6), lambda pkt: pkt.req_type == 0x03), ConditionalField(ByteField("accept_info", 0xcb), lambda pkt: pkt.req_type == 0x03), ConditionalField(SignedShortField("idx", -1), lambda pkt: pkt.req_type == 0x03), ConditionalField( IP6Field("address6", "::"), lambda pkt: pkt.req_type == 0x03 and pkt.version == 3), ConditionalField(IntField("rc", 0), lambda pkt: pkt.req_type == 0x03), ConditionalField(ByteField("echo_data", 0), lambda pkt: pkt.req_type == 0x03), ConditionalField(ByteField("filler", 0), lambda pkt: pkt.req_type == 0x03), # Monitor Command fields (GW_SEND_CMD) ConditionalField(ByteEnumKeysField("cmd", 0, rfc_monitor_cmd_values), lambda pkt: pkt.req_type == 0x09), # General padding for non implemented request types ConditionalField(StrFixedLenField("padd_v12", "\x00" * 61, length=61), lambda pkt: pkt.version < 3 and pkt.req_type == 0x09), ConditionalField( StrFixedLenField("padd_v12", "\x00" * 62, length=62), lambda pkt: pkt.version < 3 and pkt.req_type not in [0x03, 0x09]), ConditionalField( StrFixedLenField("padd_v3", "\x00" * 133, length=133), lambda pkt: pkt.version == 3 and pkt.req_type == 0x09), ConditionalField( StrFixedLenField("padd_v3", "\x00" * 134, length=134), lambda pkt: pkt.version == 3 and pkt.req_type not in [0x03, 0x09]), ]
def i2repr(self, pkt, x): return IP6Field.i2repr(self, pkt, x)
def h2i(self, pkt, x): return IP6Field.h2i(self, pkt, x)
class ICMPExtensionInterfaceInformation(ICMPExtensionObject): name = 'ICMP Extension Object - Interface Information Object (RFC5837)' fields_desc = [ ShortField('len', None), ByteField('classnum', 2), BitField('interface_role', 0, 2), BitField('reserved', 0, 2), BitField('has_ifindex', 0, 1), BitField('has_ipaddr', 0, 1), BitField('has_ifname', 0, 1), BitField('has_mtu', 0, 1), ConditionalField( IntField('ifindex', None), lambda pkt: pkt.has_ifindex == 1), ConditionalField( ShortField('afi', None), lambda pkt: pkt.has_ipaddr == 1), ConditionalField( ShortField('reserved2', 0), lambda pkt: pkt.has_ipaddr == 1), ConditionalField( IPField('ip4', None), lambda pkt: pkt.afi == 1), ConditionalField( IP6Field('ip6', None), lambda pkt: pkt.afi == 2), ConditionalField( FieldLenField('ifname_len', None, fmt='B', length_of='ifname'), lambda pkt: pkt.has_ifname == 1), ConditionalField( StrLenField('ifname', None, length_from=lambda pkt: pkt.ifname_len), lambda pkt: pkt.has_ifname == 1), ConditionalField( IntField('mtu', None), lambda pkt: pkt.has_mtu == 1) ] def self_build(self, field_pos_list=None): if self.afi is None: if self.ip4 is not None: self.afi = 1 elif self.ip6 is not None: self.afi = 2 if self.has_ifindex and self.ifindex is None: warning('has_ifindex set but ifindex is not set.') if self.has_ipaddr and self.afi is None: warning('has_ipaddr set but afi is not set.') if self.has_ipaddr and self.ip4 is None and self.ip6 is None: warning('has_ipaddr set but ip4 or ip6 is not set.') if self.has_ifname and self.ifname is None: warning('has_ifname set but ifname is not set.') if self.has_mtu and self.mtu is None: warning('has_mtu set but mtu is not set.') return ICMPExtensionObject.self_build(self, field_pos_list=field_pos_list)
def __init__(self, name, default, size, length_of=None): IP6Field.__init__(self, name, default) self.length_of = length_of
class ISIS_IPv6NeighborAddressSubTlv(ISIS_GenericSubTlv): name = "ISIS IPv6 Neighbor Address (S)" fields_desc = [ByteEnumField("type", 13, _isis_subtlv_names_1), FieldLenField("len", None, length_of="address", fmt="B"), IP6Field("address", "::")]
class SAPMSProperty(Packet): """SAP Message Server Property packet. Packet containing information about properties. """ name = "SAP Message Server Property" fields_desc = [ StrNullFixedLenField("client", None, 40), IntEnumField("id", 0x00, ms_property_id_values), # MS_PROPERTY_VHOST ConditionalField(ShortEnumKeysField("logon", 0, ms_logon_type_values), lambda pkt: pkt.id in [0x02]), ConditionalField(StrFixedLenField("pad", None, 12), lambda pkt: pkt.id in [0x02]), ConditionalField(ShortField("len", 0), lambda pkt: pkt.id in [0x02]), ConditionalField( StrLenField("value", "", length_from=lambda pkt: pkt.len), lambda pkt: pkt.id in [0x02]), ConditionalField(ShortField("pad2", 0xffff), lambda pkt: pkt.id in [0x02]), # MS_PROPERTY_IPADR ConditionalField(IPField("address", "0.0.0.0"), lambda pkt: pkt.id in [0x03]), ConditionalField(IP6Field("address6", "::"), lambda pkt: pkt.id in [0x03]), # MS_PROPERTY_PARAM ConditionalField( FieldLenField("param_len", 0, length_of="param", fmt="I"), lambda pkt: pkt.id in [0x04]), ConditionalField( StrLenField("param", "", length_from=lambda pkt: pkt.param_len), lambda pkt: pkt.id in [0x04]), ConditionalField( StrLenField("param_padding", "", length_from=lambda pkt: 100 - pkt.param_len), lambda pkt: pkt.id in [0x04]), ConditionalField(ShortField("pad3", 0), lambda pkt: pkt.id in [0x04]), ConditionalField( FieldLenField("value_len", 0x0, length_of="value", fmt="H"), lambda pkt: pkt.id in [0x04]), ConditionalField( StrLenField("value", "", length_from=lambda pkt: pkt.value_len), lambda pkt: pkt.id in [0x04]), # MS_PROPERTY_SERVICE ConditionalField(ShortField("service", 0), lambda pkt: pkt.id in [0x05]), ConditionalField(ByteField("value", 0), lambda pkt: pkt.id in [0x05]), # Release Information fields ConditionalField(StrNullFixedLenField("release", "720", length=10), lambda pkt: pkt.id in [0x07]), ConditionalField(IntField("patchno", 0), lambda pkt: pkt.id in [0x07]), ConditionalField(IntField("supplvl", 0), lambda pkt: pkt.id in [0x07]), ConditionalField(IntField("platform", 0), lambda pkt: pkt.id in [0x07]), ]
class _SDOption_IP6(_SDOption): fields_desc = [ _SDOption_Header, IP6Field("addr", "2001:db8::1"), _SDOption_Tail ]