ru.bitel.bgbilling.kernel.network.dhcp

## Class DhcpPacket

- java.lang.Object
- - ru.bitel.bgbilling.kernel.network.dhcp.DhcpPacket

- All Implemented Interfaces:
    java.util.Comparator<DhcpOption>

      public final class DhcpPacket
      extends java.lang.Object
      implements java.util.Comparator<DhcpOption>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DhcpPacket.DhcpPacketOption<T>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `byte[]` | `chaddr`
    `static java.nio.charset.Charset` | `CHARSET`
    `byte[]` | `ciaddr`
    `static int` | `DHCP_ACK` Code for DHCPACK Message
    `static int` | `DHCP_DECLINE` Code for DHCPDECLINE Message
    `static int` | `DHCP_DISCOVER` Code for DHCPDISCOVER Message
    `static int` | `DHCP_INFORM` Code for DHCPINFORM Message
    `static int` | `DHCP_NAK` Code for DHCPNAK Message
    `static int` | `DHCP_OFFER` Code for DHCPOFFER Message
    `static int` | `DHCP_RELEASE` Code for DHCPRELEASE Message
    `static int` | `DHCP_REQUEST` Code for DHCPREQUEST Message
    `byte[]` | `file`
    `static short` | `FLAG_BROADCAST`
    `short` | `flags`
    `byte[]` | `giaddr`
    `byte` | `hlen`
    `byte` | `hops`
    `byte` | `htype`
    `byte` | `messageType`
    `byte` | `op`
    `static byte` | `OP_BOOT_REQUEST`
    `static byte` | `OP_BOOT_RESPONSE`
    `static byte` | `OPTION_AGENT_INFORMATION`
    `static byte` | `OPTION_CLIENT_IDENTIDIER`
    `static byte` | `OPTION_COOKIE_SERVER`
    `static byte` | `OPTION_DOMAIN_NAME`
    `static byte` | `OPTION_DOMAIN_NAME_SERVER`
    `static byte` | `OPTION_HOST_NAME`
    `static byte` | `OPTION_IP_ADDRESS_LEASE_TIME`
    `static byte` | `OPTION_LOG_SERVER`
    `static byte` | `OPTION_LPR_SERVER`
    `static byte` | `OPTION_NAME_SERVER`
    `static byte` | `OPTION_PARAMETER_REQUEST_LIST` опция OPTION_PARAMETER_REQUEST_LIST из реквеста, по ней упорядочиваем опции при сериализации.
    `static byte` | `OPTION_REBINDING_TIME_VALUE`
    `static byte` | `OPTION_RENEWAL_TIME_VALUE`
    `static byte` | `OPTION_REQUESTED_IP_ADDRESS`
    `static byte` | `OPTION_ROUTER`
    `static byte` | `OPTION_SERVER_IDENTIFIER`
    `static byte` | `OPTION_SUBNET_MASK`
    `static byte` | `OPTION_TIME_OFFSET`
    `static byte` | `OPTION_TIME_SERVER`
    `short` | `secs`
    `byte[]` | `siaddr`
    `byte[]` | `sname`
    `int` | `xid`
    `byte[]` | `yiaddr`
    `static byte` | `ZERO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DhcpPacket()` Конструктор пустого пакета.
    `DhcpPacket(java.nio.ByteBuffer request)` Конструктор пакета - запроса.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearSubOptions()`
    `int` | `compare(DhcpOption o1, DhcpOption o2)`
    `DhcpPacket` | `createResponse()`
    `DhcpOption` | `getOption(byte code)`
    `<O> O` | `getOption(DhcpPacket.DhcpPacketOption<O> option)` Получение опции(атрибута) из пакета.
    `<O> O` | `getOption(DhcpPacket.DhcpPacketOption<O> option, O value)` Получение опции(атрибута) из пакета.
    `DhcpOption` | `getSubOption(byte code)`
    `boolean` | `haveSubOptions()` Возвращает наличие Options.82 в запросе.
    `boolean` | `isClientAddressSet()`
    `boolean` | `isFromRelayAgent()`
    `void` | `serialize(java.nio.ByteBuffer bb)` Сериализация пакета.
    `void` | `setOption(byte code, byte[] value)`
    `void` | `setOption(byte code, java.lang.String stringValue)`
    `void` | `setOption(DhcpOption option)`
    `<O> void` | `setOption(DhcpPacket.DhcpPacketOption<O> option, O value)` Установка опции в пакет.
    `void` | `setSubOption(byte code, byte[] value)`
    `void` | `setSubOption(byte code, java.lang.String stringValue)`
    `void` | `setSubOption(DhcpOption option)`
    `java.lang.String` | `toString()`

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

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

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Field Detail

    - #### ZERO

          public static final byte ZERO

      See Also:
        Constant Field Values

    - #### CHARSET

          public static final java.nio.charset.Charset CHARSET

    - #### FLAG_BROADCAST

          public static short FLAG_BROADCAST

    - #### OP_BOOT_REQUEST

          public static final byte OP_BOOT_REQUEST

      See Also:
        Constant Field Values

    - #### OP_BOOT_RESPONSE

          public static final byte OP_BOOT_RESPONSE

      See Also:
        Constant Field Values

    - #### DHCP_DISCOVER

          public static final int DHCP_DISCOVER

      Code for DHCPDISCOVER Message
      See Also:
        Constant Field Values

    - #### DHCP_OFFER

          public static final int DHCP_OFFER

      Code for DHCPOFFER Message
      See Also:
        Constant Field Values

    - #### DHCP_REQUEST

          public static final int DHCP_REQUEST

      Code for DHCPREQUEST Message
      See Also:
        Constant Field Values

    - #### DHCP_DECLINE

          public static final int DHCP_DECLINE

      Code for DHCPDECLINE Message
      See Also:
        Constant Field Values

    - #### DHCP_ACK

          public static final int DHCP_ACK

      Code for DHCPACK Message
      See Also:
        Constant Field Values

    - #### DHCP_NAK

          public static final int DHCP_NAK

      Code for DHCPNAK Message
      See Also:
        Constant Field Values

    - #### DHCP_RELEASE

          public static final int DHCP_RELEASE

      Code for DHCPRELEASE Message
      See Also:
        Constant Field Values

    - #### DHCP_INFORM

          public static final int DHCP_INFORM

      Code for DHCPINFORM Message
      See Also:
        Constant Field Values

    - #### OPTION_SUBNET_MASK

          public static final byte OPTION_SUBNET_MASK

      See Also:
        Constant Field Values

    - #### OPTION_TIME_OFFSET

          public static final byte OPTION_TIME_OFFSET

      See Also:
        Constant Field Values

    - #### OPTION_ROUTER

          public static final byte OPTION_ROUTER

      See Also:
        Constant Field Values

    - #### OPTION_TIME_SERVER

          public static final byte OPTION_TIME_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_NAME_SERVER

          public static final byte OPTION_NAME_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_DOMAIN_NAME_SERVER

          public static final byte OPTION_DOMAIN_NAME_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_LOG_SERVER

          public static final byte OPTION_LOG_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_COOKIE_SERVER

          public static final byte OPTION_COOKIE_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_LPR_SERVER

          public static final byte OPTION_LPR_SERVER

      See Also:
        Constant Field Values

    - #### OPTION_HOST_NAME

          public static final byte OPTION_HOST_NAME

      See Also:
        Constant Field Values

    - #### OPTION_DOMAIN_NAME

          public static final byte OPTION_DOMAIN_NAME

      See Also:
        Constant Field Values

    - #### OPTION_REQUESTED_IP_ADDRESS

          public static final byte OPTION_REQUESTED_IP_ADDRESS

      See Also:
        Constant Field Values

    - #### OPTION_IP_ADDRESS_LEASE_TIME

          public static final byte OPTION_IP_ADDRESS_LEASE_TIME

      See Also:
        Constant Field Values

    - #### OPTION_SERVER_IDENTIFIER

          public static final byte OPTION_SERVER_IDENTIFIER

      See Also:
        Constant Field Values

    - #### OPTION_RENEWAL_TIME_VALUE

          public static final byte OPTION_RENEWAL_TIME_VALUE

      See Also:
        Constant Field Values

    - #### OPTION_REBINDING_TIME_VALUE

          public static final byte OPTION_REBINDING_TIME_VALUE

      See Also:
        Constant Field Values

    - #### OPTION_PARAMETER_REQUEST_LIST

          public static final byte OPTION_PARAMETER_REQUEST_LIST

      опция OPTION_PARAMETER_REQUEST_LIST из реквеста, по ней упорядочиваем опции при сериализации.
      --
      This option is used by a DHCP client to request values for specified configuration parameters. The list of requested parameters is specified as n octets, where each octet is a valid DHCP option code as defined in this document.
      The client MAY list the options in order of preference. The DHCP server is not required to return the options in the requested order, but MUST try to insert the requested options in the order requested by the client.
      See Also:
        Constant Field Values

    - #### OPTION_CLIENT_IDENTIDIER

          public static final byte OPTION_CLIENT_IDENTIDIER

      See Also:
        Constant Field Values

    - #### OPTION_AGENT_INFORMATION

          public static final byte OPTION_AGENT_INFORMATION

      See Also:
        Constant Field Values

    - #### op

          public byte op

    - #### htype

          public byte htype

    - #### hlen

          public byte hlen

    - #### hops

          public byte hops

    - #### xid

          public int xid

    - #### secs

          public short secs

    - #### flags

          public short flags

    - #### ciaddr

          public byte[] ciaddr

    - #### yiaddr

          public byte[] yiaddr

    - #### siaddr

          public byte[] siaddr

    - #### giaddr

          public byte[] giaddr

    - #### chaddr

          public byte[] chaddr

    - #### sname

          public byte[] sname

    - #### file

          public byte[] file

    - #### messageType

          public byte messageType

  - ### Constructor Detail

    - #### DhcpPacket

          public DhcpPacket()

      Конструктор пустого пакета.

    - #### DhcpPacket

          public DhcpPacket(java.nio.ByteBuffer request)

      Конструктор пакета - запроса.
      Parameters:
        `request` -

  - ### Method Detail

    - #### createResponse

          public final DhcpPacket createResponse()

    - #### haveSubOptions

          public boolean haveSubOptions()

      Возвращает наличие Options.82 в запросе.
      Returns:

    - #### clearSubOptions

          public void clearSubOptions()

    - #### serialize

          public void serialize(java.nio.ByteBuffer bb)

      Сериализация пакета.

    - #### isFromRelayAgent

          public final boolean isFromRelayAgent()

    - #### isClientAddressSet

          public final boolean isClientAddressSet()

    - #### compare

          public final int compare(DhcpOption o1,
                                   DhcpOption o2)

      Specified by:
        `compare` in interface `java.util.Comparator<DhcpOption>`

    - #### setOption

          public final void setOption(DhcpOption option)

    - #### setOption

          public final void setOption(byte code,
                                      byte[] value)

    - #### setOption

          public final void setOption(byte code,
                                      java.lang.String stringValue)

    - #### getOption

          public final DhcpOption getOption(byte code)

    - #### setSubOption

          public final void setSubOption(DhcpOption option)

    - #### setSubOption

          public final void setSubOption(byte code,
                                         byte[] value)

    - #### setSubOption

          public final void setSubOption(byte code,
                                         java.lang.String stringValue)

    - #### getSubOption

          public final DhcpOption getSubOption(byte code)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getOption

          public <O> O getOption(DhcpPacket.DhcpPacketOption<O> option)

      Получение опции(атрибута) из пакета. Если такая опция не была установлена - метод вернет null.
      Type Parameters:
        `O` -
      Parameters:
        `option` -
      Returns:

    - #### getOption

          public <O> O getOption(DhcpPacket.DhcpPacketOption<O> option,
                                 O value)

      Получение опции(атрибута) из пакета. Если такая опция не была установлена - метод вернет value.
      Type Parameters:
        `O` -
      Parameters:
        `option` -
        `value` - - значение по умолчанию
      Returns:

    - #### setOption

          public <O> void setOption(DhcpPacket.DhcpPacketOption<O> option,
                                    O value)

      Установка опции в пакет.
      Type Parameters:
        `O` -
      Parameters:
        `option` -
        `value` -