public abstract class HandshakeMessage extends AbstractMessage
| Modifier and Type | Field and Description |
|---|---|
static int |
FRAGMENT_LENGTH_BITS |
static int |
FRAGMENT_OFFSET_BITS |
static int |
MESSAGE_HEADER_LENGTH_BYTES |
static int |
MESSAGE_LENGTH_BITS |
static int |
MESSAGE_SEQ_BITS |
static int |
MESSAGE_TYPE_BITS |
| Modifier | Constructor and Description |
|---|---|
protected |
HandshakeMessage(InetSocketAddress peerAddress)
Creates a new handshake message for a given peer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
fragmentChanged()
Reset the
byteArray in order to generate an outgoing raw message
with the changed payload / fragment. |
abstract byte[] |
fragmentToByteArray()
The serialization of the handshake body (without the handshake header).
|
static HandshakeMessage |
fromByteArray(byte[] byteArray,
InetSocketAddress peerAddress)
Read handshake message from (received) byte array.
|
static HandshakeMessage |
fromGenericHandshakeMessage(GenericHandshakeMessage message,
HandshakeParameter parameter)
Create specific handshake from generic handshake message using the now
available handshake parameter.
|
ContentType |
getContentType()
Gets the message's content type.
|
int |
getFragmentLength()
Get fragment length.
|
int |
getFragmentOffset()
Get fragment offset.
|
abstract int |
getMessageLength()
Must be implemented by each subclass.
|
int |
getMessageSeq()
Get handshake message sequence number.
|
abstract HandshakeType |
getMessageType()
Returns the type of the handshake message.
|
HandshakeMessage |
getNextHandshakeMessage()
Get next handshake message.
|
protected byte[] |
getRawMessage()
Gets the raw bytes of the message received from a client that this instance
has been created from.
|
void |
setMessageSeq(int messageSeq)
Set the handshake message sequence number.
|
void |
setNextHandshakeMessage(HandshakeMessage message)
Set next handshake message.
|
int |
size()
Gets the number of bytes representing this message as defined
by TLS 1.2, Appendix A.
|
byte[] |
toByteArray()
Returns the raw binary representation of the handshake message.
|
String |
toString() |
protected void |
writeTo(org.eclipse.californium.elements.util.DatagramWriter writer)
Write handshake message to writer.
|
getPeerpublic static final int MESSAGE_TYPE_BITS
public static final int MESSAGE_LENGTH_BITS
public static final int MESSAGE_SEQ_BITS
public static final int FRAGMENT_OFFSET_BITS
public static final int FRAGMENT_LENGTH_BITS
public static final int MESSAGE_HEADER_LENGTH_BYTES
protected HandshakeMessage(InetSocketAddress peerAddress)
peerAddress - the IP address and port of the peer this message has been
received from or should be sent topublic int size()
DTLSMessagepublic abstract HandshakeType getMessageType()
HandshakeType.HandshakeType.public abstract int getMessageLength()
public abstract byte[] fragmentToByteArray()
ClientHello, the
fragments are considered to be not modified. If a modification is required,
call fragmentChanged().public final ContentType getContentType()
DTLSMessagepublic byte[] toByteArray()
getRawMessage(). For
outgoing messages the header is generated by this method and the
subclasses are responsible for the specific rest of the payload /
fragment. The result is only created once at the first call. Following
calls will get the same bytes until fragmentChanged() gets
called.byteArray,
fragmentToByteArray(),
fragmentChanged()protected void writeTo(org.eclipse.californium.elements.util.DatagramWriter writer)
writer - writer to write handshake message.protected void fragmentChanged()
byteArray in order to generate an outgoing raw message
with the changed payload / fragment.
Only used by ClientHello.setCookie(byte[]).public static HandshakeMessage fromByteArray(byte[] byteArray, InetSocketAddress peerAddress) throws HandshakeException
GenericHandshakeMessage or
FragmentedHandshakeMessage. If multiple handshake messages are
contained, the returned handshake messages are chained by
getNextHandshakeMessage().byteArray - byte array containing the handshake messagepeerAddress - peer address of handshake messageHandshakeException - if handshake message could not be read.public static HandshakeMessage fromGenericHandshakeMessage(GenericHandshakeMessage message, HandshakeParameter parameter) throws HandshakeException
message - generic handshake messageparameter - handshake parameterHandshakeException - if specific handshake message could not be
created.public int getFragmentOffset()
public int getFragmentLength()
public int getMessageSeq()
public void setMessageSeq(int messageSeq)
messageSeq - handshake message sequence numberIllegalStateException - if toByteArray() was already
called without calling fragmentChanged().public void setNextHandshakeMessage(HandshakeMessage message)
message - next handshake message.public HandshakeMessage getNextHandshakeMessage()
null, if no next handshake
message is available.protected final byte[] getRawMessage()
null if this instance has not been
created from a message received from a client.Copyright © 2023 Eclipse Foundation. All rights reserved.