A Discrete-Event Network Simulator
API
ofswitch13-socket-handler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 University of Campinas (Unicamp)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Luciano Jerez Chaves <ljerezchaves@gmail.com>
18  */
19 
20 #ifndef OFSWITCH13_SOCKET_HANDLER_H
21 #define OFSWITCH13_SOCKET_HANDLER_H
22 
23 #include "ofswitch13-interface.h"
24 
25 #include <ns3/log.h>
26 #include <ns3/packet.h>
27 #include <ns3/simulator.h>
28 #include <ns3/socket.h>
29 
30 #include <queue>
31 
32 namespace ns3
33 {
34 
48 {
49  public:
54  static TypeId GetTypeId();
55 
61  ~OFSwitch13SocketHandler() override;
62 
68 
75 
81  int SendMessage(Ptr<Packet> packet);
82 
83  protected:
85  void DoDispose() override;
86 
87  private:
93  void Send(Ptr<Socket> socket, uint32_t available);
94 
99  void Recv(Ptr<Socket> socket);
100 
103  uint32_t m_pendingBytes;
105  std::queue<Ptr<Packet>> m_txQueue;
106 };
107 
108 } // namespace ns3
109 #endif /* OFSWITCH13_SOCKET_HANDLER_H */
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:443
Class used to read/send single OpenFlow message from/to an open 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.
Callback< void, Ptr< Packet >, Address > MessageCallback
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.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.