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

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.
strcpy(minterface, argv[2]);
strcpy(msource, argv[3]);
}
igmp_xpath_ptr = (xmlChar *)realloc((xmlChar *)igmp_xpath_ptr, 1024);
sprintf(igmp_xpath_ptr, temp_xpath_ptr, minterface);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server = gethostbyname(jserver);
bzero((char*) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char*) server->h_addr, (char*)
&serv_addr.sin_addr.sin_addr, server->h_length);
serv_addr.sin_port = htons(jport);
//--Connect to the js server--//
if(connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
printf("Socket connect error\n");
}
if(fcntl(sockfd, F_SETOWN, getpid()) < 0)
error("Unable to set process owner to us\n");
printf("\nConnected to %s on port %d\n", jserver, jport);
//--Read data from the initial connect--//
sock_bytes = read(sockfd, rcvbuffer, 255);
#ifdef PRINT
printf("\n%s", rcvbuffer);
#endif
//--js intialization handshake--//
sock_bytes = write(sockfd, js_handshake1, strlen(js_handshake1));
//--Send xml PI to js server--//
sock_bytes = write(sockfd, js_handshake2, strlen(js_handshake2));
//--Send xml version and encoding to js server--//
sock_bytes = read(sockfd, rcvbuffer, 255);
//--Read return data from sock buffer--//
rcvbuffer[sock_bytes] = 0;
printf("XML connection to the Junos XML protocol server has been initialized\n");
#ifdef PRINT
printf("\n%s", rcvbuffer);
#endif
//--js login--//
sock_bytes = write(sockfd, js_login, strlen(js_login));
//--Send js command--//
while(strstr(small_buff, "superuser") == NULL) {
//--Continue to read from the buffer until match--//
sock_bytes = read(sockfd, rcvbuffer, 255);
rcvbuffer[sock_bytes] = 0;
strcat(small_buff, rcvbuffer);
//--Copy buffer contents into pim_buffer--//
}
printf("Login completed to the Junos XML protocol server\n");
#ifdef PRINT
printf("%s\n", small_buff); //--Print the small buff contents--//
#endif
Chapter 10: Writing Junos XML Protocol C Client Applications
237

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents