ns3-bgp  0.2
BGP module for ns-3.
bgp-ns3-socket-out.cc
Go to the documentation of this file.
1 
11 #include "bgp-ns3-socket-out.h"
12 
13 namespace ns3 {
14 
21 BgpNs3SocketOut::BgpNs3SocketOut(Ptr<Socket> socket, Callback<void, Ptr<Socket>, int, int> state_change_cb) {
22  _socket = socket;
23  _state_change_cb = state_change_cb;
24 }
25 
34 bool BgpNs3SocketOut::handleOut(const uint8_t *buffer, size_t length) {
35  return _socket->Send(buffer, length, 0) == (int) length;
36 }
37 
44 void BgpNs3SocketOut::notifyStateChange(int old_state, int new_state) {
45  _state_change_cb(_socket, old_state, new_state);
46 }
47 
53 void BgpNs3SocketOut::setStateChangeCallback(Callback<void, Ptr<Socket>, int, int> state_change_cb) {
54  _state_change_cb = state_change_cb;
55 }
56 
57 }
bool handleOut(const uint8_t *buffer, size_t length)
Handle output from libbgp. See libbgp document.
void notifyStateChange(int old_state, int new_state)
Handle state change notification from libbgp. See libbgp document.
Simple container class for FSM to send data to peer.
Definition: bgp-log.cc:15
void setStateChangeCallback(Callback< void, Ptr< Socket >, int, int > state_change_cb)
Set callback to use when FSM change state.
BgpNs3SocketOut(Ptr< Socket > socket, Callback< void, Ptr< Socket >, int, int > state_change_cb)
Construct the container.