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