annotate extensions/dbg_rt/dbg_rt.c @ 1119:79dd22145f52

Fix a number of compilation warnings
author Sebastien Decugis <sdecugis@freediameter.net>
date Tue, 14 May 2013 11:04:20 +0800
parents 2091bf698fb1
children 1af09cc156d6
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) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
741
d59decafe9c0 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
117
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 */
120
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
46 static int dbgrt_fwd_cb(void * cbdata, struct msg ** msg)
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 {
1119
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
48 char * buf = NULL; size_t buflen;
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 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
50
1119
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
51 LOG_D("[dbg_rt] FWD routing message: %p", msg ? *msg : NULL);
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
52 if (msg) {
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
53 CHECK_MALLOC( fd_msg_dump_treeview(&buf, &buflen, NULL, *msg, NULL, 0, 1) );
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
54 LOG_D("%s", buf);
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
55 }
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
56 free(buf);
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 }
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 /* Path selection debug callback */
120
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
61 static int dbgrt_out_cb(void * cbdata, struct msg * msg, struct fd_list * candidates)
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 struct fd_list * li;
1119
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
64 char * buf = NULL; size_t buflen;
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 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
67
1119
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
68 LOG_D("[dbg_rt] OUT routing message: %p", msg);
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
69 CHECK_MALLOC( fd_msg_dump_treeview(&buf, &buflen, NULL, msg, NULL, 0, 1) );
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
70 LOG_D("%s", buf);
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
71 LOG_D("[dbg_rt] Current list of candidates (%p): (score - id)", msg);
117
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 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
74 struct rtd_candidate *c = (struct rtd_candidate *) li;
1119
79dd22145f52 Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
75 LOG_D("[dbg_rt] %d -\t%s", c->score, c->diamid);
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 }
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 /* Register the callbacks to the daemon */
120
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
82 static int dbgrt_main(char * conffile)
117
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 TRACE_ENTRY("%p", conffile);
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85
120
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
86 CHECK_FCT( fd_rt_fwd_register ( dbgrt_fwd_cb, NULL, RT_FWD_ALL, &fwd_hdl ) );
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
87 CHECK_FCT( fd_rt_out_register ( dbgrt_out_cb, NULL, -1 /* so that it is called late */, &out_hdl ) );
117
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 return 0;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 }
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 /* Cleanup the callbacks */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 void fd_ext_fini(void)
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94 {
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 TRACE_ENTRY();
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 /* Unregister the modules */
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98 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
99 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
100
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 return ;
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102 }
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103
a42ecf6c045c New rt_debug extension for debugging the routing mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104 /* Define the entry point function */
120
d7acdc46134d Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 117
diff changeset
105 EXTENSION_ENTRY("dbg_rt", dbgrt_main);
"Welcome to our mercurial repository"