Users Guide

Table Of Contents
} else if (!strcasecmp(auth, "sha-1")) {
key = enchashbuf;
SHA1(secret, strlen(secret), hashbuf);
encode_message_digest(hashbuf, 20, enchashbuf);
#endif
} else if (!strcasecmp(auth, "md5")) {
key = enchashbuf;
md5_calc(hashbuf, secret, strlen(secret));
encode_message_digest(hashbuf, 16, enchashbuf);
}
debug("Message authentication is %s (%s)\n", auth, key);
sprintf(p, "<authentication>%s</authentication><key>%s</key>",
auth, key);
p += strlen(p);
}
debug("\n");
sprintf(p, "<version>%s</version>", version);
sprintf(p, "</authresponse>");
cgi_escape_url(encbuf, sizeof(encbuf), cmdbuf, strlen(cmdbuf), 0);
postlen = sprintf(post,
"POST /auth/command.xml HTTP/1.0\r\n"
"User-Agent: ecp\r\n"
"Host: %s\r\n"
"Pragma: no-cache\r\n"
"Content-Length: %d\r\n"
/* "Content-Type: application/x-www-form-urlencoded\r\n" */
"Content-Type: application/xml\r\n"
"\r\n"
"%s",
argv[1], strlen(encbuf), encbuf);
inet_aton(argv[1], &sa.sin_addr);
sa.sin_family = AF_INET;
sa.sin_port = htons(80);
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
exit(1);
}
if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
perror("connect");
exit(1);
}
if (write(fd, post, postlen) != postlen) {
perror("write");
exit(1);
}
while ((len = read(fd, post, sizeof(post))) > 0)
write(1, post, len);
close(fd);
exit(0);
}
static void encode_message_digest (unsigned char *md, int mdlen, char *output)
{
int i;
for (i=0; i<mdlen; i++) {
sprintf(output, "%02x", md[i]);
Dell Networking W-Series ArubaOS 6.4.x | User Guide External User Management |
1122