Class SDPHeader
java.lang.Object
uk.ac.manchester.spinnaker.messages.sdp.SDPHeader
- All Implemented Interfaces:
SerializableMessage
public final class SDPHeader extends Object implements SerializableMessage
Represents the header of an SDP message.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SDPHeader.Flag
Possible values of theflags
field. -
Constructor Summary
Constructors Constructor Description SDPHeader()
Create a header with all fields set to default.SDPHeader(ByteBuffer buffer, boolean isBMP)
Read the header from an input buffer.SDPHeader(SDPHeader.Flag flags, SDPLocation destination, int destinationPort)
Create a simple header with just the flags and destination set.SDPHeader(SDPHeader.Flag flags, SDPLocation destination, SDPPort destinationPort)
Create a simple header with just the flags and destination set. -
Method Summary
Modifier and Type Method Description void
addToBuffer(ByteBuffer buffer)
Writes this message into the given buffer as a contiguous range of bytes.SDPLocation
getDestination()
int
getDestinationPort()
SDPHeader.Flag
getFlags()
SDPLocation
getSource()
int
getSourcePort()
int
getTag()
void
setDestination(SDPLocation destination)
void
setDestinationPort(int port)
Set the target SDP port.void
setSource(SDPLocation source)
void
setSourcePort(int port)
Set the originating SDP port.void
setSourcePort(SDPPort port)
Set the originating SDP port.
-
Constructor Details
-
SDPHeader
public SDPHeader()Create a header with all fields set to default. Note that messages containing this header cannot be sent until a source and destination have been set! -
SDPHeader
Create a simple header with just the flags and destination set. Note that messages containing this header cannot be sent until a source has also been set!- Parameters:
flags
- The header flags.destination
- Where the message is bound for.destinationPort
- the SDP port that the message routes through. Note that this is not a UDP port! Those are associated with a connection, not a message.- Throws:
IllegalArgumentException
- if a bad SDP port is given
-
SDPHeader
Create a simple header with just the flags and destination set. Note that messages containing this header cannot be sent until a source has also been set!- Parameters:
flags
- The header flags.destination
- Where the message is bound for.destinationPort
- the SDP port that the message routes through. Note that this is not a UDP port! Those are associated with a connection, not a message.
-
SDPHeader
Read the header from an input buffer.- Parameters:
buffer
- The buffer to read from.isBMP
- Whether we're really talking to a BMP.
-
-
Method Details
-
addToBuffer
Description copied from interface:SerializableMessage
Writes this message into the given buffer as a contiguous range of bytes. This is so that a message can be sent. Implementors may assume that the buffer has been configured to be little-endian and that its position is at the point where they should begin writing. Once it has finished, the position should be immediately after the last byte written by this method.Calling this method should not update the internal state of the message. It should be possible to add the message to multiple buffers without special precautions by the caller.
- Specified by:
addToBuffer
in interfaceSerializableMessage
- Parameters:
buffer
- The buffer to write into.
-
getDestination
- Returns:
- What "chip" is the message going to. Note that there is a special
address for addresses off the machine; that address is not
normally representable in a
CoreLocation
.
-
setDestination
- Parameters:
destination
- What "chip" is the message going to. Note that there is a special address for addresses off the machine; that address is not normally representable in aCoreLocation
.
-
getDestinationPort
public int getDestinationPort()- Returns:
- The target SDP port. Note that this is not a UDP port.
-
setDestinationPort
public void setDestinationPort(int port)Set the target SDP port. Note that this is not a UDP port.- Parameters:
port
- The port to set it to.- Throws:
IllegalArgumentException
- If the port number is bad.
-
getSource
- Returns:
- What "chip" originated the message.
-
setSource
- Parameters:
source
- What "chip" originates the message. Note that there is a special address for origination off the machine; that address is not normally representable in aCoreLocation
.
-
getSourcePort
public int getSourcePort()- Returns:
- What SDP port originated the message. Note that this is not a UDP port.
-
setSourcePort
Set the originating SDP port. Note that this is not a UDP port.- Parameters:
port
- The port to set it to.
-
setSourcePort
public void setSourcePort(int port)Set the originating SDP port. Note that this is not a UDP port.- Parameters:
port
- The port to set it to.- Throws:
IllegalArgumentException
- If the port number is bad.
-
getFlags
- Returns:
- The flags from the header.
-
getTag
public int getTag()- Returns:
- The tag byte from the header.
-