aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorTomas Abrahamsson <[email protected]>2012-05-08 21:30:07 +0200
committerTomas Abrahamsson <[email protected]>2012-05-31 18:48:13 +0200
commitf79dd5dc88ff86c3394d25eed37432c32d80f6da (patch)
treec1b30df720fc0e3e76c084527d89f90c67378b4b /erts/emulator
parent3e348c69b6921dd0e2c5b699ccd36d46321c953c (diff)
downloadotp-f79dd5dc88ff86c3394d25eed37432c32d80f6da.tar.gz
otp-f79dd5dc88ff86c3394d25eed37432c32d80f6da.tar.bz2
otp-f79dd5dc88ff86c3394d25eed37432c32d80f6da.zip
inet_drv.c: Set sockaddr lengths in inet_set_[f]address
Set appropriate values for the sockaddr length fields---sai.sin_len and sai6.sin6_len---if those fields exist; rely on the NO_SA_LEN configure check to see if they exist. The length field exists on at least FreeBSD, and there it needs to have a proper value for instance in the call to sctp_bindx, or else that will fail with EINVAL.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 76a9b55179..6c02674414 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -3706,6 +3706,9 @@ static char* inet_set_address(int family, inet_address* dst,
if ((family == AF_INET) && (*len >= 2+4)) {
sys_memzero((char*)dst, sizeof(struct sockaddr_in));
port = get_int16(src);
+#ifndef NO_SA_LEN
+ dst->sai.sin_len = sizeof(struct sockaddr_in);
+#endif
dst->sai.sin_family = family;
dst->sai.sin_port = sock_htons(port);
sys_memcpy(&dst->sai.sin_addr, src+2, 4);
@@ -3716,6 +3719,9 @@ static char* inet_set_address(int family, inet_address* dst,
else if ((family == AF_INET6) && (*len >= 2+16)) {
sys_memzero((char*)dst, sizeof(struct sockaddr_in6));
port = get_int16(src);
+#ifndef NO_SA_LEN
+ dst->sai6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
dst->sai6.sin6_family = family;
dst->sai6.sin6_port = sock_htons(port);
dst->sai6.sin6_flowinfo = 0; /* XXX this may be set as well ?? */
@@ -3770,6 +3776,9 @@ static char *inet_set_faddress(int family, inet_address* dst,
return NULL;
}
sys_memzero((char*)dst, sizeof(struct sockaddr_in));
+#ifndef NO_SA_LEN
+ dst->sai.sin_len = sizeof(struct sockaddr_in6);
+#endif
dst->sai.sin_family = family;
dst->sai.sin_port = sock_htons(port);
dst->sai.sin_addr.s_addr = addr.s_addr;
@@ -3789,6 +3798,9 @@ static char *inet_set_faddress(int family, inet_address* dst,
return NULL;
}
sys_memzero((char*)dst, sizeof(struct sockaddr_in6));
+#ifndef NO_SA_LEN
+ dst->sai6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
dst->sai6.sin6_family = family;
dst->sai6.sin6_port = sock_htons(port);
dst->sai6.sin6_flowinfo = 0; /* XXX this may be set as well ?? */