Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual page 261

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Copyright © 2010, Juniper Networks, Inc.
//--Get IGMP membership information--//
igmp_output_ptr = (char *)realloc((char *)igmp_output_ptr,
strlen(js_handshake1));
strcpy(igmp_output_ptr, js_handshake1);
sock_bytes = write(sockfd, js_show_igmp, strlen(js_show_igmp));
while(strstr(igmp_output_ptr, "</rpc-reply>") == NULL) {
sock_bytes = read(sockfd, rcvbuffer, 255);
rcvbuffer[sock_bytes] = 0;
igmp_output_len = strlen((char *)igmp_output_ptr);
igmp_output_ptr = (char *)realloc((char *)igmp_output_ptr,
strlen(rcvbuffer)+igmp_output_len);
strcat(igmp_output_ptr, rcvbuffer);
}
#ifdef PRINT
printf("\n%s\n", igmp_output_ptr);
#endif
//--End of GET IGMP membership information--//
//--Store xPath results for pim buffer search--//
doc = getdoc(pim_output_ptr);
//--Call getdoc() to parse XML in pim_output--//
pim_result = getnodeset (doc, pim_xpath_ptr);
//--Call getnodeset() which provides xPath result--//
if (pim_result) {
nodeset = pim_result->nodesetval;
for (count_a=0; count_a < nodeset->nodeNr; count_a++) {
//--Run through all node values found--//
keyword_ptr = xmlNodeListGetString
(doc, nodeset->nodeTab[count_a]->xmlChildrenNode, 1);
strcpy(pim_result_buff[count_a], (char *)keyword_ptr);
//--Copy each node value to its own array element--//
#ifdef PRINT
printf("PIM Groups: %s\n", pim_result_buff[count_a]);
//--Print the node value--//
#endif
xmlFree(keyword_ptr);
xmlChar *keyword_ptr = NULL;
}
xmlXPathFreeObject(pim_result);
//--Free memory used by result--//
}
xmlFreeDoc(doc);
//--Free memory used by doc--//
xmlCleanupParser();
//--End of xPath search--//
//--Store xPath results for igmp buffer search--//
doc = getdoc(igmp_output_ptr);
igmp_result = getnodeset (doc, igmp_xpath_ptr);
if (igmp_result) {
nodeset = igmp_result->nodesetval;
for (count_a=0; count_a < nodeset->nodeNr; count_a++) {
keyword_ptr = xmlNodeListGetString
(doc, nodeset->nodeTab[count_a]->xmlChildrenNode, 1);
strcpy(igmp_result_buff[count_a], (char *)keyword_ptr);
#ifdef PRINT
Chapter 10: Writing Junos XML Protocol C Client Applications
//--Free memory used by keyword_ptr--//
//--Clean everything else--//
239

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents