31 static TypeId tid =
TypeId(
"ns3::OFSwitch13SocketHandler")
33 .SetGroupName(
"OFSwitch13");
39 m_pendingPacket(nullptr),
95 NS_LOG_WARN(
"No space available to send message now.");
101 int retval = socket->
Send(packet);
104 NS_LOG_ERROR(
"Error while sending OpenFlow message to socket. "
105 <<
"Discarding. Socket error: " << socket->
GetErrno());
115 static const size_t ofpHeaderSize =
sizeof(
struct ofp_header);
132 struct ofp_header header;
a polymophic address class
bool IsNull() const
Check for null implementation.
Ptr< Socket > m_socket
TCP socket.
MessageCallback m_receivedMsg
OpenFlow message callback.
void Send(Ptr< Socket > socket, uint32_t available)
Callback for bytes available in tx buffer.
OFSwitch13SocketHandler(Ptr< Socket > socket)
Complete constructor.
uint32_t m_pendingBytes
Pending bytes for message.
std::queue< Ptr< Packet > > m_txQueue
TX queue.
~OFSwitch13SocketHandler() override
Dummy destructor, see DoDispose.
void Recv(Ptr< Socket > socket)
Callback for bytes available in rx buffer.
static TypeId GetTypeId()
Register this type.
int SendMessage(Ptr< Packet > packet)
Send an OpenFlow message to the TCP socket.
Ptr< Packet > m_pendingPacket
Buffer for receiving bytes.
void DoDispose() override
Destructor implementation.
void SetReceiveCallback(MessageCallback cb)
Set the callback to invoke whenever an OpenFlow message has been received at the associated socket.
A base class which provides memory management and object aggregation.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
virtual enum Socket::SocketErrno GetErrno() const =0
Get last error number.
virtual uint32_t GetTxAvailable() const =0
Returns the number of bytes which can be sent in a single call to Send.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...