Update of /cvsroot/sblim/wbemcli
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3777
Modified Files:
ChangeLog CimCurl.cpp CimXml.cpp CimXml.h NEWS
Log Message:
Fixed 0002626: Add IPv6 LLA support to wbemcli
Index: NEWS
===================================================================
RCS file: /cvsroot/sblim/wbemcli/NEWS,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- NEWS 27 Jun 2012 00:22:00 -0000 1.44
+++ NEWS 25 Mar 2013 04:05:49 -0000 1.45
@@ -13,6 +13,7 @@
- 3324380 support optional CIMType in KEYVALUE element
- 3216622 wbemcli throws parser error on CDATA string value
- 2991546 Core dumps when property contains value within "[]"
+- 0002626 Add IPv6 LLA support to wbemcli
Changes in Version 1.6.1
========================
Index: ChangeLog
===================================================================
RCS file: /cvsroot/sblim/wbemcli/ChangeLog,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- ChangeLog 18 Apr 2012 04:52:16 -0000 1.37
+++ ChangeLog 25 Mar 2013 04:05:49 -0000 1.38
@@ -1,3 +1,9 @@
+2013-03-25 Dave Heller <hel...@us...>
+
+ * CimCurl.cpp, CimXml.cpp, CimXml.h, NEWS:
+
+ Fixed 0002626: Add IPv6 LLA support to wbemcli
+
2012-04-18 Dave Heller <hel...@us...>
* CimXml.cpp, NEWS:
Index: CimCurl.cpp
===================================================================
RCS file: /cvsroot/sblim/wbemcli/CimCurl.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CimCurl.cpp 17 Apr 2012 16:17:02 -0000 1.14
+++ CimCurl.cpp 25 Mar 2013 04:05:49 -0000 1.15
@@ -155,6 +155,15 @@
/* Initialize curl with the url */
rv = curl_easy_setopt(mHandle, CURLOPT_URL, mUri.c_str());
+
+ /* Set IPv6 scope (zone) identifier if provided */
+ if (url.zone_id >= 0) {
+#if LIBCURL_VERSION_NUM >= 0x071300
+ rv = curl_easy_setopt(mHandle, CURLOPT_ADDRESS_SCOPE, url.zone_id);
+#else
+ throw URLException("IPv6 zone identifier requires libcurl 7.19 or greater");
+#endif
+ }
/* Disable progress output */
rv = curl_easy_setopt(mHandle, CURLOPT_NOPROGRESS, 1);
Index: CimXml.h
===================================================================
RCS file: /cvsroot/sblim/wbemcli/CimXml.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- CimXml.h 17 Apr 2012 16:17:02 -0000 1.39
+++ CimXml.h 25 Mar 2013 04:05:49 -0000 1.40
@@ -821,9 +821,11 @@
class URL {
+ int getNetDeviceNum(string);
public:
string scheme;
string host;
+ long zone_id;
string port;
string cName;
string user;
Index: CimXml.cpp
===================================================================
RCS file: /cvsroot/sblim/wbemcli/CimXml.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- CimXml.cpp 27 Jun 2012 00:22:00 -0000 1.73
+++ CimXml.cpp 25 Mar 2013 04:05:49 -0000 1.74
@@ -36,6 +36,8 @@
#include <iostream>
#include <cstdlib>
#include <cstdio>
+#include <algorithm>
+#include <errno.h>
#ifdef WIN32
#include <malloc.h>
#define strcasecmp stricmp
@@ -2948,7 +2950,7 @@
URL::URL(const char *U)
{
int pint,indir=0;
- char *p,*q,*phelp,*np,*last,*un,*b;
+ char *p,*q,*phelp,*np,*last,*un,*b,*h,*z;
char *origu, *u;
u = origu = strdup(U);
@@ -3036,6 +3038,27 @@
port=string(p+1); // we may do that as we are at the end of the string
}
if (host.size()==0) throw URLException("Could not locate hostname");
+
+ // Extract IPv6 zone identifier, if present.
+ if ((z = strchr((h = strdup(host.c_str())),'%'))) {
+#ifdef WIN32
+ throw URLException("Zone id lookup not supported on win32");
+#else
+ *(strchr(z,']')) = 0;
+ z++;
+ // TODO support percent encoding per rfc6874
+ if (*z == 0 || strlen(z) != strlen(strtok(z, "!$%&*=?@^~")))
+ throw URLException("Malformed IPv6 zone id");
+ *(strchr(h,'%')) = 0;
+ host = string(h+1);
+ if ((zone_id = atoi(z)) <= 0) zone_id = URL::getNetDeviceNum(string(z));
+ free(h);
+#endif
+ }
+ else {
+ zone_id = -1;
+ }
+
pint=strtol(port.c_str(),&np,10);
if (*np) throw URLException("Invalid port number");
@@ -3124,7 +3147,31 @@
return;
}
+int URL::getNetDeviceNum(string devName) {
+#ifdef WIN32
+ throw URLException("Zone id lookup not supported on win32");
+#else
+ FILE *fp;
+ string filename = "/proc/net/if_inet6";
+ string scnfmt = "%*32s %2x %*2x %*2x %*2x %32s\n";
+ char dev_name[32]; // sufficient?
+ int dev_num;
+
+ if ((fp = fopen(filename.c_str(), "r")) == 0) {
+ if (DBGX) cerr<<"--- cannot access "<<filename<<" ("<<strerror(errno)<<")"<<endl;
+ throw URLException("Zone id lookup failure");
+ }
+
+ std::transform(devName.begin(), devName.end(), devName.begin(), ::tolower);
+ while (2 == fscanf(fp, scnfmt.c_str(), &dev_num, dev_name)) {
+ if (strcmp(devName.c_str(), dev_name) == 0) { /* match */
+ return dev_num;
+ }
+ }
+ return -1; // zone id not found in interfaces table
+#endif
+}
int URL::refLookAhead(char *u, char **nu)
{
|