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