Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
oai
freediameter
Commits
260872a2
Commit
260872a2
authored
Dec 07, 2010
by
Sebastien Decugis
Browse files
Continued work on dbg_interactive.fdx
parent
c48ac09e
Changes
2
Hide whitespace changes
Inline
Side-by-side
doc/dbg_interactive.py.sample
View file @
260872a2
...
...
@@ -20,17 +20,27 @@
print FD_PROJECT_NAME, FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, FD_PROJECT_VERSION_REV
# Change the global debug level of the framework (cvar contains all global variables)
cvar.fd_g_debug_lvl = FULL
# Turn on debug for a specific function
cvar.fd_debug_one_function = "gc_th_fct"
#
Use
freeDiameter's debug facility
#
Print messages to
freeDiameter's debug facility
fd_log_debug("3 + 4 = %d\n", 7)
# Hum... Currently I get "3 + 4 = 0" output... need some fix...
# Change the global debug level of the framework
cvar.fd_g_debug_lvl = FULL
# SWIG deals with structures as follow:
# Take the structure:
# struct foo { int a; }
# The following functions are available to python:
# s = new_foo() --> s = calloc(1, sizeof(struct foo))
# foo_a_set(s, 2) --> s->a = 2
# foo_a_get(s) --> returns s->a value
# delete_foo(s) --> free(s)
# Display the local Diameter Identity:
...
...
@@ -55,19 +65,29 @@ fd_peer_add(mypeer, "python", None, None)
# Lists
mylist = new_fd_list()
fd_list_init(mylist, None)
l1 = new_fd_list()
l2 = new_fd_list()
fd_list_in
it
(l
2
,
None
)
fd_list_
insert_after(mylist, l2
)
fd_list_
unlink
(l2)
fd_list_in
sert_after
(l
1
,
l2
)
fd_list_
dump(l1
)
fd_list_
dump
(l2)
delete_fd_list(l2)
delete_fd_list(mylist)
fd_list_dump(l1)
delete_fd_list(l1)
# Dictionary
gdict = fd_config_cnf_dict_get(cvar.fd_g_config)
@@@ fd_dict_search ( gdict, DICT_APPLICATION, APPLICATION_BY_ID, id, res, -1 )
id = new_int_ptr()
int_ptr_assign(id, 3)
res = new_dict_object_ptr()
err = fd_dict_search ( gdict, DICT_APPLICATION, APPLICATION_BY_ID, id, res, -1 )
obj = dict_object_ptr_value(res)
t = new_dict_object_type_ptr()
err = fd_dict_gettype(obj, t)
dict_object_type_ptr_dump(t)
v = new_dict_application_data()
err = fd_dict_getval(obj, v)
dict_application_data_application_name_get(v)
extensions/dbg_interactive/diwrap.i
View file @
260872a2
/* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */
%
module
diwrap
%
begin
%
{
/*********************************************************************************************************
* Software License Agreement (BSD License) *
* Author: Sebastien Decugis <sdecugis@nict.go.jp> *
...
...
@@ -32,12 +35,12 @@
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*********************************************************************************************************/
%
}
/* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */
%
module
diwrap
/* Include standard types & functions used in freeDiameter headers */
%
include
<
stdint
.
i
>
%
init
%
{
/* TODO: How to load the proxy classes here? */
%
}
%
{
/* Define types etc. */
...
...
@@ -45,26 +48,103 @@
#
include
<
freeDiameter
/
extension
.
h
>
%
}
/* Include standard types & functions used in freeDiameter headers */
%
include
<
stdint
.
i
>
%
include
<
cpointer
.
i
>
%
include
<
typemaps
.
i
>
/* Some functions are not available through the wrapper */
%
ignore
fd_lib_init
;
%
ignore
fd_lib_fini
;
%
ignore
fd_sess_start
;
/* Inline functions seems to give problems to SWIG -- just remove the inline definition */
%
define
__inline__
%
enddef
/* Make some global-variables read-only */
/* Make some global-variables read-only
(mainly to avoid warnings)
*/
%
immutable
fd_g_config
;
%
immutable
peer_state_str
;
/* Overwrite a few functions prototypes for usability */
/* Overwrite a few functions prototypes for usability
: default parameters values, OUTPUT typemaps, ...
*/
extern
void
fd_list_init
(
struct
fd_list
*
list
,
void
*
obj
=
NULL
)
;
/*
extern int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object ** OUTPUT );
extern int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object ** OUTPUT, int retval );
extern int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object ** OUTPUT);
extern int fd_dict_getval ( struct dict_object * object, void * INOUT);
//extern int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * OUTPUT);
extern int fd_dict_getdict ( struct dict_object * object, struct dictionary ** OUTPUT);
*/
/* Retrieve the compile-time definitions of freeDiameter */
%
include
"freeDiameter/freeDiameter-host.h"
%
include
"freeDiameter/libfreeDiameter.h"
%
include
"freeDiameter/freeDiameter.h"
/* Some pointer types that are useful */
%
pointer_class
(
int
,
int_ptr
)
;
%
pointer_class
(
enum
dict_object_type
,
dict_object_type_ptr
)
;
%
pointer_functions
(
struct
dict_object
*
,
dict_object_ptr
)
;
%
pointer_functions
(
struct
session
*
,
session_ptr
)
;
/* Extend some structures for usability/debug in python */
%
extend
fd_list
{
fd_list
(
void
*
o
=
NULL
)
{
struct
fd_list
*
li
;
li
=
(
struct
fd_list
*
)
malloc
(
sizeof
(
struct
fd_list
))
;
if
(
!
li
)
{
fd_log_debug
(
"Out of memory!
\n
"
)
;
return
NULL
;
}
fd_list_init
(
li
,
o
)
;
return
li
;
}
~
fd_list
()
{
fd_list_unlink
(
$
self
)
;
free
(
$
self
)
;
}
void
dump
()
{
fd_log_debug
(
"list: %p
\n
"
,
$
self
)
;
fd_log_debug
(
" - next: %p
\n
"
,
$
self-
>
next
)
;
fd_log_debug
(
" - prev: %p
\n
"
,
$
self-
>
prev
)
;
fd_log_debug
(
" - head: %p
\n
"
,
$
self-
>
head
)
;
fd_log_debug
(
" - o : %p
\n
"
,
$
self-
>
o
)
;
}
}
;
%
extend
dict_object_type_ptr
{
void
dump
()
{
%
#
define
CASE_STR
(
x
)
case
x
:
fd_log_debug
(
#
x
"
\n
"
)
;
break
;
switch
(
*
$
self
)
{
CASE_STR
(
DICT_VENDOR
)
CASE_STR
(
DICT_APPLICATION
)
CASE_STR
(
DICT_TYPE
)
CASE_STR
(
DICT_ENUMVAL
)
CASE_STR
(
DICT_AVP
)
CASE_STR
(
DICT_COMMAND
)
CASE_STR
(
DICT_RULE
)
default
:
fd_log_debug
(
"Invalid value (%d)"
,
*
$
self
)
;
break
;
}
}
}
%
inline
%
{
void
session_ptr_showsid
(
struct
session
*
s
)
{
char
*
sid
;
int
ret
=
fd_sess_getsid
(
s
,
&
sid
);
if
(
ret
!=
0
)
{
fd_log_debug
(
"Error %d
\n
"
,
ret
)
;
/* throw an exception in SWIG? */
return
;
}
fd_log_debug
(
"%s
\n
"
,
sid
)
;
}
%
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment