Mercurial > hg > freeDiameter
comparison extensions/app_radgw/rgwx_debug.c @ 256:042af0000c0a
Ported the auth plugin
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 16 Apr 2010 16:57:39 +0900 |
parents | cb4307a1cd29 |
children | 5df55136361b |
comparison
equal
deleted
inserted
replaced
255:cb4307a1cd29 | 256:042af0000c0a |
---|---|
35 | 35 |
36 /* Debug plugin for app_radgw */ | 36 /* Debug plugin for app_radgw */ |
37 | 37 |
38 #include "rgw_common.h" | 38 #include "rgw_common.h" |
39 | 39 |
40 struct rgwp_config { | 40 /* Store the configuration string in the state */ |
41 char * confstring; | 41 static int debug_conf_parse ( char * conf_file, struct rgwp_config ** state ) |
42 }; | |
43 | |
44 /* The function called at plugin initialization */ | |
45 static struct rgwp_config * debug_conf_parse ( char * conf_file ) | |
46 { | 42 { |
47 struct rgwp_config * ret = NULL; | 43 TRACE_ENTRY("%p %p", conf_file, state); |
44 CHECK_PARAMS(state); | |
48 | 45 |
49 TRACE_ENTRY("%p", conf_file); | 46 *state = (void *)conf_file; |
50 | 47 |
51 CHECK_MALLOC_DO( ret = malloc(sizeof(struct rgwp_config)), return NULL ); | 48 return 0; |
52 | |
53 ret->confstring = conf_file; | |
54 | |
55 return ret; | |
56 } | 49 } |
57 | 50 |
58 /* This function is called when the plugin is unloaded, to cleanup all the states */ | |
59 static void debug_conf_free(struct rgwp_config * cs) | |
60 { | |
61 TRACE_ENTRY("%p", cs); | |
62 CHECK_PARAMS_DO( cs, ); | |
63 free(cs); | |
64 return; | |
65 } | |
66 | 51 |
67 /* Function to display the content of a RADIUS message (more friendly way than radius_msg_dump) */ | 52 /* Function to display the content of a RADIUS message (more friendly way than radius_msg_dump) */ |
68 static void debug_dump_radius(struct radius_msg *msg) | 53 static void debug_dump_radius(struct radius_msg *msg) |
69 { | 54 { |
70 unsigned char *auth; | 55 unsigned char *auth; |
88 /* Function called when a new RADIUS message is being converted to Diameter */ | 73 /* Function called when a new RADIUS message is being converted to Diameter */ |
89 static int debug_rad_req( struct rgwp_config * cs, struct session * session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) | 74 static int debug_rad_req( struct rgwp_config * cs, struct session * session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli ) |
90 { | 75 { |
91 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); | 76 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); |
92 | 77 |
93 fd_log_debug("------------- RADIUS/Diameter Request Debug%s%s%s -------------\n", cs->confstring ? " [" : "", cs->confstring ?: "", cs->confstring ? "]" : ""); | 78 fd_log_debug("------------- RADIUS/Diameter Request Debug%s%s%s -------------\n", cs ? " [" : "", cs ? (char *)cs : "", cs ? "]" : ""); |
94 | 79 |
95 if (!rad_req) { | 80 if (!rad_req) { |
96 fd_log_debug(" RADIUS request: NULL pointer\n"); | 81 fd_log_debug(" RADIUS request: NULL pointer\n"); |
97 } else { | 82 } else { |
98 fd_log_debug(" RADIUS request (%p) DUMP:\n", rad_req); | 83 fd_log_debug(" RADIUS request (%p) DUMP:\n", rad_req); |
111 } else { | 96 } else { |
112 fd_log_debug(" Diameter message (%p) DUMP:\n", *diam_fw); | 97 fd_log_debug(" Diameter message (%p) DUMP:\n", *diam_fw); |
113 fd_msg_dump_walk(0, *diam_fw); | 98 fd_msg_dump_walk(0, *diam_fw); |
114 } | 99 } |
115 | 100 |
116 fd_log_debug("=========== Debug%s%s%s complete =============\n", cs->confstring ? " [" : "", cs->confstring ?: "", cs->confstring ? "]" : ""); | 101 fd_log_debug("=========== Debug%s%s%s complete =============\n", cs ? " [" : "", cs ? (char *)cs : "", cs ? "]" : ""); |
117 | 102 |
118 return 0; | 103 return 0; |
119 } | 104 } |
120 | 105 |
121 /* This one, when Diameter answer is converted to RADIUS */ | 106 /* This one, when Diameter answer is converted to RADIUS */ |
122 static int debug_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli ) | 107 static int debug_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli ) |
123 { | 108 { |
124 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli); | 109 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli); |
125 | 110 |
126 fd_log_debug("------------- RADIUS/Diameter Answer Debug%s%s%s -------------\n", cs->confstring ? " [" : "", cs->confstring ?: "", cs->confstring ? "]" : ""); | 111 fd_log_debug("------------- RADIUS/Diameter Answer Debug%s%s%s -------------\n", cs ? " [" : "", cs ? (char *)cs : "", cs ? "]" : ""); |
127 | 112 |
128 if (!diam_ans || ! *diam_ans) { | 113 if (!diam_ans || ! *diam_ans) { |
129 fd_log_debug(" Diameter message: NULL pointer\n"); | 114 fd_log_debug(" Diameter message: NULL pointer\n"); |
130 } else { | 115 } else { |
131 fd_log_debug(" Diameter message (%p) DUMP:\n", *diam_ans); | 116 fd_log_debug(" Diameter message (%p) DUMP:\n", *diam_ans); |
137 } else { | 122 } else { |
138 fd_log_debug(" RADIUS answer (%p) DUMP:\n", *rad_fw); | 123 fd_log_debug(" RADIUS answer (%p) DUMP:\n", *rad_fw); |
139 debug_dump_radius(*rad_fw); | 124 debug_dump_radius(*rad_fw); |
140 } | 125 } |
141 | 126 |
142 fd_log_debug("=========== Debug%s%s%s complete =============\n", cs->confstring ? " [" : "", cs->confstring ?: "", cs->confstring ? "]" : ""); | 127 fd_log_debug("=========== Debug%s%s%s complete =============\n", cs ? " [" : "", cs ? (char *)cs : "", cs ? "]" : ""); |
143 return 0; | 128 return 0; |
144 } | 129 } |
145 | 130 |
146 | 131 |
147 /* The exported symbol */ | 132 /* The exported symbol */ |
148 struct rgw_api rgwp_descriptor = { | 133 struct rgw_api rgwp_descriptor = { |
149 debug_conf_parse, | 134 .rgwp_name = "debug", |
150 debug_conf_free, | 135 .rgwp_conf_parse = debug_conf_parse, |
151 debug_rad_req, | 136 .rgwp_conf_free = NULL, |
152 debug_diam_ans | 137 .rgwp_rad_req = debug_rad_req, |
138 .rgwp_diam_ans = debug_diam_ans | |
153 }; | 139 }; |