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