Support IPv6 literal adresses.
authorZdeněk Salvet <salvet@ics.muni.cz>
Wed, 28 Jul 2010 13:17:39 +0000 (13:17 +0000)
committerZdeněk Salvet <salvet@ics.muni.cz>
Wed, 28 Jul 2010 13:17:39 +0000 (13:17 +0000)
org.glite.jobid.api-c/src/cjobid.c
org.glite.lb.client/src/perftest_jobreg.c
org.glite.lb.common/src/lb_perftest.c
org.glite.lb.common/src/param.c
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/notification.c
org.glite.lb.utils/src/dump.c
org.glite.lb.utils/src/load.c
org.glite.lb.utils/src/purge.c

index 3c8631d..7d8641e 100644 (file)
@@ -84,7 +84,7 @@ int glite_jobid_recreate(const char* bkserver, int port, const char *unique, gli
         return EINVAL;
 
     out->BShost = strdup(bkserver);
-    portbeg = strchr(out->BShost, ':');
+    portbeg = strrchr(out->BShost, ':');
     if (portbeg) {
        *portbeg = 0;
         /* try to get port number */
@@ -164,10 +164,12 @@ int glite_jobid_parse(const char *idString, glite_jobid_t *jobId)
 
     pom = strdup(idString + sizeof(GLITE_JOBID_PROTO_PREFIX) - 1);
     pom1 = strchr(pom, '/');
-    pom2 = strchr(pom, ':');
 
     if (!pom1) { free(pom); free(out); return EINVAL; }
 
+    pom2 = strrchr(pom, ':');
+    if (pom2 && strchr(pom2,']')) pom2 = NULL;
+
     if ( pom2 && (pom1 > pom2)) {
        pom[pom2-pom]     = '\0';
        out->BShost  = strdup(pom);
index 6946ab4..80cdc81 100644 (file)
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
        dprintf(("generating jobids..."));
        {
                char *name=server?server:strdup(PROXY_SERVER);
-               char *p = strchr(name,':');
+               char *p = strrchr(name,':');
                int  port;
 
                if (p)  { *p=0; port = atoi(p+1); }
index de03a01..cf4cc7a 100644 (file)
@@ -311,7 +311,7 @@ glite_wll_perftest_init(const char *host,
        {
                char *p;
 
-               p = strchr(host, ':');
+               p = strrchr(host, ':');
                if(p) 
                        *p = 0;
                dest_host = strdup(host);
index ca38e4e..7a0a0d8 100644 (file)
@@ -83,7 +83,7 @@ static int extract_port(edg_wll_ContextParam param,int dflt)
 {
        char    *p = NULL,*s = mygetenv(param);
 
-        if (s) p = strchr(s,':');
+        if (s) p = strrchr(s,':');
        return  p ? atoi(p+1) : dflt;
 }
 
@@ -100,7 +100,7 @@ static char *extract_host(edg_wll_ContextParam param,const char *dflt)
        s = mygetenv(param);
        if (!s && !dflt) return NULL;
        s = strdup(s?s:dflt),
-       p = strchr(s,':');
+       p = strrchr(s,':');
        if (p) *p = 0;
        return s;
 }
index 2b817c8..047a2c7 100644 (file)
@@ -614,7 +614,7 @@ int main(int argc, char *argv[])
        if (mode & SERVICE_SERVER) {
                if ( fake_host )
                {
-                       char    *p = strchr(fake_host,':');
+                       char    *p = strrchr(fake_host,':');
 
                        if (p)
                        {
@@ -1897,7 +1897,14 @@ static int asyn_gethostbyaddr(char **name, char **service, const struct sockaddr
         }
 
        if (ar.err == NETDB_SUCCESS) {
-               if (name) *name = ar.host;
+               if (name) {
+                       if (numeric && addr->sa_family == AF_INET6) {
+                               asprintf(name,"[%s]",ar.host);
+                               free(ar.host);
+                       } else {
+                               *name = ar.host;
+                       }
+               }
                if (service) *service = ar.service;
        }
        err = ar.err;
index 1d0b9f1..dd6f1bd 100644 (file)
@@ -126,7 +126,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                        free(ju); ju = NULL;
 
                        dest = strdup(jobc[1]);
-                       if ( !(aux = strchr(dest, ':')) )
+                       if ( !(aux = strrchr(dest, ':')) )
                        {
                                edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination");
                                free(dest);
index 34e9bc8..e36b6c5 100644 (file)
@@ -125,6 +125,7 @@ int edg_wll_NotifNewServer(
                        goto cleanup;
                }
                if ( !strncmp(address_override, "0.0.0.0", aux-address_override) || 
+                    !strncmp(address_override, "[::]", aux-address_override) ||
                     !strncmp(address_override, "::", aux-address_override) )
                        trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1);
        }
@@ -248,6 +249,7 @@ int edg_wll_NotifBindServer(
                                goto rollback;
                        }
                        if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ||
+                            !strncmp(address_override, "[::]", aux-address_override) ||
                             !strncmp(address_override, "::", aux-address_override) )
                                trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1);
                }
@@ -669,7 +671,7 @@ static int update_notif(
        }
        if ( dest )
        {
-               host = strchr(dest, ':');
+               host = strrchr(dest, ':');
                port = atoi(host+1);
                if ( !(host = strndup(dest, host-dest)) )
                {
index 783a3c5..0bba745 100644 (file)
@@ -131,7 +131,7 @@ int main(int argc,char *argv[])
        edg_wll_InitContext(&ctx);
        if ( server )
        {
-               char *p = strchr(server, ':');
+               char *p = strrchr(server, ':');
                if ( p )
                {
                        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1));
index 1431d2f..db2cd16 100644 (file)
@@ -104,7 +104,7 @@ int main(int argc,char *argv[])
        edg_wll_InitContext(&ctx);
        if ( server )
        {
-               char *p = strchr(server, ':');
+               char *p = strrchr(server, ':');
                if ( p )
                {
                        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1));
index 73cf082..4c7ac92 100644 (file)
@@ -274,7 +274,7 @@ int main(int argc,char *argv[])
 
        if ( server )
        {
-               char *p = strchr(server, ':');
+               char *p = strrchr(server, ':');
                if ( p )
                {
                        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1));