aboutsummaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.landwerlin@openwide.fr>2009-04-25 23:30:19 +0200
committerRiku Voipio <riku.voipio@nokia.com>2009-06-16 16:56:29 +0300
commitb975b83becfc0d17b490e64a40f5c9c3e69f574f (patch)
tree23c5d88e3457fcac6eed28204afe6d04d0bbb786 /linux-user/syscall.c
parent6f932f9172228f51afebad9b215d1874e887eb65 (diff)
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d1febff7f6..76481261b1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -943,6 +943,24 @@ static abi_long do_select(int n,
return ret;
}
+static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn,
+ abi_ulong target_addr,
+ socklen_t len)
+{
+ struct target_ip_mreqn *target_smreqn;
+
+ target_smreqn = lock_user(VERIFY_READ, target_addr, len, 1);
+ if (!target_smreqn)
+ return -TARGET_EFAULT;
+ mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr;
+ mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr;
+ if (len == sizeof(struct target_ip_mreqn))
+ mreqn->imr_ifindex = tswapl(target_smreqn->imr_ifindex);
+ unlock_user(target_smreqn, target_addr, 0);
+
+ return 0;
+}
+
static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
abi_ulong target_addr,
socklen_t len)
@@ -1118,6 +1136,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
{
abi_long ret;
int val;
+ struct ip_mreqn *ip_mreq;
switch(level) {
case SOL_TCP:
@@ -1156,6 +1175,17 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
}
ret = get_errno(setsockopt(sockfd, level, optname, &val, sizeof(val)));
break;
+ case IP_ADD_MEMBERSHIP:
+ case IP_DROP_MEMBERSHIP:
+ if (optlen < sizeof (struct target_ip_mreq) ||
+ optlen > sizeof (struct target_ip_mreqn))
+ return -TARGET_EINVAL;
+
+ ip_mreq = (struct ip_mreqn *) alloca(optlen);
+ target_to_host_ip_mreq(ip_mreq, optval_addr, optlen);
+ ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq, optlen));
+ break;
+
default:
goto unimplemented;
}