ZeroSDN Controller  1.0
A modular distributed Software-Defined Network Controller
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros
SwitchConnectionUtil Class Reference

This class contains helper functions for communicating with OpenFlow switches. More...

#include <SwitchConnectionUtil.h>

Classes

struct  HandshakeResult
 

Static Public Member Functions

static HandshakeResult attemptHandshake (std::shared_ptr< Poco::Net::SocketStream > socket, const of_version_t openFlowVersion)
 
static bool parseOpenFlowFromSocketToBuffer (uint8_t *buffer, Poco::Net::SocketStream &fromSocket)
 
static bool writeOpenFlowToSocket (Poco::Net::SocketStream &toSocket, uint8_t *buffer)
 
static bool writeOpenFlowToSocket (Poco::Net::SocketStream &toSocket, of_object_t *const openFlowMsg)
 
static void buildSimplePacketInTopic (MessageType &topic, of_packet_in_t *const packetIn)
 
static void buildPacketInTopic (MessageType &topic, of_packet_in_t *const packetIn, const uint64_t switchId)
 

Static Public Attributes

static const uint32_t OF_HEADER_LENGTH = 8
 length of the OpenFlow message header in bytes More...
 
static const int ethPayloadOffset = 14
 constants used for experimental topic construction More...
 
static const int etherTypePos = 12
 
static const int ipv4 = 0x0800
 
static const int ipv6 = 0x86DD
 
static const int protoPos4 = ethPayloadOffset + 9
 
static const int protoPos6 = ethPayloadOffset + 6
 

Detailed Description

This class contains helper functions for communicating with OpenFlow switches.

Author
Andre Kutzleb
Date
18.07.2015

Member Function Documentation

SwitchConnectionUtil::HandshakeResult SwitchConnectionUtil::attemptHandshake ( std::shared_ptr< Poco::Net::SocketStream >  socket,
const of_version_t  openFlowVersion 
)
static

Attempts to perform an OpenFlow handshake over the given socket and returns the outcome.

Exchanges Hello, then a Feature-Request/Reply with the opposite side.

Parameters
socketthe connection used for the handshake.
ofVersionthe openFlow version used in the handshake. the handshake will fail if the switch does nto speak this version.
Returns
a HandshakeResult object detailing the result of the handshake.
static void SwitchConnectionUtil::buildPacketInTopic ( MessageType &  topic,
of_packet_in_t *const  packetIn,
const uint64_t  switchId 
)
inlinestatic

Constructs a MessageType (topic) based on the payload of the given packetIn OpenFlow message using the libtins library to identify ethertype/protocol type.

Parameters
topictopic to append bytes (at least ethertype) to.
packetInOpenFlow PACKET_IN message with an EthernetII frame as payload
switchIdfor the HPMOM packet, UDP topics are appended with the id of the switch - this is not necessary normally.
Returns
a MessageType depending on the payload according to the definitions in SwitchAdapter.topics
static void SwitchConnectionUtil::buildSimplePacketInTopic ( MessageType &  topic,
of_packet_in_t *const  packetIn 
)
inlinestatic

Extends to basic packetIn topic with ethertype / protocoltype (if ipv4/ipv6). Uses fixed offsets and may produce wrong results. may be faster than the libtins based topic construction.

USE AT YOUR OWN RISK.

Parameters
topictopic to append bytes (at least ethertype) to.
packetInOpenFlow PACKET_IN message with an EthernetII frame as payload
static bool SwitchConnectionUtil::parseOpenFlowFromSocketToBuffer ( uint8_t *  buffer,
Poco::Net::SocketStream &  fromSocket 
)
inlinestatic

Reads an OpenFlow message from the given socket into the given buffer.

Parameters
bufferthe buffer that the function will write to.
fromSocketthe socket from which the OpenFlow message will be read.
Returns
true if the read was sucessful, or false if the underlying connection failed while reading.
static bool SwitchConnectionUtil::writeOpenFlowToSocket ( Poco::Net::SocketStream &  toSocket,
uint8_t *  buffer 
)
inlinestatic

Writes the given OpenFlow message (contained in the buffer) to the given socket.

Parameters
toSocketthe socket where the OpenFlow message will be written to.
bufferthe buffer containing an OpenFlow message to be written to the socket.
Returns
true if the write was successful, or false if the underlying connection failed while writing.
static bool SwitchConnectionUtil::writeOpenFlowToSocket ( Poco::Net::SocketStream &  toSocket,
of_object_t *const  openFlowMsg 
)
inlinestatic

Writes the given OpenFlow message to the given socket.

Parameters
toSocketthe socket where the OpenFlow message will be written to.
openFlowMsgthe message to be written to the socket.
Returns
true if the write was scucessful, or false if the underlying connection failed while writing.

Member Data Documentation

const int SwitchConnectionUtil::etherTypePos = 12
static
const int SwitchConnectionUtil::ethPayloadOffset = 14
static

constants used for experimental topic construction

const int SwitchConnectionUtil::ipv4 = 0x0800
static
const int SwitchConnectionUtil::ipv6 = 0x86DD
static
const uint32_t SwitchConnectionUtil::OF_HEADER_LENGTH = 8
static

length of the OpenFlow message header in bytes

const int SwitchConnectionUtil::protoPos4 = ethPayloadOffset + 9
static
const int SwitchConnectionUtil::protoPos6 = ethPayloadOffset + 6
static

The documentation for this class was generated from the following files: