Patchwork [05/10] linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option

login
register
mail settings
Submitter Peter Maydell
Date Aug. 14, 2012, 9:40 a.m.
Message ID <1344937236-611-6-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/177209/
State New
Headers show

Comments

Peter Maydell - Aug. 14, 2012, 9:40 a.m.
From: Jing Huang <jing.huang.pku@gmail.com>

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 |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 47f0eb3..700163e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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>
@@ -1452,6 +1453,25 @@  static abi_long do_setsockopt(int sockfd, int level, int optname,
             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;
+        }
+        break;
     case TARGET_SOL_SOCKET:
         switch (optname) {
             /* Options with 'int' argument.  */