Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : #ifndef VNSW_AGENT_SERVICES_ICMP_ERROR_PROTO_H_ 6 : #define VNSW_AGENT_SERVICES_ICMP_ERROR_PROTO_H_ 7 : 8 : #include <boost/asio.hpp> 9 : #include "pkt/proto.h" 10 : 11 : struct FlowKey; 12 : 13 : class IcmpErrorProto : public Proto { 14 : public: 15 : struct Stats { 16 2 : Stats() { Reset(); } 17 2 : ~Stats() { } 18 2 : void Reset() { 19 2 : df_msgs = 0; 20 2 : drops = 0; 21 2 : interface_errors = 0; 22 2 : invalid_flow_index = 0; 23 2 : } 24 : 25 : uint32_t df_msgs; 26 : uint32_t drops; 27 : uint32_t interface_errors; 28 : uint32_t invalid_flow_index; 29 : }; 30 : typedef boost::function<bool(uint32_t, FlowKey *, bool *)> FlowIndexToKeyFn; 31 : 32 : IcmpErrorProto(Agent *agent, boost::asio::io_context &io); 33 : virtual ~IcmpErrorProto(); 34 : 35 : void Shutdown() { } 36 0 : void Register(FlowIndexToKeyFn fn) { flow_index_to_key_fn_ = fn; } 37 : bool FlowIndexToKey(uint32_t index, FlowKey *key, bool *is_nat_flow); 38 : ProtoHandler *AllocProtoHandler(boost::shared_ptr<PktInfo> info, 39 : boost::asio::io_context &io); 40 : 41 : void incrememt_df_msgs() { stats_.df_msgs++; } 42 0 : void increment_drops() { stats_.drops++; } 43 0 : void increment_interface_errors() { stats_.interface_errors++; } 44 0 : void increment_invalid_flow_index() { stats_.invalid_flow_index++; } 45 : const Stats &GetStats() const { return stats_; } 46 : void ClearStats() { stats_.Reset(); } 47 : 48 : private: 49 : Stats stats_; 50 : FlowIndexToKeyFn flow_index_to_key_fn_; 51 : DISALLOW_COPY_AND_ASSIGN(IcmpErrorProto); 52 : }; 53 : 54 : #endif // VNSW_AGENT_SERVICES_ICMP_ERROR_PROTO_H_