OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pkt_init.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <io/event_manager.h>
6 #include <cmn/agent_cmn.h>
7 #include <cmn/agent_factory.h>
8 #include "sandesh/sandesh_trace.h"
9 #include "pkt/pkt_init.h"
10 #include "pkt/pkt_handler.h"
11 #include "pkt/proto.h"
12 #include "pkt/proto_handler.h"
13 #include "pkt/flow_proto.h"
14 #include "pkt/flow_table.h"
15 #include "pkt/packet_buffer.h"
16 #include "pkt/control_interface.h"
17 #include "pkt/flow_mgmt.h"
18 
20 
22  agent_(agent), control_interface_(NULL),
23  pkt_handler_(NULL), flow_proto_(NULL),
24  packet_buffer_manager_(new PacketBufferManager(this)) {
25 }
26 
28 }
29 
30 void PktModule::Init(bool run_with_vrouter) {
31  boost::asio::io_context &io = *agent_->event_manager()->io_service();
32 
33  pkt_handler_.reset(new PktHandler(agent_, this));
34 
35  if (control_interface_) {
37  }
38 
39  flow_proto_.reset(new FlowProto(agent_, io));
40  flow_proto_->Init();
41 
42  uint16_t table_count = agent_->flow_thread_count();
43  for (uint8_t i = 0; i < table_count; i++) {
45  flow_mgmt_manager_list_[i]->Init();
46  }
48 }
49 
51  flow_proto_->InitDone();
52 }
53 
55  control_interface_ = intf;
56 }
57 
59  flow_proto_->Shutdown();
60  flow_proto_.reset(NULL);
61 
63  control_interface_ = NULL;
64 
65  FlowMgmtManagerList::iterator it = flow_mgmt_manager_list_.begin();
66  while (it != flow_mgmt_manager_list_.end()) {
67  (*it)->Shutdown();
68  it++;
69  }
70 
73 }
74 
77 }
78 
80  flow_proto_->FlushFlows();
81 }
82 
84  if (control_interface_ == NULL)
85  return;
86 
89  transport = Interface::TRANSPORT_SOCKET;
90  }
91 
94  transport);
95 }
96 
97 FlowTable *PktModule::flow_table(uint16_t index) const {
98  return flow_proto_->GetTable(index);
99 }
PktModule(Agent *agent)
Definition: pkt_init.cc:21
void CreateInterfaces()
Definition: pkt_init.cc:83
void STLDeleteValues(Container *container)
Definition: util.h:101
SandeshTraceBufferPtr PacketTraceBuf
void FlushFlows()
Definition: pkt_init.cc:79
boost::scoped_ptr< PktHandler > pkt_handler_
Definition: pkt_init.h:61
bool vrouter_on_host_dpdk() const
Definition: agent.cc:1057
FlowTable * flow_table(uint16_t index) const
Definition: pkt_init.cc:97
boost::asio::io_context * io_service()
Definition: event_manager.h:42
InterfaceTable * interface_table() const
Definition: agent.h:465
void Init(bool run_with_vrouter)
Definition: pkt_init.cc:30
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:18
static void InitLogQueue(Agent *agent)
Definition: flow_mgmt.cc:75
void Init(PktHandler *pkt_handler)
Agent * agent_
Definition: pkt_init.h:59
void Shutdown()
Definition: pkt_init.cc:58
Definition: agent.h:358
ControlInterface * control_interface_
Definition: pkt_init.h:60
void InitDone()
Definition: pkt_init.cc:50
EventManager * event_manager() const
Definition: agent.h:1103
static void ShutdownLogQueue()
Definition: flow_mgmt.cc:84
FlowMgmtManagerList flow_mgmt_manager_list_
Definition: pkt_init.h:64
boost::scoped_ptr< FlowProto > flow_proto_
Definition: pkt_init.h:62
virtual const std::string & Name() const =0
static void Create(InterfaceTable *table, const std::string &ifname, Interface::Transport transport)
Definition: interface.cc:674
virtual ~PktModule()
Definition: pkt_init.cc:27
void set_control_interface(ControlInterface *val)
Definition: pkt_init.cc:54
void IoShutdown()
Definition: pkt_init.cc:75
uint16_t flow_thread_count() const
Definition: agent.h:1202
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
Definition: sandesh_trace.h:46