Line data Source code
1 : /* 2 : * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_PROTO_H_ 7 : #define SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_PROTO_H_ 8 : 9 : #include "cmn/agent.h" 10 : #include "cmn/agent_cmn.h" 11 : #include "base/queue_task.h" 12 : #include "pkt/proto.h" 13 : #include "pkt/proto_handler.h" 14 : #include "pkt/flow_token.h" 15 : #include "mac_ip_learning.h" 16 : #include "mac_learning_event.h" 17 : 18 : class MacLearningPartition; 19 : class MacAgingTable; 20 : 21 : class MacLearningProto : public Proto { 22 : public: 23 : typedef boost::shared_ptr<MacLearningPartition> MacLearningPartitionPtr; 24 : typedef boost::shared_ptr<MacIpLearningTable> MacIpLearningTablePtr; 25 : typedef std::vector<MacLearningPartitionPtr> MacLearningPartitionList; 26 : 27 : typedef boost::shared_ptr<MacAgingTable> MacAgingTablePtr; 28 : 29 : MacLearningProto(Agent *agent, 30 : boost::asio::io_context &io); 31 4 : virtual ~MacLearningProto() {} 32 : 33 0 : virtual bool Validate(PktInfo *msg) { return true; } 34 : virtual ProtoHandler* 35 : AllocProtoHandler(boost::shared_ptr<PktInfo> info, 36 : boost::asio::io_context &io); 37 : MacLearningPartition* Find(uint32_t index); 38 : 39 : void Delete(uint32_t index) { 40 : mac_learning_partition_list_[index].reset(); 41 : } 42 : bool Enqueue(PktInfoPtr msg); 43 : void Init(); 44 : uint32_t Hash(uint32_t vrf_id, const MacAddress &mac); 45 148 : uint32_t size() { 46 148 : return mac_learning_partition_list_.size(); 47 : } 48 : 49 20 : TokenPool* add_tokens() { 50 20 : return &add_tokens_; 51 : } 52 : 53 2 : TokenPool* change_tokens() { 54 2 : return &change_tokens_; 55 : } 56 : 57 2 : TokenPool* delete_tokens() { 58 2 : return &delete_tokens_; 59 : } 60 : 61 : TokenPtr GetToken(MacLearningEntryRequest::Event event); 62 : virtual void TokenAvailable(TokenPool *pool); 63 : MacIpLearningTable* GetMacIpLearningTable(); 64 : 65 : private: 66 : MacLearningPartitionList mac_learning_partition_list_; 67 : MacIpLearningTablePtr mac_ip_learning_tbl_; 68 : TokenPool add_tokens_; 69 : TokenPool change_tokens_; 70 : TokenPool delete_tokens_; 71 : DISALLOW_COPY_AND_ASSIGN(MacLearningProto); 72 : }; 73 : #endif