Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_proto_hpp 6 : #define vnsw_agent_proto_hpp 7 : 8 : #include "pkt_handler.h" 9 : 10 : class Agent; 11 : class ProtoHandler; 12 : class TokenPool; 13 : 14 : // Protocol task (work queue for each protocol) 15 : class Proto { 16 : public: 17 : typedef WorkQueue<boost::shared_ptr<PktInfo> > ProtoWorkQueue; 18 : 19 : Proto(Agent *agent, const char *task_name, PktHandler::PktModuleName mod, 20 : boost::asio::io_context &io); 21 : virtual ~Proto(); 22 : 23 97 : virtual bool Validate(PktInfo *msg) { return true; } 24 : virtual bool Enqueue(boost::shared_ptr<PktInfo> msg); 25 0 : virtual void ProcessStats(PktStatsType::Type type) { return; } 26 : virtual ProtoHandler *AllocProtoHandler(boost::shared_ptr<PktInfo> info, 27 : boost::asio::io_context &io) = 0; 28 : 29 : void FreeBuffer(PktInfo *msg); 30 : bool ProcessProto(boost::shared_ptr<PktInfo> msg_info); 31 : bool RunProtoHandler(ProtoHandler *handler); 32 2 : void set_trace(bool val) { trace_ = val; } 33 : void set_free_buffer(bool val) { free_buffer_ = val; } 34 0 : boost::asio::io_context &get_io_service() const { return io_; } 35 481 : Agent *agent() const { return agent_; } 36 : const ProtoWorkQueue *work_queue() const { return &work_queue_; } 37 0 : virtual void TokenAvailable(TokenPool *pool) {assert(0);} 38 : protected: 39 : Agent *agent_; 40 : PktHandler::PktModuleName module_; 41 : bool trace_; 42 : bool free_buffer_; 43 : boost::asio::io_context &io_; 44 : ProtoWorkQueue work_queue_; 45 : 46 : private: 47 : DISALLOW_COPY_AND_ASSIGN(Proto); 48 : }; 49 : 50 : #endif // vnsw_agent_proto_hpp