Mercurial > hg > freeDiameter
annotate doc/dbg_interactive.py.sample @ 636:c23ca590fa57
Still making progress on the dbg_interactive interface.
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 15 Dec 2010 18:24:33 +0900 |
parents | 134e4fb9eef5 |
children | 22e8fac3b2d6 |
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 |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
89 ##### Create a dedicated dictionary for our tests |
627
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" |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
97 my_vendor = d.new_obj(DICT_VENDOR, v) |
627
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" |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
106 my_appl = d.new_obj(DICT_APPLICATION, a, my_vendor) |
627
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" |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
113 my_type_int = d.new_obj(DICT_TYPE, t, my_appl) |
627
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" |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
116 my_type_os = d.new_obj(DICT_TYPE, t, my_appl) |
627
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 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
123 d.new_obj(DICT_ENUMVAL, c, my_type_int) |
627
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" |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
126 c.enum_value.os = "This is a very long AVP value that we prefer to represent as a constant" |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
127 c.enum_value.os.dump() |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
128 d.new_obj(DICT_ENUMVAL, c, my_type_os) |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
129 del c |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
130 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
131 # AVP |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
132 a = dict_avp_data() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
133 a.avp_code = 234 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
134 a.avp_name = "my integer avp" |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
135 a.avp_flag_mask = AVP_FLAG_MANDATORY |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
136 a.avp_basetype = AVP_TYPE_INTEGER32 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
137 my_avp_int = d.new_obj(DICT_AVP, a, my_type_int) |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
138 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
139 a.avp_vendor = 123 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
140 a.avp_name = "my OS avp" |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
141 a.avp_flag_mask = AVP_FLAG_MANDATORY + AVP_FLAG_VENDOR |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
142 a.avp_flag_val = AVP_FLAG_VENDOR |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
143 a.avp_basetype = AVP_TYPE_OCTETSTRING |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
144 my_avp_os = d.new_obj(DICT_AVP, a, my_type_os) |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
145 del a |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
146 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
147 # Command |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
148 c = dict_cmd_data() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
149 c.cmd_code = 345 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
150 c.cmd_name = "My-Python-Request" |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
151 c.cmd_flag_mask = CMD_FLAG_REQUEST + CMD_FLAG_PROXIABLE |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
152 c.cmd_flag_val = CMD_FLAG_REQUEST + CMD_FLAG_PROXIABLE |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
153 my_req = d.new_obj(DICT_COMMAND, c, my_appl) |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
154 c.cmd_name = "My-Python-Answer" |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
155 c.cmd_flag_val = CMD_FLAG_PROXIABLE |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
156 my_ans = d.new_obj(DICT_COMMAND, c, my_appl) |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
157 del c |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
158 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
159 # Rule |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
160 r = dict_rule_data() |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
161 r.rule_avp = my_avp_int |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
162 r.rule_position = RULE_REQUIRED |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
163 r.rule_min = -1 |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
164 r.rule_max = -1 |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
165 d.new_obj(DICT_RULE, r, my_req) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
166 d.new_obj(DICT_RULE, r, my_ans) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
167 r.rule_avp = my_avp_os |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
168 d.new_obj(DICT_RULE, r, my_req) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
169 d.new_obj(DICT_RULE, r, my_ans) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
170 del r |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
171 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
172 d.dump() |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
173 del d |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
174 |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
176 ####### Now play with the "real" dictionary |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
178 gdict = cvar.fd_g_config.cnf_dict |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
179 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
180 appl = gdict.search ( DICT_APPLICATION, APPLICATION_BY_ID, 3 ) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
181 appl.dump() |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
182 avp = gdict.search ( DICT_AVP, AVP_BY_NAME, "Origin-Host") |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
183 avp.dump() |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
184 errcmd = gdict.error_cmd() |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
185 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
186 v = avp.getval() |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
187 print v.avp_code |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
188 del v |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
189 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
190 t = avp.gettype() |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
191 print t |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
192 del t |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
193 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
194 dict = avp.getdict() |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
195 del dict |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
196 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
197 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
198 ############# Sessions ############ |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
199 |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
200 # handler |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
201 def my_cleanup(state,sid): |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
202 print "Cleaning up python state for session:", sid |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
203 print "Received state:", state |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
204 del state |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
205 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
206 hdl = session_handler(my_cleanup) |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
207 hdl.dump() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
208 del hdl |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
209 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
210 # Session |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
211 hdl = session_handler(my_cleanup) |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
212 s1 = session() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
213 s1.getsid() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
214 s2 = session("this.is.a.full.session.id") |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
215 r,s3,isnew = fd_sess_fromsid("this.is.a.full.session.id") |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
216 s4 = session("host.id", "opt.part") |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
217 s4.settimeout(30) # the python wrapper takes a number of seconds as parameter for simplicity |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
218 s4.dump() |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
219 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
220 # states |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
221 mystate = [ 34, "blah", [ 32, 12 ] ] |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
222 s1.store(hdl, mystate) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
223 del mystate |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
224 gotstate = s1.retrieve(hdl) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
225 print gotstate |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
226 del gotstate |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
227 |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
228 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
229 ############# Routing ############ |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
230 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
231 rd = rt_data() |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
232 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
233 rd.add("p1.testbed.aaa", "testbed.aaa") |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
234 rd.add("p2.testbed.aaa", "testbed.aaa") |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
235 rd.add("p3.testbed.aaa", "testbed.aaa") |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
236 rd.add("p4.testbed.aaa", "testbed.aaa") |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
237 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
238 rd.remove("p2.testbed.aaa") |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
239 |
636
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
240 rd.error("p3.testbed.aaa", "relay.testbed.aaa", 3002) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
241 |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
242 list = rd.extract(-1) |
c23ca590fa57
Still making progress on the dbg_interactive interface.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
635
diff
changeset
|
243 list[0].dump() |
635
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
244 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
245 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
246 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
247 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
248 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
249 |
134e4fb9eef5
Continued work on python interface
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
627
diff
changeset
|
250 ######################### old stuff (need update) ###################### |
622
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
251 |
cfbf7ed5dccd
Added some limited example for dbg_interactive
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
252 |
624
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
253 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
254 # Messages |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
263 pmsg = new_msg_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
264 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
|
265 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
|
266 pavp = new_avp_pptr() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
272 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 val = new_avp_value() |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 delete_avp_value(val) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
284 |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
285 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
|
286 fd_msg_free(msg) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
287 delete_avp_pptr(pavp) |
a5682d003ed9
Finally got the proxy aka shadow class to work
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
623
diff
changeset
|
288 |
627
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
289 |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
290 # 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
|
291 mypeer = peer_info() |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
292 mypeer.pi_diamid = "nas.testbed.aaa" |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
293 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
|
294 fd_peer_add(mypeer, "python", None, None) |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
295 del mypeer |
330be61dbf43
Improvements to usability, still work ongoing
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
624
diff
changeset
|
296 |