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_dhcpv6_proto_hpp 7 : #define vnsw_agent_dhcpv6_proto_hpp 8 : 9 : #include "pkt/proto.h" 10 : #include "services/dhcpv6_handler.h" 11 : 12 : #define DHCPV6_TRACE(obj, arg) \ 13 : do { \ 14 : std::ostringstream _str; \ 15 : _str << arg; \ 16 : Dhcpv6##obj::TraceMsg(Dhcpv6TraceBuf, __FILE__, __LINE__, _str.str()); \ 17 : } while (false) \ 18 : 19 : // DHCPv6 DUID types 20 : #define DHCPV6_DUID_TYPE_LLT 1 21 : #define DHCPV6_DUID_TYPE_EN 2 22 : #define DHCPV6_DUID_TYPE_LL 3 23 : 24 : class Dhcpv6Proto : public Proto { 25 : public: 26 : static const uint32_t kDhcpMaxPacketSize = 1024; 27 : struct Duid { 28 : uint16_t type; 29 : uint16_t hw_type; 30 : uint8_t mac[ETHER_ADDR_LEN]; 31 : }; 32 : 33 : struct DhcpStats { 34 2 : DhcpStats() { Reset(); } 35 2 : void Reset() { 36 2 : solicit = advertise = request = confirm = renew = 37 2 : rebind = reply = release = decline = reconfigure = 38 2 : information_request = error = 0; 39 2 : } 40 : 41 : uint32_t solicit; 42 : uint32_t advertise; 43 : uint32_t request; 44 : uint32_t confirm; 45 : uint32_t renew; 46 : uint32_t rebind; 47 : uint32_t reply; 48 : uint32_t release; 49 : uint32_t decline; 50 : uint32_t reconfigure; 51 : uint32_t information_request; 52 : uint32_t error; 53 : }; 54 : 55 : Dhcpv6Proto(Agent *agent, boost::asio::io_context &io, 56 : bool run_with_vrouter); 57 : virtual ~Dhcpv6Proto(); 58 : ProtoHandler *AllocProtoHandler(boost::shared_ptr<PktInfo> info, 59 : boost::asio::io_context &io); 60 : void Shutdown(); 61 : 62 0 : const Duid *server_duid() const { return &server_duid_; } 63 : 64 0 : void IncrStatsSolicit() { stats_.solicit++; } 65 0 : void IncrStatsAdvertise() { stats_.advertise++; } 66 0 : void IncrStatsRequest() { stats_.request++; } 67 0 : void IncrStatsConfirm() { stats_.confirm++; } 68 0 : void IncrStatsRenew() { stats_.renew++; } 69 0 : void IncrStatsRebind() { stats_.rebind++; } 70 0 : void IncrStatsReply() { stats_.reply++; } 71 0 : void IncrStatsRelease() { stats_.release++; } 72 0 : void IncrStatsDecline() { stats_.decline++; } 73 0 : void IncrStatsReconfigure() { stats_.reconfigure++; } 74 0 : void IncrStatsInformationRequest() { stats_.information_request++; } 75 0 : void IncrStatsError() { stats_.error++; } 76 0 : const DhcpStats &GetStats() const { return stats_; } 77 0 : void ClearStats() { stats_.Reset(); } 78 : 79 : private: 80 : bool run_with_vrouter_; 81 : DhcpStats stats_; 82 : Duid server_duid_; 83 : 84 : DISALLOW_COPY_AND_ASSIGN(Dhcpv6Proto); 85 : }; 86 : 87 : #endif // vnsw_agent_dhcpv6_proto_hpp