4 /* TODO: get this from installed headers */
5 #include "../../../glibc/sysdeps/nacl/nacl_syscalls.h"
7 /* TODO: get these from libnacl rather than hardcoding them */
8 static int (*imc_sendmsg
)(int fd
, const struct NaClImcMsgHdr
*msg
, int flags
) =
9 NACL_SYSCALL_ADDR(NACL_sys_imc_sendmsg
);
10 static int (*imc_recvmsg
)(int fd
, struct NaClImcMsgHdr
*msg
, int flags
) =
11 NACL_SYSCALL_ADDR(NACL_sys_imc_recvmsg
);
14 static PyObject
*py_imc_sendmsg(PyObject
*self
, PyObject
*args
)
19 struct NaClImcMsgIoVec iov
;
20 struct NaClImcMsgHdr msg
;
22 if(!PyArg_ParseTuple(args
, "is#", &fd
, &data
, &data_size
))
25 iov
.length
= data_size
;
30 imc_sendmsg(fd
, &msg
, 0);
35 static PyObject
*py_imc_recvmsg(PyObject
*self
, PyObject
*args
)
39 struct NaClImcMsgIoVec iov
;
40 struct NaClImcMsgHdr msg
;
43 if(!PyArg_ParseTuple(args
, "i", &fd
))
46 iov
.length
= sizeof(buffer
);
51 result
= imc_recvmsg(fd
, &msg
, 0);
53 return PyString_FromStringAndSize(buffer
, result
);
60 static PyMethodDef module_methods
[] = {
61 { "imc_sendmsg", py_imc_sendmsg
, METH_VARARGS
,
62 "NaCl imc_sendmsg() syscall: sends a message" },
63 { "imc_recvmsg", py_imc_recvmsg
, METH_VARARGS
,
64 "NaCl imc_recvmsg() syscall: receives a message" },
65 { NULL
, NULL
, 0, NULL
} /* Sentinel */
70 Py_InitModule3("nacl", module_methods
, "NaCl syscall wrappers");