annotate extensions/rt_debug/rt_debug.c @ 117:a42ecf6c045c

New rt_debug extension for debugging the routing mechanism
author Sebastien Decugis <sdecugis@nict.go.jp>
date Wed, 09 Dec 2009 15:27:18 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
5 * Copyright (c) 2009, WIDE Project and NICT *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 /*
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37 * Debug-only extension for routing module;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 * displays state information at the end of routing information process.
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 #include <freeDiameter/extension.h>
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
42 static struct fd_rt_fwd_hdl * fwd_hdl = NULL;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
43 static struct fd_rt_out_hdl * out_hdl = NULL;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45 /* Proxying debug callback */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 static int rtdebug_fwd_cb(void * cbdata, struct msg ** msg)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 TRACE_ENTRY("%p %p", cbdata, msg);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 fd_log_debug("[rt_debug] FWD routing message: %p\n", msg ? *msg : NULL);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 if (msg)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 fd_msg_dump_walk(INFO, *msg);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 /* Path selection debug callback */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 static int rtdebug_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 struct fd_list * li;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 TRACE_ENTRY("%p %p %p", cbdata, msg, candidates);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 fd_log_debug("[rt_debug] OUT routing message: %p\n", msg);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 fd_msg_dump_walk(INFO, msg);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 fd_log_debug("[rt_debug] Current list of candidates (%p)\n", msg);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 for (li = candidates->next; li != candidates; li = li->next) {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69 struct rtd_candidate *c = (struct rtd_candidate *) li;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 fd_log_debug("[rt_debug] - %d\t%s\n", c->score, c->diamid);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
73 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 /* Register the callbacks to the daemon */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77 static int rtdebug_main(char * conffile)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 TRACE_ENTRY("%p", conffile);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
80
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
81 CHECK_FCT( fd_rt_fwd_register ( rtdebug_fwd_cb, NULL, RT_FWD_ALL, &fwd_hdl ) );
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 CHECK_FCT( fd_rt_out_register ( rtdebug_out_cb, NULL, -1 /* so that it is called late */, &out_hdl ) );
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
86
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
87 /* Cleanup the callbacks */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 void fd_ext_fini(void)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 TRACE_ENTRY();
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 /* Unregister the modules */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 CHECK_FCT_DO( fd_rt_fwd_unregister ( fwd_hdl, NULL ), /* continue */ );
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94 CHECK_FCT_DO( fd_rt_out_unregister ( out_hdl, NULL ), /* continue */ );
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96 return ;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 /* Define the entry point function */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 EXTENSION_ENTRY("rt_debug", rtdebug_main);
"Welcome to our mercurial repository"