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.
  • 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

      public SDPHeader​(SDPHeader.Flag flags, SDPLocation destination, int destinationPort)
      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

      public SDPHeader​(SDPHeader.Flag flags, SDPLocation destination, SDPPort destinationPort)
      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

      public SDPHeader​(ByteBuffer buffer, boolean isBMP)
      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

      public void addToBuffer​(ByteBuffer buffer)
      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 interface SerializableMessage
      Parameters:
      buffer - The buffer to write into.
    • getDestination

      public SDPLocation 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

      public void setDestination​(SDPLocation destination)
      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 a CoreLocation.
    • 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

      public SDPLocation getSource()
      Returns:
      What "chip" originated the message.
    • setSource

      public void setSource​(SDPLocation source)
      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 a CoreLocation.
    • getSourcePort

      public int getSourcePort()
      Returns:
      What SDP port originated the message. Note that this is not a UDP port.
    • setSourcePort

      public void setSourcePort​(SDPPort port)
      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

      public SDPHeader.Flag getFlags()
      Returns:
      The flags from the header.
    • getTag

      public int getTag()
      Returns:
      The tag byte from the header.