tuwien.auto.calimero.knxnetip.servicetype
Class KNXnetIPHeader

java.lang.Object
  extended by tuwien.auto.calimero.knxnetip.servicetype.KNXnetIPHeader

public class KNXnetIPHeader
extends java.lang.Object

The common KNXnet/IP header used at the first position in every KNXnet/IP frame.

It contains the protocol version, length of this header, the total frame length and the service type identifier of the service carried by the frame. The header, most certainly, is followed by a KNXnet/IP body, depending on the service type, i.e. every KNXnet/IP frame consists at least of this header.

The header itself, however, only consists of the pure header structure, it will not store or read any frame body content.
It is used for KNXnet/IP frame to retrieve general information in the first place, followed by processing of the frame through more specific service types.
Most service type identifiers are listed as public constants in this header interface.

The KNXnet/IP implementation status is 1.0.

Objects of this type are immutable.


Field Summary
static int CONNECT_REQ
          Service type identifier for a connect request.
static int CONNECT_RES
          Service type identifier for a connect response.
static int CONNECTIONSTATE_REQ
          Service type identifier for a connection state request.
static int CONNECTIONSTATE_RES
          Service type identifier for a connection state response.
static int DESCRIPTION_REQ
          Service type identifier for a description request.
static int DESCRIPTION_RES
          Service type identifier for a description response.
static int DEVICE_CONFIGURATION_ACK
          Service type identifier to confirm the reception of the configuration request.
static int DEVICE_CONFIGURATION_REQ
          Service type identifier for configuration request (read / write device configuration data, interface properties).
static int DISCONNECT_REQ
          Service type identifier for a disconnect request.
static int DISCONNECT_RES
          Service type identifier for a disconnect response.
static short KNXNETIP_VERSION_10
          Version identifier for KNXnet/IP protocol version 1.0.
static int ROUTING_IND
          Service type identifier for sending KNX telegrams over IP networks with multicast.
static int ROUTING_LOST_MSG
          Service type identifier to indicate the loss of routing messages with multicast.
static int SEARCH_REQ
          Service type identifier for a search request.
static int SEARCH_RES
          Service type identifier for a search response.
static int TUNNELING_ACK
          Service type identifier to confirm the reception of a tunneling request.
static int TUNNELING_REQ
          Service type identifier to send and receive single KNX frames between client and server.
 
Constructor Summary
KNXnetIPHeader(byte[] frame, int offset)
          Creates a new KNXnet/IP header by reading in the header of a KNXnet/IP frame.
KNXnetIPHeader(int serviceType, int bodyLength)
          Creates a new KNXnet/IP header for the given service and frame body length.
 
Method Summary
 int getServiceType()
          Returns the service type identifier.
 int getStructLength()
          Returns the length of the KNXnet/IP header structure.
 int getTotalLength()
          Returns the total length of the KNXnet/IP frame the header is part of.
 int getVersion()
          Returns the KNXnet/IP protocol version of the frame.
 byte[] toByteArray()
          Returns the byte representation of the KNXnet/IP header structure.
 java.lang.String toString()
          Returns a textual representation of this KNXnet/IP header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECT_REQ

public static final int CONNECT_REQ
Service type identifier for a connect request.

See Also:
Constant Field Values

CONNECT_RES

public static final int CONNECT_RES
Service type identifier for a connect response.

See Also:
Constant Field Values

CONNECTIONSTATE_REQ

public static final int CONNECTIONSTATE_REQ
Service type identifier for a connection state request.

See Also:
Constant Field Values

CONNECTIONSTATE_RES

public static final int CONNECTIONSTATE_RES
Service type identifier for a connection state response.

See Also:
Constant Field Values

DESCRIPTION_REQ

public static final int DESCRIPTION_REQ
Service type identifier for a description request.

See Also:
Constant Field Values

DESCRIPTION_RES

public static final int DESCRIPTION_RES
Service type identifier for a description response.

See Also:
Constant Field Values

DEVICE_CONFIGURATION_ACK

public static final int DEVICE_CONFIGURATION_ACK
Service type identifier to confirm the reception of the configuration request.

See Also:
Constant Field Values

DEVICE_CONFIGURATION_REQ

public static final int DEVICE_CONFIGURATION_REQ
Service type identifier for configuration request (read / write device configuration data, interface properties).

See Also:
Constant Field Values

DISCONNECT_REQ

public static final int DISCONNECT_REQ
Service type identifier for a disconnect request.

See Also:
Constant Field Values

DISCONNECT_RES

public static final int DISCONNECT_RES
Service type identifier for a disconnect response.

See Also:
Constant Field Values

KNXNETIP_VERSION_10

public static final short KNXNETIP_VERSION_10
Version identifier for KNXnet/IP protocol version 1.0.

See Also:
Constant Field Values

ROUTING_IND

public static final int ROUTING_IND
Service type identifier for sending KNX telegrams over IP networks with multicast.

See Also:
Constant Field Values

ROUTING_LOST_MSG

public static final int ROUTING_LOST_MSG
Service type identifier to indicate the loss of routing messages with multicast.

See Also:
Constant Field Values

SEARCH_REQ

public static final int SEARCH_REQ
Service type identifier for a search request.

See Also:
Constant Field Values

SEARCH_RES

public static final int SEARCH_RES
Service type identifier for a search response.

See Also:
Constant Field Values

TUNNELING_ACK

public static final int TUNNELING_ACK
Service type identifier to confirm the reception of a tunneling request.

See Also:
Constant Field Values

TUNNELING_REQ

public static final int TUNNELING_REQ
Service type identifier to send and receive single KNX frames between client and server.

See Also:
Constant Field Values
Constructor Detail

KNXnetIPHeader

public KNXnetIPHeader(byte[] frame,
                      int offset)
               throws KNXFormatException
Creates a new KNXnet/IP header by reading in the header of a KNXnet/IP frame.

Parameters:
frame - byte array with contained KNXnet/IP frame
offset - start offset of KNXnet/IP header structure in frame
Throws:
KNXFormatException - if frame is too short for header, on wrong header size or not supported KNXnet/IP protocol version

KNXnetIPHeader

public KNXnetIPHeader(int serviceType,
                      int bodyLength)
Creates a new KNXnet/IP header for the given service and frame body length.

Parameters:
serviceType - service type identifier specifying the service followed after the header, 0 <= type <= 0xFFFF
bodyLength - length of the frame body, i.e. byte length of the following service structure
Method Detail

getServiceType

public final int getServiceType()
Returns the service type identifier.

Returns:
service type as unsigned short

getStructLength

public int getStructLength()
Returns the length of the KNXnet/IP header structure.

Returns:
the length in bytes

getTotalLength

public final int getTotalLength()
Returns the total length of the KNXnet/IP frame the header is part of.

The total length is calculated by adding the header length and the length of the service contained in the frame.

Returns:
the total length in bytes

getVersion

public int getVersion()
Returns the KNXnet/IP protocol version of the frame.

Returns:
protocol version as unsigned byte

toByteArray

public byte[] toByteArray()
Returns the byte representation of the KNXnet/IP header structure.

Returns:
byte array containing structure

toString

public java.lang.String toString()
Returns a textual representation of this KNXnet/IP header.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object