Patchwork [2/3] linux-user: make do_setsockopt() support SOL_RAW ICMP_FILTER socket option

login
register
mail settings
Submitter Jing Huang
Date July 14, 2012, 5:12 p.m.
Message ID <CAK8mDgrZgnARjEm0Dp+W9yGt1WQ-DHEMFbipgnhXm97YXWfwwg@mail.gmail.com>
Download mbox | patch
Permalink /patch/171010/
State New
Headers show

Comments

Jing Huang - July 14, 2012, 5:12 p.m.
This patch makes do_setsockopt() support SOL_RAW ICMP_FILTER socket option

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
---
 linux-user/syscall.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

             /* Options with 'int' argument.  */

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fa251df..ed93af0 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>
@@ -1442,6 +1443,23 @@  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*/
+            optname = ICMP_FILTER;
+            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,
+                                        (char *)&val, sizeof(val)));
+            break;
+        default:
+            goto unimplemented;
+        }
+        break;
     case TARGET_SOL_SOCKET:
         switch (optname) {