8 #include <pugixml/pugixml.hpp>
19 uint32_t response_code,
31 pugi->AddNode(
"iq",
"");
32 pugi->AddAttribute(
"type", iq_type);
37 pugi->AddAttribute(
"to", to);
40 pugi->AddAttribute(
"id",
id.str());
42 pugi->AddChildNode(
"dns",
"");
43 pugi->AddAttribute(
"transid",
id.str());
45 std::stringstream code;
46 code << response_code;
50 pugi->AddChildNode(
"update",
"");
51 node =
pugi->FindNode(
"update");
55 pugi->AddChildNode(
"response",
"");
56 pugi->AddAttribute(
"code", code.str());
57 pugi->AddChildNode(
"update",
"");
58 node =
pugi->FindNode(
"update");
62 pugi->AddChildNode(
"query",
"");
63 node =
pugi->FindNode(
"query");
67 pugi->AddChildNode(
"response",
"");
68 pugi->AddAttribute(
"code", code.str());
69 pugi->AddChildNode(
"query",
"");
70 node =
pugi->FindNode(
"query");
83 pugi::xml_node node_c;
85 node_c = node->append_child(
"virtual-dns");
88 node_c = node->append_child(
"zone");
89 node_c.text().set(xmpp_data->
zone.c_str());
91 for (DnsItems::iterator item = xmpp_data->
items.begin();
92 item != xmpp_data->
items.end(); ++item) {
93 node_c = node->append_child(
"entry");
100 pugi::xml_node node_c;
102 node_c = node->append_child(
"class");
103 node_c.text().set(item.
eclass);
105 node_c = node->append_child(
"type");
106 node_c.text().set(item.
type);
108 node_c = node->append_child(
"name");
109 node_c.text().set(item.
name.c_str());
111 if (item.
data !=
"") {
112 node_c = node->append_child(
"data");
113 node_c.text().set(item.
data.c_str());
116 if (item.
ttl != (uint32_t) -1) {
117 node_c = node->append_child(
"ttl");
118 node_c.text().set(item.
ttl);
121 if (item.
priority != (uint16_t) -1) {
122 node_c = node->append_child(
"priority");
130 uint16_t &resp_code,
DnsUpdateData *data, std::string source_name) {
131 std::stringstream id(dns.attribute(
"transid").value());
134 pugi::xml_node resp = dns.first_child();
135 if (strcmp(resp.name(),
"response") == 0) {
136 std::stringstream code(resp.attribute(
"code").value());
138 return DecodeDns(resp.first_child(),
type,
true, data, source_name);
148 if (strcmp(node.name(),
"update") == 0) {
151 }
else if (strcmp(node.name(),
"query") == 0) {
156 DNS_XMPP_TRACE(DnsXmppTrace,
"Dns XMPP response : unknown tag : " <<
164 for (pugi::xml_node node = dnsdata.first_child(); node;
165 node = node.next_sibling()) {
166 if (strcmp(node.name(),
"virtual-dns") == 0) {
168 }
else if (strcmp(node.name(),
"zone") == 0) {
169 data->
zone = node.child_value();
170 }
else if (strcmp(node.name(),
"entry") == 0) {
172 for (pugi::xml_node entry = node.first_child(); entry;
173 entry = entry.next_sibling()) {
174 if (strcmp(entry.name(),
"class") == 0) {
175 std::stringstream cl(entry.child_value());
177 }
else if (strcmp(entry.name(),
"type") == 0) {
178 std::stringstream
type(entry.child_value());
180 }
else if (strcmp(entry.name(),
"name") == 0) {
181 item.
name = entry.child_value();
182 }
else if (strcmp(entry.name(),
"data") == 0) {
183 item.
data = entry.child_value();
184 }
else if (strcmp(entry.name(),
"ttl") == 0) {
185 std::stringstream ttl(entry.child_value());
187 }
else if (strcmp(entry.name(),
"priority") == 0) {
188 std::stringstream prio(entry.child_value());
192 "Dns XMPP response : unknown tag : " <<
198 data->
items.push_back(item);
200 DNS_XMPP_TRACE(DnsXmppTrace,
"Dns XMPP response : unknown tag : " <<
static bool DnsAgentXmppDecode(const pugi::xml_node dns, XmppType &type, uint32_t &xid, uint16_t &resp_code, DnsUpdateData *data, std::string source_name="")
static void EncodeDnsItem(pugi::xml_node *node, DnsItem &entry)
static void EncodeDnsData(pugi::xml_node *node, DnsUpdateData *xmpp_data)
static std::size_t DnsAgentXmppEncode(XmppChannel *channel, XmppType type, uint32_t trans_id, uint32_t resp_code, DnsUpdateData *xmpp_data, uint8_t *data)
static bool DecodeDns(const pugi::xml_node node, XmppType &type, bool is_resp, DnsUpdateData *data, std::string source_name)
static bool DecodeDnsItems(const pugi::xml_node dnsdata, DnsUpdateData *data, std::string source_name)
virtual const std::string & ToString() const =0
virtual const std::string & FromString() const =0
static const char * kDnsPeer
static int EncodeMessage(const XmppChatMessage *, uint8_t *data, size_t size)
static XmlBase * AllocXmppXmlImpl(const char *doc=NULL)
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
SandeshTraceBufferPtr SandeshTraceBufferCreate(const std::string &buf_name, size_t buf_size, bool trace_enable=true)
SandeshTraceBufferPtr AgentXmppTraceBuf(SandeshTraceBufferCreate("Xmpp", 500))
#define DNS_XMPP_TRACE(obj, arg)