Mercurial > hg > freeDiameter
annotate doc/dbg_interactive.py.sample @ 627:330be61dbf43
Improvements to usability, still work ongoing
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 14 Dec 2010 11:53:24 +0900 |
parents | a5682d003ed9 |
children | 134e4fb9eef5 |
rev | line source |
---|---|
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 # Example file for the dbg_interactive.fdx extension. |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 # |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 # This extension provides an interactive python interpreter console that allows |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 # interacting with freeDiameter framework. |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 # |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 # The adaptation layer between Python and C is provided by SWIG (http://swig.org). |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 # You may refer to SWIG documentation for more information on how the wrapper is generated and used. |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
8 # The name of the module wrapping freeDiameter framework is: _fDpy |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 # |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 # Similar to all freeDiameter extensions, an optional filename can be specified in the |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 # main freeDiameter.conf configuration file for the dbg_interactive.fdx extension. |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 # If such file is provided, it will be passed to the python interpreter as a python script |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 # to execute. Otherwise, the interpreter will be interactive. |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 # |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
15 # SWIG deals with structures as follow: |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
16 # Given the structure: |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
17 # struct foo { int a; } |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
18 # The following functions are available to python (their C equivalent processing is given in [ ]): |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
19 # s = new_foo() [ s = calloc(1, sizeof(struct foo)) ] |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
20 # foo_a_set(s, 2) [ s->a = 2 ] |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
21 # foo_a_get(s) [ returns s->a value ] |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
22 # delete_foo(s) [ free(s) ] |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
23 # |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
24 # In addition, thanks to the proxy (aka shadow) class, we can also do the more user-friendly: |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
25 # s = foo() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
26 # s.a = 2 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
27 # s.a |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
28 # del s |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
29 # |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
30 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
31 # The remaining of this file gives some examples of how to use the python interpreter. |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
32 # Note that the support is not yet totally usable. You'll probably have to extend some classes |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
33 # or write some typemaps in the source code of the extension to do what you want. |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
36 ############# Compilation-time constants (from freeDiameter-host.h) ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
37 |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 # Display current version |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
39 print "%s %d.%d.%d" % (FD_PROJECT_NAME, FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, FD_PROJECT_VERSION_REV) |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
42 ############# Debug ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
43 |
623
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
44 # Change the global debug level of the framework (cvar contains all global variables) |
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
45 cvar.fd_g_debug_lvl = FULL |
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
46 |
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
47 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
48 # Turn on debug for a specific function (if framework compiled with DEBUG support) |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 cvar.fd_debug_one_function = "gc_th_fct" |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 |
623
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
52 # Print messages to freeDiameter's debug facility |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
53 # Note: the python version does not support printf-like argument list. The formating should be done in python. |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
54 # See SWIG documentation about varargs functions for more information. |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
55 fd_log_debug("3 + 4 = %d\n" % (7)) |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
56 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
57 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
58 # Display some framework state information |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
59 r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_PEERS, 0, None) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
60 r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_SERV, 0, None) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
61 r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_EXT, 0, None) |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
64 ############# Global variables ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
65 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
66 # Display the local Diameter Identity: |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
67 print "Local Diameter Identity:", cvar.fd_g_config.cnf_diamid |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
68 # Display realm, without using the low-level functions (skip proxy classe definitions): |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
69 print "Realm:", _fDpy.fd_config_cnf_diamrlm_get(_fDpy.cvar.fd_g_config) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
70 |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
73 ############# Lists ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
74 l1 = fd_list() # The creator has an implicit fd_list_init call |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
75 l2 = fd_list() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
76 fd_list_insert_after(l1, l2) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
77 l1.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
78 del l2 # The destructor has an implicit fd_list_unlink call |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
79 l1.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
80 del l1 |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
83 ############# Hash ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
84 hex(fd_hash("hello world")) # A typemap is applied to accept binary data |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
87 ############# Dictionary ############ |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
88 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
89 # Create a dedicated dictionary for our tests |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
90 d = dictionary() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
91 d.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
92 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
93 # New vendor |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
94 v = dict_vendor_data() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
95 v.vendor_id = 123 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
96 v.vendor_name = "My test vendor" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
97 r, my_vendor = fd_dict_new(d, DICT_VENDOR, v, None) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
98 del v |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
99 d.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
100 d.vendors_list() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
101 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
102 # New application |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
103 a = dict_application_data() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
104 a.application_id = 99 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
105 a.application_name = "My test appl" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
106 r, my_appl = fd_dict_new(d, DICT_APPLICATION, a, my_vendor) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
107 del a |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
108 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
109 # New type (callbacks are not supported yet...) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
110 t = dict_type_data() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
111 t.type_base = AVP_TYPE_INTEGER32 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
112 t.type_name = "My integer AVP" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
113 r, my_type_int = fd_dict_new(d, DICT_TYPE, t, my_appl) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
114 t.type_base = AVP_TYPE_OCTETSTRING |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
115 t.type_name = "My binary buffer AVP" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
116 r, my_type_os = fd_dict_new(d, DICT_TYPE, t, my_appl) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
117 del t |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
118 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
119 # Constants |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
120 c = dict_enumval_data() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
121 c.enum_name = "AVP_VALUE_TROIS" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
122 c.enum_value.i32 = 3 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
123 fd_dict_new(d, DICT_ENUMVAL, c, my_type_int) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
124 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
125 c.enum_name = "A_BUFFER_CONSTANT" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
126 osval = avp_value_os("This is a very long AVP value that we prefer to represent as a constant") |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
127 c.enum_value.os = osval |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
128 c.enum_value.os.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
129 del d |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
130 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
131 c = dict_enumval_data() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
132 c.enum_value.os = "coucou" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
133 c.enum_value.os.dump() |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
136 gdict = cvar.fd_g_config.cnf_dict |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
137 r, obj = fd_dict_search ( gdict, DICT_APPLICATION, APPLICATION_BY_ID, 3, -1 ) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
138 obj.dump() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
139 r, obj = fd_dict_search( gdict, DICT_AVP, AVP_BY_NAME, "Origin-Host", -1) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
140 obj.dump() |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
141 |
623
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
142 t = new_dict_object_type_ptr() |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
143 fd_dict_gettype(obj, t) |
623
fc4f5815f0aa
Continued work on dbg_interactive.fdx
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
622
diff
changeset
|
144 dict_object_type_ptr_dump(t) |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
145 delete_dict_object_type_ptr(t) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
146 objdata = new_dict_application_data() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
147 fd_dict_getval(obj, objdata) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
148 dict_application_data_application_name_get(objdata) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
149 delete_dict_application_data(objdata) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
150 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
151 vd = new_dict_vendor_data() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
152 dict_vendor_data_vendor_id_set(vd, 123) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
153 dict_vendor_data_vendor_name_set(vd, "my test vendor") |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
154 pobj = new_dict_object_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
155 fd_dict_new ( gdict, DICT_VENDOR, vd, None, pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
156 delete_dict_vendor_data(vd) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
157 obj = dict_object_pptr_value(pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
158 delete_dict_object_pptr(pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
159 fd_dict_dump_object(obj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
160 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
161 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
162 # Sessions |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
163 pmyhdl = new_session_handler_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
164 fd_sess_handler_create_internal(pmyhdl, None) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
165 ### Have to work on this one, a cleanup handler is actually required. |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
166 ### How to define the handler in python ? |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
167 myhdl = session_handler_pptr_value(pmyhdl) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
168 delete_session_handler_pptr(pmyhdl) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
169 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
170 psess = new_session_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
171 fd_sess_new (psess, fd_config_cnf_diamid_get(cvar.fd_g_config), "dbg_interactive", 0) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
172 sess = session_pptr_value(psess) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
173 fd_sess_dump(0, sess) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
174 fd_sess_destroy(psess) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
175 delete_session_pptr(psess) |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
178 # Routing data |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
179 prtd = new_rt_data_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
180 fd_rtd_init(prtd) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
181 fd_rtd_candidate_add(rt_data_pptr_value(prtd), "p1.testbed.aaa", "testbed.aaa") |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
182 fd_rtd_candidate_add(rt_data_pptr_value(prtd), "p2.testbed.aaa", "testbed.aaa") |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
183 fd_rtd_candidate_add(rt_data_pptr_value(prtd), "p3.testbed.aaa", "testbed.aaa") |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
184 fd_rtd_candidate_del(rt_data_pptr_value(prtd), "p2.testbed.aaa", 0) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
185 pcands = new_fd_list_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
186 fd_rtd_candidate_extract(rt_data_pptr_value(prtd), pcands, 0) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
187 li = fd_list_pptr_value(pcands) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
188 li = fd_list_next_get(li) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
189 c = fd_list_to_rtd_candidate(li) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
190 rtd_candidate_diamid_get(c) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
191 li = fd_list_next_get(li) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
192 c = fd_list_to_rtd_candidate(li) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
193 rtd_candidate_diamid_get(c) |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
194 |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
195 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
196 # Messages |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
197 gdict = fd_config_cnf_dict_get(cvar.fd_g_config) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
198 pobj = new_dict_object_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
199 fd_dict_search ( gdict, DICT_COMMAND, CMD_BY_NAME, char_to_void("Capabilities-Exchange-Request"), pobj, -1 ) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
200 cerdict = dict_object_pptr_value(pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
201 fd_dict_search ( gdict, DICT_AVP, AVP_BY_NAME, char_to_void("Origin-Host"), pobj, -1 ) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
202 ohdict = dict_object_pptr_value(pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
203 delete_dict_object_pptr(pobj) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
204 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
205 pmsg = new_msg_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
206 fd_msg_new(cerdict, MSGFL_ALLOC_ETEID, pmsg) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
207 msg = msg_pptr_value(pmsg); |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
208 pavp = new_avp_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
209 fd_msg_avp_new(ohdict, 0, pavp) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
210 avp = avp_pptr_value(pavp); |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
211 fd_msg_avp_add(msg, MSG_BRW_FIRST_CHILD, avp) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
212 fd_msg_dump_walk(0, msg) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
213 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
214 pahdr = new_avp_hdr_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
215 fd_msg_avp_hdr(avp, pahdr) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
216 ahdr = avp_hdr_pptr_value(pahdr) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
217 delete_avp_hdr_pptr(pahdr) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
218 avp_hdr_avp_code_get(ahdr) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
219 os = new_avp_value_os() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
220 avp_value_os_fromstr(os, fd_config_cnf_diamid_get(cvar.fd_g_config)) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
221 val = new_avp_value() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
222 avp_value_os_set(val, os) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
223 delete_avp_value_os(os) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
224 fd_msg_avp_setvalue(avp, val) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
225 delete_avp_value(val) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
226 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
227 r,buf = fd_msg_bufferize_py(msg) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
228 fd_msg_free(msg) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
229 delete_avp_pptr(pavp) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
230 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
231 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
232 # Create a new peer_info structure and add the peer to the framework. |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
233 mypeer = peer_info() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
234 mypeer.pi_diamid = "nas.testbed.aaa" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
235 mypeer.config.pic_flags.pro4 = 1 # 1 for TCP, for some reason PI_P4_TCP is not defined |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
236 fd_peer_add(mypeer, "python", None, None) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
237 del mypeer |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
238 |