OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mac_learning_proto.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_PROTO_H_
6 #define SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_PROTO_H_
7 
8 #include "cmn/agent.h"
9 #include "cmn/agent_cmn.h"
10 #include "base/queue_task.h"
11 #include "pkt/proto.h"
12 #include "pkt/proto_handler.h"
13 #include "pkt/flow_token.h"
14 #include "mac_ip_learning.h"
15 #include "mac_learning_event.h"
16 
18 class MacAgingTable;
19 
20 class MacLearningProto : public Proto {
21 public:
22  typedef boost::shared_ptr<MacLearningPartition> MacLearningPartitionPtr;
23  typedef boost::shared_ptr<MacIpLearningTable> MacIpLearningTablePtr;
24  typedef std::vector<MacLearningPartitionPtr> MacLearningPartitionList;
25 
26  typedef boost::shared_ptr<MacAgingTable> MacAgingTablePtr;
27 
29  boost::asio::io_context &io);
30  virtual ~MacLearningProto() {}
31 
32  virtual bool Validate(PktInfo *msg) { return true; }
33  virtual ProtoHandler*
34  AllocProtoHandler(boost::shared_ptr<PktInfo> info,
35  boost::asio::io_context &io);
36  MacLearningPartition* Find(uint32_t index);
37 
38  void Delete(uint32_t index) {
39  mac_learning_partition_list_[index].reset();
40  }
41  bool Enqueue(PktInfoPtr msg);
42  void Init();
43  uint32_t Hash(uint32_t vrf_id, const MacAddress &mac);
44  uint32_t size() {
45  return mac_learning_partition_list_.size();
46  }
47 
49  return &add_tokens_;
50  }
51 
53  return &change_tokens_;
54  }
55 
57  return &delete_tokens_;
58  }
59 
61  virtual void TokenAvailable(TokenPool *pool);
63 
64 private:
65  tbb::mutex::scoped_lock mutex_;
72 };
73 #endif
virtual bool Validate(PktInfo *msg)
MacIpLearningTablePtr mac_ip_learning_tbl_
tbb::mutex::scoped_lock mutex_
MacLearningPartition * Find(uint32_t index)
virtual ProtoHandler * AllocProtoHandler(boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
TokenPool * add_tokens()
void Delete(uint32_t index)
TokenPool * delete_tokens()
MacLearningPartitionList mac_learning_partition_list_
Definition: agent.h:358
MacIpLearningTable * GetMacIpLearningTable()
TokenPtr GetToken(MacLearningEntryRequest::Event event)
virtual void TokenAvailable(TokenPool *pool)
bool Enqueue(PktInfoPtr msg)
std::vector< MacLearningPartitionPtr > MacLearningPartitionList
boost::shared_ptr< MacLearningPartition > MacLearningPartitionPtr
boost::shared_ptr< MacIpLearningTable > MacIpLearningTablePtr
virtual ~MacLearningProto()
boost::shared_ptr< Token > TokenPtr
Definition: flow_token.h:11
uint32_t Hash(uint32_t vrf_id, const MacAddress &mac)
MacLearningProto(Agent *agent, boost::asio::io_context &io)
DISALLOW_COPY_AND_ASSIGN(MacLearningProto)
TokenPool * change_tokens()
boost::shared_ptr< MacAgingTable > MacAgingTablePtr
boost::shared_ptr< PktInfo > PktInfoPtr
Definition: pkt_handler.h:61