The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
base.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 
17 /**
18  * $Id: b506605dfa2cffd167c4de8c2984538051795c39 $
19  * @file src/process/eap_aka/base.c
20  * @brief EAP-AKA process module
21  *
22  * The state machine for EAP-SIM, EAP-AKA and EAP-AKA' is common to all methods
23  * and is in src/lib/eap_aka_sim/state_machine.c
24  *
25  * The process modules for the different EAP methods just define the sections
26  * for that EAP method, and parse different config items.
27  *
28  * @copyright 2021 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
29  */
30 
31 #include <freeradius-devel/eap_aka_sim/base.h>
32 #include <freeradius-devel/eap_aka_sim/attrs.h>
33 #include <freeradius-devel/eap_aka_sim/state_machine.h>
34 #include <freeradius-devel/server/virtual_servers.h>
35 #include <freeradius-devel/server/process.h>
36 
38  { FR_CONF_OFFSET("request_identity", eap_aka_sim_process_conf_t, request_identity ),
39  .func = cf_table_parse_int,
41  { FR_CONF_OFFSET("strip_permanent_identity_hint", eap_aka_sim_process_conf_t,
42  strip_permanent_identity_hint ), .dflt = "yes" },
43  { FR_CONF_OFFSET_TYPE_FLAGS("ephemeral_id_length", FR_TYPE_SIZE, 0, eap_aka_sim_process_conf_t, ephemeral_id_length ), .dflt = "14" }, /* 14 for compatibility */
44  { FR_CONF_OFFSET("protected_success", eap_aka_sim_process_conf_t, protected_success ), .dflt = "no" },
45 
47 };
48 
50  /*
51  * Identity negotiation
52  * The initial identity here is the EAP-Identity.
53  * We can then choose to request additional
54  * identities.
55  */
56  {
57  .name = "recv",
58  .name2 = "Identity-Response",
59  .component = MOD_AUTHORIZE,
60  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_common_identity_response)
61  },
62  {
63  .name = "send",
64  .name2 = "Identity-Request",
65  .component = MOD_AUTHORIZE,
66  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_common_identity_request)
67  },
68 
69  /*
70  * Optional override sections if the user *really*
71  * wants to apply special policies for subsequent
72  * request/response rounds.
73  */
74  {
75  .name = "send",
76  .name2 = "AKA-Identity-Request",
77  .component = MOD_AUTHORIZE,
78  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_aka_identity_request)
79  },
80  {
81  .name = "recv",
82  .name2 = "AKA-Identity-Response",
83  .component = MOD_AUTHORIZE,
84  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_aka_identity_response)
85  },
86 
87  /*
88  * Full-Authentication
89  */
90  {
91  .name = "send",
92  .name2 = "Challenge-Request",
93  .component = MOD_AUTHORIZE,
94  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_aka_challenge_request)
95  },
96  {
97  .name = "recv",
98  .name2 = "Challenge-Response",
99  .component = MOD_AUTHORIZE,
100  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_aka_challenge_response)
101  },
102 
103  /*
104  * Fast-Re-Authentication
105  */
106  {
107  .name = "send",
108  .name2 = "Reauthentication-Request",
109  .component = MOD_AUTHORIZE,
110  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_common_reauthentication_request)
111  },
112  {
113  .name = "recv",
114  .name2 = "Reauthentication-Response",
115  .component = MOD_AUTHORIZE,
116  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_common_reauthentication_response)
117  },
118 
119  /*
120  * Failures originating from the supplicant
121  */
122  {
123  .name = "recv",
124  .name2 = "Client-Error",
125  .component = MOD_AUTHORIZE,
126  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_common_client_error)
127  },
128  {
129  .name = "recv",
130  .name2 = "Authentication-Reject",
131  .component = MOD_AUTHORIZE,
132  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_aka_authentication_reject)
133  },
134  {
135  .name = "recv",
136  .name2 = "Synchronization-Failure",
137  .component = MOD_AUTHORIZE,
138  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_aka_synchronization_failure)
139  },
140 
141  /*
142  * Failure originating from the server
143  */
144  {
145  .name = "send",
146  .name2 = "Failure-Notification",
147  .component = MOD_AUTHORIZE,
148  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_common_failure_notification)
149  },
150  {
151  .name = "recv",
152  .name2 = "Failure-Notification-ACK",
153  .component = MOD_AUTHORIZE,
154  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_common_failure_notification_ack)
155  },
156 
157  /*
158  * Protected success indication
159  */
160  {
161  .name = "send",
162  .name2 = "Success-Notification",
163  .component = MOD_AUTHORIZE,
164  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_common_success_notification)
165  },
166  {
167  .name = "recv",
168  .name2 = "Success-Notification-ACK",
169  .component = MOD_AUTHORIZE,
170  .offset = offsetof(eap_aka_sim_process_conf_t, actions.recv_common_success_notification_ack)
171  },
172 
173  /*
174  * Final EAP-Success and EAP-Failure messages
175  */
176  {
177  .name = "send",
178  .name2 = "EAP-Success",
179  .component = MOD_AUTHORIZE,
180  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_eap_success)
181  },
182  {
183  .name = "send",
184  .name2 = "EAP-Failure",
185  .component = MOD_AUTHORIZE,
186  .offset = offsetof(eap_aka_sim_process_conf_t, actions.send_eap_failure)
187  },
188 
189  /*
190  * Fast-Reauth vectors
191  */
192  {
193  .name = "store",
194  .name2 = "session",
195  .component = MOD_AUTHORIZE,
196  .offset = offsetof(eap_aka_sim_process_conf_t, actions.store_session)
197  },
198  {
199  .name = "load",
200  .name2 = "session",
201  .component = MOD_AUTHORIZE,
202  .offset = offsetof(eap_aka_sim_process_conf_t, actions.load_session)
203  },
204  {
205  .name = "clear",
206  .name2 = "session",
207  .component = MOD_AUTHORIZE,
208  .offset = offsetof(eap_aka_sim_process_conf_t, actions.clear_session)
209  },
210 
211  /*
212  * Pseudonym processing
213  */
214  {
215  .name = "store",
216  .name2 = "pseudonym",
217  .component = MOD_AUTHORIZE,
218  .offset = offsetof(eap_aka_sim_process_conf_t, actions.store_pseudonym)
219  },
220  {
221  .name = "load",
222  .name2 = "pseudonym",
223  .component = MOD_AUTHORIZE,
224  .offset = offsetof(eap_aka_sim_process_conf_t, actions.load_pseudonym)
225  },
226  {
227  .name = "clear",
228  .name2 = "pseudonym",
229  .component = MOD_AUTHORIZE,
230  .offset = offsetof(eap_aka_sim_process_conf_t, actions.clear_pseudonym)
231  },
232 
234 };
235 
236 static int mod_instantiate(module_inst_ctx_t const *mctx)
237 {
238  eap_aka_sim_process_conf_t *inst = talloc_get_type_abort(mctx->inst->data, eap_aka_sim_process_conf_t);
239 
241 
242  /*
243  * This isn't allowed, so just munge
244  * it to no id request.
245  */
247 
248  return 0;
249 }
250 
251 static int mod_load(void)
252 {
253  if (unlikely(fr_aka_sim_init() < 0)) return -1;
254 
256 
257  return 0;
258 }
259 
260 static void mod_unload(void)
261 {
263 
264  fr_aka_sim_free();
265 }
266 
269  .common = {
270  .magic = MODULE_MAGIC_INIT,
271  .name = "eap_aka",
272  .onload = mod_load,
273  .unload = mod_unload,
274  .config = submodule_config,
275  .instantiate = mod_instantiate,
276  .inst_size = sizeof(eap_aka_sim_process_conf_t),
277  .inst_type = "eap_aka_sim_process_conf_t"
278  },
280  .compile_list = compile_list,
281  .dict = &dict_eap_aka_sim,
282 };
#define unlikely(_x)
Definition: build.h:378
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition: cf_parse.c:1474
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:241
Defines a CONF_PAIR to C data type mapping.
Definition: cf_parse.h:563
@ MOD_AUTHORIZE
1 methods index for authorize section.
Definition: components.h:34
void *_CONST data
Module instance's parsed configuration.
Definition: dl_module.h:165
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:65
@ FR_EAP_METHOD_AKA
Definition: types.h:68
int fr_aka_sim_xlat_func_register(void)
Definition: xlat.c:497
void fr_aka_sim_xlat_func_unregister(void)
Definition: xlat.c:521
void fr_aka_sim_free(void)
Definition: base.c:285
int fr_aka_sim_init(void)
Definition: base.c:254
fr_dict_t const * dict_eap_aka_sim
Definition: base.c:48
fr_table_num_sorted_t const fr_aka_sim_id_request_table[]
Definition: id.c:33
size_t fr_aka_sim_id_request_table_len
Definition: id.c:41
@ AKA_SIM_INIT_ID_REQ
We've requested no ID. This is used for last_id_req.
Definition: id.h:78
@ AKA_SIM_NO_ID_REQ
We're not requesting any ID.
Definition: id.h:79
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
Definition: merged_model.c:115
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
Definition: module_ctx.h:52
Temporary structure to hold arguments for instantiation calls.
Definition: module_ctx.h:51
static int mod_load(void)
Definition: base.c:251
static virtual_server_compile_t const compile_list[]
Definition: base.c:49
fr_process_module_t process_eap_aka
Definition: base.c:268
static void mod_unload(void)
Definition: base.c:260
static conf_parser_t submodule_config[]
Definition: base.c:37
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition: base.c:236
module_t common
Common fields for all loadable modules.
Definition: process.h:55
Common public symbol definition for all process modules.
Definition: process.h:54
eap_aka_sim_process_conf_t * inst
unlang_action_t eap_aka_sim_state_machine_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Resumes the state machine when receiving a new response packet.
eap_type_t type
The preferred EAP-Type of this instance of the EAP-SIM/AKA/AKA' state machine.
fr_aka_sim_id_req_type_t request_identity
Whether we always request the identity of the subscriber.
#define COMPILE_TERMINATOR
char const * name
Name of the processing section, such as "recv" or "send".
Processing sections which are allowed in this virtual server.