com.h3c.of.ctl.pkt

## Interface MessageContext

- All Known Subinterfaces:
    MessageContextForHost, MessageContextForPath
  All Known Implementing Classes:
    MessageContextAdapter

      public interface MessageContext

  Provides a context when processing a specific OpenFlow PacketIn message. The source message event, (available via `srcEvent()`), contains the `PacketIn` message. The `PacketSequencer` will decode the packet to determine the `protocols` used. The decoded packet model is available via `decodedPacket()`.

  When the context is created, a mutable PacketOut message is also constructed and kept in the context. Note that the protocol version, transaction ID (xid), ingress port, and buffer ID of the PacketIn message are copied to the PacketOut message. `SequencedPacketListener`s can manipulate the PacketOut message via the `PacketOut` API.

  Packet listeners (in the `ADVISOR` role) may add `Hint`s to the message context to help listeners further downstream make decisions.

  Once a packet listener (in the `DIRECTOR` role) has determined that the PacketOut message is ready to send back to the datapath, it indicates this to the `PacketSequencer` by returning `true` from its `event()` callback. The sequencer will then forward the PacketOut message to the controller for sending.

  Packet listeners downstream of the DIRECTOR that caused the PacketOut to be sent, still get to see the message context, and can therefore observe what transpired.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MessageContext` | `addHint(Hint hint)` Adds a hint to the context.
    `Packet` | `decodedPacket()` Returns the decoded packet data generated by the Network Packet Library facility.
    `boolean` | `failedToSend()` This flag is set in the unlikely event that the packet sequencer failed to send the PacketOut message via the controller.
    `OfmPacketOut` | `getCompletedPacketOut()` Returns the PacketOut message that was sent back to the source datapath.
    `List<Hint>` | `getHints()` Returns the hints contained in this context, in the order they were added by the Advisors.
    `OfmPacketIn` | `getPacketIn()` Convenience method that returns the PacketIn message from the message event.
    `List<ProtocolId>` | `getProtocols()` Returns an ordered list of `protocols` decoded from the packet.
    `ProtocolVersion` | `getVersion()` Returns the protocol version of the associated PacketIn message event.
    `boolean` | `isHandled()` Returns true if the associated message event has already been handled.
    `boolean` | `isTestPacket()` Returns true if the associated packet has been determined to be a diagnostic test packet.
    `PacketOut` | `packetOut()` Returns the API for manipulating the PacketOut message.
    `void` | `resetHandled()`
    `MessageEvent` | `srcEvent()` Returns the associated PacketIn message event.
    `String` | `toDebugString()` Returns a multi-line string representation of this message context, suitable for debugging.

- - ### Method Detail

    - #### srcEvent

          MessageEvent srcEvent()

      Returns the associated PacketIn message event.
      Returns:
        the PacketIn message event

    - #### getVersion

          ProtocolVersion getVersion()

      Returns the protocol version of the associated PacketIn message event.
      Returns:
        the protocol version

    - #### getPacketIn

          OfmPacketIn getPacketIn()

      Convenience method that returns the PacketIn message from the message event.
      Returns:
        the PacketIn message

    - #### decodedPacket

          Packet decodedPacket()

      Returns the decoded packet data generated by the Network Packet Library facility. This will be null if there is no packet data associated with the PacketIn message.
      Returns:
        the decoded packet data

    - #### getProtocols

          List<ProtocolId> getProtocols()

      Returns an ordered list of `protocols` decoded from the packet. The protocols are ordered from outermost to innermost layer. This will be null if there is no packet data associated with the PacketIn message.
      Returns:
        the list of protocols

    - #### packetOut

          PacketOut packetOut()

      Returns the API for manipulating the PacketOut message.
      Returns:
        the packet out API

    - #### getCompletedPacketOut

          OfmPacketOut getCompletedPacketOut()

      Returns the PacketOut message that was sent back to the source datapath. Note that this method will return null if the PacketOut message has not yet been sent.
      Returns:
        the PacketOut message

    - #### addHint

          MessageContext addHint(Hint hint)

      Adds a hint to the context.
      Parameters:
        `hint` - the hint to be added
      Returns:
        self, for chaining
      Throws:
        `NullPointerException` - if hint is null

    - #### getHints

          List<Hint> getHints()

      Returns the hints contained in this context, in the order they were added by the Advisors.
      Returns:
        the hints

    - #### isHandled

          boolean isHandled()

      Returns true if the associated message event has already been handled.
      Returns:
        true if handled; false otherwise

    - #### isTestPacket

          boolean isTestPacket()

      Returns true if the associated packet has been determined to be a diagnostic test packet.
      Returns:
        true if a diagnostic test packet; false otherwise

    - #### failedToSend

          boolean failedToSend()

      This flag is set in the unlikely event that the packet sequencer failed to send the PacketOut message via the controller.
      Returns:
        true if an error occurred during send

    - #### toDebugString

          String toDebugString()

      Returns a multi-line string representation of this message context, suitable for debugging.
      Returns:
        a multi-line string representation

    - #### resetHandled

          void resetHandled()

Copyright © 2014. All Rights Reserved.