Message ID | 1328708375-12246-1-git-send-email-yhalperi@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, Feb 08, 2012 at 03:39:35PM +0200, Yonit Halperin wrote: > RHBZ #788444 769512 ACK, just a few comment fixes (take it or leave it). > > CC: Gerd Hoffmann <kraxel@redhat.com> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > Signed-off-by: Yonit Halperin <yhalperi@redhat.com> > --- > server/reds.c | 21 +++++++++++++++++---- > server/spice.h | 6 ++++++ > 2 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/server/reds.c b/server/reds.c > index 2492a89..828ba65 100644 > --- a/server/reds.c > +++ b/server/reds.c > @@ -2005,7 +2005,7 @@ static void reds_get_spice_ticket(RedLinkInfo *link) > > #if HAVE_SASL > static char *addr_to_string(const char *format, > - struct sockaddr *sa, > + struct sockaddr_storage *sa, > socklen_t salen) { > char *addr; > char host[NI_MAXHOST]; > @@ -2013,7 +2013,7 @@ static char *addr_to_string(const char *format, > int err; > size_t addrlen; > > - if ((err = getnameinfo(sa, salen, > + if ((err = getnameinfo((struct sockaddr *)sa, salen, > host, sizeof(host), > serv, sizeof(serv), > NI_NUMERICHOST | NI_NUMERICSERV)) != 0) { > @@ -2402,11 +2402,13 @@ static void reds_start_auth_sasl(RedLinkInfo *link) > RedsSASL *sasl = &link->stream->sasl; > > /* Get local & remote client addresses in form IPADDR;PORT */ > - if (!(localAddr = addr_to_string("%s;%s", &link->stream->info.laddr, link->stream->info.llen))) { > + if (!(localAddr = addr_to_string("%s;%s", &link->stream->info.laddr_ext, > + link->stream->info.llen_ext))) { > goto error; > } > > - if (!(remoteAddr = addr_to_string("%s;%s", &link->stream->info.paddr, link->stream->info.plen))) { > + if (!(remoteAddr = addr_to_string("%s;%s", &link->stream->info.paddr_ext, > + link->stream->info.plen_ext))) { > free(localAddr); > goto error; > } > @@ -2717,10 +2719,21 @@ static RedLinkInfo *reds_init_client_connection(int socket) > > stream->socket = socket; > /* gather info + send event */ > + > + /* deprecated fields. Filling them for backward compatibility */ /* deprecated fields. Filling them for backward compatibility, will * truncate for ipv6 addresses (RHBZ #769512) */ > stream->info.llen = sizeof(stream->info.laddr); > stream->info.plen = sizeof(stream->info.paddr); > getsockname(stream->socket, (struct sockaddr*)(&stream->info.laddr), &stream->info.llen); > getpeername(stream->socket, (struct sockaddr*)(&stream->info.paddr), &stream->info.plen); > + > + stream->info.flags |= SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT; > + stream->info.llen_ext = sizeof(stream->info.laddr_ext); > + stream->info.plen_ext = sizeof(stream->info.paddr_ext); > + getsockname(stream->socket, (struct sockaddr*)(&stream->info.laddr_ext), > + &stream->info.llen_ext); > + getpeername(stream->socket, (struct sockaddr*)(&stream->info.paddr_ext), > + &stream->info.plen_ext); > + > reds_stream_channel_event(stream, SPICE_CHANNEL_EVENT_CONNECTED); > > openssl_init(link); > diff --git a/server/spice.h b/server/spice.h > index c582e6c..7397655 100644 > --- a/server/spice.h > +++ b/server/spice.h > @@ -54,6 +54,7 @@ typedef struct SpiceCoreInterface SpiceCoreInterface; > #define SPICE_CHANNEL_EVENT_DISCONNECTED 3 > > #define SPICE_CHANNEL_EVENT_FLAG_TLS (1 << 0) > +#define SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT (1 << 1) > > typedef struct SpiceWatch SpiceWatch; > typedef void (*SpiceWatchFunc)(int fd, int event, void *opaque); > @@ -66,9 +67,14 @@ typedef struct SpiceChannelEventInfo { > int type; > int id; > int flags; > + /* deprecated, can't hold ipv6 addresses, kept for backward compatibility */ > struct sockaddr laddr; > struct sockaddr paddr; > socklen_t llen, plen; > + /* should be used if (flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) */ valid if and only if (flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) > + struct sockaddr_storage laddr_ext; > + struct sockaddr_storage paddr_ext; > + socklen_t llen_ext, plen_ext; > } SpiceChannelEventInfo; > > struct SpiceCoreInterface { > -- > 1.7.7.6 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/spice-devel
diff --git a/server/reds.c b/server/reds.c index 2492a89..828ba65 100644 --- a/server/reds.c +++ b/server/reds.c @@ -2005,7 +2005,7 @@ static void reds_get_spice_ticket(RedLinkInfo *link) #if HAVE_SASL static char *addr_to_string(const char *format, - struct sockaddr *sa, + struct sockaddr_storage *sa, socklen_t salen) { char *addr; char host[NI_MAXHOST]; @@ -2013,7 +2013,7 @@ static char *addr_to_string(const char *format, int err; size_t addrlen; - if ((err = getnameinfo(sa, salen, + if ((err = getnameinfo((struct sockaddr *)sa, salen, host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV)) != 0) { @@ -2402,11 +2402,13 @@ static void reds_start_auth_sasl(RedLinkInfo *link) RedsSASL *sasl = &link->stream->sasl; /* Get local & remote client addresses in form IPADDR;PORT */ - if (!(localAddr = addr_to_string("%s;%s", &link->stream->info.laddr, link->stream->info.llen))) { + if (!(localAddr = addr_to_string("%s;%s", &link->stream->info.laddr_ext, + link->stream->info.llen_ext))) { goto error; } - if (!(remoteAddr = addr_to_string("%s;%s", &link->stream->info.paddr, link->stream->info.plen))) { + if (!(remoteAddr = addr_to_string("%s;%s", &link->stream->info.paddr_ext, + link->stream->info.plen_ext))) { free(localAddr); goto error; } @@ -2717,10 +2719,21 @@ static RedLinkInfo *reds_init_client_connection(int socket) stream->socket = socket; /* gather info + send event */ + + /* deprecated fields. Filling them for backward compatibility */ stream->info.llen = sizeof(stream->info.laddr); stream->info.plen = sizeof(stream->info.paddr); getsockname(stream->socket, (struct sockaddr*)(&stream->info.laddr), &stream->info.llen); getpeername(stream->socket, (struct sockaddr*)(&stream->info.paddr), &stream->info.plen); + + stream->info.flags |= SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT; + stream->info.llen_ext = sizeof(stream->info.laddr_ext); + stream->info.plen_ext = sizeof(stream->info.paddr_ext); + getsockname(stream->socket, (struct sockaddr*)(&stream->info.laddr_ext), + &stream->info.llen_ext); + getpeername(stream->socket, (struct sockaddr*)(&stream->info.paddr_ext), + &stream->info.plen_ext); + reds_stream_channel_event(stream, SPICE_CHANNEL_EVENT_CONNECTED); openssl_init(link); diff --git a/server/spice.h b/server/spice.h index c582e6c..7397655 100644 --- a/server/spice.h +++ b/server/spice.h @@ -54,6 +54,7 @@ typedef struct SpiceCoreInterface SpiceCoreInterface; #define SPICE_CHANNEL_EVENT_DISCONNECTED 3 #define SPICE_CHANNEL_EVENT_FLAG_TLS (1 << 0) +#define SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT (1 << 1) typedef struct SpiceWatch SpiceWatch; typedef void (*SpiceWatchFunc)(int fd, int event, void *opaque); @@ -66,9 +67,14 @@ typedef struct SpiceChannelEventInfo { int type; int id; int flags; + /* deprecated, can't hold ipv6 addresses, kept for backward compatibility */ struct sockaddr laddr; struct sockaddr paddr; socklen_t llen, plen; + /* should be used if (flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) */ + struct sockaddr_storage laddr_ext; + struct sockaddr_storage paddr_ext; + socklen_t llen_ext, plen_ext; } SpiceChannelEventInfo; struct SpiceCoreInterface {