Line data Source code
1 : /*
2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3 : */
4 :
5 : #ifndef _vnsw_agent_services_sandesh_h_
6 : #define _vnsw_agent_services_sandesh_h_
7 :
8 : #include <services/services_types.h>
9 :
10 : struct Dhcpv4Options;
11 : struct dhcphdr;
12 : struct Dhcpv6Hdr;
13 : struct dnshdr;
14 : struct ArpKey;
15 : class ArpEntry;
16 :
17 : class ServicesSandesh {
18 : public:
19 0 : ServicesSandesh() {}
20 0 : virtual ~ServicesSandesh() {}
21 :
22 : void HandleRequest(PktHandler::PktModuleName mod, std::string ctxt, bool more);
23 : void MetadataHandleRequest(std::string ctxt, bool more);
24 : void PktStatsSandesh(std::string ctxt, bool more);
25 :
26 : static void MacToString(const unsigned char *mac, std::string &mac_str);
27 : static std::string & DhcpMsgType(uint32_t msg_type);
28 : static std::string & Dhcpv6MsgType(uint32_t msg_type);
29 :
30 : private:
31 : std::string IntToString(uint32_t val);
32 : std::string IntToHexString(uint32_t val);
33 : void PktToHexString(uint8_t *pkt, int32_t len, std::string &msg);
34 : std::string IpProtocol(uint16_t prot);
35 :
36 : void DhcpStatsSandesh(std::string ctxt, bool more);
37 : void Dhcpv6StatsSandesh(std::string ctxt, bool more);
38 : void ArpStatsSandesh(std::string ctxt, bool more);
39 : void BfdStatsSandesh(std::string ctxt, bool more);
40 : void DnsStatsSandesh(std::string ctxt, bool more);
41 : void IcmpStatsSandesh(std::string ctxt, bool more);
42 : void IgmpStatsSandesh(std::string ctxt, bool more);
43 : void Icmpv6StatsSandesh(std::string ctxt, bool more);
44 :
45 : void ArpPktTrace(PktTrace::Pkt &pkt, ArpPktSandesh *resp);
46 : void DhcpPktTrace(PktTrace::Pkt &pkt, DhcpPktSandesh *resp);
47 : void Dhcpv6PktTrace(PktTrace::Pkt &pkt, Dhcpv6PktSandesh *resp);
48 : void DnsPktTrace(PktTrace::Pkt &pkt, DnsPktSandesh *resp);
49 : void IcmpPktTrace(PktTrace::Pkt &pkt, IcmpPktSandesh *resp);
50 : void Icmpv6PktTrace(PktTrace::Pkt &pkt, Icmpv6PktSandesh *resp);
51 : void OtherPktTrace(PktTrace::Pkt &pkt, PktSandesh *resp);
52 :
53 : void FillPktData(PktTrace::Pkt &pkt, PktData &resp);
54 : uint16_t FillVrouterHdr(PktTrace::Pkt &pkt, VrouterHdr &resp);
55 : int FillMacHdr(struct ether_header *eth, MacHdr &resp);
56 : void FillArpHdr(ether_arp *arp, ArpHdr &resp);
57 : void FillIpv4Hdr(struct ip *ip, Ipv4Hdr &resp);
58 : void FillIpv6Hdr(ip6_hdr *ip, Ipv6Hdr &resp);
59 : void FillIcmpv4Hdr(struct icmp *icmp, Icmpv4Hdr &resp);
60 : void FillIcmpv6Hdr(icmp6_hdr *icmp, Icmpv6Hdr &resp, int32_t len);
61 : void FillUdpHdr(udphdr *udp, UdpHdr &resp);
62 : void FillDhcpv4Options(Dhcpv4Options *opt, std::string &resp,
63 : std::string &other, int32_t len);
64 : void FillDhcpv4Hdr(dhcphdr *dhcp, Dhcpv4Hdr &resp, int32_t len);
65 : void FillDhcpv6Hdr(Dhcpv6Hdr *dhcp, Dhcpv6Header &resp, int32_t len);
66 : void FillDnsHdr(dnshdr *dns, DnsHdr &resp, int32_t dnslen);
67 : std::string FillOptionString(char *data, int32_t len, std::string msg);
68 : std::string FillOptionInteger(uint32_t data, std::string msg);
69 : std::string FillOptionIp(uint32_t data, std::string msg);
70 : void FillHostRoutes(uint8_t *data, int len, std::string &resp);
71 :
72 : DISALLOW_COPY_AND_ASSIGN(ServicesSandesh);
73 : };
74 :
75 : class ArpSandesh {
76 : public:
77 : static const uint8_t entries_per_sandesh = 100;
78 0 : ArpSandesh(SandeshResponse *resp) : iter_(0), resp_(resp) {};
79 : bool SetArpEntry(const ArpKey &key, const ArpEntry *entry);
80 0 : void Response() { resp_->Response(); }
81 : void SetInterfaceArpStatsEntry(
82 : ArpProto::InterfaceArpMap::const_iterator &it,
83 : std::vector<InterfaceArpStats> &list);
84 :
85 : private:
86 : int iter_;
87 : SandeshResponse *resp_;
88 : DISALLOW_COPY_AND_ASSIGN(ArpSandesh);
89 : };
90 :
91 : #endif // _vnsw_agent_services_sandesh_h_
|