]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
authorJing Huang <jing.huang.pku@gmail.com>
Tue, 24 Jul 2012 13:59:23 +0000 (13:59 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 14 Aug 2012 19:26:55 +0000 (20:26 +0100)
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
linux-user/syscall.c

index 4bc11f186ddf126175f045f1c6c8b514952656a3..ae9c1d0d12791229bee815b658a4c0fe5d920e6d 100644 (file)
@@ -60,6 +60,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <linux/wireless.h>
+#include <linux/icmp.h>
 #include "qemu-common.h"
 #ifdef TARGET_GPROF
 #include <sys/gmon.h>
@@ -1448,6 +1449,25 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
             unlock_user (ip_mreq_source, optval_addr, 0);
             break;
 
+        default:
+            goto unimplemented;
+        }
+        break;
+    case SOL_RAW:
+        switch (optname) {
+        case ICMP_FILTER:
+            /* struct icmp_filter takes an u32 value */
+            if (optlen < sizeof(uint32_t)) {
+                return -TARGET_EINVAL;
+            }
+
+            if (get_user_u32(val, optval_addr)) {
+                return -TARGET_EFAULT;
+            }
+            ret = get_errno(setsockopt(sockfd, level, optname,
+                                       &val, sizeof(val)));
+            break;
+
         default:
             goto unimplemented;
         }