From f8d8f7d017aaeb013e0738e8c92620882ebb5e51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Wed, 6 Mar 2013 09:44:11 +0000 Subject: [PATCH] - Notification client can bind to addresses specified by hostname (Fixes SB #100721) - Conservative solution: hostname resolution is done multiple times by the client. - Notification client recognizes square brackets enclosing host address in endpoint specification --- org.glite.lb.client/src/notification.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c index b20663d..ff20bbb 100644 --- a/org.glite.lb.client/src/notification.c +++ b/org.glite.lb.client/src/notification.c @@ -90,7 +90,12 @@ static void get_name_and_port(const char *address, char **name, int *port) *port = atoi(p+1); *p = 0; } - *name = strdup(n); + if (p = strrchr(n, '[')) { + int len = strcspn(p+1, "]"); + *name = (char*)malloc(sizeof(char*) * (len+1)); + strncpy(*name, p+1, len); + } + else *name = strdup(n); free(n); } @@ -102,7 +107,7 @@ static int daemon_listen(edg_wll_Context ctx, const char *name, char *port, int int gaie; memset (&hints, '\0', sizeof (hints)); - hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV | AI_PASSIVE | AI_ADDRCONFIG; + hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE | AI_ADDRCONFIG; hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET6; -- 1.8.2.3