docstring
stringlengths
52
499
function
stringlengths
67
35.2k
__index_level_0__
int64
52.6k
1.16M
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff=None, offset=0): property_type = UBInt16(enum_ref=TableFeaturePropType) property_type.unpack(buff, offset) self.__class__ = TableFeaturePropType(property_type.value).find_class() length = UBInt16() length.unpack(buff, offset=offset+2) super...
592,908
Create a InstructionsProperty with the optional parameters below. Args: type(|TableFeaturePropType_v0x04|): Property Type value of this instance. next_table_ids(|ListOfInstruction_v0x04|): List of InstructionGotoTable instances.
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_INSTRUCTIONS, instruction_ids=None): super().__init__(property_type=property_type) self.instruction_ids = instruction_ids if instruction_ids else [] self.update_length()
592,909
Create a NextTablesProperty with the optional parameters below. Args: type(|TableFeaturePropType_v0x04|): Property Type value of this instance. next_table_ids (|ListOfInstruction_v0x04|): List of InstructionGotoTable instances.
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_NEXT_TABLES, next_table_ids=None): super().__init__(property_type) self.next_table_ids = (ListOfInstruction() if next_table_ids is None else next_table_ids) self.update_length()
592,910
Create a ActionsProperty with the optional parameters below. Args: type(|TableFeaturePropType_v0x04|): Property Type value of this instance. action_ids(|ListOfActions_v0x04|): List of Action instances.
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_WRITE_ACTIONS, action_ids=None): super().__init__(property_type) self.action_ids = action_ids if action_ids else ListOfActions() self.update_length()
592,911
Create an OxmProperty with the optional parameters below. Args: type(|TableFeaturePropType_v0x04|): Property Type value of this instance. oxm_ids(|ListOfOxmHeader_v0x04|): List of OxmHeader instances.
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_MATCH, oxm_ids=None): super().__init__(property_type) self.oxm_ids = ListOfOxmHeader() if oxm_ids is None else oxm_ids self.update_length()
592,912
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff=None, offset=0): length = UBInt16() length.unpack(buff, offset) super().unpack(buff[:offset+length.value], offset)
592,914
Given an OpenFlow Message Type, return an empty message of that type. Args: messageType (:class:`~pyof.v0x01.common.header.Type`): Python-openflow message. Returns: Empty OpenFlow message of the requested message type. Raises: KytosUndefinedMessageType: Unkown Message_...
def new_message_from_message_type(message_type): message_type = str(message_type) if message_type not in MESSAGE_TYPES: raise ValueError('"{}" is not known.'.format(message_type)) message_class = MESSAGE_TYPES.get(message_type) message_instance = message_class() return message_instan...
592,917
Given an OF Header, return an empty message of header's message_type. Args: header (~pyof.v0x01.common.header.Header): Unpacked OpenFlow Header. Returns: Empty OpenFlow message of the same type of message_type attribute from the given header. The header attribute of the message...
def new_message_from_header(header): message_type = header.message_type if not isinstance(message_type, Type): try: if isinstance(message_type, str): message_type = Type[message_type] elif isinstance(message_type, int): message_type = Type(mes...
592,918
Unpack the whole buffer, including header pack. Args: buffer (bytes): Bytes representation of a openflow message. Returns: object: Instance of openflow message.
def unpack_message(buffer): hdr_size = Header().get_size() hdr_buff, msg_buff = buffer[:hdr_size], buffer[hdr_size:] header = Header() header.unpack(hdr_buff) message = new_message_from_header(header) message.unpack(msg_buff) return message
592,919
Create a MeterBandHeader with the optional parameters below. Args: band_type (MeterBandType): One of OFPMBT_*. rate (int): Rate for this band. burst_size (int): Size of bursts.
def __init__(self, band_type=None, rate=None, burst_size=None): super().__init__() self.band_type = band_type self.rate = rate self.burst_size = burst_size self.update_length()
592,920
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff=None, offset=0): band_type = UBInt16(enum_ref=MeterBandType) band_type.unpack(buff, offset) self.__class__ = MeterBandType(band_type.value).find_class() length = UBInt16() length.unpack(buff, offset=offset+2) super().unpack(buff[:offset+le...
592,921
Create a MeterMod with the optional parameters below. Args: xid (int): Headers transaction id. Defaults to random. command (MeterModCommand): One of OFPMC_*. flags (MeterFlags): One of OFPMF_*. meter_id (int): Meter instance. bands (MeterBandHeader): ...
def __init__(self, xid=None, command=None, flags=None, meter_id=None, bands=None): super().__init__(xid) self.command = command self.flags = flags self.meter_id = meter_id self.bands = bands
592,922
Create a MeterBandDrop with the optional parameters below. Args: rate (int): Rate for dropping packets. burst_size (int): Size of bursts.
def __init__(self, rate=None, burst_size=None): super().__init__(MeterBandType.OFPMBT_DROP, rate, burst_size)
592,923
Create a MeterBandDscpRemark with the optional parameters below. Args: rate (int): Rate for remarking packets. burst_size (int): Size of bursts. prec_level (int): Number of precendence level to substract.
def __init__(self, rate=None, burst_size=None, prec_level=None): super().__init__(MeterBandType.OFPMBT_DSCP_REMARK, rate, burst_size) self.prec_level = prec_level
592,924
Create a MeterBandExperimenter with the optional parameters below. Args: rate (int): Rate for remarking packets. burst_size (int): Size of bursts. experimenter (int): Experimenter ID which takes the same form as in :class:`.ExperimenterHeader`.
def __init__(self, rate=None, burst_size=None, experimenter=None): super().__init__(MeterBandType.OFPMBT_EXPERIMENTER, rate, burst_size) self.experimenter = experimenter
592,925
Create a Desc with the optional parameters below. Args: mfr_desc (str): Manufacturer description hw_desc (str): Hardware description sw_desc (str): Software description serial_num (str): Serial number dp_desc (str): Datapath description
def __init__(self, mfr_desc=None, hw_desc=None, sw_desc=None, serial_num=None, dp_desc=None): super().__init__() self.mfr_desc = mfr_desc self.hw_desc = hw_desc self.sw_desc = sw_desc self.serial_num = serial_num self.dp_desc = dp_desc
592,930
Unpack a binary message into this object's attributes. Pass the correct length for list unpacking. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking.
def unpack(self, buff, offset=0): unpack_length = UBInt16() unpack_length.unpack(buff, offset) super().unpack(buff[:offset+unpack_length], offset)
592,931
Create a GroupDescStats with the optional parameters below. Args: length (int): Length of this entry. group_type (|GroupType_v0x04|): One of OFPGT_*. group_id (int): Group identifier. buckets (|ListOfBuckets_v0x04|): List of buckets in group.
def __init__(self, length=None, group_type=None, group_id=None, buckets=None): super().__init__() self.length = length self.group_type = group_type self.group_id = group_id self.buckets = buckets
592,933
Create a GroupFeatures with the optional parameters below. Args: types: Bitmap of OFPGT_* values supported. capabilities: Bitmap of OFPGFC_* capability supported. max_groups: 4-position array; Maximum number of groups for each type. actions: 4-pos...
def __init__(self, types=None, capabilities=None, max_groups1=None, max_groups2=None, max_groups3=None, max_groups4=None, actions1=None, actions2=None, actions3=None, actions4=None): super().__init__() self.types = types self.capabilities = capabilities...
592,934
Create a MeterConfig with the optional parameters below. Args: flags (|MeterFlags_v0x04|): Meter configuration flags.The default value is MeterFlags.OFPMF_STATS meter_id (|Meter_v0x04|): Meter Indentify.The value Meter.OFPM_ALL is used to ...
def __init__(self, flags=MeterFlags.OFPMF_STATS, meter_id=None, bands=None): super().__init__() self.flags = flags self.meter_id = meter_id self.bands = bands if bands else []
592,935
Create a MeterFeatures with the optional parameters below. Args: max_meter(int): Maximum number of meters. band_types (|MeterBandType_v0x04|): Bitmaps of OFPMBT_* values supported. capabilities (|MeterFlags_v0x04|): Bitmaps of "ofp_meter_flags". m...
def __init__(self, max_meter=None, band_types=None, capabilities=None, max_bands=None, max_color=None): super().__init__() self.max_meter = max_meter self.band_types = band_types self.capabilities = capabilities self.max_bands = max_bands self.ma...
592,936
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff=None, offset=0): length = UBInt16() length.unpack(buff, offset) length.unpack(buff, offset=offset+MeterStats.meter_id.get_size()) super().unpack(buff[:offset+length.value], offset=offset)
592,938
Create a TableStats with the optional parameters below. Args: table_id (int): Identifier of table. Lower numbered tables are consulted first. active_count (int): Number of active entries. lookup_count (int): Number of packets looked up in table. ...
def __init__(self, table_id=None, active_count=None, lookup_count=None, matched_count=None): super().__init__() self.table_id = table_id self.active_count = active_count self.lookup_count = lookup_count self.matched_count = matched_count
592,939
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff=None, offset=0): instruction_type = UBInt16(enum_ref=InstructionType) instruction_type.unpack(buff, offset) self.__class__ = InstructionType(instruction_type.value).find_class() length = UBInt16() length.unpack(buff, offset=offset+2) super...
592,941
Create a InstructionApplyAction with the optional parameters below. Args: actions (:class:`~.actions.ListOfActions`): Actions associated with OFPIT_APPLY_ACTIONS.
def __init__(self, actions=None): super().__init__(InstructionType.OFPIT_APPLY_ACTIONS) self.actions = actions if actions else []
592,942
Create a InstructionClearAction with the optional parameters below. Args: actions (:class:`~.actions.ListOfActions`): Actions associated with OFPIT_CLEAR_ACTIONS.
def __init__(self, actions=None): super().__init__(InstructionType.OFPIT_CLEAR_ACTIONS) self.actions = actions if actions else []
592,943
Create a InstructionGotoTable with the optional parameters below. Args: length (int): Length of this struct in bytes. table_id (int): set next table in the lookup pipeline.
def __init__(self, table_id=Meter.OFPM_ALL): super().__init__(InstructionType.OFPIT_GOTO_TABLE) self.table_id = table_id
592,944
Create a InstructionMeter with the optional parameters below. Args: meter_id (int): Meter instance.
def __init__(self, meter_id=Meter.OFPM_ALL): super().__init__(InstructionType.OFPIT_METER) self.meter_id = meter_id
592,945
Create a InstructionWriteAction with the optional parameters below. Args: actions (:class:`~.actions.ListOfActions`): Actions associated with OFPIT_WRITE_ACTIONS.
def __init__(self, actions=None): super().__init__(InstructionType.OFPIT_WRITE_ACTIONS) self.actions = actions if actions else []
592,946
Create InstructionWriteMetadata with the optional parameters below. Args: metadata (int): Metadata value to write. metadata_mask (int): Metadata write bitmask.
def __init__(self, metadata=0, metadata_mask=0): super().__init__(InstructionType.OFPIT_WRITE_METADATA) self.metadata = metadata self.metadata_mask = metadata_mask
592,947
Create an OXM TLV struct with the optional parameters below. Args: oxm_class (OxmClass): Match class: member class or reserved class oxm_field (OxmMatchFields, OxmOfbMatchField): Match field within the class oxm_hasmask (bool): Set if OXM include a bitmask in...
def __init__(self, oxm_class=OxmClass.OFPXMC_OPENFLOW_BASIC, oxm_field=None, oxm_hasmask=False, oxm_value=None): super().__init__() self.oxm_class = oxm_class self.oxm_field_and_mask = None self.oxm_length = None self.oxm_value = oxm_value # Attr...
592,948
Unpack the buffer into a OxmTLV. Args: buff (bytes): The binary data to be unpacked. offset (int): If we need to shift the beginning of the data.
def unpack(self, buff, offset=0): super().unpack(buff, offset) # Recover field from field_and_hasmask. try: self.oxm_field = self._unpack_oxm_field() except ValueError as exception: raise UnpackException(exception) # The last bit of field_and_mas...
592,949
Describe the flow match header structure. Args: match_type (MatchType): One of OFPMT_* (MatchType) items. length (int): Length of Match (excluding padding) followed by Exactly (length - 4) (possibly 0) bytes containing OXM TLVs, then e...
def __init__(self, match_type=MatchType.OFPMT_OXM, oxm_match_fields=None): super().__init__() self.match_type = match_type self.oxm_match_fields = oxm_match_fields or OxmMatchFields() self._update_match_length()
592,954
Return the value for the 'field_type' field in oxm_match_fields. Args: field_type (~pyof.v0x04.common.flow_match.OxmOfbMatchField, ~pyof.v0x04.common.flow_match.OxmMatchFields): The type of the OXM field you want the value. Returns: The i...
def get_field(self, field_type): for field in self.oxm_match_fields: if field.oxm_field == field_type: return field.oxm_value return None
592,959
Create a Header with the optional parameters below. Args: message_type (~pyof.v0x04.common.header.Type): One of the OFPT_* constants. length (int): Length including this ofp_header. xid (int): Transaction id associated with this packet. Replies use ...
def __init__(self, message_type=None, length=None, xid=None): super().__init__() self.message_type = message_type self.length = length self.xid = xid
592,960
Create a GenericType with the optional parameters below. Args: value: The type's value. enum_ref (type): If :attr:`value` is from an Enum, specify its type.
def __init__(self, value=None, enum_ref=None): self._value = value self.enum_ref = enum_ref
592,961
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
def unpack(self, buff, offset=0): try: self._value = struct.unpack_from(self._fmt, buff, offset)[0] if self.enum_ref: self._value = self.enum_ref(self._value) except (struct.error, TypeError, ValueError) as exception: msg = '{}; fmt = {}, buff...
592,966
Get the module pyof version based on the module fullname. Args: module_fullname (str): The fullname of the module (e.g.: pyof.v0x01.common.header) Returns: str: openflow version. The openflow version, on the format 'v0x0?' if any. Or None ...
def get_pyof_version(module_fullname): ver_module_re = re.compile(r'(pyof\.)(v0x\d+)(\..*)') matched = ver_module_re.match(module_fullname) if matched: version = matched.group(2) return version return None
592,969
Calculate the total struct size in bytes. For each struct attribute, sum the result of each one's ``get_size()`` method. Args: value: In structs, the user can assign other value instead of a class' instance. Returns: int: Total number of bytes u...
def get_size(self, value=None): if value is None: return sum(cls_val.get_size(obj_val) for obj_val, cls_val in self._get_attributes()) elif isinstance(value, type(self)): return value.get_size() else: msg = "{} is not an instanc...
592,980
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. It is an inplace method and it receives the binary data of the message **without the header**. Args: buff (bytes): Binary data packa...
def unpack(self, buff, offset=0): begin = offset for name, value in self.get_class_attributes(): if type(value).__name__ != "Header": size = self._unpack_attribute(name, value, buff, begin) begin += size
592,986
Create a SwitchConfig with the optional parameters below. Args: xid (int): xid to be used on the message header. flags (ConfigFlag): OFPC_* flags. miss_send_len (int): UBInt16 max bytes of new flow that the datapath should send to the controller.
def __init__(self, xid=None, flags=None, miss_send_len=None): super().__init__(xid) self.flags = flags self.miss_send_len = miss_send_len
592,990
Create a AggregateStatsRequest with the optional parameters below. Args: match (~pyof.v0x01.common.flow_match.Match): Fields to match. table_id (int): ID of table to read (from pyof_table_stats) 0xff for all tables or 0xfe for emergency. out_port (int): Requi...
def __init__(self, match=Match(), table_id=0xff, out_port=Port.OFPP_NONE): super().__init__() self.match = match self.table_id = table_id self.out_port = out_port
592,992
Create a QueueStats with the optional parameters below. Args: port_no (:class:`int`, :class:`~pyof.v0x01.common.phy_port.Port`): Port Number. queue_id (int): Queue ID. tx_bytes (int): Number of transmitted bytes. tx_packets (int): Number of transm...
def __init__(self, port_no=None, queue_id=None, tx_bytes=None, tx_packets=None, tx_errors=None): super().__init__() self.port_no = port_no self.queue_id = queue_id self.tx_bytes = tx_bytes self.tx_packets = tx_packets self.tx_errors = tx_errors
592,994
Create a QueueStatsRequest with the optional parameters below. Args: port_no (:class:`int`, :class:`~pyof.v0x01.common.phy_port.Port`): All ports if :attr:`.Port.OFPP_ALL`. queue_id (int): All queues if OFPQ_ALL (``0xfffffff``).
def __init__(self, port_no=None, queue_id=None): super().__init__() self.port_no = port_no self.queue_id = queue_id
592,995
Create instance attributes. Args: vendor (int): 32-bit vendor ID. body (bytes): Vendor-defined body
def __init__(self, vendor=None, body=b''): super().__init__() self.vendor = vendor self.body = body
592,997
Create an ActionHeader with the optional parameters below. Args: action_type (~pyof.v0x01.common.action.ActionType): The type of the action. length (int): Length of action, including this header.
def __init__(self, action_type=None, length=None): super().__init__() self.action_type = action_type self.length = length
593,000
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): self.action_type = UBInt16(enum_ref=ActionType) self.action_type.unpack(buff, offset) for cls in ActionHeader.__subclasses__(): if self.action_type.value in cls.get_allowed_types(): self.__class__ = cls break...
593,001
Create an ActionOutput with the optional parameters below. Args: port (:class:`~pyof.v0x01.common.phy_port.Port` or :class:`int`): Output port. max_length (int): Max length to send to controller.
def __init__(self, port=None, max_length=UBINT16_MAX_VALUE): super().__init__(action_type=ActionType.OFPAT_OUTPUT, length=8) self.port = port self.max_length = max_length
593,002
Create an ActionEnqueue with the optional parameters below. Args: port (physical port or :attr:`.Port.OFPP_IN_PORT`): Queue's port. queue_id (int): Where to enqueue the packets.
def __init__(self, port=None, queue_id=None): super().__init__(action_type=ActionType.OFPAT_ENQUEUE, length=16) self.port = port self.queue_id = queue_id
593,003
Create an ActionVlanVid with the optional parameters below. Args: vlan_id (int): VLAN priority.
def __init__(self, vlan_id=None): super().__init__(action_type=ActionType.OFPAT_SET_VLAN_VID, length=8) self.vlan_id = vlan_id
593,004
Create an ActionVlanPCP with the optional parameters below. Args: vlan_pcp (int): VLAN Priority. .. note:: The vlan_pcp field is 8 bits long, but only the lower 3 bits have meaning.
def __init__(self, vlan_pcp=None): super().__init__(action_type=ActionType.OFPAT_SET_VLAN_PCP, length=8) self.vlan_pcp = vlan_pcp
593,005
Create an ActionDLAddr with the optional parameters below. Args: action_type (:class:`~pyof.v0x01.common.action.ActionType`): :attr:`~ActionType.OFPAT_SET_DL_SRC` or :attr:`~ActionType.OFPAT_SET_DL_DST`. dl_addr (:class:`~.HWAddress`): Ethernet address. ...
def __init__(self, action_type=None, dl_addr=None): super().__init__(action_type, length=16) self.dl_addr = dl_addr
593,006
Create an ActionNWAddr with the optional parameters below. Args: action_type (:class:`~pyof.v0x01.common.action.ActionType`): :attr:`~ActionType.OFPAT_SET_NW_SRC` or :attr:`~ActionType.OFPAT_SET_NW_DST`. nw_addr (int): IP Address.
def __init__(self, action_type=None, nw_addr=None): super().__init__(action_type, length=8) self.nw_addr = nw_addr
593,007
Create an ActionNWTos with the optional parameters below. Args: action_type (:class:`~pyof.v0x01.common.action.ActionType`): :attr:`~ActionType.OFPAT_SET_NW_SRC` or :attr:`~ActionType.OFPAT_SET_NW_DST`. nw_tos (int): IP ToS (DSCP field, 6 bits).
def __init__(self, action_type=None, nw_tos=None): super().__init__(action_type, length=8) self.nw_tos = nw_tos
593,008
Create an ActionTPPort with the optional parameters below. Args: action_type (:class:`~pyof.v0x01.common.action.ActionType`): :attr:`~ActionType.OFPAT_SET_TP_SRC` or :attr:`~ActionType.OFPAT_SET_TP_DST`. tp_port (int): TCP/UDP/other port to set.
def __init__(self, action_type=None, tp_port=None): super().__init__(action_type, length=8) self.tp_port = tp_port
593,009
Create an ActionVendorHeader with the optional parameters below. Args: length (int): Length is a multiple of 8. vender (int): Vendor ID with the same form as in VendorHeader. Defaults to None.
def __init__(self, length=None, vendor=None): super().__init__(action_type=ActionType.OFPAT_VENDOR, length=length) self.vendor = vendor
593,010
Assign parameters to object attributes. Args: xid (int): Header's xid. reason (~pyof.v0x04.asynchronous.port_status.PortReason): Addition, deletion or modification. desc (~pyof.v0x04.common.port.Port): Port description.
def __init__(self, xid=None, reason=None, desc=None): super().__init__(xid) self.reason = reason self.desc = desc
593,011
Create a RoleRequest with the optional parameters below. Args: xid (int): OpenFlow xid to the header. role (:class:`~.controller2switch.common.ControllerRole`): Is the new role that the controller wants to assume. generation_id (int): Master Election Generati...
def __init__(self, xid=None, role=None, generation_id=None): super().__init__(xid, role, generation_id) self.header.message_type = Type.OFPT_ROLE_REQUEST
593,013
Create a MultipartRequest with the optional parameters below. Args: xid (int): xid to the header. multipart_type (int): One of the OFPMP_* constants. flags (int): OFPMPF_REQ_* flags. body (bytes): Body of the request.
def __init__(self, xid=None, multipart_type=None, flags=0, body=b''): super().__init__(xid) self.multipart_type = multipart_type self.flags = flags self.body = body
593,014
Create a PortStatsRequest with the optional parameters below. Args: port_no (:class:`int`, :class:`~pyof.v0x04.common.port.PortNo`): :attr:`StatsType.OFPST_PORT` message must request statistics either for a single port (specified in ``port_no``) or for all ...
def __init__(self, port_no=PortNo.OFPP_ANY): super().__init__() self.port_no = port_no
593,017
Create a GroupStatsRequest with the optional parameters below. Args: group_id(int): ID of group to read. OFPG_ALL to request informatio for all groups.
def __init__(self, group_id=Group.OFPG_ALL): super().__init__() self.group_id = group_id
593,018
Create a MeterMultipartRequest with the optional parameters below. Args: meter_id(Meter): Meter Indentify.The value Meter.OFPM_ALL is used to refer to all Meters on the switch.
def __init__(self, meter_id=Meter.OFPM_ALL): super().__init__() self.meter_id = meter_id
593,019
Create a QueueGetConfigRequest with the optional parameters below. Args: xid (int): xid of OpenFlow header port (:class:`~.common.port.PortNo`): Target port for the query.
def __init__(self, xid=None, port=None): super().__init__(xid) self.port = port
593,020
Create an EchoReply with the optional parameters below. Args: xid (int): xid to be used on the message header. data (bytes): arbitrary-length data field.
def __init__(self, xid=None, data=None): super().__init__(xid) self.data = data
593,026
Take the parameters to inform the user about the error. Args: item_class (:obj:`type`): The class of the item that was being inserted in the list when the exception was raised. expected_class (:obj:`type`): The expected type that didn't match against the ...
def __init__(self, item_class, expected_class): super().__init__() self.item_class = item_class self.expected_class = expected_class
593,027
Unpack *buff* into this object. Do nothing, since the _length is already defined and it is just a Pad. Keep buff and offset just for compability with other unpack methods. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: ...
def unpack(self, buff, offset=0): super().unpack(buff, offset) self.wildcards = UBInt32(value=FlowWildCards.OFPFW_ALL, enum_ref=FlowWildCards) self.wildcards.unpack(buff, offset)
593,030
Update wildcards attribute. This method update a wildcards considering the attributes of the current instance. Args: field (str): Name of the updated field. value (GenericType): New value used in the field.
def fill_wildcards(self, field=None, value=0): if field in [None, 'wildcards'] or isinstance(value, Pad): return default_value = getattr(Match, field) if isinstance(default_value, IPAddress): if field == 'nw_dst': shift = FlowWildCards.OFPFW_NW_D...
593,031
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): begin = offset hexas = [] while begin < offset + 8: number = struct.unpack("!B", buff[begin:begin+1])[0] hexas.append("%.2x" % number) begin += 1 self._value = ':'.join(hexas)
593,033
Create a Char with the optional parameters below. Args: value: The character to be build. length (int): Character size.
def __init__(self, value=None, length=0): super().__init__(value) self.length = length self._fmt = '!{}{}'.format(self.length, 's')
593,034
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): try: begin = offset end = begin + self.length unpacked_data = struct.unpack(self._fmt, buff[begin:end])[0] except struct.error: raise Exception("%s: %s" % (offset, buff)) self._value = unpacked_data.decod...
593,036
Create an IPAddress with the parameters below. Args: address (str): IP Address using ipv4. Defaults to '0.0.0.0/32'
def __init__(self, address="0.0.0.0/32", netmask=None): if '/' in address: address, netmask = address.split('/') else: netmask = 32 if netmask is None else netmask super().__init__(address) self.netmask = int(netmask)
593,038
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): try: unpacked_data = struct.unpack('!4B', buff[offset:offset+4]) self._value = '.'.join([str(x) for x in unpacked_data]) except struct.error as exception: raise exceptions.UnpackException('%s; %s: %s' % (exception, ...
593,039
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): def _int2hex(number): return "{0:0{1}x}".format(number, 2) try: unpacked_data = struct.unpack('!6B', buff[offset:offset+6]) except struct.error as exception: raise exceptions.UnpackException('%s; %s: %s' % (exception...
593,042
Return the size in bytes. Args: value (bytes): In structs, the user can assign other value instead of this class' instance. Here, in such cases, ``self`` is a class attribute of the struct. Returns: int: The address size in bytes.
def get_size(self, value=None): if value is None: value = self._value if hasattr(value, 'get_size'): return value.get_size() return len(self.pack(value))
593,044
Initialize the list with one item or a list of items. Args: items (iterable, ``pyof_class``): Items to be stored.
def __init__(self, items): super().__init__() if isinstance(items, list): self.extend(items) elif items: self.append(items)
593,045
Unpack the elements of the list. Args: buff (bytes): The binary data to be unpacked. item_class (:obj:`type`): Class of the expected items on this list. offset (int): If we need to shift the beginning of the data.
def unpack(self, buff, item_class, offset=0): begin = offset limit_buff = len(buff) while begin < limit_buff: item = item_class() item.unpack(buff, begin) self.append(item) begin += item.get_size()
593,047
Return the size in bytes. Args: value: In structs, the user can assign other value instead of this class' instance. Here, in such cases, ``self`` is a class attribute of the struct. Returns: int: The size in bytes.
def get_size(self, value=None): if value is None: if not self: # If this is a empty list, then returns zero return 0 elif issubclass(type(self[0]), GenericType): # If the type of the elements is GenericType, then returns the ...
593,048
Create a FixedTypeList with the parameters follows. Args: pyof_class (:obj:`type`): Class of the items to be stored. items (iterable, ``pyof_class``): Items to be stored.
def __init__(self, pyof_class, items=None): self._pyof_class = pyof_class super().__init__(items)
593,050
Append one item to the list. Args: item: Item to be appended. Its type must match the one defined in the constructor. Raises: :exc:`~.exceptions.WrongListItemType`: If the item has a different type than the one specified in the constructor.
def append(self, item): if isinstance(item, list): self.extend(item) elif issubclass(item.__class__, self._pyof_class): list.append(self, item) else: raise exceptions.WrongListItemType(item.__class__.__name__, ...
593,051
Insert an item at the specified index. Args: index (int): Position to insert the item. item: Item to be inserted. It must have the type specified in the constructor. Raises: :exc:`~.exceptions.WrongListItemType`: If the item has a different ...
def insert(self, index, item): if issubclass(item.__class__, self._pyof_class): list.insert(self, index, item) else: raise exceptions.WrongListItemType(item.__class__.__name__, self._pyof_class.__name__)
593,052
Unpack the elements of the list. This unpack method considers that all elements have the same size. To use this class with a pyof_class that accepts elements with different sizes, you must reimplement the unpack method. Args: buff (bytes): The binary data to be unpacked. ...
def unpack(self, buff, offset=0): # pylint: disable=arguments-differ super().unpack(buff, self._pyof_class, offset)
593,053
Append one item to the list. Args: item: Item to be appended. Raises: :exc:`~.exceptions.WrongListItemType`: If an item has a different type than the first item to be stored.
def append(self, item): if isinstance(item, list): self.extend(item) elif not self: list.append(self, item) elif item.__class__ == self[0].__class__: list.append(self, item) else: raise exceptions.WrongListItemType(item.__class__._...
593,055
Insert an item at the specified index. Args: index (int): Position to insert the item. item: Item to be inserted. Raises: :exc:`~.exceptions.WrongListItemType`: If an item has a different type than the first item to be stored.
def insert(self, index, item): if not self: list.append(self, item) elif item.__class__ == self[0].__class__: list.insert(self, index, item) else: raise exceptions.WrongListItemType(item.__class__.__name__, ...
593,056
Create a HelloElemHeader with the optional parameters below. Args: element_type: One of OFPHET_*. length: Length in bytes of the element, including this header, excluding padding.
def __init__(self, element_type=None, length=None, content=b''): super().__init__() self.element_type = element_type self.length = length self.content = content
593,058
Create a Hello with the optional parameters below. Args: xid (int): xid to be used on the message header. elements: List of elements - 0 or more
def __init__(self, xid=None, elements=None): super().__init__(xid) self.elements = elements
593,059
Create ActionExperimenterHeader with the optional parameters below. Args: experimenter (int): The experimenter field is the Experimenter ID, which takes the same form as in struct ofp_experimenter.
def __init__(self, length=None, experimenter=None): super().__init__(action_type=ActionType.OFPAT_EXPERIMENTER) self.length = length self.experimenter = experimenter
593,061
Create an ActionGroup with the optional parameters below. Args: group_id (int): The group_id indicates the group used to process this packet. The set of buckets to apply depends on the group type.
def __init__(self, group_id=None): super().__init__(action_type=ActionType.OFPAT_GROUP, length=8) self.group_id = group_id
593,062
Create an ActionSetMPLSTTL with the optional parameters below. Args: mpls_ttl (int): The mpls_ttl field is the MPLS TTL to set.
def __init__(self, mpls_ttl=None): super().__init__(action_type=ActionType.OFPAT_SET_MPLS_TTL, length=8) self.mpls_ttl = mpls_ttl
593,063
Create an ActionSetNWTTL with the optional parameters below. Args: nw_ttl (int): the TTL address to set in the IP header.
def __init__(self, nw_ttl=None): super().__init__(action_type=ActionType.OFPAT_SET_NW_TTL, length=8) self.nw_ttl = nw_ttl
593,064
Create a ActionOutput with the optional parameters below. Args: port (:class:`Port` or :class:`int`): Output port. max_length (int): Max length to send to controller.
def __init__(self, port=None, max_length=ControllerMaxLen.OFPCML_NO_BUFFER): super().__init__(action_type=ActionType.OFPAT_OUTPUT, length=16) self.port = port self.max_length = max_length
593,065
Create an ActionPopMPLS with the optional parameters below. Args: ethertype (int): indicates the Ethertype of the payload.
def __init__(self, ethertype=None): super().__init__(action_type=ActionType.OFPAT_POP_MPLS) self.ethertype = ethertype
593,066
Create a ActionPush with the optional parameters below. Args: action_type (:class:`ActionType`): indicates which tag will be pushed (VLAN, MPLS, PBB). ethertype (int): indicates the Ethertype of the new tag.
def __init__(self, action_type=None, ethertype=None): super().__init__(action_type, length=8) self.ethertype = ethertype
593,067
Create a ActionSetField with the optional parameters below. Args: length (int): length padded to 64 bits, followed by exactly oxm_len bytes containing a single OXM TLV, then exactly ((oxm_len + 4) + 7)/8*8 - (oxm_len + 4) ...
def __init__(self, field=None): super().__init__(action_type=ActionType.OFPAT_SET_FIELD) self.field = OxmTLV() if field is None else field
593,068
Create an ActionSetQueue with the optional parameters below. Args: queue_id (int): The queue_id send packets to given queue on port.
def __init__(self, queue_id=None): super().__init__(action_type=ActionType.OFPAT_SET_QUEUE, length=8) self.queue_id = queue_id
593,071
Unpack a binary struct into this object's attributes. Return the values instead of the lib's basic types. Check if the protocols involved are Ethernet and IPv4. Other protocols are currently not supported. Args: buff (bytes): Binary buffer. offset (int): Where t...
def unpack(self, buff, offset=0): super().unpack(buff, offset) if not self.is_valid(): raise UnpackException("Unsupported protocols in ARP packet")
593,073
Unpack a binary struct into this object's attributes. Return the values instead of the lib's basic types. After unpacking, the abscence of a `tpid` value causes the assignment of None to the field values to indicate that there is no VLAN information. Args: buff (by...
def unpack(self, buff, offset=0): super().unpack(buff, offset) if self.tpid.value: self._validate() self.tpid = self.tpid.value self.pcp = self._tci.value >> 13 self.cfi = (self._tci.value >> 12) & 1 self.vid = self._tci.value & 4095 ...
593,077
Create an instance and set its attributes. Args: tlv_type (int): Type used by this class. Defaults to 127. value (:class:`~pyof.foundation.basic_types.BinaryData`): Value stored by GenericTLV.
def __init__(self, tlv_type=127, value=None): super().__init__() self.tlv_type = tlv_type self._value = BinaryData() if value is None else value
593,081
Unpack a binary message into this object's attributes. Unpack the binary value *buff* and update this object attributes based on the results. Args: buff (bytes): Binary data package to be unpacked. offset (int): Where to begin unpacking. Raises: Exc...
def unpack(self, buff, offset=0): header = UBInt16() header.unpack(buff[offset:offset+2]) self.tlv_type = header.value >> 9 length = header.value & 511 begin, end = offset + 2, offset + 2 + length self._value = BinaryData(buff[begin:end])
593,083
Unpack a binary struct into this object's attributes. Return the values instead of the lib's basic types. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: If unpack fails.
def unpack(self, buff, offset=0): super().unpack(buff, offset) self.version = self._version_ihl.value >> 4 self.ihl = self._version_ihl.value & 15 self.dscp = self._dscp_ecn.value >> 2 self.ecn = self._dscp_ecn.value & 3 self.length = self.length.value s...
593,088
Create an instance and set its attributes. Args: tlv_type (int): Type used by this class. Defaults to 1. sub_type (int): Sub type value used by this class. Defaults to 7. sub_value (:class:`~pyof.foundation.basic_types.BinaryData`): Data stored by TLVWithSubT...
def __init__(self, tlv_type=1, sub_type=7, sub_value=None): super().__init__(tlv_type) self.sub_type = sub_type self.sub_value = BinaryData() if sub_value is None else sub_value
593,089