Line data Source code
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 : 17 : class MacLearningPartition; 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 : 28 : MacLearningProto(Agent *agent, 29 : boost::asio::io_context &io); 30 6 : virtual ~MacLearningProto() {} 31 : 32 0 : 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 24 : uint32_t size() { 45 24 : return mac_learning_partition_list_.size(); 46 : } 47 : 48 21 : TokenPool* add_tokens() { 49 21 : return &add_tokens_; 50 : } 51 : 52 3 : TokenPool* change_tokens() { 53 3 : return &change_tokens_; 54 : } 55 : 56 3 : TokenPool* delete_tokens() { 57 3 : return &delete_tokens_; 58 : } 59 : 60 : TokenPtr GetToken(MacLearningEntryRequest::Event event); 61 : virtual void TokenAvailable(TokenPool *pool); 62 : MacIpLearningTable* GetMacIpLearningTable(); 63 : 64 : private: 65 : MacLearningPartitionList mac_learning_partition_list_; 66 : MacIpLearningTablePtr mac_ip_learning_tbl_; 67 : TokenPool add_tokens_; 68 : TokenPool change_tokens_; 69 : TokenPool delete_tokens_; 70 : DISALLOW_COPY_AND_ASSIGN(MacLearningProto); 71 : }; 72 : #endif