Changeset 623:fc4f5815f0aa in freeDiameter for extensions/dbg_interactive/diwrap.i
- Timestamp:
- Dec 7, 2010, 5:24:53 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/diwrap.i
r621 r623 1 /* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */ 2 %module diwrap 3 %begin %{ 1 4 /********************************************************************************************************* 2 5 * Software License Agreement (BSD License) * … … 33 36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 34 37 *********************************************************************************************************/ 38 %} 35 39 36 /* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */37 %module diwrap38 40 39 /* Include standard types & functions used in freeDiameter headers */ 40 %include <stdint.i> 41 %init %{ 42 /* TODO: How to load the proxy classes here? */ 43 %} 41 44 42 45 %{ … … 46 49 %} 47 50 51 52 /* Include standard types & functions used in freeDiameter headers */ 53 %include <stdint.i> 54 %include <cpointer.i> 55 %include <typemaps.i> 56 48 57 /* Some functions are not available through the wrapper */ 49 58 %ignore fd_lib_init; 50 59 %ignore fd_lib_fini; 51 %ignore fd_sess_start;52 60 53 61 /* Inline functions seems to give problems to SWIG -- just remove the inline definition */ … … 55 63 %enddef 56 64 57 /* Make some global-variables read-only */65 /* Make some global-variables read-only (mainly to avoid warnings) */ 58 66 %immutable fd_g_config; 59 67 %immutable peer_state_str; 60 68 61 /* Overwrite a few functions prototypes for usability */69 /* Overwrite a few functions prototypes for usability: default parameters values, OUTPUT typemaps, ... */ 62 70 extern void fd_list_init ( struct fd_list * list, void * obj = NULL ); 71 72 73 /* 74 extern int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object ** OUTPUT ); 75 extern int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object ** OUTPUT, int retval ); 76 extern int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object ** OUTPUT); 77 extern int fd_dict_getval ( struct dict_object * object, void * INOUT); 78 //extern int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * OUTPUT); 79 extern int fd_dict_getdict ( struct dict_object * object, struct dictionary ** OUTPUT); 80 */ 63 81 64 82 … … 69 87 70 88 89 /* Some pointer types that are useful */ 90 %pointer_class(int, int_ptr); 91 %pointer_class(enum dict_object_type, dict_object_type_ptr); 92 %pointer_functions(struct dict_object *, dict_object_ptr); 93 %pointer_functions(struct session *, session_ptr); 94 95 96 97 98 /* Extend some structures for usability/debug in python */ 99 %extend fd_list { 100 fd_list(void * o = NULL) { 101 struct fd_list * li; 102 li = (struct fd_list *) malloc(sizeof(struct fd_list)); 103 if (!li) { 104 fd_log_debug("Out of memory!\n"); 105 return NULL; 106 } 107 fd_list_init(li, o); 108 return li; 109 } 110 ~fd_list() { 111 fd_list_unlink($self); 112 free($self); 113 } 114 void dump() { 115 fd_log_debug("list: %p\n", $self); 116 fd_log_debug(" - next: %p\n", $self->next); 117 fd_log_debug(" - prev: %p\n", $self->prev); 118 fd_log_debug(" - head: %p\n", $self->head); 119 fd_log_debug(" - o : %p\n", $self->o); 120 } 121 }; 122 123 %extend dict_object_type_ptr { 124 void dump() { 125 %#define CASE_STR(x) case x: fd_log_debug(#x "\n"); break; 126 switch (*$self) { 127 CASE_STR(DICT_VENDOR) 128 CASE_STR(DICT_APPLICATION) 129 CASE_STR(DICT_TYPE) 130 CASE_STR(DICT_ENUMVAL) 131 CASE_STR(DICT_AVP) 132 CASE_STR(DICT_COMMAND) 133 CASE_STR(DICT_RULE) 134 default: fd_log_debug("Invalid value (%d)", *$self); break; 135 } 136 } 137 } 138 139 %inline %{ 140 void session_ptr_showsid(struct session * s) { 141 char * sid; 142 int ret = fd_sess_getsid ( s, &sid ); 143 if (ret != 0) { 144 fd_log_debug("Error %d\n", ret); 145 /* throw an exception in SWIG? */ 146 return; 147 } 148 fd_log_debug("%s\n", sid); 149 } 150 %}
Note: See TracChangeset
for help on using the changeset viewer.