comparison extensions/app_radgw/rgwx_sample.c @ 255:cb4307a1cd29

Added two plugins for RADIUS/Diameter gateway debug.
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 15 Apr 2010 11:56:32 +0900
parents
children 042af0000c0a
comparison
equal deleted inserted replaced
254:a857024cb48b 255:cb4307a1cd29
1 /*********************************************************************************************************
2 * Software License Agreement (BSD License) *
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
4 * *
5 * Copyright (c) 2009, WIDE Project and NICT *
6 * All rights reserved. *
7 * *
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
9 * permitted provided that the following conditions are met: *
10 * *
11 * * Redistributions of source code must retain the above *
12 * copyright notice, this list of conditions and the *
13 * following disclaimer. *
14 * *
15 * * Redistributions in binary form must reproduce the above *
16 * copyright notice, this list of conditions and the *
17 * following disclaimer in the documentation and/or other *
18 * materials provided with the distribution. *
19 * *
20 * * Neither the name of the WIDE Project or NICT nor the *
21 * names of its contributors may be used to endorse or *
22 * promote products derived from this software without *
23 * specific prior written permission of WIDE Project and *
24 * NICT. *
25 * *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34 *********************************************************************************************************/
35
36 /* Sample radius/diameter gateway plugin, for developers to see the structure of a plugin. */
37
38 #include "rgw_common.h"
39
40 /* The state of this extension */
41 struct rgwp_config {
42 /* In a real extension, we would store the parsed configuration file, and the states of the extension */
43 int state;
44 };
45
46 /* The function called at plugin initialization */
47 static struct rgwp_config * sample_conf_parse ( char * conf_file )
48 {
49 struct rgwp_config * ret = NULL;
50
51 TRACE_ENTRY("%p", conf_file);
52
53 CHECK_MALLOC_DO( ret = malloc(sizeof(struct rgwp_config)), return NULL );
54
55 ret->state = 1;
56
57 return ret;
58 }
59
60 /* This function is called when the plugin is unloaded, to cleanup all the states */
61 static void sample_conf_free(struct rgwp_config * cs)
62 {
63 TRACE_ENTRY("%p", cs);
64 CHECK_PARAMS_DO( cs, );
65 free(cs);
66 return;
67 }
68
69 /* This function is called on incoming RADIUS messages. It should handle (some) RADIUS data and store into the Diameter message. */
70 static int sample_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 )
71 {
72 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli);
73 CHECK_PARAMS(cs);
74 TRACE_DEBUG(INFO, "RADIUS/Diameter Sample plugin received a new RADIUS message.");
75 return 0;
76 }
77
78 /* This function is called when a Diameter answer is coming back. It should remove the AVPs and add the attributes in the RADIUS message. */
79 static int sample_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli )
80 {
81 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli);
82 CHECK_PARAMS(cs);
83 TRACE_DEBUG(INFO, "RADIUS/Diameter Sample plugin received a new Diameter answer.");
84 return 0;
85 }
86
87
88 /* Finally, we declare the structure that will be loaded by main RADIUS/Diameter gateway extension */
89 struct rgw_api rgwp_descriptor = {
90 sample_conf_parse,
91 sample_conf_free,
92 sample_rad_req,
93 sample_diam_ans
94 };
"Welcome to our mercurial repository"