Mercurial > hg > waaad
annotate extensions/radius_gw/sub_echo_drop.c @ 385:03b512313cc1
Added code to handle sessions
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 28 May 2009 13:32:37 +0900 |
parents | 98806d0e175f |
children | 540ed390c04f |
rev | line source |
---|---|
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
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 * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 /* See sub_echo_drop.h for details */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 #define DECLARE_API_POINTERS |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 #include "sub_echo_drop.h" |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
41 int sub_echo_drop_verbosity = SUB_ECHO_DROP_VERBO; |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
43 /* Create the configuration and state structure */ |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 static struct rga_conf_state * sed_cs_create(char * conffile) |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 struct rga_conf_state * cs = NULL; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 TRACE_ENTRY("%p", conffile); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 if ( ! conffile ) { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 log_error("No configuration file specified for extension sub_echo_drop!\n"); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 return NULL; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 } |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 /* Create a new storage for extension state */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 CHECK_MALLOC_DO( cs = malloc(sizeof(struct rga_conf_state)), return NULL ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 memset(cs, 0, sizeof(struct rga_conf_state)); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 rg_list_init(&cs->conf); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 /* Initialize the session handler, to store "echo" attributes */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 CHECK_FCT_DO( sess_regext( &cs->sess_hdl ), { free(cs); return NULL; } ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 /* Parse the configuration file with the yacc parser */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 cs->conffile = conffile; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 CHECK_FCT_DO( sed_conf_parse(cs), { sess_deregext(cs->sess_hdl); free(cs); return NULL; } ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 |
376
98806d0e175f
Unified debug messages when loading extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
374
diff
changeset
|
68 TRACE_DEBUG(INFO, "Sub extension Echo/Drop initialized with configuration: '%s'", cs->conffile); |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
69 if (TRACE_BOOL(FULL)) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
70 struct rg_list * li; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
71 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
72 for (li = cs->conf.next; li != &cs->conf; li = li->next) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
73 struct sed_conf_item * sci = (struct sed_conf_item *)li; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
74 char * act = (sci->action == ACT_ECHO) ? "ECHO" : "DROP"; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
75 if (sci->ext) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
76 log_debug(" %s Code: %hhu, Vendor: %u, Ext-Type: %hu\n", act, sci->code, sci->vendor_id, sci->extype); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
77 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
78 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
79 if (sci->tlv) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
80 log_debug(" %s Code: %hhu, Vendor: %u, Type: %hhu\n", act, sci->code, sci->vendor_id, sci->type); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
81 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
82 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
83 if (sci->vsa) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
84 log_debug(" %s Code: %hhu, Vendor: %u\n", act, sci->code, sci->vendor_id); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
85 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
86 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
87 log_debug(" %s Code: %hhu\n", act, sci->code); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
88 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
89 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
90 |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 /* We're done */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 return cs; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 } |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
95 /* Destroy the state */ |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
96 static void sed_cs_destroy(struct rga_conf_state * cs) |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
99 TRACE_ENTRY("%p", cs); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
100 CHECK_PARAMS_DO( cs, ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 while (! rg_list_is_empty(&cs->conf) ) { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 struct rg_list * li = cs->conf.next; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 rg_list_unlink(li); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 free(li); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
106 } |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 CHECK_FCT_DO( sess_deregext( cs->sess_hdl ), ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 free(cs); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 return; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 } |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
114 /* Destroy a list of attributes saved in a session */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
115 static void ssi_cleanup(void * ptr) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
116 { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
117 TRACE_ENTRY("%p", ptr); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
118 CHECK_PARAMS_DO( ptr , return ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
119 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
120 struct rg_list *list = (struct rg_list *)ptr; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
121 while (! rg_list_is_empty(list) ) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
122 struct sed_saved_item * ssi = (struct sed_saved_item *)(list->next); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
123 rg_list_unlink(&ssi->chain); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
124 free(ssi); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
125 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
126 free(list); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
127 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
128 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
129 /* Handle attributes from a RADIUS request as specified in the configuration */ |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
376
diff
changeset
|
130 static int sed_rad_req(struct rga_conf_state * cs, sess_id_t ** session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, msg_t ** diam_fw, void * cli ) |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
131 { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
132 size_t *nattr_pos; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
133 size_t nattr_used = 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
134 int idx; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
135 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
136 struct rg_list echo_list; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
137 struct rg_list *li; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
138 |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
376
diff
changeset
|
139 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
140 CHECK_PARAMS(cs && rad_req); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
141 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
142 rg_list_init(&echo_list); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
143 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
144 CHECK_MALLOC( nattr_pos = malloc(rad_req->attr_size * sizeof(size_t)) ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
145 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
146 /* For each attribute in the original message */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
147 for (idx = 0; idx < rad_req->attr_used; idx++) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
148 int action = 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
149 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
150 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
151 /* Look if we have a matching attribute in our configuration */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
152 for (li = cs->conf.next; li != &cs->conf; li = li->next) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
153 struct sed_conf_item * sci = (struct sed_conf_item *)li; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
154 uint32_t vid; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
155 unsigned char * ptr; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
156 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
157 if (sci->code < attr->type) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
158 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
159 if (sci->code > attr->type) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
160 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
161 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
162 /* matching code */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
163 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
164 if (! sci->vsa) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
165 action = sci->action; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
166 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
167 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
168 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
169 if (attr->length < 8) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
170 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
171 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
172 ptr = (unsigned char *)(attr + 1); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
173 /* since attr is not aligned, we cannot access *(attr+1) directly */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
174 memcpy(&vid, ptr, sizeof(uint32_t)); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
175 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
176 if (sci->vendor_id < ntohl(vid)) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
177 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
178 if (sci->vendor_id > ntohl(vid)) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
179 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
180 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
181 /* Matching vendor */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
182 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
183 if ( ! sci->tlv && ! sci->ext ) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
184 action = sci->action; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
185 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
186 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
187 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
188 if (attr->length < 10) |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
189 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
190 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
191 if (sci->tlv) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
192 struct radius_attr_vendor * tl = (struct radius_attr_vendor *)(ptr + sizeof(uint32_t)); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
193 if (tl->vendor_type == sci->type) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
194 action = sci->action; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
195 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
196 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
197 continue; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
198 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
199 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
200 if (sci->ext) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
201 /* To be done */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
202 ASSERT(0); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
203 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
204 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
205 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
206 switch (action) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
207 case ACT_DROP: |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
208 TRACE_DEBUG(FULL, "Dropping attribute with code %hhd", attr->type); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
209 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
210 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
211 case ACT_ECHO: |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
212 { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
213 struct sed_saved_item * sav = NULL; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
214 TRACE_DEBUG(FULL, "Saving attribute with code %hhd", attr->type); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
215 CHECK_MALLOC( sav = malloc(sizeof(struct sed_saved_item) + attr->length - sizeof(struct radius_attr_hdr)) ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
216 rg_list_init(&sav->chain); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
217 memcpy(&sav->attr, attr, attr->length); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
218 rg_list_insert_before(&echo_list, &sav->chain); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
219 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
220 break; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
221 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
222 case 0: /* Attribute was not specified in the configuration */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
223 default: /* unknown action value */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
224 /* We just keep the attribute in the RADIUS message */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
225 nattr_pos[nattr_used++] = rad_req->attr_pos[idx]; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
226 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
227 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
228 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
229 /* Save the echoed values in the session, if any */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
230 if (!rg_list_is_empty(&echo_list)) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
231 CHECK_PARAMS(session && *session); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
232 CHECK_MALLOC( li = malloc(sizeof(struct rg_list)) ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
233 memcpy(li, &echo_list, sizeof(struct rg_list)); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
234 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
235 /* Check that we have no previous data stored for this session, for debug */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
236 ASSERT( sess_data_dereg(*session, cs->sess_hdl, NULL) == ENOENT ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
237 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
238 /* Save the list in the session */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
239 CHECK_FCT( sess_data_reg(*session, cs->sess_hdl, li, ssi_cleanup) ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
240 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
241 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
242 /* Finally update the radius message to remove all handled attributes */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
243 free(rad_req->attr_pos); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
244 rad_req->attr_pos = nattr_pos; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
245 rad_req->attr_used = nattr_used; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
246 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
247 return 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
248 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
249 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
250 /* Process an answer: add back the ECHO attributes, if any */ |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
376
diff
changeset
|
251 static int sed_diam_ans(struct rga_conf_state * cs, sess_id_t ** session, msg_t ** diam_ans, struct radius_msg ** rad_fw, void * cli ) |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
252 { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
253 int ret; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
254 struct rg_list * list = NULL; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
255 |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
376
diff
changeset
|
256 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli); |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
257 CHECK_PARAMS(cs); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
258 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
259 /* If there is no session associated, just give up */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
260 if (! session || ! *session) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
261 TRACE_DEBUG(FULL, "No session associated with the message, nothing to do here..."); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
262 return 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
263 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
264 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
265 /* No try and retrieve any data from the session */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
266 ret = sess_data_dereg( *session, cs->sess_hdl, (void *)&list ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
267 if (ret == ENOENT) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
268 TRACE_DEBUG(FULL, "No data saved in the session, no attribute to add back"); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
269 return 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
270 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
271 CHECK_FCT(ret); /* Return if another error occurred */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
272 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
273 /* From this point on, we have a list of attributes to add to the radius message */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
274 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
275 CHECK_PARAMS( rad_fw ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
276 if ( *rad_fw == NULL ) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
277 /* Will implement this when main extension is complete */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
278 ASSERT(0); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
279 return ENOTSUP; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
280 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
281 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
282 while (! rg_list_is_empty(list) ) { |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
283 struct sed_saved_item * ssi = (struct sed_saved_item *)(list->next); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
284 struct radius_attr_hdr * rc; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
285 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
286 rg_list_unlink(&ssi->chain); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
287 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
288 TRACE_DEBUG(FULL, "Echo attribute in the RADIUS answer: type %hhu, len: %hhu", ssi->attr.type, ssi->attr.length); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
289 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
290 /* Add this attribute in the RADIUS message */ |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
291 CHECK_MALLOC( radius_msg_add_attr(*rad_fw, ssi->attr.type, (unsigned char *)(ssi + 1), ssi->attr.length - sizeof(struct radius_attr_hdr)) ); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
292 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
293 free(ssi); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
294 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
295 free(list); |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
296 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
297 return 0; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
298 } |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
299 |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
300 |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
301 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
302 int rga_register(int version, waaad_api_t * waaad_api, struct radius_gw_api * api) |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
303 { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
304 TRACE_ENTRY("%d %p %p", version, waaad_api, api); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
305 CHECK_PARAMS( waaad_api && api ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
306 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
307 if (version != RADIUS_GW_API_VER) { |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
308 log_error("ABI version mismatch, please recompile this extension (%s)\n", __FILE__); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
309 return EINVAL; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
310 } |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
311 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
312 /* Required to use the waaad api from this sub-extension: */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
313 EXTENSION_API_INIT_INTERN( API_MODULE_ALL, "sub_echo_drop", waaad_api ); |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
314 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
315 /* Initialize the radius_gw api callbacks */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
316 api->rga_conf_parse_cb = sed_cs_create; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
317 api->rga_conf_free_cb = sed_cs_destroy; |
374
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
318 api->rga_rad_req_cb = sed_rad_req; |
883330e610e1
Progress on the echo_drop sub extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
373
diff
changeset
|
319 api->rga_diam_ans_cb = sed_diam_ans; |
373
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
320 |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
321 /* We're done, we must not initialize any state here since the extension must be re-entrant, but in sample_conf_parse */ |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
322 return 0; |
0cb02e490017
Added sub_echo_drop files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
323 } |