summaryrefslogtreecommitdiffstats
path: root/transport/socket/src/name.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-01-27 07:19:43 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-01-28 06:11:33 -0800
commit15b3f715ac6c7dc127723908f269f0418b61de71 (patch)
tree8ea40582f5cc79db685668d85b98eb5e2cf3b60d /transport/socket/src/name.c
parente5a43ac65f60b7c4163eba6d7e15b60c54879813 (diff)
transport/socket: guess an appropriate address family when it is not specified in configuration.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 561 (with address family set to 'inet-sdp', transport/socket doesn't work correctly) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=561
Diffstat (limited to 'transport/socket/src/name.c')
-rw-r--r--transport/socket/src/name.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/transport/socket/src/name.c b/transport/socket/src/name.c
index b8d9664adb0..120a669c87b 100644
--- a/transport/socket/src/name.c
+++ b/transport/socket/src/name.c
@@ -462,18 +462,28 @@ client_bind (transport_t *this,
}
int32_t
-socket_client_get_remote_sockaddr (transport_t *this,
+socket_client_get_remote_sockaddr (transport_t *this,
struct sockaddr *sockaddr,
- socklen_t *sockaddr_len)
+ socklen_t *sockaddr_len,
+ sa_family_t *sa_family)
{
int32_t ret = 0;
+ if ((sockaddr == NULL) || (sockaddr_len == NULL)
+ || (sa_family == NULL)) {
+ ret = -1;
+ goto err;
+ }
+
+
ret = client_fill_address_family (this, &sockaddr->sa_family);
if (ret) {
ret = -1;
goto err;
}
+ *sa_family = sockaddr->sa_family;
+
switch (sockaddr->sa_family)
{
case AF_INET_SDP:
@@ -497,6 +507,10 @@ socket_client_get_remote_sockaddr (transport_t *this,
ret = -1;
}
+ if (*sa_family == AF_UNSPEC) {
+ *sa_family = sockaddr->sa_family;
+ }
+
err:
return ret;
}
@@ -547,17 +561,22 @@ out:
int32_t
-socket_server_get_local_sockaddr (transport_t *this,
- struct sockaddr *addr,
- socklen_t *addr_len)
+socket_server_get_local_sockaddr (transport_t *this, struct sockaddr *addr,
+ socklen_t *addr_len, sa_family_t *sa_family)
{
int32_t ret = -1;
+ if ((addr == NULL) || (addr_len == NULL) || (sa_family == NULL)) {
+ goto err;
+ }
+
ret = server_fill_address_family (this, &addr->sa_family);
if (ret == -1) {
goto err;
}
+ *sa_family = addr->sa_family;
+
switch (addr->sa_family)
{
case AF_INET_SDP:
@@ -574,6 +593,10 @@ socket_server_get_local_sockaddr (transport_t *this,
break;
}
+ if (*sa_family == AF_UNSPEC) {
+ *sa_family = addr->sa_family;
+ }
+
err:
return ret;
}