linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt
authorLionel Landwerlin <lionel.landwerlin@openwide.fr>
Sat, 25 Apr 2009 21:31:18 +0000 (23:31 +0200)
committerRiku Voipio <riku.voipio@nokia.com>
Thu, 7 May 2009 13:32:12 +0000 (16:32 +0300)
linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt

Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>

linux-user/syscall.c
linux-user/syscall_defs.h

index e9f17bd..4d2d9e6 100644 (file)
@@ -1142,6 +1142,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
     abi_long ret;
     int val;
     struct ip_mreqn *ip_mreq;
+    struct ip_mreq_source *ip_mreq_source;
 
     switch(level) {
     case SOL_TCP:
@@ -1191,6 +1192,18 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
             ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq, optlen));
             break;
 
+        case IP_BLOCK_SOURCE:
+        case IP_UNBLOCK_SOURCE:
+        case IP_ADD_SOURCE_MEMBERSHIP:
+        case IP_DROP_SOURCE_MEMBERSHIP:
+            if (optlen != sizeof (struct target_ip_mreq_source))
+                return -TARGET_EINVAL;
+
+            ip_mreq_source = lock_user(VERIFY_READ, optval_addr, optlen, 1);
+            ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen));
+            unlock_user (ip_mreq_source, optval_addr, 0);
+            break;
+
         default:
             goto unimplemented;
         }
index 9560687..0078065 100644 (file)
@@ -125,6 +125,13 @@ struct target_ip_mreqn {
     abi_long imr_ifindex;
 };
 
+struct target_ip_mreq_source {
+    /* big endian */
+    uint32_t imr_multiaddr;
+    uint32_t imr_interface;
+    uint32_t imr_sourceaddr;
+};
+
 struct target_timeval {
     abi_long tv_sec;
     abi_long tv_usec;