Changeset 624:a5682d003ed9 in freeDiameter for extensions/dbg_interactive/dbg_interactive.i
- Timestamp:
- Dec 9, 2010, 5:14:24 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/dbg_interactive.i
r623 r624 1 1 /* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */ 2 %module diwrap2 %module fDpy 3 3 %begin %{ 4 4 /********************************************************************************************************* … … 38 38 %} 39 39 40 41 %init %{42 /* TODO: How to load the proxy classes here? */43 %}44 45 40 %{ 46 /* Define types etc.*/41 /* This text is included in the generated wrapper verbatim */ 47 42 #define SWIG 48 43 #include <freeDiameter/extension.h> … … 53 48 %include <stdint.i> 54 49 %include <cpointer.i> 50 %include <cdata.i> 51 %include <cstring.i> 55 52 %include <typemaps.i> 56 53 … … 80 77 */ 81 78 82 83 79 /* Retrieve the compile-time definitions of freeDiameter */ 84 80 %include "freeDiameter/freeDiameter-host.h" … … 88 84 89 85 /* 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); 86 %pointer_functions(int, int_ptr); 87 %pointer_functions(uint8_t *, uint8_t_pptr); 88 %pointer_cast(char *, void *, char_to_void); 94 89 90 %pointer_functions(struct fd_list *, fd_list_pptr); 95 91 92 %pointer_functions(enum dict_object_type, dict_object_type_ptr); 93 %pointer_functions(struct dict_object *, dict_object_pptr); 94 95 %pointer_functions(struct session *, session_pptr); 96 %pointer_functions(struct session_handler *, session_handler_pptr); 97 %pointer_functions(session_state *, session_state_pptr); 98 99 %pointer_functions(struct rt_data *, rt_data_pptr); 100 %pointer_cast(struct fd_list *, struct rtd_candidate *, fd_list_to_rtd_candidate); 101 102 %pointer_functions(struct msg *, msg_pptr); 103 %pointer_functions(struct msg_hdr *, msg_hdr_pptr); 104 %pointer_functions(struct avp *, avp_pptr); 105 %pointer_functions(struct avp_hdr *, avp_hdr_pptr); 96 106 97 107 … … 103 113 if (!li) { 104 114 fd_log_debug("Out of memory!\n"); 115 PyErr_SetString(PyExc_MemoryError,"Not enough memory"); 105 116 return NULL; 106 117 } … … 121 132 }; 122 133 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 } 134 %inline %{ 135 void dict_object_type_ptr_dump(enum dict_object_type * t) { 136 #define CASE_STR(x) case x: fd_log_debug(#x "\n"); break; 137 switch (*t) { 138 CASE_STR(DICT_VENDOR) 139 CASE_STR(DICT_APPLICATION) 140 CASE_STR(DICT_TYPE) 141 CASE_STR(DICT_ENUMVAL) 142 CASE_STR(DICT_AVP) 143 CASE_STR(DICT_COMMAND) 144 CASE_STR(DICT_RULE) 145 default: 146 fd_log_debug("Invalid value (%d)", *t); 147 PyErr_SetString(PyExc_IndexError,"Invalid dictionary type object"); 136 148 } 137 149 } 150 %} 138 151 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; 152 %extend avp_value_os { 153 void fromstr(char * string) { 154 if ($self->data) free($self->data); 155 $self->data = (uint8_t *)strdup(string); 156 if (!$self->data) { 157 fd_log_debug("Out of memory!\n"); 158 PyErr_SetString(PyExc_MemoryError,"Not enough memory"); 159 $self->len = 0; 160 return; 161 } 162 $self->len = strlen(string); 147 163 } 148 fd_log_debug("%s\n", sid); 164 %newobject as_str; 165 char * tostr() { 166 char * r; 167 if ($self->len == 0) 168 return NULL; 169 r = malloc($self->len + 1); 170 if (r) { 171 strncpy(r, (char *)$self->data, $self->len + 1); 172 } else { 173 fd_log_debug("Out of memory!\n"); 174 PyErr_SetString(PyExc_MemoryError,"Not enough memory"); 175 } 176 return r; 177 } 178 }; 179 180 %extend avp_value { 181 void os_set(void * os) { 182 memcpy(&$self->os, os, sizeof($self->os)); 183 } 184 }; 185 186 %cstring_output_allocate_size(char ** swig_buffer, size_t * swig_len, free(*$1)) 187 %inline %{ 188 int fd_msg_bufferize_py ( struct msg * msg, char ** swig_buffer, size_t * swig_len ) { 189 return fd_msg_bufferize(msg, (void *)swig_buffer, swig_len); 149 190 } 150 %} 191 %}; 192
Note: See TracChangeset
for help on using the changeset viewer.