comparison extensions/app_radgw/rgwx_sample.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
38 #include "rgw_common.h" 38 #include "rgw_common.h"
39 39
40 /* The state of this extension */ 40 /* The state of this extension */
41 struct rgwp_config { 41 struct rgwp_config {
42 /* In a real extension, we would store the parsed configuration file, and the states of the extension */ 42 /* In a real extension, we would store the parsed configuration file, and the states of the extension */
43 int state; 43 int init;
44 }; 44 };
45 45
46 /* The function called at plugin initialization */ 46 /* The function called at plugin initialization */
47 static struct rgwp_config * sample_conf_parse ( char * conf_file ) 47 static int sample_conf_parse ( char * conf_file, struct rgwp_config ** state )
48 { 48 {
49 struct rgwp_config * ret = NULL; 49 TRACE_ENTRY("%p %p", conf_file, state);
50 CHECK_PARAMS(state);
50 51
51 TRACE_ENTRY("%p", conf_file); 52 CHECK_MALLOC( *state = malloc(sizeof(struct rgwp_config)) );
52 53
53 CHECK_MALLOC_DO( ret = malloc(sizeof(struct rgwp_config)), return NULL ); 54 (*state)->init = 1;
54 55
55 ret->state = 1; 56 return 0;
56
57 return ret;
58 } 57 }
59 58
60 /* This function is called when the plugin is unloaded, to cleanup all the states */ 59 /* This function is called when the plugin is unloaded, to cleanup all the states */
61 static void sample_conf_free(struct rgwp_config * cs) 60 static void sample_conf_free(struct rgwp_config * state)
62 { 61 {
63 TRACE_ENTRY("%p", cs); 62 TRACE_ENTRY("%p", state);
64 CHECK_PARAMS_DO( cs, ); 63 CHECK_PARAMS_DO( state, );
65 free(cs); 64 free(state);
66 return; 65 return;
67 } 66 }
68 67
69 /* This function is called on incoming RADIUS messages. It should handle (some) RADIUS data and store into the Diameter message. */ 68 /* 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 ) 69 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 )
85 } 84 }
86 85
87 86
88 /* Finally, we declare the structure that will be loaded by main RADIUS/Diameter gateway extension */ 87 /* Finally, we declare the structure that will be loaded by main RADIUS/Diameter gateway extension */
89 struct rgw_api rgwp_descriptor = { 88 struct rgw_api rgwp_descriptor = {
90 sample_conf_parse, 89 .rgwp_name = "sample",
91 sample_conf_free, 90 .rgwp_conf_parse = sample_conf_parse,
92 sample_rad_req, 91 .rgwp_conf_free = sample_conf_free,
93 sample_diam_ans 92 .rgwp_rad_req = sample_rad_req,
93 .rgwp_diam_ans = sample_diam_ans
94 }; 94 };
"Welcome to our mercurial repository"