<commit_before>"""For the controller to send a packet out through the datapath."""
from copy import deepcopy

from pyof.foundation.base import GenericMessage
from pyof.foundation.basic_types import BinaryData, UBInt16, UBInt32
from pyof.foundation.exceptions import PackException, ValidationError
from pyof.v0x01.common.header import Header, Type
from pyof.v0x01.common.phy_port import Port
from pyof.v0x01.controller2switch.common import ListOfActions

__all__ = ('PacketOut',)

# Classes

#: in_port valid virtual port values, for validation
_VIRT_IN_PORTS = (Port.OFPP_LOCAL, Port.OFPP_CONTROLLER, Port.OFPP_NONE)


class PacketOut(GenericMessage):
    """Send packet (controller -> datapath)."""

    header = Header(message_type=Type.OFPT_PACKET_OUT)
    buffer_id = UBInt32()
    in_port = UBInt16(enum_ref=Port)
    actions_len = UBInt16()
    actions = ListOfActions()
    data = BinaryData()

    def __init__(self, xid=None, buffer_id=None, in_port=None, actions=None,
                 data=b''):
        """The constructor just assings parameters to object attributes.

        Args:
            xid (int): xid of the message header.
            buffer_id (int): ID assigned by datapath (-1 if none).
            in_port (:class:`int`, :class:`.Port`): Packet's input port
                (:attr:`.Port.OFPP_NONE` if none). Virtual ports OFPP_IN_PORT,
                OFPP_TABLE, OFPP_NORMAL, OFPP_FLOOD, and OFPP_ALL cannot be
                used as input port.
            actions (ListOfActions): Actions (class ActionHeader).
            data (bytes): Packet data. The length is inferred from the length
                field in the header. (Only meaningful if buffer_id == -1).<commit_msg>Adding meaningfull default values for packet_out<commit_after>"""For the controller to send a packet out through the datapath."""
from copy import deepcopy

from pyof.foundation.base import GenericMessage
from pyof.foundation.basic_types import BinaryData, UBInt16, UBInt32
from pyof.foundation.exceptions import PackException, ValidationError
from pyof.v0x01.common.constants import NO_BUFFER
from pyof.v0x01.common.header import Header, Type
from pyof.v0x01.common.phy_port import Port
from pyof.v0x01.controller2switch.common import ListOfActions

__all__ = ('PacketOut',)

# Classes

#: in_port valid virtual port values, for validation
_VIRT_IN_PORTS = (Port.OFPP_LOCAL, Port.OFPP_CONTROLLER, Port.OFPP_NONE)


class PacketOut(GenericMessage):
    """Send packet (controller -> datapath)."""

    header = Header(message_type=Type.OFPT_PACKET_OUT)
    buffer_id = UBInt32()
    in_port = UBInt16(enum_ref=Port)
    actions_len = UBInt16()
    actions = ListOfActions()
    data = BinaryData()

    def __init__(self, xid=None, buffer_id=NO_BUFFER, in_port=Port.OFPP_NONE,
                 actions=None, data=b''):
        """The constructor just assings parameters to object attributes.

        Args:
            xid (int): xid of the message header.
            buffer_id (int): ID assigned by datapath (-1 if none).
            in_port (:class:`int`, :class:`.Port`): Packet's input port
                (:attr:`.Port.OFPP_NONE` if none). Virtual ports OFPP_IN_PORT,
                OFPP_TABLE, OFPP_NORMAL, OFPP_FLOOD, and OFPP_ALL cannot be
                used as input port.
            actions (ListOfActions): Actions (class ActionHeader).
            data (bytes): Packet data. The length is inferred from the length
                field in the header. (Only meaningful if buffer_id == -1).
{'fraction_non_alphanumeric': 0.09111617312072894, 'fraction_numerical': 0.013382687927107062, 'mean_word_length': 3.3157248157248156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1203435', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1047, 'n_words': 320}