class FlowMatchDescriptorField_v1_0(Packet): """ OpenFlow Flow Match Descriptor Field """ name = 'FlowMatchDescriptorField_v1_0' fields_desc = [ IntField('<FlowWildcard>', None), ShortField('Ingresss<PortNumber>', None), SourceMACField(MACField('EthernetSourceAddress', None)), DestMACField(MACField('EthernetDestinationAddress', None)), XShortField('<VD+802.1QVID>', None), XByteField('PCP', None), XByteField('Reserved', None), ShortField('EthernetType/Length', None), ByteField('IPv4Protocol', None), X3BytesField('_Reserved', None), SourceIPField('IPv4SourceAddress', None), IPField('IPv4DestinationAddress', None), ShortField('SourcePort', None), ShortField('DestinationPort', None), ]
class PortDescriptorField_v1_0(Packet): """ OpenFlow Port Descriptor Field """ name = 'PortDescriptorField_v1_0' fields_desc = [ ShortField('<PortNumber>', None), MACField('EthernetAddress', None), StrFixedLenField('PortDescription', None, 16), XIntField('<PortConfigurationFlags>', None), XIntField('<PortStatusFlags>', None), XIntField('Current<PortFeatureFlags>', None), XIntField('Advertising<PortFeatureFlags>', None), XIntField('Supported<PortFeatureFlags>', None), XIntField('LinkLayerNeighborAdvertising<PortFeatureFlags>', None), ]
class PortDescriptorField_v1_3(Packet): """ OpenFlow Port Descriptor Field """ name = 'PortDescriptorField_v1_3' fields_desc = [ ShortField('<PortNumber>', None), XByteField('PortDescriptorFieldPad', None), MACField('EthernetAddress', None), XByteField('PortDescriptorFieldPad2', None), StrFixedLenField('Name', None, 16), XIntField('<PortConfigurationFlags>', None), XIntField('<PortStatusFlags>', None), XIntField('Current<PortFeatureFlags>', None), XIntField('Advertising<PortFeatureFlags>', None), XIntField('Supported<PortFeatureFlags>', None), XIntField('PeerAdvertising<PortFeatureFlags>', None), IntField('CurrentSpeed', None), IntField('MaxSpeed', None), ]
class OpenFlowBody_v1_3(Packet): """ OpenFlow Packet v1.3 """ name = 'OpenFlowBody_v1_3' fields_desc = [ # Header ByteEnumField('Type', None, ofp_v1_3_message_type), ShortField('Length', None), IntField('ID', None), # Error message body ConditionalField(ShortField('ErrorType', None), lambda pkt: pkt.Type == 1), ConditionalField(ShortField('ErrorCode', None), lambda pkt: pkt.Type == 1), # Echo Request / Echo Reply message body ConditionalField(StrField('Data', None), lambda pkt: pkt.Type in [1, 2, 3]), # Vendor message body #ConditionalField(IntField('VendorID', None), lambda pkt: pkt.Type == 4), # type ???? # Experimenter ConditionalField(XIntField('ExperimenterID', None), lambda pkt: pkt.Type == 4), ConditionalField(IntField('ExperimenterType', None), lambda pkt: pkt.Type == 4), # Features Reply message body ConditionalField(XLongField('DatapathID', None), lambda pkt: pkt.Type == 6), ConditionalField(IntField('MaxBuffers', None), lambda pkt: pkt.Type == 6), ConditionalField(ByteField('MaxTables', None), lambda pkt: pkt.Type == 6), ConditionalField(ByteField('AuxiliaryID', None), lambda pkt: pkt.Type == 6), ConditionalField(XByteField('FeaturesReplyPad', None), lambda pkt: pkt.Type == 6), ConditionalField(XIntField('Capabilities', None), lambda pkt: pkt.Type == 6), ConditionalField(IntField('FeaturesReplyReserved', None), lambda pkt: pkt.Type == 6), # Set Config message body ConditionalField(XShortField('SwitchConfigurationFlags', None), lambda pkt: pkt.Type == 9), ConditionalField(ShortField('MissSendLength', None), lambda pkt: pkt.Type == 9), # Packet Input Notification message body ConditionalField( IntField('PacketInputNotificationPacketBufferID', None), lambda pkt: pkt.Type == 10), ConditionalField(ShortField('EthernetFrameLength', None), lambda pkt: pkt.Type == 10), ConditionalField(ByteField('PacketInputNotificationReason', None), lambda pkt: pkt.Type == 10), ConditionalField(ByteField('PacketInputNotificationTableID', None), lambda pkt: pkt.Type == 10), ConditionalField(XLongField('PacketInputNotificationCookie', None), lambda pkt: pkt.Type == 10), # Flow Removed Notification message body ConditionalField(XLongField('FlowRemovedNotificationCookie', None), lambda pkt: pkt.Type == 11), ConditionalField(ShortField('FlowRemovedNotificationPriority', None), lambda pkt: pkt.Type == 11), ConditionalField(ByteField('FlowRemovedNotificationReason', None), lambda pkt: pkt.Type == 11), ConditionalField(ByteField('FlowRemovedNotificationTableID', None), lambda pkt: pkt.Type == 11), ConditionalField(IntField('Duration_sec', None), lambda pkt: pkt.Type == 11), ConditionalField(IntField('Duration_nsec', None), lambda pkt: pkt.Type == 11), ConditionalField( ShortField('FlowRemovedNotificationIdleTimeout', None), lambda pkt: pkt.Type == 11), ConditionalField(ShortField('HardTimeout', None), lambda pkt: pkt.Type == 11), ConditionalField(LongField('NumberOfPacketsTransferred', None), lambda pkt: pkt.Type == 11), ConditionalField(LongField('NumberOfOctetsTransferred', None), lambda pkt: pkt.Type == 11), # Port Status Notification message body ConditionalField(ByteField('PortStatusNotificationReason', None), lambda pkt: pkt.Type == 12), ConditionalField(XByteField('PortStatusNotificationPad', None), lambda pkt: pkt.Type == 12), ConditionalField( _PacketField('PortStatusNotification<PortDescriptors>', None, PortDescriptorField_v1_3, 39), lambda pkt: pkt.Type == 12), # Packet Output message body ConditionalField(IntField('PacketOutputPacketBufferID', None), lambda pkt: pkt.Type == 13), ConditionalField(IntField('PacketOutputIngress<PortNumber>', None), lambda pkt: pkt.Type == 13), ConditionalField(ShortField('LengthOfActionDescriptors', None), lambda pkt: pkt.Type == 13), ConditionalField(XByteField('PacketOutputPad', None), lambda pkt: pkt.Type == 13), ConditionalField( _PacketField('PacketOutput<ActionDescriptors>', None, ActionDescriptorField_v1_3, 5), lambda pkt: pkt.Type == 13), # Flow Modification message body ConditionalField(LongField('FlowModificationCookie', None), lambda pkt: pkt.Type == 14), ConditionalField(XLongField('FlowModificationCookieMask', None), lambda pkt: pkt.Type == 14), ConditionalField(ByteField('FlowModificationTableID', None), lambda pkt: pkt.Type == 14), ConditionalField(ByteField('FlowModificationCommand', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('FlowModificationIdleTimeout', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('FlowModificationHardTimeout', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('FlowModificationPriority', None), lambda pkt: pkt.Type == 14), ConditionalField(IntField('FlowModificationPacketBufferID', None), lambda pkt: pkt.Type == 14), ConditionalField(IntField('FlowModificationOutputPort', None), lambda pkt: pkt.Type == 14), ConditionalField(IntField('FlowModificationOutputGroup', None), lambda pkt: pkt.Type == 14), ConditionalField(XShortField('FlowModificationFlags', None), lambda pkt: pkt.Type == 14), ConditionalField(XByteField('FlowModificationPad', None), lambda pkt: pkt.Type == 14), # Group Modification message body ConditionalField(ShortField('GroupModificationCommand', None), lambda pkt: pkt.Type == 15), ConditionalField(ByteField('GroupModificationType', None), lambda pkt: pkt.Type == 15), ConditionalField(ByteField('GroupModificationPad', None), lambda pkt: pkt.Type == 15), ConditionalField(IntField('GroupModificationGroupID', None), lambda pkt: pkt.Type == 15), ConditionalField( _PacketField('GroupModificationBucket', None, OpenFlowBucket_v1_3, 18), lambda pkt: pkt.Type == 15), # Port Modification message body ConditionalField(ShortField('PortModification<PortNumber>', None), lambda pkt: pkt.Type == 16), ConditionalField(XByteField('PortModificationPad', None), lambda pkt: pkt.Type == 16), ConditionalField(MACField('PortModificationEthernetAddress', None), lambda pkt: pkt.Type == 16), ConditionalField(XByteField('PortModificationPad2', None), lambda pkt: pkt.Type == 16), ConditionalField(XIntField('<PortConfigurationFlags>', None), lambda pkt: pkt.Type == 16), ConditionalField(XIntField('<PortConfigurationFlags>Mask', None), lambda pkt: pkt.Type == 16), ConditionalField(XIntField('<PortConfigurationFlags>Advertise', None), lambda pkt: pkt.Type == 16), ConditionalField(XByteField('PortModificationPad3', None), lambda pkt: pkt.Type == 16), # Table Modification message body ConditionalField(ByteField('TableModificationTableID', None), lambda pkt: pkt.Type == 17), ConditionalField(XByteField('TableModificationPad', None), lambda pkt: pkt.Type == 17), ConditionalField(XIntField('TableModificationConfiguration', None), lambda pkt: pkt.Type == 17), # Multipart Request / Multipart Reply message body ConditionalField(ShortField('MultipartType', None), lambda pkt: pkt.Type in [18, 19]), ConditionalField(XShortField('MultipartFlags', None), lambda pkt: pkt.Type in [18, 19]), ConditionalField(XByteField('MultipartPad', None), lambda pkt: pkt.Type in [18, 19]), ConditionalField(ByteField('MultipartBody', None), lambda pkt: pkt.Type in [18, 19]), # Barrier Reply message body ConditionalField(IntField('BarrierReplyID', None), lambda pkt: pkt.Type == 21), # Queue Get Config Request / Queue Get Config Reply message body ConditionalField(IntField('QueueGetConfigRequestPort', None), lambda pkt: pkt.Type in [22, 23]), ConditionalField(ByteField('QueueGetConfigRequestPad', None), lambda pkt: pkt.Type in [22, 23]), ConditionalField( _PacketField('OpenFlowPacketQueue', None, OpenFlowPacketQueue_v1_3, 16), lambda pkt: pkt.Type == 23), # Role Request / Role Reply message body ConditionalField(IntField('RoleRequestRole', None), lambda pkt: pkt.Type in [24, 25]), ConditionalField(ByteField('RoleRequestPad', None), lambda pkt: pkt.Type in [24, 25]), ConditionalField(LongField('RoleRequestGenerationID', None), lambda pkt: pkt.Type in [24, 25]), # Get Async Reply / Set Async messages body ConditionalField(XIntField('GetAsyncReplyPacketInMask', None), lambda pkt: pkt.Type in [27, 28]), ConditionalField(XIntField('GetAsyncReplyPortStatusMask', None), lambda pkt: pkt.Type in [27, 28]), ConditionalField(XIntField('GetAsyncReplyFlowRemovedMask', None), lambda pkt: pkt.Type in [27, 28]), # Meter Modification message body ConditionalField(ShortField('MeterModificationCommand', None), lambda pkt: pkt.Type == 29), ConditionalField(XShortField('MeterModificationFlags', None), lambda pkt: pkt.Type == 29), ConditionalField(IntField('MeterModificationMeterID', None), lambda pkt: pkt.Type == 29), ConditionalField( _PacketField('MeterModificationMeterBand', None, OpenFlowMeterBand_v1_3, 12), lambda pkt: pkt.Type == 29), StrField('Payload', None), ]
class OpenFlowBody_v1_0(Packet): """ OpenFlow Packet v1.0 """ name = 'OpenFlowBody_v1_0' fields_desc = [ # Header ByteEnumField('Type', None, ofp_v1_0_message_type), ShortField('Length', None), IntField('ID', None), # Error message body ConditionalField(ShortField('ErrorType', None), lambda pkt: pkt.Type == 1), ConditionalField(ShortField('ErrorCode', None), lambda pkt: pkt.Type == 1), # Echo Request / Echo Reply message body ConditionalField(StrField('Data', None), lambda pkt: pkt.Type in [2, 3]), # Vendor message body ConditionalField(IntField('VendorID', None), lambda pkt: pkt.Type == 4), # Features Reply message body ConditionalField(XLongField('DatapathID', None), lambda pkt: pkt.Type == 6), ConditionalField(IntField('AvailableNumberOfPacketsCanBeHeld', None), lambda pkt: pkt.Type == 6), ConditionalField(ByteField('NumberOfFlowTabs', None), lambda pkt: pkt.Type == 6), ConditionalField(X3BytesField('FeaturesReplyReserved', None), lambda pkt: pkt.Type == 6), ConditionalField(XIntField('<SwitchCapabilityFlags>', None), lambda pkt: pkt.Type == 6), ConditionalField(XIntField('ActionCapabilityFlags', None), lambda pkt: pkt.Type == 6), ConditionalField( _PacketField('FeaturesReply<PortDescriptors>', None, PortDescriptorField_v1_0, 48), lambda pkt: pkt.Type == 6), # Get Config Reply / Set Config message body ConditionalField(XShortField('SwitchConfigurationFlags', None), lambda pkt: pkt.Type in [8, 9]), ConditionalField(ShortField('MissSendLength', None), lambda pkt: pkt.Type in [8, 9]), # Packet Input Notification message body ConditionalField( IntField('PacketInputNotificationPacketBufferID', None), lambda pkt: pkt.Type == 10), ConditionalField(ShortField('EthernetFrameLength', None), lambda pkt: pkt.Type == 10), ConditionalField( ShortField('PacketInputNotificationIngresss<PortNumber>', None), lambda pkt: pkt.Type == 10), ConditionalField(ByteField('PacketInputNotificationReason', None), lambda pkt: pkt.Type == 10), ConditionalField(XByteField('PacketInputNotificationReserved', None), lambda pkt: pkt.Type == 10), ConditionalField( StrLenField('EthenretFrame', None, length_from=lambda pkt: pkt.EthernetFrameLength), lambda pkt: pkt.Type == 10), # Flow Removed Notification message body ConditionalField( _PacketField('FlowRemovedNotification<FlowMatchDescriptor>', None, FlowMatchDescriptorField_v1_0, 40), lambda pkt: pkt.Type == 11), ConditionalField(ShortField('FlowRemovedNotificationPriority', None), lambda pkt: pkt.Type == 11), ConditionalField(ByteField('FlowRemovedNotificationReason', None), lambda pkt: pkt.Type == 11), ConditionalField(XByteField('FlowRemovedNotificationReserved', None), lambda pkt: pkt.Type == 11), ConditionalField(IntField('LifetimeDuration', None), lambda pkt: pkt.Type == 11), ConditionalField( ShortField('FlowRemovedNotificationSoftLifetime', None), lambda pkt: pkt.Type == 11), ConditionalField( StrFixedLenField('FlowRemovedNotification_Reserved', None, 48), lambda pkt: pkt.Type == 11), ConditionalField(LongField('NumberOfPacketsTransferred', None), lambda pkt: pkt.Type == 11), ConditionalField(LongField('NumberOfOctetsTransferred', None), lambda pkt: pkt.Type == 11), # Port Status Notification message body ConditionalField(ByteField('PortStatusNotificationReason', None), lambda pkt: pkt.Type == 12), ConditionalField( StrFixedLenField('PortStatusNotificationReserved', None, 64), lambda pkt: pkt.Type == 12), ConditionalField( _PacketField('PortStatusNotification<PortDescriptors>', None, PortDescriptorField_v1_0, 48), lambda pkt: pkt.Type == 12), # Packet Output message body ConditionalField(IntField('PacketOutputPacketBufferID', None), lambda pkt: pkt.Type == 13), ConditionalField(ShortField('PacketOutputIngress<PortNumber>', None), lambda pkt: pkt.Type == 13), ConditionalField(ShortField('LengthOfActionDescriptors', None), lambda pkt: pkt.Type == 13), ConditionalField( _PacketField('PacketOutput<ActionDescriptors>', None, ActionDescriptorField_v1_0), ## ???? bytes ## lambda pkt: pkt.Type == 13), ConditionalField(StrField('<PacketData>', None), lambda pkt: pkt.Type == 13), # Flow Modification message body ConditionalField( _PacketField('FlowModification<FlowMatchDescriptor>', None, FlowMatchDescriptorField_v1_0, 40), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('Command', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('FlowModificationSoftLifetime', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('HardLifetime', None), lambda pkt: pkt.Type == 14), ConditionalField(ShortField('FlowModificationPriority', None), lambda pkt: pkt.Type == 14), ConditionalField(IntField('FlowModificationPacketBufferID', None), lambda pkt: pkt.Type == 14), ConditionalField( ShortField('FlowModificationEgress<PortNumber>', None), lambda pkt: pkt.Type == 14), ConditionalField(XShortField('FlowModificationCU', None), lambda pkt: pkt.Type == 14), ConditionalField(XIntField('FlowModificationReserved', None), lambda pkt: pkt.Type == 14), ConditionalField( _PacketField('FlowModification<ActionDescriptors>', None, ActionDescriptorField_v1_0), ## ???? bytes lambda pkt: pkt.Type == 14), # Port Modification message body ConditionalField(ShortField('PortModification<PortNumber>', None), lambda pkt: pkt.Type == 15), ConditionalField(MACField('Ethernet Address', None), lambda pkt: pkt.Type == 15), ConditionalField(XIntField('<PortConfigurationFlags>', None), lambda pkt: pkt.Type == 15), ConditionalField(XIntField('<PortConfigurationFlags>Mask', None), lambda pkt: pkt.Type == 15), ConditionalField(XIntField('<PortFeatureFlags>', None), lambda pkt: pkt.Type == 15), # Stats Request message body ConditionalField( _PacketField('StatsRequest', None, StatsRequestBody_v1_0, 48), lambda pkt: pkt.Type == 16), # Stats Reply message body ConditionalField( _PacketField('StatsReply', None, StatsReplyBody_v1_0), ## ???? bytes lambda pkt: pkt.Type == 17), StrField('Payload', None), ]
class ActionDescriptorField_v1_0(Packet): """ OpenFlow Action Descriptor Field """ name = 'ActionDescriptorField_v1_0' fields_desc = [ ByteEnumField('Type', None, ofp_v1_0_action_descriptor_type), ShortField('Length', None), # Output Action Descriptor ConditionalField(ShortField('Egress<PortNumber>', None), lambda pkt: pkt.Type == 0), ConditionalField(ShortField('MaxLength', None), lambda pkt: pkt.Type == 0), # VLAN VID Action Descriptor ConditionalField(XShortField('CU+802.1QVID', None), lambda pkt: pkt.Type == 1), ConditionalField(XShortField('VLANVIDReserved', None), lambda pkt: pkt.Type == 1), # VLAN PCP Action Descriptor ConditionalField(XByteField('CU+PCP', None), lambda pkt: pkt.Type == 2), ConditionalField(X3BytesField('VLANPCPReserved', None), lambda pkt: pkt.Type == 2), # Strip VLAN tag Action Descriptor ConditionalField(XIntField('StripVLANTagReserved', None), lambda pkt: pkt.Type == 3), # Ethernet Address Action Descriptor (Ethernet source address) / # Ethernet Address Action Descriptor (Ethernet destination address) ConditionalField( SourceMACField(MACField('EthernetSourceAddress', None)), lambda pkt: pkt.Type == 4), ConditionalField( DestMACField(MACField('EthernetDestinationAddress', None)), lambda pkt: pkt.Type == 5), ConditionalField(StrFixedLenField('EthernetAddressReserved', None, 48), lambda pkt: pkt.Type in [4, 5]), # IPv4 Address Action Descriptor (IPv4 source address) / # IPv4 Address Action Descriptor (IPv4 destination address) ConditionalField(SourceIPField('IPv4SourceAddress', None), lambda pkt: pkt.Type == 6), ConditionalField(IPField('IPv4DestinationAddress', None), lambda pkt: pkt.Type == 7), # IPv4 DSCP Action Descriptor ConditionalField(ByteField('IPv4DSCP+CU', None), lambda pkt: pkt.Type == 8), ConditionalField(X3BytesField('IPv4DSCPReserved', None), lambda pkt: pkt.Type == 8), # TCP/UDP Port Action Descriptor (TCP/UDP source port) / # TCP/UDP Port Action Descriptor (TCP/UDP destination port) ConditionalField(ShortField('SourcePort', None), lambda pkt: pkt.Type == 9), ConditionalField(ShortField('DestinationPort', None), lambda pkt: pkt.Type == 10), ConditionalField(ShortField('TCP/UDPReserved', None), lambda pkt: pkt.Type in [9, 10]), # Vendor Action Descriptor ConditionalField(IntField('VendorID', None), lambda pkt: pkt.Type == 65535), ]
class P4wifi(Packet): name = "P4wifi" fields_desc = [ MACField("bssid", None), MACField("mac", None)]