Changeset 623:fc4f5815f0aa in freeDiameter
- Timestamp:
- Dec 7, 2010, 5:24:53 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/dbg_interactive.py.sample
r622 r623 21 21 22 22 23 # Change the global debug level of the framework (cvar contains all global variables) 24 cvar.fd_g_debug_lvl = FULL 25 26 23 27 # Turn on debug for a specific function 24 28 cvar.fd_debug_one_function = "gc_th_fct" 25 29 26 30 27 # UsefreeDiameter's debug facility31 # Print messages to freeDiameter's debug facility 28 32 fd_log_debug("3 + 4 = %d\n", 7) 29 33 # Hum... Currently I get "3 + 4 = 0" output... need some fix... 30 34 31 35 32 # Change the global debug level of the framework 33 cvar.fd_g_debug_lvl = FULL 36 # SWIG deals with structures as follow: 37 # Take the structure: 38 # struct foo { int a; } 39 # The following functions are available to python: 40 # s = new_foo() --> s = calloc(1, sizeof(struct foo)) 41 # foo_a_set(s, 2) --> s->a = 2 42 # foo_a_get(s) --> returns s->a value 43 # delete_foo(s) --> free(s) 34 44 35 45 … … 56 66 57 67 # Lists 58 mylist = new_fd_list() 59 fd_list_init(mylist, None) 68 l1 = new_fd_list() 60 69 l2 = new_fd_list() 61 fd_list_in it(l2, None)62 fd_list_ insert_after(mylist, l2)63 fd_list_ unlink(l2)70 fd_list_insert_after(l1, l2) 71 fd_list_dump(l1) 72 fd_list_dump(l2) 64 73 delete_fd_list(l2) 65 delete_fd_list(mylist) 74 fd_list_dump(l1) 75 delete_fd_list(l1) 76 66 77 67 78 # Dictionary 68 79 gdict = fd_config_cnf_dict_get(cvar.fd_g_config) 69 @@@ fd_dict_search ( gdict, DICT_APPLICATION, APPLICATION_BY_ID, id, res, -1 ) 80 id = new_int_ptr() 81 int_ptr_assign(id, 3) 82 res = new_dict_object_ptr() 83 err = fd_dict_search ( gdict, DICT_APPLICATION, APPLICATION_BY_ID, id, res, -1 ) 84 obj = dict_object_ptr_value(res) 85 t = new_dict_object_type_ptr() 86 err = fd_dict_gettype(obj, t) 87 dict_object_type_ptr_dump(t) 88 v = new_dict_application_data() 89 err = fd_dict_getval(obj, v) 90 dict_application_data_application_name_get(v) 70 91 71 92 72 93 73 -
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.