Changeset 638:9448cba86673 in freeDiameter for extensions/dbg_interactive/peers.i
- Timestamp:
- Dec 17, 2010, 6:41:19 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/peers.i
r637 r638 36 36 /* Do not include this directly, use dbg_interactive.i instead */ 37 37 38 /****** PEERS *********/ 39 40 %{ 41 static void fd_add_cb(struct peer_info *peer, void *data) { 42 /* Callback called when the peer connection completes (or fails) */ 43 PyObject *PyPeer, *PyFunc; 44 PyObject *result = NULL; 45 46 if (!data) { 47 TRACE_DEBUG(INFO, "Internal error: missing callback\n"); 48 return; 49 } 50 PyFunc = data; 51 52 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 53 54 /* Convert the argument */ 55 PyPeer = SWIG_NewPointerObj((void *)peer, SWIGTYPE_p_peer_info, 0 ); 56 57 /* Call the function */ 58 result = PyEval_CallFunction(PyFunc, "(O)", PyPeer); 59 60 Py_XDECREF(result); 61 Py_XDECREF(PyFunc); 62 63 SWIG_PYTHON_THREAD_END_BLOCK; 64 return; 65 } 66 %} 67 68 %extend peer_info { 69 /* Wrapper around fd_peer_add to allow calling the python callback */ 70 void add(PyObject * PyCb=NULL) { 71 int ret; 72 73 if (PyCb) { 74 Py_XINCREF(PyCb); 75 ret = fd_peer_add ( $self, "dbg_interactive", fd_add_cb, PyCb ); 76 } else { 77 ret = fd_peer_add ( $self, "dbg_interactive", NULL, NULL ); 78 } 79 if (ret != 0) { 80 DI_ERROR(ret, NULL, NULL); 81 } 82 } 83 84 /* Add an endpoint */ 85 void add_endpoint(char * endpoint) { 86 fd_log_debug("What is the best way in python to pass an endpoint? (ip + port)"); 87 } 88 89 }
Note: See TracChangeset
for help on using the changeset viewer.