com.h3c.util.pkt

## Class Codec

- java.lang.Object
- - com.h3c.util.pkt.Codec

-     public class Codec
      extends Object

  This is the main encoding and decoding API for the Packet Library.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Codec()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Packet` | `decodeEthernet(byte[] fb)` Decodes an Ethernet packet.
    `static Packet` | `decodeEthernet(byte[] fb, int height)` Decodes an Ethernet packet.
    `static byte[]` | `encode(Packet pkt)` Encode a packet.
    `static byte[]` | `encode(Packet pkt, int minLen)` Encode a packet specifying the minimum encode length.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Codec

          public Codec()

  - ### Method Detail

    - #### encode

          public static byte[] encode(Packet pkt)

      Encode a packet.
      Parameters:
        `pkt` - packet to encode
      Returns:
        the encoded packet

    - #### encode

          public static byte[] encode(Packet pkt,
                      int minLen)

      Encode a packet specifying the minimum encode length. In the case of Ethernet packets, the minimum length is used to determine the amount of padding appended after the payload.
      Parameters:
        `pkt` - packet to encode
        `minLen` - minimum packet encode length
      Returns:
        the encoded packet

    - #### decodeEthernet

          public static Packet decodeEthernet(byte[] fb)

      Decodes an Ethernet packet.
      Parameters:
        `fb` - encoded frame bytes
      Returns:
        the new packet containing the decoded protocol layers
      Throws:
        `ProtocolException` - if there is an error parsing from reader

    - #### decodeEthernet

          public static Packet decodeEthernet(byte[] fb,
                              int height)

      Decodes an Ethernet packet.
      Parameters:
        `fb` - encoded frame bytes
        `height` - number of layers to decode before stopping
      Returns:
        the new packet containing the decoded protocol layers
      Throws:
        `ProtocolException` - if there is an error parsing from reader

Copyright © 2014. All Rights Reserved.