# Ethernet

class `ryu.lib.packet.ethernet.``ethernet`(dst='ff:ff:ff:ff:ff:ff', src='00:00:00:00:00:00', ethertype=2048)

  Ethernet header encoder/decoder class.

  An instance has the following attributes at least. MAC addresses are represented as a string like '08:60:6e:7f:74:e7'. __init__ takes the corresponding args in this order.

  Attribute | Description | Example
  --- | --- | ---
  dst | destination address | 'ff:ff:ff:ff:ff:ff'
  src | source address | '08:60:6e:7f:74:e7'
  ethertype | ether type | 0x0800

  classmethod `get_packet_type`(type_)

    Override method for the ethernet IEEE802.3 Length/Type field (self.ethertype).

    If the value of Length/Type field is less than or equal to 1500 decimal(05DC hexadecimal), it means Length interpretation and be passed to the LLC sublayer.

  classmethod `parser`(buf)

    Decode a protocol header.

    This method is used only when decoding a packet.

    Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.

    - An object to describe the decoded header.
    - A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.
    - The rest of packet.
  `serialize`(payload, prev)

    Encode a protocol header.

    This method is used only when encoding a packet.

    Encode a protocol header. Returns a bytearray which contains the header.

    payload is the rest of the packet which will immediately follow this header.

    prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.