Commits

Victor Stinner  committed f78bea4

move socketcall parameters to SYSCALL_PROTOTYPES

  • Participants
  • Parent commits 9fa95da

Comments (0)

Files changed (3)

File ptrace/syscall/prototypes.py

             ("struct sockaddr*", "name"),
             ("socklen_t*", "namelen"),
         )),
+    "getpeername" : ("long", (
+            ("int", "fd"),
+            ("struct sockaddr*", "name"),
+            ("socklen_t*", "namelen"),
+        )),
     "getsockopt" : ("long", (
             ("int", "fd"),
             ("int", "level"),
     "alarm" : ("long", (
             ("unsigned int", "seconds"),
         )),
+    "recv": ("ssize_t", (
+            ("int", "sockfd"),
+            ("void*", "buf"),
+            ("size_t", "len"),
+            ("int", "flags"),
+        )),
+    "recvfrom": ("ssize_t", (
+            ("int", "sockfd"),
+            ("void*", "buf"),
+            ("size_t", "len"),
+            ("int", "flags"),
+            ("struct sockaddr*", "src_addr"),
+            ("socklen_t", "addrlen"),
+        )),
+    "recvmsg": ("ssize_t", (
+            ("int", "sockfd"),
+            ("struct msghdr*", "msg"),
+            ("int", "flags"),
+        )),
+    "send": ("ssize_t", (
+            ("int", "sockfd"),
+            ("const void*", "buf"),
+            ("size_t", "len"),
+            ("int", "flags"),
+        )),
+    "sendto": ("ssize_t", (
+            ("int", "sockfd"),
+            ("const void*", "buf"),
+            ("size_t", "len"),
+            ("int", "flags"),
+            ("const struct sockaddr*", "dest_addr"),
+            ("socklen_t", "addrlen"),
+        )),
+    "sendmsg": ("ssize_t", (
+            ("int", "sockfd"),
+            ("const struct msghdr*", "buf"),
+            ("int", "flags"),
+        )),
+    "listen": ("int", (
+            ("int", "fd"),
+            ("int", "backlog"),
+        )),
+    "accept": ("int", (
+            ("int", "fd"),
+            ("struct sockaddr*", "addr"),
+            ("socklen_t*", "addrlen"),
+        )),
+    "socketpair": ("int", (
+            ("int", "family"),
+            ("int", "type"),
+            ("int", "protocol"),
+            ("int*", "sockvec"),
+        )),
+    "shutdown": ("int", (
+            ("int", "fd"),
+            ("int", "how"),
+        )),
 }
 
 for orig, copies in ALIASES.iteritems():

File ptrace/syscall/socketcall.py

 from ptrace.cpu_info import CPU_WORD_SIZE
 from ptrace.ctypes_tools import ntoh_ushort, ntoh_uint
+from ptrace.syscall import SYSCALL_PROTOTYPES
 from ptrace.syscall.socketcall_constants import SOCKETCALL, SOCKET_FAMILY
 from ptrace.syscall.socketcall_struct import sockaddr, sockaddr_in, sockaddr_un
 from ctypes import c_int
     function.name = socketcall.getText()
 
     # Create arguments
-    formats = SOCKETCALL[socketcall.value][1]
+    function.restype, formats = SYSCALL_PROTOTYPES[function.name]
     for argtype, argname in formats:
         value = process.readWord(address)
         function.addArgument(value, argname, argtype)

File ptrace/syscall/socketcall_constants.py

 SOCKETCALL = {
-    1: ("socket", (
-        ("int", "family"),
-        ("int", "type"),
-        ("int", "protocol"),
-    )),
-    2: ("bind", (
-        ("int", "fd"),
-        ("struct sockaddr*", "umyaddr"),
-        ("int", "addrlen"),
-    )),
-    3: ("connect", (
-        ("int", "fd"),
-        ("struct sockaddr*", "uservaddr"),
-        ("int", "addrlen"),
-    )),
-    4: ("listen", (
-        ("int", "fd"),
-        ("int", "backlog"),
-    )),
-    5: ("accept", (
-        ("int", "fd"),
-        ("struct sockaddr*", "upeer_sockaddr"),
-        ("int", "upeer_addrlen"),
-    )),
-    6: ("getsockname", (
-        ("int", "fd"),
-        ("struct sockaddr*", "sockaddr"),
-        ("int", "sockaddr_len"),
-    )),
-    7: ("getpeername", (
-        ("int", "fd"),
-        ("struct sockaddr*", "sockaddr"),
-        ("int", "sockaddr_len"),
-    )),
-    8: ("socketpair", (
-        ("int", "family"),
-        ("int", "type"),
-        ("int", "protocol"),
-        ("int*", "sockvec"),
-    )),
-    9: ("send", (
-        ("int", "fd"),
-        ("char*", "buf"),
-        ("size_t", "len"),
-        ("int", "flags"),
-    )),
-    10: ("recv", (
-        ("int", "fd"),
-        ("char*", "buf"),
-        ("size_t", "len"),
-        ("int", "flags"),
-    )),
-    11: ("sendto", (
-        ("int", "fd"),
-        ("char*", "buf"),
-        ("size_t", "len"),
-        ("int", "flags"),
-        ("struct sockaddr*", "addr"),
-        ("socklen_t", "addr_len"),
-    )),
-    12: ("recvfrom", (
-        ("int", "fd"),
-        ("char*", "buf"),
-        ("size_t", "len"),
-        ("int", "flags"),
-        ("struct sockaddr*", "addr"),
-        ("int*", "addr_len"),
-    )),
-    13: ("shutdown", (
-        ("int", "fd"),
-        ("int", "how"),
-    )),
-    14: ("setsockopt", (
-        ("int", "fd"),
-        ("int", "level"),
-        ("int", "optname"),
-        ("char*", "optval"),
-        ("int", "optlen"),
-    )),
-    15: ("getsockopt", (
-        ("struct socket*", "sock"),
-        ("int", "level"),
-        ("int", "optname"),
-        ("char*", "optval"),
-        ("int", "optlen"),
-    )),
-    16: ("sendmsg", (
-        ("int", "fd"),
-        ("struct msghdr*", "msg"),
-        ("int", "flags"),
-    )),
-    17: ("recvmsg", (
-        ("int", "fd"),
-        ("struct msghdr*", "msg"),
-        ("unsigned int", "flags"),
-    )),
+    1: "socket",
+    2: "bind",
+    3: "connect",
+    4: "listen",
+    5: "accept",
+    6: "getsockname",
+    7: "getpeername",
+    8: "socketpair",
+    9: "send",
+    10: "recv",
+    11: "sendto",
+    12: "recvfrom",
+    13: "shutdown",
+    14: "setsockopt",
+    15: "getsockopt",
+    16: "sendmsg",
+    17: "recvmsg",
 }
 
 SOCKET_FAMILY = {