diff options
-rw-r--r-- | vpp-api/python/pneum/pneum.c | 5 | ||||
-rw-r--r-- | vpp-api/python/pneum/pneum.h | 2 | ||||
-rw-r--r-- | vpp-api/python/pneum/test_pneum.c | 2 | ||||
-rw-r--r-- | vpp-api/python/vpp_papi/pneum_wrap.c | 8 | ||||
-rw-r--r-- | vpp-api/python/vpp_papi/vpp_papi.py | 8 |
5 files changed, 16 insertions, 9 deletions
diff --git a/vpp-api/python/pneum/pneum.c b/vpp-api/python/pneum/pneum.c index 7250cf6a..ebe47b2f 100644 --- a/vpp-api/python/pneum/pneum.c +++ b/vpp-api/python/pneum/pneum.c @@ -116,11 +116,14 @@ pneum_rx_thread_fn (void *arg) } int -pneum_connect (char *name) +pneum_connect (char * name, char * chroot_prefix) { int rv = 0; pneum_main_t *pm = &pneum_main; + if (chroot_prefix != NULL) + vl_set_memory_root_path (chroot_prefix); + if ((rv = vl_client_api_map("/vpe-api"))) { clib_warning ("vl_client_api map rv %d", rv); return rv; diff --git a/vpp-api/python/pneum/pneum.h b/vpp-api/python/pneum/pneum.h index 75fccf84..75b10f8d 100644 --- a/vpp-api/python/pneum/pneum.h +++ b/vpp-api/python/pneum/pneum.h @@ -15,7 +15,7 @@ #ifndef included_pneum_h #define included_pneum_h -int pneum_connect(char *name); +int pneum_connect(char * name, char * chroot_prefix); int pneum_disconnect(void); int pneum_read(char **data, int *l); int pneum_write(char *data, int len); diff --git a/vpp-api/python/pneum/test_pneum.c b/vpp-api/python/pneum/test_pneum.c index b3131953..20c29a7e 100644 --- a/vpp-api/python/pneum/test_pneum.c +++ b/vpp-api/python/pneum/test_pneum.c @@ -76,7 +76,7 @@ int main (int argc, char ** argv) vl_api_show_version_t message; vl_api_show_version_t *mp; int async = 1; - int rv = pneum_connect("pneum_client"); + int rv = pneum_connect("pneum_client", NULL); if (rv != 0) { printf("Connect failed: %d\n", rv); diff --git a/vpp-api/python/vpp_papi/pneum_wrap.c b/vpp-api/python/vpp_papi/pneum_wrap.c index 7a511974..18c4f233 100644 --- a/vpp-api/python/vpp_papi/pneum_wrap.c +++ b/vpp-api/python/vpp_papi/pneum_wrap.c @@ -44,11 +44,11 @@ wrap_pneum_callback (char *data, int len) static PyObject * wrap_connect (PyObject *self, PyObject *args) { - char *name; + char * name, * chroot_prefix = NULL; int rv; - PyObject *temp; + PyObject * temp; - if (!PyArg_ParseTuple(args, "sO:set_callback", &name, &temp)) + if (!PyArg_ParseTuple(args, "sO|s:wrap_connect", &name, &temp, &chroot_prefix)) return (NULL); if (!PyCallable_Check(temp)) { @@ -61,7 +61,7 @@ wrap_connect (PyObject *self, PyObject *args) pneum_callback = temp; /* Remember new callback */ Py_BEGIN_ALLOW_THREADS - rv = pneum_connect(name); + rv = pneum_connect(name, chroot_prefix); Py_END_ALLOW_THREADS return PyLong_FromLong(rv); } diff --git a/vpp-api/python/vpp_papi/vpp_papi.py b/vpp-api/python/vpp_papi/vpp_papi.py index 42ddcdc3..9c2d2b2b 100644 --- a/vpp-api/python/vpp_papi/vpp_papi.py +++ b/vpp-api/python/vpp_papi/vpp_papi.py @@ -86,12 +86,16 @@ def handler(signum, frame): print('Signal handler called with signal', signum) raise IOError("Couldn't connect to VPP!") -def connect(name): +def connect(name, chroot_prefix = None): # Set the signal handler signal.signal(signal.SIGALRM, handler) signal.alarm(3) # 3 second - rv = vpp_api.connect(name, msg_handler) + if not chroot_prefix: + rv = vpp_api.connect(name, msg_handler) + else: + rv = vpp_api.connect(name, msg_handler, chroot_prefix) + signal.alarm(0) # |