Mercurial > hg > freeDiameter
annotate extensions/app_radgw/rgwx_auth.c @ 526:6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 01 Sep 2010 16:21:15 +0900 |
parents | ddbcd21af4e0 |
children | 4cb8f63a0f67 |
rev | line source |
---|---|
256 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * | |
4 * * | |
258
5df55136361b
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
256
diff
changeset
|
5 * Copyright (c) 2010, WIDE Project and NICT * |
256 | 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 /* RADIUS Access-Request messages translation plugin */ | |
37 | |
38 #include "rgw_common.h" | |
39 | |
40 /* Attributes missing from radius.h */ | |
41 #define RADIUS_ATTR_CHAP_PASSWORD 3 | |
42 #define RADIUS_ATTR_ARAP_PASSWORD 70 | |
43 | |
44 /* Other constants we use */ | |
45 #define AI_NASREQ 1 /* Diameter NASREQ */ | |
46 #define AI_EAP 5 /* Diameter EAP application */ | |
47 #define CC_AA 265 /* AAR */ | |
48 #define CC_DIAMETER_EAP 268 /* DER */ | |
49 #define ACV_ART_AUTHORIZE_AUTHENTICATE 3 /* AUTHORIZE_AUTHENTICATE */ | |
50 #define ACV_OAP_RADIUS 1 /* RADIUS */ | |
51 #define ACV_ASS_STATE_MAINTAINED 0 /* STATE_MAINTAINED */ | |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
52 #define ACV_ASS_NO_STATE_MAINTAINED 1 /* NO_STATE_MAINTAINED */ |
256 | 53 #define ER_DIAMETER_MULTI_ROUND_AUTH 1001 |
54 #define ER_DIAMETER_LIMITED_SUCCESS 2002 | |
55 | |
56 /* The state we keep for this plugin */ | |
57 struct rgwp_config { | |
58 struct { | |
59 struct dict_object * ARAP_Password; /* ARAP-Password */ | |
60 struct dict_object * ARAP_Security; /* ARAP-Security */ | |
61 struct dict_object * ARAP_Security_Data; /* ARAP-Security-Data */ | |
62 struct dict_object * Auth_Application_Id; /* Auth-Application-Id */ | |
63 struct dict_object * Auth_Request_Type; /* Auth-Request-Type */ | |
64 struct dict_object * Authorization_Lifetime; /* Authorization-Lifetime */ | |
65 struct dict_object * Callback_Number; /* Callback-Number */ | |
66 struct dict_object * Called_Station_Id; /* Called-Station-Id */ | |
67 struct dict_object * Calling_Station_Id; /* Calling-Station-Id */ | |
68 struct dict_object * CHAP_Algorithm; /* CHAP-Algorithm */ | |
69 struct dict_object * CHAP_Auth; /* CHAP-Auth */ | |
70 struct dict_object * CHAP_Challenge; /* CHAP-Challenge */ | |
71 struct dict_object * CHAP_Ident; /* CHAP-Ident */ | |
72 struct dict_object * CHAP_Response; /* CHAP-Response */ | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
73 struct dict_object * Destination_Host; /* Destination-Host */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
74 struct dict_object * Destination_Realm; /* Destination-Realm */ |
256 | 75 struct dict_object * Connect_Info; /* Connect-Info */ |
76 struct dict_object * EAP_Payload; /* EAP-Payload */ | |
77 struct dict_object * Error_Message; /* Error-Message */ | |
78 struct dict_object * Error_Reporting_Host; /* Error-Reporting-Host */ | |
79 struct dict_object * Failed_AVP; /* Failed-AVP */ | |
80 struct dict_object * Framed_Compression; /* Framed-Compression */ | |
81 struct dict_object * Framed_IP_Address; /* Framed-IP-Address */ | |
82 struct dict_object * Framed_IP_Netmask; /* Framed-IP-Netmask */ | |
83 struct dict_object * Framed_Interface_Id; /* Framed-Interface-Id */ | |
84 struct dict_object * Framed_IPv6_Prefix; /* Framed-IPv6-Prefix */ | |
85 struct dict_object * Framed_MTU; /* Framed-MTU */ | |
86 struct dict_object * Framed_Protocol; /* Framed-Protocol */ | |
87 struct dict_object * Login_IP_Host; /* Login-IP-Host */ | |
88 struct dict_object * Login_IPv6_Host; /* Login-IPv6-Host */ | |
89 struct dict_object * Login_LAT_Group; /* Login-LAT-Group */ | |
90 struct dict_object * Login_LAT_Node; /* Login-LAT-Node */ | |
91 struct dict_object * Login_LAT_Port; /* Login-LAT-Port */ | |
92 struct dict_object * Login_LAT_Service; /* Login-LAT-Service */ | |
93 struct dict_object * NAS_Identifier; /* NAS-Identifier */ | |
94 struct dict_object * NAS_IP_Address; /* NAS-IP-Address */ | |
95 struct dict_object * NAS_IPv6_Address; /* NAS-IPv6-Address */ | |
96 struct dict_object * NAS_Port; /* NAS-Port */ | |
97 struct dict_object * NAS_Port_Id; /* NAS-Port-Id */ | |
98 struct dict_object * NAS_Port_Type; /* NAS-Port-Type */ | |
99 struct dict_object * Origin_AAA_Protocol; /* Origin-AAA-Protocol */ | |
100 struct dict_object * Origin_Host; /* Origin-Host */ | |
101 struct dict_object * Origin_Realm; /* Origin-Realm */ | |
102 struct dict_object * Originating_Line_Info; /* Originating-Line-Info */ | |
103 struct dict_object * Port_Limit; /* Port-Limit */ | |
104 struct dict_object * Re_Auth_Request_Type; /* Re-Auth-Request-Type */ | |
105 struct dict_object * Result_Code; /* Result-Code */ | |
106 struct dict_object * Service_Type; /* Service-Type */ | |
107 struct dict_object * Session_Id; /* Session-Id */ | |
108 struct dict_object * Session_Timeout; /* Session-Timeout */ | |
109 struct dict_object * State; /* State */ | |
110 struct dict_object * Tunneling; /* Tunneling */ | |
111 struct dict_object * Tunnel_Type; /* Tunnel-Type */ | |
112 struct dict_object * Tunnel_Medium_Type; /* Tunnel-Medium-Type */ | |
113 struct dict_object * Tunnel_Client_Endpoint; /* Tunnel-Client-Endpoint */ | |
114 struct dict_object * Tunnel_Server_Endpoint; /* Tunnel-Server-Endpoint */ | |
115 struct dict_object * Tunnel_Private_Group_Id; /* Tunnel-Private-Group-Id */ | |
116 struct dict_object * Tunnel_Preference; /* Tunnel-Preference */ | |
117 struct dict_object * Tunnel_Client_Auth_Id; /* Tunnel-Client-Auth-Id */ | |
118 struct dict_object * Tunnel_Server_Auth_Id; /* Tunnel-Server-Auth-Id */ | |
119 struct dict_object * User_Name; /* User-Name */ | |
120 struct dict_object * User_Password; /* User-Password */ | |
121 | |
122 } dict; /* cache of the dictionary objects we use */ | |
271
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
123 struct session_handler * sess_hdl; /* We store RADIUS request authenticator information in the session */ |
256 | 124 char * confstr; |
526
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
125 |
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
126 int ignore_nai; |
256 | 127 }; |
128 | |
129 /* Initialize the plugin */ | |
526
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
130 static int auth_conf_parse(char * confstr, struct rgwp_config ** state) |
256 | 131 { |
132 struct rgwp_config * new; | |
264
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
133 struct dict_object * app; |
256 | 134 |
526
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
135 TRACE_ENTRY("%p %p", confstr, state); |
256 | 136 CHECK_PARAMS( state ); |
137 | |
138 CHECK_MALLOC( new = malloc(sizeof(struct rgwp_config)) ); | |
139 memset(new, 0, sizeof(struct rgwp_config)); | |
140 | |
141 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) ); | |
526
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
142 new->confstr = confstr; |
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
143 |
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
144 if (strstr(confstr, "nonai")) |
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
145 new->ignore_nai = 1; |
256 | 146 |
147 /* Resolve all dictionary objects we use */ | |
148 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Password", &new->dict.ARAP_Password, ENOENT) ); | |
149 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Security", &new->dict.ARAP_Security, ENOENT) ); | |
150 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Security-Data", &new->dict.ARAP_Security_Data, ENOENT) ); | |
151 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &new->dict.Auth_Application_Id, ENOENT) ); | |
152 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Request-Type", &new->dict.Auth_Request_Type, ENOENT) ); | |
153 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Authorization-Lifetime", &new->dict.Authorization_Lifetime, ENOENT) ); | |
154 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Callback-Number", &new->dict.Callback_Number, ENOENT) ); | |
155 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Called-Station-Id", &new->dict.Called_Station_Id, ENOENT) ); | |
156 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Calling-Station-Id", &new->dict.Calling_Station_Id, ENOENT) ); | |
157 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CHAP-Algorithm", &new->dict.CHAP_Algorithm, ENOENT) ); | |
158 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CHAP-Auth", &new->dict.CHAP_Auth, ENOENT) ); | |
159 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CHAP-Challenge", &new->dict.CHAP_Challenge, ENOENT) ); | |
160 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CHAP-Ident", &new->dict.CHAP_Ident, ENOENT) ); | |
161 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CHAP-Response", &new->dict.CHAP_Response, ENOENT) ); | |
162 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Connect-Info", &new->dict.Connect_Info, ENOENT) ); | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
163 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &new->dict.Destination_Host, ENOENT) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
164 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &new->dict.Destination_Realm, ENOENT) ); |
256 | 165 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "EAP-Payload", &new->dict.EAP_Payload, ENOENT) ); |
166 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Message", &new->dict.Error_Message, ENOENT) ); | |
167 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Reporting-Host", &new->dict.Error_Reporting_Host, ENOENT) ); | |
168 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Failed-AVP", &new->dict.Failed_AVP, ENOENT) ); | |
169 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Compression", &new->dict.Framed_Compression, ENOENT) ); | |
170 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IP-Address", &new->dict.Framed_IP_Address, ENOENT) ); | |
171 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IP-Netmask", &new->dict.Framed_IP_Netmask, ENOENT) ); | |
172 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Interface-Id", &new->dict.Framed_Interface_Id, ENOENT) ); | |
173 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IPv6-Prefix", &new->dict.Framed_IPv6_Prefix, ENOENT) ); | |
174 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-MTU", &new->dict.Framed_MTU, ENOENT) ); | |
175 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Protocol", &new->dict.Framed_Protocol, ENOENT) ); | |
176 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-IP-Host", &new->dict.Login_IP_Host, ENOENT) ); | |
177 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-IPv6-Host", &new->dict.Login_IPv6_Host, ENOENT) ); | |
178 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Group", &new->dict.Login_LAT_Group, ENOENT) ); | |
179 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Node", &new->dict.Login_LAT_Node, ENOENT) ); | |
180 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Port", &new->dict.Login_LAT_Port, ENOENT) ); | |
181 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Service", &new->dict.Login_LAT_Service, ENOENT) ); | |
182 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Identifier", &new->dict.NAS_Identifier, ENOENT) ); | |
183 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-IP-Address", &new->dict.NAS_IP_Address, ENOENT) ); | |
184 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-IPv6-Address", &new->dict.NAS_IPv6_Address, ENOENT) ); | |
185 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port", &new->dict.NAS_Port, ENOENT) ); | |
186 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port-Id", &new->dict.NAS_Port_Id, ENOENT) ); | |
187 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port-Type", &new->dict.NAS_Port_Type, ENOENT) ); | |
188 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-AAA-Protocol", &new->dict.Origin_AAA_Protocol, ENOENT) ); | |
189 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &new->dict.Origin_Host, ENOENT) ); | |
190 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &new->dict.Origin_Realm, ENOENT) ); | |
191 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Originating-Line-Info", &new->dict.Originating_Line_Info, ENOENT) ); | |
192 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Port-Limit", &new->dict.Port_Limit, ENOENT) ); | |
193 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Re-Auth-Request-Type", &new->dict.Re_Auth_Request_Type, ENOENT) ); | |
194 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &new->dict.Result_Code, ENOENT) ); | |
195 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Service-Type", &new->dict.Service_Type, ENOENT) ); | |
196 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &new->dict.Session_Id, ENOENT) ); | |
197 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Timeout", &new->dict.Session_Timeout, ENOENT) ); | |
198 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "State", &new->dict.State, ENOENT) ); | |
199 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunneling", &new->dict.Tunneling, ENOENT) ); | |
200 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Type", &new->dict.Tunnel_Type, ENOENT) ); | |
201 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Medium-Type", &new->dict.Tunnel_Medium_Type, ENOENT) ); | |
202 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Client-Endpoint", &new->dict.Tunnel_Client_Endpoint, ENOENT) ); | |
203 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Server-Endpoint", &new->dict.Tunnel_Server_Endpoint, ENOENT) ); | |
204 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Private-Group-Id", &new->dict.Tunnel_Private_Group_Id, ENOENT) ); | |
205 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Preference", &new->dict.Tunnel_Preference, ENOENT) ); | |
206 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Client-Auth-Id", &new->dict.Tunnel_Client_Auth_Id, ENOENT) ); | |
207 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Server-Auth-Id", &new->dict.Tunnel_Server_Auth_Id, ENOENT) ); | |
208 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &new->dict.User_Name, ENOENT) ); | |
209 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Password", &new->dict.User_Password, ENOENT) ); | |
210 | |
264
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
211 /* This plugin provides the following Diameter authentication applications support: */ |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
212 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Network Access Server Application", &app, ENOENT) ); |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
213 CHECK_FCT( fd_disp_app_support ( app, NULL, 1, 0 ) ); |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
214 |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
215 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Extensible Authentication Protocol (EAP) Application", &app, ENOENT) ); |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
216 CHECK_FCT( fd_disp_app_support ( app, NULL, 1, 0 ) ); |
a3b2cde34f7b
Advertize support for translated applications
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
262
diff
changeset
|
217 |
262
cc2c568ef319
Missing affectation
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
218 *state = new; |
256 | 219 return 0; |
220 } | |
221 | |
222 /* deinitialize */ | |
223 static void auth_conf_free(struct rgwp_config * state) | |
224 { | |
225 TRACE_ENTRY("%p", state); | |
226 CHECK_PARAMS_DO( state, return ); | |
227 CHECK_FCT_DO( fd_sess_handler_destroy( &state->sess_hdl ), ); | |
228 free(state); | |
229 return; | |
230 } | |
231 | |
232 /* Handle an incoming RADIUS request */ | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
233 static int auth_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 ) |
256 | 234 { |
235 int idx; | |
236 int got_id = 0; | |
237 int got_mac = 0; | |
238 int got_passwd = 0; | |
239 int got_eap = 0; | |
240 int got_empty_eap = 0; | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
241 const char * prefix = "Diameter/"; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
242 size_t pref_len; |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
243 uint8_t * dh = NULL; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
244 size_t dh_len = 0; |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
245 uint8_t * dr = NULL; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
246 size_t dr_len = 0; |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
247 uint8_t * si = NULL; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
248 size_t si_len = 0; |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
249 uint8_t * un = NULL; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
250 size_t un_len = 0; |
256 | 251 size_t nattr_used = 0; |
252 struct avp ** avp_tun = NULL, *avp = NULL; | |
253 union avp_value value; | |
254 | |
255 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli); | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
256 CHECK_PARAMS(cs && session && rad_req && (rad_req->hdr->code == RADIUS_CODE_ACCESS_REQUEST) && rad_ans && diam_fw && *diam_fw); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
257 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
258 pref_len = strlen(prefix); |
256 | 259 |
260 /* | |
261 Guidelines: | |
262 http://tools.ietf.org/html/rfc4005#section-9.1 | |
263 http://tools.ietf.org/html/rfc4072#section-6.1 | |
264 | |
265 When a Translation Agent receives a RADIUS message, the following | |
266 steps should be taken: | |
267 | |
268 - If a Message-Authenticator attribute is present, the value MUST | |
269 be checked but not included in the Diameter message. If it is | |
270 incorrect, the RADIUS message should be silently discarded. | |
271 The gateway system SHOULD generate and include a Message- | |
272 Authenticator in returned RADIUS responses. | |
273 -> done in rgw_msg_auth_check | |
274 | |
275 - The transport address of the sender MUST be checked against the | |
276 NAS identifying attributes. See the description of NAS- | |
277 Identifier and NAS-IP-Address below. | |
278 -> done in rgw_clients_check_origin | |
279 | |
280 - The Translation Agent must maintain transaction state | |
281 information relevant to the RADIUS request, such as the | |
282 Identifier field in the RADIUS header, any existing RADIUS | |
283 Proxy-State attribute, and the source IP address and port | |
284 number of the UDP packet. These may be maintained locally in a | |
285 state table or saved in a Proxy-Info AVP group. A Diameter | |
286 Session-Id AVP value must be created using a session state | |
287 mapping mechanism. | |
288 -> Identifier, source and port are saved along with the request, | |
289 and associated with the session state. | |
290 -> sub_echo_drop should handle the Proxy-State attribute (conf issue) | |
291 | |
292 - The Diameter Origin-Host and Origin-Realm AVPs MUST be created | |
293 and added by using the information from an FQDN corresponding | |
294 to the NAS-IP-Address attribute (preferred if available), | |
295 and/or to the NAS-Identifier attribute. (Note that the RADIUS | |
296 NAS-Identifier is not required to be an FQDN.) | |
297 -> done in rgw_msg_create_base. | |
298 | |
299 - The response MUST have an Origin-AAA-Protocol AVP added, | |
300 indicating the protocol of origin of the message. | |
301 -> what "response" ??? Added to the AAR / DER in this function. | |
302 | |
303 - The Proxy-Info group SHOULD be added, with the local server's | |
304 identity specified in the Proxy-Host AVP. This should ensure | |
305 that the response is returned to this system. | |
306 -> We don't need this, answer is always routed here anyway. | |
307 | |
308 For EAP: | |
309 | |
310 o RADIUS EAP-Message attribute(s) are translated to a Diameter | |
311 EAP-Payload AVP. If multiple RADIUS EAP-Message attributes are | |
312 present, they are concatenated and translated to a single Diameter | |
313 EAP-Payload AVP. | |
314 -> concatenation done by radius_msg_get_eap | |
315 | |
316 -> the remaining is specific conversion rules | |
317 */ | |
318 | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
319 /* Check basic information is there, and also retrieve some attribute information */ |
256 | 320 for (idx = 0; idx < rad_req->attr_used; idx++) { |
321 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
322 uint8_t * attr_val = (uint8_t *)(attr + 1); |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
323 size_t attr_len = attr->length - sizeof(struct radius_attr_hdr); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
324 |
256 | 325 switch (attr->type) { |
326 case RADIUS_ATTR_NAS_IP_ADDRESS: | |
327 case RADIUS_ATTR_NAS_IDENTIFIER: | |
328 case RADIUS_ATTR_NAS_IPV6_ADDRESS: | |
329 got_id = 1; | |
330 break; | |
331 case RADIUS_ATTR_MESSAGE_AUTHENTICATOR: | |
332 got_mac = 1; | |
333 break; | |
334 case RADIUS_ATTR_EAP_MESSAGE: | |
335 got_eap = 1; | |
336 if (attr->length == 2) | |
337 got_empty_eap = 1; | |
338 break; | |
339 case RADIUS_ATTR_USER_PASSWORD: | |
340 case RADIUS_ATTR_CHAP_PASSWORD: | |
341 case RADIUS_ATTR_ARAP_PASSWORD: | |
342 got_passwd += 1; | |
343 break; | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
344 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
345 /* Is there a State attribute with prefix "Diameter/" in the message? (in that case: Diameter/Destination-Host/Destination-Realm/Session-Id) */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
346 /* NOTE: RFC4005 says "Origin-Host" here, but it's not coherent with the rules for answers. Destination-Host makes more sense */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
347 case RADIUS_ATTR_STATE: |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
348 if ((attr_len > pref_len + 5 /* for the '/'s and non empty strings */ ) |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
349 && ! memcmp(attr_val, prefix, pref_len)) { |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
350 int i, start; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
351 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
352 TRACE_DEBUG(ANNOYING, "Found a State attribute with '%s' prefix (attr #%d).", prefix, idx); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
353 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
354 /* Now parse the value and check its content is valid. Unfortunately we cannot use strchr here since strings are not \0-terminated */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
355 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
356 i = start = pref_len; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
357 dh = attr_val + i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
358 for (; (i < attr_len - 2) && (attr_val[i] != '/'); i++) /* loop */; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
359 if ( i >= attr_len - 2 ) continue; /* the attribute format is not good */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
360 dh_len = i - start; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
361 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
362 start = ++i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
363 dr = attr_val + i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
364 for (; (i < attr_len - 1) && (attr_val[i] != '/'); i++) /* loop */; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
365 if ( i >= attr_len - 1 ) continue; /* the attribute format is not good */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
366 dr_len = i - start; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
367 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
368 i++; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
369 si = attr_val + i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
370 si_len = attr_len - i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
371 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
372 TRACE_DEBUG(ANNOYING, "Attribute parsed successfully: DH:'%.*s' DR:'%.*s' SI:'%.*s'.", dh_len, dh, dr_len, dr, si_len, si); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
373 /* Remove from the message */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
374 for (i = idx + 1; i < rad_req->attr_used; i++) |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
375 rad_req->attr_pos[i - 1] = rad_req->attr_pos[i]; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
376 rad_req->attr_used -= 1; |
384 | 377 idx--; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
378 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
379 break; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
380 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
381 case RADIUS_ATTR_USER_NAME: |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
382 TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", attr_len, attr_len ? (char *)attr_val : ""); |
386
ce8d20725308
Allow empty User-Name RADIUS attributes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
385
diff
changeset
|
383 un = attr_val; |
ce8d20725308
Allow empty User-Name RADIUS attributes
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
385
diff
changeset
|
384 un_len = attr_len; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
385 break; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
386 |
256 | 387 } |
388 } | |
389 if (!got_id) { | |
390 TRACE_DEBUG(INFO, "RADIUS Access-Request did not contain a NAS IP or Identifier attribute, reject."); | |
391 return EINVAL; | |
392 } | |
393 /* [Note 1] An Access-Request that contains either a User-Password or | |
394 CHAP-Password or ARAP-Password or one or more EAP-Message attributes | |
395 MUST NOT contain more than one type of those four attributes. If it | |
396 does not contain any of those four attributes, it SHOULD contain a | |
397 Message-Authenticator. If any packet type contains an EAP-Message | |
398 attribute it MUST also contain a Message-Authenticator. A RADIUS | |
399 server receiving an Access-Request not containing any of those four | |
400 attributes and also not containing a Message-Authenticator attribute | |
401 SHOULD silently discard it. */ | |
402 if (((got_eap + got_passwd) > 1) || (got_eap && !got_mac) || (!got_eap && !got_passwd && !got_mac)) { | |
403 TRACE_DEBUG(INFO, "RADIUS Access-Request not conform to RFC3579 sec 3.3 note 1, discard."); | |
404 return EINVAL; | |
405 } | |
406 | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
407 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
408 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
409 /* |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
410 - If the RADIUS request contained a State attribute and the |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
411 prefix of the data is "Diameter/", the data following the |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
412 prefix contains the Diameter Origin-Host/Origin-Realm/Session- |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
413 Id. If no such attributes are present and the RADIUS command |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
414 is an Access-Request, a new Session-Id is created. The |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
415 Session-Id is included in the Session-Id AVP. |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
416 */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
417 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
418 /* Add the Destination-Realm AVP */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
419 CHECK_FCT( fd_msg_avp_new ( cs->dict.Destination_Realm, 0, &avp ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
420 if (dr) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
421 value.os.data = (unsigned char *)dr; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
422 value.os.len = dr_len; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
423 } else { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
424 int i = 0; |
526
6fe3e5cf9fb2
Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
405
diff
changeset
|
425 if (un && ! cs->ignore_nai) { |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
426 /* Is there an '@' in the user name? We don't care for decorated NAI here */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
427 for (i = un_len - 2; i > 0; i--) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
428 if (un[i] == '@') { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
429 i++; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
430 break; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
431 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
432 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
433 } |
388
554fe1d67acc
Fix small issue in the gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
386
diff
changeset
|
434 if (i <= 0) { |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
435 /* Not found in the User-Name => we use the local domain of this gateway */ |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
436 value.os.data = (uint8_t *)fd_g_config->cnf_diamrlm; |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
437 value.os.len = fd_g_config->cnf_diamrlm_len; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
438 } else { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
439 value.os.data = un + i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
440 value.os.len = un_len - i; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
441 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
442 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
443 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
444 CHECK_FCT( fd_msg_avp_add ( *diam_fw, *session ? MSG_BRW_LAST_CHILD : MSG_BRW_FIRST_CHILD, avp) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
445 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
446 /* Add the Destination-Host if found */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
447 if (dh) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
448 CHECK_FCT( fd_msg_avp_new ( cs->dict.Destination_Host, 0, &avp ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
449 value.os.data = (unsigned char *)dh; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
450 value.os.len = dh_len; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
451 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
452 CHECK_FCT( fd_msg_avp_add ( *diam_fw, *session ? MSG_BRW_LAST_CHILD : MSG_BRW_FIRST_CHILD, avp) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
453 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
454 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
455 /* Create the session if it is not already done */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
456 if (*session == NULL) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
457 char * sess_str = NULL; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
458 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
459 if (si_len) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
460 /* We already have the Session-Id, just use it */ |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
461 CHECK_FCT( fd_sess_fromsid ( (char *) /* this cast will be removed later */ si, si_len, session, NULL) ); |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
462 } else { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
463 /* Create a new Session-Id string */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
464 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
465 char * fqdn; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
466 char * realm; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
467 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
468 /* Get information on the RADIUS client */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
469 CHECK_FCT( rgw_clients_get_origin(cli, &fqdn, &realm) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
470 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
471 /* If we have a user name, create the new session with it */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
472 if (un) { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
473 int len; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
474 /* If not found, create a new Session-Id. The format is: {fqdn;hi32;lo32;username;diamid} */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
475 CHECK_MALLOC( sess_str = malloc(un_len + 1 /* ';' */ + fd_g_config->cnf_diamid_len + 1 /* '\0' */) ); |
405
ddbcd21af4e0
Fix a few warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
476 len = sprintf(sess_str, "%.*s;%s", (int)un_len, un, fd_g_config->cnf_diamid); |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
477 CHECK_FCT( fd_sess_new(session, fqdn, sess_str, len) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
478 free(sess_str); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
479 } else { |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
480 /* We don't have enough information to create the Session-Id, the RADIUS message is probably invalid */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
481 TRACE_DEBUG(INFO, "RADIUS Access-Request does not contain a User-Name attribute, rejecting."); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
482 return EINVAL; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
483 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
484 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
485 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
486 /* Now, add the Session-Id AVP at beginning of Diameter message */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
487 CHECK_FCT( fd_sess_getsid(*session, &sess_str) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
488 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
489 TRACE_DEBUG(FULL, "[auth.rgwx] Translating new message for session '%s'...", sess_str); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
490 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
491 /* Add the Session-Id AVP as first AVP */ |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
492 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
493 value.os.data = (unsigned char *)sess_str; |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
494 value.os.len = strlen(sess_str); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
495 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
496 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) ); |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
497 } |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
498 |
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
499 |
256 | 500 /* Add the appropriate command code & Auth-Application-Id */ |
501 { | |
502 struct msg_hdr * header = NULL; | |
503 CHECK_FCT( fd_msg_hdr ( *diam_fw, &header ) ); | |
504 header->msg_flags = CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE; | |
505 if (got_eap) { | |
506 header->msg_code = CC_DIAMETER_EAP; | |
507 header->msg_appl = AI_EAP; | |
508 } else { | |
509 header->msg_code = CC_AA; | |
510 header->msg_appl = AI_NASREQ; | |
511 } | |
512 | |
513 /* Add the Auth-Application-Id */ | |
514 { | |
515 CHECK_FCT( fd_msg_avp_new ( cs->dict.Auth_Application_Id, 0, &avp ) ); | |
516 value.i32 = header->msg_appl; | |
517 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
518 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
519 } | |
520 } | |
521 | |
522 /* The type of request is identified through the Auth-Request-Type AVP | |
523 [BASE]. The recommended value for most RADIUS interoperabily | |
524 situations is AUTHORIZE_AUTHENTICATE. */ | |
525 | |
526 /* Add Auth-Request-Type AVP */ | |
527 { | |
528 CHECK_FCT( fd_msg_avp_new ( cs->dict.Auth_Request_Type, 0, &avp ) ); | |
529 value.i32 = ACV_ART_AUTHORIZE_AUTHENTICATE; | |
530 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
531 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
532 } | |
533 | |
534 /* Add Origin-AAA-Protocol AVP */ | |
535 { | |
536 CHECK_FCT( fd_msg_avp_new ( cs->dict.Origin_AAA_Protocol, 0, &avp ) ); | |
537 value.i32 = ACV_OAP_RADIUS; | |
538 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
539 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
540 } | |
541 | |
542 /* Convert the EAP payload (concat RADIUS attributes) */ | |
543 if (got_eap) { | |
544 CHECK_FCT( fd_msg_avp_new ( cs->dict.EAP_Payload, 0, &avp ) ); | |
545 | |
546 /* o An empty RADIUS EAP-Message attribute (with length 2) signifies | |
547 EAP-Start, and it is translated to an empty EAP-Payload AVP. */ | |
548 if (got_empty_eap) { | |
549 value.os.len = 0; | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
550 value.os.data = (uint8_t *)""; |
256 | 551 } else { |
552 CHECK_MALLOC( value.os.data = radius_msg_get_eap(rad_req, &value.os.len) ); | |
553 } | |
554 | |
555 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
556 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
557 } | |
558 | |
559 /* Tunnel AVPs need some preparation */ | |
560 /* Convert the attributes one by one */ | |
561 for (idx = 0; idx < rad_req->attr_used; idx++) { | |
562 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]); | |
563 | |
564 switch (attr->type) { | |
565 | |
566 /* This macro converts a RADIUS attribute to a Diameter AVP of type OctetString */ | |
567 #define CONV2DIAM_STR( _dictobj_ ) \ | |
568 CHECK_PARAMS( attr->length >= 2 ); \ | |
569 /* Create the AVP with the specified dictionary model */ \ | |
570 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ | |
571 value.os.len = attr->length - 2; \ | |
572 value.os.data = (unsigned char *)(attr + 1); \ | |
573 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ | |
574 /* Add the AVP in the Diameter message. */ \ | |
575 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \ | |
576 | |
577 /* Same thing, for scalar AVPs of 32 bits */ | |
578 #define CONV2DIAM_32B( _dictobj_ ) \ | |
579 CHECK_PARAMS( attr->length == 6 ); \ | |
580 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ | |
581 { \ | |
582 uint8_t * v = (uint8_t *)(attr + 1); \ | |
583 value.u32 = (v[0] << 24) \ | |
584 | (v[1] << 16) \ | |
585 | (v[2] << 8) \ | |
586 | v[3] ; \ | |
587 } \ | |
588 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ | |
589 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \ | |
590 | |
591 /* And the 64b version */ | |
592 #define CONV2DIAM_64B( _dictobj_ ) \ | |
593 CHECK_PARAMS( attr->length == 10); \ | |
594 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ | |
595 { \ | |
596 uint8_t * v = (uint8_t *)(attr + 1); \ | |
597 value.u64 = ((uint64_t)(v[0]) << 56) \ | |
598 | ((uint64_t)(v[1]) << 48) \ | |
599 | ((uint64_t)(v[2]) << 40) \ | |
600 | ((uint64_t)(v[3]) << 32) \ | |
601 | ((uint64_t)(v[4]) << 24) \ | |
602 | ((uint64_t)(v[5]) << 16) \ | |
603 | ((uint64_t)(v[6]) << 8) \ | |
604 | (uint64_t)(v[7]) ; \ | |
605 } \ | |
606 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ | |
607 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \ | |
608 | |
609 /* RFC 2865 */ | |
610 /* | |
611 - The Destination-Realm AVP is created from the information found | |
612 in the RADIUS User-Name attribute. | |
613 -> done in rgw_msg_create_base | |
614 */ | |
615 case RADIUS_ATTR_USER_NAME: | |
616 CONV2DIAM_STR( User_Name ); | |
617 break; | |
618 | |
619 /* | |
620 - If the RADIUS User-Password attribute is present, the password | |
621 must be unencrypted by using the link's RADIUS shared secret. | |
622 The unencrypted value must be forwarded in a User-Password AVP | |
623 using Diameter security. | |
624 */ | |
625 case RADIUS_ATTR_USER_PASSWORD: | |
626 if ((attr->length - 2) % 16) { | |
627 TRACE_DEBUG(INFO, "Invalid length of User-Password attribute: %hhd", attr->length); | |
628 return EINVAL; | |
629 } | |
630 { | |
631 /* Decipher following this logic (refers to rfc2865#section-5.2 ) | |
632 b1 = MD5(S + RA) p1 = c(1) xor b1 | |
633 b2 = MD5(S + c(1)) p2 = c(2) xor b2 | |
634 ... | |
635 */ | |
636 | |
637 uint8_t *ciph = (uint8_t *)(attr+1); /* c(i) */ | |
638 size_t ciph_len = attr->length - 2; | |
639 uint8_t deciph[128]; /* pi */ | |
640 size_t deciph_len = 0; | |
641 uint8_t * secret; /* S */ | |
642 size_t secret_len; | |
643 uint8_t hash[16]; /* b(i) */ | |
644 const uint8_t *addr[2]; | |
645 size_t len[2]; | |
646 | |
647 /* Retrieve the shared secret */ | |
648 CHECK_FCT(rgw_clients_getkey(cli, &secret, &secret_len)); | |
649 | |
650 /* Initial b1 = MD5(S + RA) */ | |
651 addr[0] = secret; | |
652 len[0] = secret_len; | |
653 addr[1] = rad_req->hdr->authenticator; | |
654 len[1] = 16; | |
655 md5_vector(2, addr, len, hash); | |
656 | |
657 /* loop */ | |
658 while (deciph_len < ciph_len) { | |
659 int i; | |
660 /* pi = c(i) xor bi */ | |
661 for (i = 0; i < 16; i++) | |
662 deciph[deciph_len + i] = ciph[deciph_len + i] ^ hash[i]; | |
663 /* do we have to remove the padding '\0's ? */ | |
664 | |
665 /* b(i+1) = MD5(S + c(i) */ | |
666 addr[1] = ciph + deciph_len; | |
667 md5_vector(2, addr, len, hash); | |
668 | |
669 deciph_len += 16; | |
670 } | |
671 | |
672 /* Now save this value in the AVP */ | |
673 CHECK_FCT( fd_msg_avp_new ( cs->dict.User_Password, 0, &avp ) ); | |
674 value.os.data = &deciph[0]; | |
675 value.os.len = deciph_len; | |
676 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
677 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
678 } | |
679 break; | |
680 | |
681 | |
682 /* | |
683 - If the RADIUS CHAP-Password attribute is present, the Ident and | |
684 Data portion of the attribute are used to create the CHAP-Auth | |
685 grouped AVP. | |
686 */ | |
687 case RADIUS_ATTR_CHAP_PASSWORD: | |
688 CHECK_PARAMS( attr->length == 19 /* RFC 2865 */); | |
689 { | |
690 uint8_t * c = (uint8_t *)(attr + 1); | |
691 struct avp * chap_auth; | |
692 CHECK_FCT( fd_msg_avp_new ( cs->dict.CHAP_Auth, 0, &chap_auth ) ); | |
693 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, chap_auth) ); | |
694 | |
695 CHECK_FCT( fd_msg_avp_new ( cs->dict.CHAP_Algorithm, 0, &avp ) ); | |
696 value.u32 = 5; /* The only value defined currently... */ | |
697 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
698 CHECK_FCT( fd_msg_avp_add ( chap_auth, MSG_BRW_LAST_CHILD, avp) ); | |
699 | |
700 CHECK_FCT( fd_msg_avp_new ( cs->dict.CHAP_Ident, 0, &avp ) ); | |
701 value.os.data = c; | |
702 value.os.len = 1; | |
703 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
704 CHECK_FCT( fd_msg_avp_add ( chap_auth, MSG_BRW_LAST_CHILD, avp) ); | |
705 | |
706 c++; | |
707 | |
708 CHECK_FCT( fd_msg_avp_new ( cs->dict.CHAP_Response, 0, &avp ) ); | |
709 value.os.data = c; | |
710 value.os.len = attr->length - 3; | |
711 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
712 CHECK_FCT( fd_msg_avp_add ( chap_auth, MSG_BRW_LAST_CHILD, avp) ); | |
713 } | |
714 break; | |
715 | |
716 case RADIUS_ATTR_NAS_IP_ADDRESS: | |
717 CONV2DIAM_STR( NAS_IP_Address ); | |
718 break; | |
719 | |
720 case RADIUS_ATTR_NAS_PORT: | |
721 CONV2DIAM_32B( NAS_Port ); | |
722 break; | |
723 | |
724 case RADIUS_ATTR_SERVICE_TYPE: | |
725 CONV2DIAM_32B( Service_Type ); | |
726 break; | |
727 | |
728 case RADIUS_ATTR_FRAMED_PROTOCOL: | |
729 CONV2DIAM_32B( Framed_Protocol ); | |
730 break; | |
731 | |
732 case RADIUS_ATTR_FRAMED_IP_ADDRESS: | |
733 CONV2DIAM_STR( Framed_IP_Address ); | |
734 break; | |
735 | |
736 case RADIUS_ATTR_FRAMED_IP_NETMASK: | |
737 CONV2DIAM_STR( Framed_IP_Netmask ); | |
738 break; | |
739 | |
740 /* Framed-Routing never present in an Access-Request */ | |
741 /* Filter-Id never present in an Access-Request */ | |
742 | |
743 case RADIUS_ATTR_FRAMED_MTU: | |
744 CONV2DIAM_32B( Framed_MTU ); | |
745 break; | |
746 | |
747 case RADIUS_ATTR_FRAMED_COMPRESSION: | |
748 CONV2DIAM_32B( Framed_Compression ); | |
749 break; | |
750 | |
751 case RADIUS_ATTR_LOGIN_IP_HOST: | |
752 CONV2DIAM_STR( Login_IP_Host ); | |
753 break; | |
754 | |
755 /* Login-Service never present in an Access-Request */ | |
756 /* Login-TCP-Port never present in an Access-Request */ | |
757 /* Reply-Message never present in an Access-Request */ | |
758 | |
759 case RADIUS_ATTR_CALLBACK_NUMBER: | |
760 CONV2DIAM_STR( Callback_Number ); | |
761 break; | |
762 | |
763 /* Callback-Id never present in an Access-Request */ | |
764 /* Framed-Route never present in an Access-Request */ | |
765 /* Framed-IPX-Network never present in an Access-Request */ | |
766 | |
767 case RADIUS_ATTR_STATE: | |
768 CONV2DIAM_STR( State ); | |
769 break; | |
770 | |
771 /* Class never present in an Access-Request */ | |
772 | |
773 case RADIUS_ATTR_VENDOR_SPECIFIC: | |
774 /* RFC 4005, Section 9.6 : | |
775 Systems that don't have vendor format knowledge MAY discard such | |
776 attributes without knowing a suitable translation. | |
777 | |
778 [conversion rule in 9.6.2] | |
779 */ | |
780 if (attr->length >= 6) { | |
781 uint32_t vendor_id; | |
782 uint8_t * c = (uint8_t *)(attr + 1); | |
783 | |
784 vendor_id = c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]; | |
785 c += 4; | |
786 | |
787 switch (vendor_id) { | |
788 | |
789 /* For the vendors we KNOW they follow the VSA recommended format, we convert following the rules of RFC4005 (9.6.2) */ | |
790 case RADIUS_VENDOR_ID_MICROSOFT : /* RFC 2548 */ | |
791 /* other vendors ? */ | |
792 { | |
793 size_t left; | |
794 struct radius_attr_vendor *vtlv; | |
795 | |
796 left = attr->length - 6; | |
797 vtlv = (struct radius_attr_vendor *)c; | |
798 | |
799 while ((left >= 2) && (vtlv->vendor_length <= left)) { | |
800 /* Search our dictionary for corresponding Vendor's AVP */ | |
801 struct dict_avp_request req; | |
802 struct dict_object * avp_model = NULL; | |
803 memset(&req, 0, sizeof(struct dict_avp_request)); | |
804 req.avp_vendor = vendor_id; | |
805 req.avp_code = vtlv->vendor_type; | |
806 | |
807 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_CODE_AND_VENDOR, &req, &avp_model, 0) ); | |
808 if (!avp_model) { | |
809 TRACE_DEBUG(FULL, "Unknown attribute (vendor 0x%x, code 0x%x) ignored.", req.avp_vendor, req.avp_code); | |
810 } else { | |
811 CHECK_FCT( fd_msg_avp_new ( avp_model, 0, &avp ) ); | |
812 value.os.len = vtlv->vendor_length - 2; | |
813 value.os.data = (unsigned char *)(vtlv + 1); | |
814 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); | |
815 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); | |
816 } | |
817 c += vtlv->vendor_length; | |
818 left -= vtlv->vendor_length; | |
819 vtlv = (struct radius_attr_vendor *)c; | |
820 } | |
821 } | |
822 break; | |
823 | |
824 /* Other vendors we KNOw how to convert the attributes would be added here... */ | |
825 /* case RADIUS_VENDOR_ID_CISCO : | |
826 break; */ | |
827 /* case RADIUS_VENDOR_ID_IETF : (extended RADIUS attributes) | |
828 break; */ | |
829 | |
830 /* When we don't know, just discard the attribute... VSA are optional with regards to RADIUS anyway */ | |
831 default: | |
832 /* do nothing */ | |
833 TRACE_DEBUG(FULL, "VSA attribute from vendor %d discarded", vendor_id); | |
834 | |
835 } | |
836 } | |
837 break; | |
838 | |
839 /* Session-Timeout never present in an Access-Request */ | |
840 /* Idle-Timeout never present in an Access-Request */ | |
841 /* Termination-Action never present in an Access-Request */ | |
842 | |
843 case RADIUS_ATTR_CALLED_STATION_ID: | |
844 CONV2DIAM_STR( Called_Station_Id ); | |
845 break; | |
846 | |
847 case RADIUS_ATTR_CALLING_STATION_ID: | |
848 CONV2DIAM_STR( Calling_Station_Id ); | |
849 break; | |
850 | |
851 case RADIUS_ATTR_NAS_IDENTIFIER: | |
852 CONV2DIAM_STR( NAS_Identifier ); | |
853 break; | |
854 | |
855 /* Proxy-State is handled by echo_drop.rgwx plugin, we ignore it here */ | |
856 | |
857 case RADIUS_ATTR_LOGIN_LAT_SERVICE: | |
858 CONV2DIAM_STR( Login_LAT_Service ); | |
859 break; | |
860 | |
861 case RADIUS_ATTR_LOGIN_LAT_NODE: | |
862 CONV2DIAM_STR( Login_LAT_Node ); | |
863 break; | |
864 | |
865 case RADIUS_ATTR_LOGIN_LAT_GROUP: | |
866 CONV2DIAM_STR( Login_LAT_Group ); | |
867 break; | |
868 | |
869 /* Framed-AppleTalk-Link never present in an Access-Request */ | |
870 /* Framed-AppleTalk-Network never present in an Access-Request */ | |
871 /* Framed-AppleTalk-Zone never present in an Access-Request */ | |
872 | |
873 case RADIUS_ATTR_CHAP_CHALLENGE: | |
874 CONV2DIAM_STR( CHAP_Challenge ); | |
875 break; | |
876 | |
877 case RADIUS_ATTR_NAS_PORT_TYPE: | |
878 CONV2DIAM_32B( NAS_Port_Type ); | |
879 break; | |
880 | |
881 case RADIUS_ATTR_PORT_LIMIT: | |
882 CONV2DIAM_32B( Port_Limit ); | |
883 break; | |
884 | |
885 case RADIUS_ATTR_LOGIN_LAT_PORT: | |
886 CONV2DIAM_STR( Login_LAT_Port ); | |
887 break; | |
888 | |
889 | |
890 /* RFC 3162 */ | |
891 case RADIUS_ATTR_NAS_IPV6_ADDRESS: | |
892 CONV2DIAM_STR( NAS_IPv6_Address ); | |
893 break; | |
894 | |
895 case RADIUS_ATTR_FRAMED_INTERFACE_ID: | |
896 CONV2DIAM_64B( Framed_Interface_Id ); | |
897 break; | |
898 | |
899 case RADIUS_ATTR_FRAMED_IPV6_PREFIX: | |
900 CONV2DIAM_STR( Framed_IPv6_Prefix ); | |
901 break; | |
902 | |
903 case RADIUS_ATTR_LOGIN_IPV6_HOST: | |
904 CONV2DIAM_STR( Login_IPv6_Host ); | |
905 break; | |
906 | |
907 /* Framed-IPv6-Route never present in an Access-Request */ | |
908 /* Framed-IPv6-Pool never present in an Access-Request */ | |
909 | |
910 | |
911 /* RFC 2868 */ | |
912 /* Prepare the top-level Tunneling AVP for each tag values, as needed, and add to the Diameter message. | |
913 This macro is called when an AVP is added inside the group, so we will not have empty grouped AVPs */ | |
914 #define AVP_TUN_PREPARE() { \ | |
915 if (avp_tun == NULL) { \ | |
916 CHECK_MALLOC( avp_tun = calloc(sizeof(struct avp *), 32 ) ); \ | |
917 } \ | |
918 tag = *(uint8_t *)(attr + 1); \ | |
919 if (tag > 0x1F) tag = 0; \ | |
920 if (avp_tun[tag] == NULL) { \ | |
271
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
921 CHECK_FCT( fd_msg_avp_new ( cs->dict.Tunneling, 0, &avp_tun[tag] ) ); \ |
256 | 922 CHECK_FCT( fd_msg_avp_add (*diam_fw, MSG_BRW_LAST_CHILD, avp_tun[tag]));\ |
923 } \ | |
924 } | |
925 | |
926 /* Convert an attribute to an OctetString AVP and add inside the Tunneling AVP corresponding to the tag */ | |
271
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
927 #define CONV2DIAM_TUN_STR( _dictobj_ ) { \ |
256 | 928 uint8_t tag; \ |
929 CHECK_PARAMS( attr->length >= 3); \ | |
930 AVP_TUN_PREPARE(); \ | |
931 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ | |
932 value.os.len = attr->length - (tag ? 3 : 2); \ | |
933 value.os.data = ((unsigned char *)(attr + 1)) + (tag ? 1 : 0); \ | |
934 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ | |
935 CHECK_FCT( fd_msg_avp_add ( avp_tun[tag], MSG_BRW_LAST_CHILD, avp) ); \ | |
936 } | |
937 | |
938 /* Convert an attribute to a scalar AVP and add inside the Tunneling AVP corresponding to the tag */ | |
271
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
939 #define CONV2DIAM_TUN_24B( _dictobj_ ) { \ |
256 | 940 uint8_t tag; \ |
941 CHECK_PARAMS( attr->length == 6); \ | |
942 AVP_TUN_PREPARE(); \ | |
943 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \ | |
944 { \ | |
945 uint8_t * v = (uint8_t *)(attr + 1); \ | |
946 value.u32 = (v[1] << 16) | (v[2] <<8) | v[3] ; \ | |
947 } \ | |
948 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \ | |
949 CHECK_FCT( fd_msg_avp_add ( avp_tun[tag], MSG_BRW_LAST_CHILD, avp) ); \ | |
950 } | |
951 | |
952 /* | |
953 - If the RADIUS message contains Tunnel information [RADTunnels], | |
954 the attributes or tagged groups should each be converted to a | |
955 Diameter Tunneling Grouped AVP set. If the tunnel information | |
956 contains a Tunnel-Password attribute, the RADIUS encryption | |
957 must be resolved, and the password forwarded, by using Diameter | |
958 security methods. | |
959 -> If the RADIUS message does not use properly the Tag info, result is unpredictable here.. | |
960 */ | |
961 case RADIUS_ATTR_TUNNEL_TYPE: | |
962 CONV2DIAM_TUN_24B( Tunnel_Type ); | |
963 break; | |
964 | |
965 case RADIUS_ATTR_TUNNEL_MEDIUM_TYPE: | |
966 CONV2DIAM_TUN_24B( Tunnel_Medium_Type ); | |
967 break; | |
968 | |
969 case RADIUS_ATTR_TUNNEL_CLIENT_ENDPOINT: | |
970 CONV2DIAM_TUN_STR( Tunnel_Client_Endpoint ); | |
971 break; | |
972 | |
973 case RADIUS_ATTR_TUNNEL_SERVER_ENDPOINT: | |
974 CONV2DIAM_TUN_STR( Tunnel_Server_Endpoint ); | |
975 break; | |
976 | |
977 /* Tunnel-Password never present in an Access-Request */ | |
978 | |
979 case RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID: | |
980 CONV2DIAM_TUN_STR( Tunnel_Private_Group_Id ); | |
981 break; | |
982 | |
983 /* Tunnel-Assignment-ID never present in an Access-Request */ | |
984 | |
985 case RADIUS_ATTR_TUNNEL_PREFERENCE: | |
986 CONV2DIAM_TUN_24B( Tunnel_Preference ); | |
987 break; | |
988 | |
989 case RADIUS_ATTR_TUNNEL_CLIENT_AUTH_ID: | |
990 CONV2DIAM_TUN_STR( Tunnel_Client_Auth_Id ); | |
991 break; | |
992 | |
993 case RADIUS_ATTR_TUNNEL_SERVER_AUTH_ID: | |
994 CONV2DIAM_TUN_STR( Tunnel_Server_Auth_Id ); | |
995 break; | |
996 | |
997 | |
998 /* RFC 2869 */ | |
999 case RADIUS_ATTR_ARAP_PASSWORD: | |
1000 CONV2DIAM_STR( ARAP_Password ); | |
1001 break; | |
1002 | |
1003 /* ARAP-Features never present in an Access-Request */ | |
1004 /* ARAP-Zone-Access never present in an Access-Request */ | |
1005 | |
1006 case RADIUS_ATTR_ARAP_SECURITY: | |
1007 CONV2DIAM_32B( ARAP_Security ); | |
1008 break; | |
1009 | |
1010 case RADIUS_ATTR_ARAP_SECURITY_DATA: | |
1011 CONV2DIAM_STR( ARAP_Security_Data ); | |
1012 break; | |
1013 | |
1014 /* Password-Retry never present in an Access-Request */ | |
1015 /* Prompt never present in an Access-Request */ | |
1016 | |
1017 case RADIUS_ATTR_CONNECT_INFO: | |
1018 CONV2DIAM_STR( Connect_Info ); | |
1019 break; | |
1020 | |
1021 /* Configuration-Token never present in an Access-Request */ | |
1022 /* ARAP-Challenge-Response never present in an Access-Request */ | |
1023 /* Acct-Interim-Interval never present in an Access-Request */ | |
1024 | |
1025 case RADIUS_ATTR_NAS_PORT_ID: | |
1026 CONV2DIAM_STR( NAS_Port_Id ); | |
1027 break; | |
1028 | |
1029 /* Framed-Pool never present in an Access-Request */ | |
1030 | |
1031 | |
1032 /* RFC 2869 / 3579 */ | |
1033 case RADIUS_ATTR_ORIGINATING_LINE_INFO: | |
1034 CONV2DIAM_STR( Originating_Line_Info ); | |
1035 break; | |
1036 | |
1037 case RADIUS_ATTR_MESSAGE_AUTHENTICATOR: | |
1038 case RADIUS_ATTR_EAP_MESSAGE: | |
1039 /* It was already handled, just remove the attribute */ | |
1040 break; | |
1041 | |
1042 /* Default */ | |
1043 default: /* unknown attribute */ | |
1044 /* We just keep the attribute in the RADIUS message */ | |
1045 rad_req->attr_pos[nattr_used++] = rad_req->attr_pos[idx]; | |
1046 } | |
1047 } | |
1048 | |
1049 /* Destroy tunnel pointers (if we used it) */ | |
1050 free(avp_tun); | |
1051 | |
1052 /* Update the radius message to remove all handled attributes */ | |
1053 rad_req->attr_used = nattr_used; | |
1054 | |
1055 /* Store the request identifier in the session (if provided) */ | |
385
69057a6d68ec
Fix a possible race condition
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
384
diff
changeset
|
1056 if (*session) { |
256 | 1057 unsigned char * req_auth; |
1058 CHECK_MALLOC(req_auth = malloc(16)); | |
1059 memcpy(req_auth, &rad_req->hdr->authenticator[0], 16); | |
1060 | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
1061 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &req_auth ) ); |
256 | 1062 } |
1063 | |
1064 return 0; | |
1065 } | |
1066 | |
356
e203fc0c95e3
Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
296
diff
changeset
|
1067 static int auth_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli, int * stateful ) |
256 | 1068 { |
273
bce8e5b7bf78
Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
271
diff
changeset
|
1069 struct msg_hdr * hdr; |
256 | 1070 struct avp *avp, *next, *avp_x, *avp_y, *asid, *aoh; |
1071 struct avp_hdr *ahdr, *sid, *oh; | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1072 uint8_t buf[254]; /* to store some attributes values (with final '\0') */ |
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1073 size_t sz; |
256 | 1074 int ta_set = 0; |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1075 int no_str = 0; /* indicate if an STR is required for this server */ |
256 | 1076 uint8_t tuntag = 0; |
1077 unsigned char * req_auth = NULL; | |
1078 | |
1079 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli); | |
1080 CHECK_PARAMS(cs && session && diam_ans && *diam_ans && rad_fw && *rad_fw); | |
1081 | |
1082 /* Retrieve the request identified which was stored in the session */ | |
1083 if (session) { | |
1084 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, session, &req_auth ) ); | |
1085 } | |
1086 | |
1087 /* | |
1088 - If the Diameter Command-Code is set to AA-Answer and the | |
1089 Result-Code AVP is set to DIAMETER_MULTI_ROUND_AUTH, the | |
1090 gateway must send a RADIUS Access-Challenge. This must have | |
1091 the Origin-Host, Origin-Realm, and Diameter Session-Id AVPs | |
1092 encapsulated in the RADIUS State attribute, with the prefix | |
1093 "Diameter/", concatenated in the above order separated with "/" | |
1094 characters, in UTF-8 [UTF-8]. This is necessary to ensure that | |
1095 the Translation Agent receiving the subsequent RADIUS Access- | |
1096 Request will have access to the Session Identifier and be able | |
1097 to set the Destination-Host to the correct value. | |
1098 -> done here bellow | |
1099 | |
1100 - If the Command-Code is set to AA-Answer, the Diameter Session- | |
1101 Id AVP is saved in a new RADIUS Class attribute whose format | |
1102 consists of the string "Diameter/" followed by the Diameter | |
1103 Session Identifier. This will ensure that the subsequent | |
1104 Accounting messages, which could be received by any Translation | |
1105 Agent, would have access to the original Diameter Session | |
1106 Identifier. | |
1107 -> done here but only for Access-Accept messages (Result-Code = success) | |
1108 */ | |
1109 | |
1110 /* MACROS to help in the process: convert AVP data to RADIUS attributes. */ | |
1111 /* Control large attributes: _trunc_ = 0 => error; _trunc_ = 1 => truncate; _trunc = 2 => create several attributes */ | |
1112 #define CONV2RAD_STR( _attr_, _data_, _len_, _trunc_) { \ | |
1113 size_t __l = (size_t)(_len_); \ | |
1114 size_t __off = 0; \ | |
1115 TRACE_DEBUG(FULL, "Converting AVP to "#_attr_); \ | |
1116 if ((_trunc_) == 0) { \ | |
1117 CHECK_PARAMS( __l <= 253 ); \ | |
1118 } \ | |
1119 if ((__l > 253) && (_trunc_ == 1)) { \ | |
1120 TRACE_DEBUG(INFO, "[auth.rgwx] AVP truncated in "#_attr_); \ | |
1121 __l = 253; \ | |
1122 } \ | |
1123 do { \ | |
1124 size_t __w = (__l > 253) ? 253 : __l; \ | |
1125 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), (_data_) + __off, __w)); \ | |
1126 __off += __w; \ | |
1127 __l -= __w; \ | |
1128 } while (__l); \ | |
1129 } | |
1130 | |
1131 #define CONV2RAD_32B( _attr_, _data_) { \ | |
1132 uint32_t __v = htonl((uint32_t)(_data_)); \ | |
1133 TRACE_DEBUG(FULL, "Converting AVP to "#_attr_); \ | |
1134 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), (uint8_t *)&__v, sizeof(__v))); \ | |
1135 } | |
1136 | |
1137 #define CONV2RAD_64B( _attr_, _data_) { \ | |
1138 uint64_t __v = htonll((uint64_t)(_data_)); \ | |
1139 TRACE_DEBUG(FULL, "Converting AVP to "#_attr_); \ | |
1140 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), (uint8_t *)&__v, sizeof(__v))); \ | |
1141 } | |
1142 | |
1143 /* Search the different AVPs we handle here */ | |
1144 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Session_Id, &asid) ); | |
1145 CHECK_FCT( fd_msg_avp_hdr ( asid, &sid ) ); | |
1146 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Origin_Host, &aoh) ); | |
1147 CHECK_FCT( fd_msg_avp_hdr ( aoh, &oh ) ); | |
1148 | |
1149 /* Check the Diameter error code */ | |
1150 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Result_Code, &avp) ); | |
1151 ASSERT( avp ); /* otherwise the message should have been discarded a lot earlier because of ABNF */ | |
1152 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1153 switch (ahdr->avp_value->u32) { | |
1154 case ER_DIAMETER_MULTI_ROUND_AUTH: | |
1155 (*rad_fw)->hdr->code = RADIUS_CODE_ACCESS_CHALLENGE; | |
1156 break; | |
1157 case ER_DIAMETER_SUCCESS: | |
1158 case ER_DIAMETER_LIMITED_SUCCESS: | |
1159 (*rad_fw)->hdr->code = RADIUS_CODE_ACCESS_ACCEPT; | |
1160 break; | |
1161 | |
1162 default: | |
1163 (*rad_fw)->hdr->code = RADIUS_CODE_ACCESS_REJECT; | |
1164 fd_log_debug("[auth.rgwx] Received Diameter answer with error code '%d' from server '%.*s', session %.*s, translating into Access-Reject\n", | |
1165 ahdr->avp_value->u32, | |
1166 oh->avp_value->os.len, oh->avp_value->os.data, | |
1167 sid->avp_value->os.len, sid->avp_value->os.data); | |
1168 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Error_Message, &avp) ); | |
1169 if (avp) { | |
1170 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1171 fd_log_debug("[auth.rgwx] Error-Message content: '%.*s'\n", | |
1172 ahdr->avp_value->os.len, ahdr->avp_value->os.data); | |
1173 } | |
1174 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Error_Reporting_Host, &avp) ); | |
1175 if (avp) { | |
1176 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1177 fd_log_debug("[auth.rgwx] Error-Reporting-Host: '%.*s'\n", | |
1178 ahdr->avp_value->os.len, ahdr->avp_value->os.data); | |
1179 } | |
1180 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Failed_AVP, &avp) ); | |
1181 if (avp) { | |
1182 fd_log_debug("[auth.rgwx] Failed-AVP was included in the message.\n"); | |
1183 /* Dump its content ? */ | |
1184 } | |
1185 return 0; | |
1186 } | |
1187 /* Remove this Result-Code avp */ | |
1188 CHECK_FCT( fd_msg_free( avp ) ); | |
1189 | |
1190 /* Creation of the State or Class attribute with session information */ | |
1191 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Origin_Realm, &avp) ); | |
1192 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1193 | |
1194 /* Now, save the session-id and eventually server info in a STATE or CLASS attribute */ | |
1195 if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_CHALLENGE) { | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1196 if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), "Diameter/%.*s/%.*s/%.*s", |
405
ddbcd21af4e0
Fix a few warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
1197 (int)oh->avp_value->os.len, (char *)oh->avp_value->os.data, |
ddbcd21af4e0
Fix a few warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
1198 (int)ahdr->avp_value->os.len, (char *)ahdr->avp_value->os.data, |
ddbcd21af4e0
Fix a few warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
1199 (int)sid->avp_value->os.len, (char *)sid->avp_value->os.data))) { |
256 | 1200 TRACE_DEBUG(INFO, "Data truncated in State attribute: %s", buf); |
1201 } | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1202 CONV2RAD_STR(RADIUS_ATTR_STATE, buf, sz, 0); |
256 | 1203 } |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1204 |
256 | 1205 if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) { |
273
bce8e5b7bf78
Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
271
diff
changeset
|
1206 /* Add the Session-Id */ |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1207 if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), "Diameter/%.*s", |
405
ddbcd21af4e0
Fix a few warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
1208 (int)sid->avp_value->os.len, sid->avp_value->os.data))) { |
256 | 1209 TRACE_DEBUG(INFO, "Data truncated in Class attribute: %s", buf); |
1210 } | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1211 CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, sz, 0); |
256 | 1212 } |
1213 | |
1214 /* Unlink the Origin-Realm now; the others are unlinked at the end of this function */ | |
1215 CHECK_FCT( fd_msg_free( avp ) ); | |
1216 | |
1217 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Session_Timeout, &avp) ); | |
1218 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Authorization_Lifetime, &avp_x) ); | |
1219 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Re_Auth_Request_Type, &avp_y) ); | |
1220 /* | |
1221 When translating a Diameter AA-Answer (with successful result code) | |
1222 to RADIUS Access-Accept that contains a Session-Timeout or | |
1223 Authorization-Lifetime AVP, take the following steps: | |
1224 | |
1225 - If the Diameter message contains a Session-Timeout AVP but no | |
1226 Authorization-Lifetime AVP, translate it to a Session-Timeout | |
1227 attribute (not a Termination-Action). | |
1228 */ | |
1229 if ((avp != NULL) && (avp_x == NULL)) { | |
1230 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1231 CONV2RAD_32B( RADIUS_ATTR_SESSION_TIMEOUT, ahdr->avp_value->u32 ); | |
1232 } | |
1233 | |
1234 /* | |
1235 - If the Diameter message contains an Authorization-Lifetime AVP | |
1236 but no Session-Timeout AVP, translate it to a Session-Timeout | |
1237 attribute and a Termination-Action set to AA-REQUEST. (Remove | |
1238 Authorization-Lifetime and Re-Auth-Request-Type.) | |
1239 */ | |
1240 if ((avp == NULL) && (avp_x != NULL)) { | |
1241 CHECK_FCT( fd_msg_avp_hdr ( avp_x, &ahdr ) ); | |
1242 CONV2RAD_32B( RADIUS_ATTR_SESSION_TIMEOUT, ahdr->avp_value->u32 ); | |
1243 CONV2RAD_32B( RADIUS_ATTR_TERMINATION_ACTION, RADIUS_TERMINATION_ACTION_RADIUS_REQUEST ); | |
1244 ta_set = 1; | |
1245 } | |
1246 | |
1247 /* | |
1248 - If the Diameter message has both, the Session-Timeout must be | |
1249 greater than or equal to the Authorization-Lifetime (required | |
1250 by [BASE]). Translate it to a Session-Timeout value (with | |
1251 value from Authorization-Lifetime AVP, the smaller one) and | |
1252 with the Termination-Action set to AA-REQUEST. (Remove the | |
1253 Authorization-Lifetime and Re-Auth-Request-Type.) | |
1254 */ | |
1255 if ((avp != NULL) && (avp_x != NULL)) { | |
1256 CHECK_FCT( fd_msg_avp_hdr ( avp_x, &ahdr ) ); | |
1257 CONV2RAD_32B( RADIUS_ATTR_SESSION_TIMEOUT, ahdr->avp_value->u32 ); | |
1258 CONV2RAD_32B( RADIUS_ATTR_TERMINATION_ACTION, RADIUS_TERMINATION_ACTION_RADIUS_REQUEST ); | |
1259 ta_set = 1; | |
1260 } | |
1261 | |
1262 /* -> Not too sure about Auth-Grace-Period... we'll just discard it for now */ | |
1263 | |
1264 if (avp) { | |
1265 CHECK_FCT( fd_msg_free( avp ) ); | |
1266 } | |
1267 if (avp_x) { | |
1268 CHECK_FCT( fd_msg_free( avp_x ) ); | |
1269 } | |
1270 if (avp_y) { | |
1271 CHECK_FCT( fd_msg_free( avp_y ) ); | |
1272 } | |
1273 | |
1274 | |
1275 /* | |
1276 - If a Proxy-State attribute was present in the RADIUS request, | |
1277 the same attribute is added in the response. This information | |
1278 may be found in the Proxy-Info AVP group, or in a local state | |
1279 table. | |
1280 -> handled by sub_echo_drop | |
1281 | |
1282 - If state information regarding the RADIUS request was saved in | |
1283 a Proxy-Info AVP or local state table, the RADIUS Identifier | |
1284 and UDP IP Address and port number are extracted and used in | |
1285 issuing the RADIUS reply. | |
1286 -> was saved with the full request | |
1287 */ | |
1288 | |
1289 | |
1290 /* Now loop in the list of AVPs and convert those that we know how */ | |
1291 CHECK_FCT( fd_msg_browse(*diam_ans, MSG_BRW_FIRST_CHILD, &next, NULL) ); | |
1292 | |
1293 while (next) { | |
1294 int handled = 1; | |
1295 avp = next; | |
1296 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &next, NULL) ); | |
1297 | |
1298 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) ); | |
1299 | |
1300 if (!(ahdr->avp_flags & AVP_FLAG_VENDOR)) { | |
1301 switch (ahdr->avp_code) { | |
1302 | |
1303 /* RFC 4005 (AVP in the order of the AA-Request/Answer AVP Table) */ | |
1304 case DIAM_ATTR_ACCT_INTERIM_INTERVAL: | |
1305 CONV2RAD_32B(RADIUS_ATTR_ACCT_INTERIM_INTERVAL, ahdr->avp_value->u32); | |
1306 break; | |
1307 | |
1308 case DIAM_ATTR_ARAP_CHALLENGE_RESPONSE: | |
1309 CONV2RAD_STR(RADIUS_ATTR_ARAP_CHALLENGE_RESPONSE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1310 break; | |
1311 | |
1312 case DIAM_ATTR_ARAP_FEATURES: | |
1313 CONV2RAD_STR(RADIUS_ATTR_ARAP_FEATURES, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1314 break; | |
1315 | |
1316 /* ARAP-Password is not present in answers */ | |
1317 | |
1318 case DIAM_ATTR_ARAP_SECURITY: | |
1319 CONV2RAD_32B(RADIUS_ATTR_ARAP_SECURITY, ahdr->avp_value->u32); | |
1320 break; | |
1321 | |
1322 case DIAM_ATTR_ARAP_SECURITY_DATA: | |
1323 CONV2RAD_STR(RADIUS_ATTR_ARAP_SECURITY_DATA, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1324 break; | |
1325 | |
1326 case DIAM_ATTR_ARAP_ZONE_ACCESS: | |
1327 CONV2RAD_32B(RADIUS_ATTR_ARAP_ZONE_ACCESS, ahdr->avp_value->u32); | |
1328 break; | |
1329 | |
1330 case DIAM_ATTR_AUTH_APPLICATION_ID: | |
1331 /* We just remove this AVP */ | |
1332 break; | |
1333 | |
1334 case DIAM_ATTR_AUTH_GRACE_PERIOD: | |
1335 /* We just remove this AVP (?) */ | |
1336 break; | |
1337 | |
1338 case DIAM_ATTR_AUTH_REQUEST_TYPE: | |
1339 /* We only check the value */ | |
1340 if (ahdr->avp_value->u32 != 3) { | |
1341 fd_log_debug("[auth.rgwx] Received Diameter answer with Auth-Request-Type set to %d (%s) from server %.*s, session %.*s.\n" | |
1342 " This may cause interoperability problems with RADIUS.\n", | |
1343 ahdr->avp_value->u32, | |
1344 (ahdr->avp_value->u32 == 1) ? "AUTHENTICATE_ONLY" : | |
1345 ((ahdr->avp_value->u32 == 2) ? "AUTHORIZE_ONLY" : "???"), | |
1346 oh->avp_value->os.len, oh->avp_value->os.data, | |
1347 sid->avp_value->os.len, sid->avp_value->os.len); | |
1348 } | |
1349 break; | |
1350 | |
1351 case DIAM_ATTR_AUTH_SESSION_STATE: | |
1352 if ((!ta_set) && (ahdr->avp_value->u32 == ACV_ASS_STATE_MAINTAINED)) { | |
1353 CONV2RAD_32B( RADIUS_ATTR_TERMINATION_ACTION, RADIUS_TERMINATION_ACTION_RADIUS_REQUEST ); | |
1354 } | |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1355 |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1356 if (ahdr->avp_value->u32 == ACV_ASS_NO_STATE_MAINTAINED) { |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1357 no_str = 1; |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1358 } |
256 | 1359 break; |
1360 | |
1361 /* Authorization-Lifetime already handled */ | |
1362 | |
1363 case DIAM_ATTR_CALLBACK_ID: | |
1364 CONV2RAD_STR(RADIUS_ATTR_CALLBACK_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1365 break; | |
1366 | |
1367 case DIAM_ATTR_CALLBACK_NUMBER: | |
1368 CONV2RAD_STR(RADIUS_ATTR_CALLBACK_NUMBER, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1369 break; | |
1370 | |
1371 /* Called-Station-Id is not present in answers */ | |
1372 /* Calling-Station-Id is not present in answers */ | |
1373 /* CHAP-Auth is not present in answers */ | |
1374 /* CHAP-Challenge is not present in answers */ | |
1375 | |
1376 case DIAM_ATTR_CLASS: | |
1377 CONV2RAD_STR(RADIUS_ATTR_CLASS, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1378 break; | |
1379 | |
1380 case DIAM_ATTR_CONFIGURATION_TOKEN: | |
1381 /* We might as well remove it since it's not supposed to be sent to the NAS... */ | |
1382 CONV2RAD_STR(RADIUS_ATTR_CONFIGURATION_TOKEN, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1383 break; | |
1384 | |
1385 /* Connect-Info is not present in answers */ | |
1386 | |
1387 case DIAM_ATTR_FILTER_ID: | |
1388 CONV2RAD_STR(RADIUS_ATTR_FILTER_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1389 break; | |
1390 | |
1391 case DIAM_ATTR_FRAMED_APPLETALK_LINK: | |
1392 CONV2RAD_32B(RADIUS_ATTR_FRAMED_APPLETALK_LINK, ahdr->avp_value->u32); | |
1393 break; | |
1394 | |
1395 case DIAM_ATTR_FRAMED_APPLETALK_NETWORK: | |
1396 CONV2RAD_32B(RADIUS_ATTR_FRAMED_APPLETALK_NETWORK, ahdr->avp_value->u32); | |
1397 break; | |
1398 | |
1399 case DIAM_ATTR_FRAMED_APPLETALK_ZONE: | |
1400 CONV2RAD_STR(RADIUS_ATTR_FRAMED_APPLETALK_ZONE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1401 break; | |
1402 | |
1403 case DIAM_ATTR_FRAMED_COMPRESSION: | |
1404 CONV2RAD_32B(RADIUS_ATTR_FRAMED_COMPRESSION, ahdr->avp_value->u32); | |
1405 break; | |
1406 | |
1407 case DIAM_ATTR_FRAMED_INTERFACE_ID: | |
1408 CONV2RAD_64B(RADIUS_ATTR_FRAMED_INTERFACE_ID, ahdr->avp_value->u64); | |
1409 break; | |
1410 | |
1411 case DIAM_ATTR_FRAMED_IP_ADDRESS: | |
1412 CONV2RAD_STR(RADIUS_ATTR_FRAMED_IP_ADDRESS, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1413 break; | |
1414 | |
1415 case DIAM_ATTR_FRAMED_IP_NETMASK: | |
1416 CONV2RAD_STR(RADIUS_ATTR_FRAMED_IP_NETMASK, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1417 break; | |
1418 | |
1419 case DIAM_ATTR_FRAMED_IPV6_PREFIX: | |
1420 CONV2RAD_STR(RADIUS_ATTR_FRAMED_IPV6_PREFIX, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1421 break; | |
1422 | |
1423 case DIAM_ATTR_FRAMED_IPV6_POOL: | |
1424 CONV2RAD_STR(RADIUS_ATTR_FRAMED_IPV6_POOL, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1425 break; | |
1426 | |
1427 case DIAM_ATTR_FRAMED_IPV6_ROUTE: | |
1428 CONV2RAD_STR(RADIUS_ATTR_FRAMED_IPV6_ROUTE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1429 break; | |
1430 | |
1431 case DIAM_ATTR_FRAMED_IPX_NETWORK: | |
1432 CONV2RAD_32B(RADIUS_ATTR_FRAMED_IPX_NETWORK, ahdr->avp_value->u32); | |
1433 break; | |
1434 | |
1435 case DIAM_ATTR_FRAMED_MTU: | |
1436 CONV2RAD_32B(RADIUS_ATTR_FRAMED_MTU, ahdr->avp_value->u32); | |
1437 break; | |
1438 | |
1439 case DIAM_ATTR_FRAMED_POOL: | |
1440 CONV2RAD_STR(RADIUS_ATTR_FRAMED_POOL, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1441 break; | |
1442 | |
1443 case DIAM_ATTR_FRAMED_PROTOCOL: | |
1444 CONV2RAD_32B(RADIUS_ATTR_FRAMED_PROTOCOL, ahdr->avp_value->u32); | |
1445 break; | |
1446 | |
1447 case DIAM_ATTR_FRAMED_ROUTE: | |
1448 CONV2RAD_STR(RADIUS_ATTR_FRAMED_ROUTE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1449 break; | |
1450 | |
1451 case DIAM_ATTR_FRAMED_ROUTING: | |
1452 CONV2RAD_32B(RADIUS_ATTR_FRAMED_ROUTING, ahdr->avp_value->u32); | |
1453 break; | |
1454 | |
1455 case DIAM_ATTR_IDLE_TIMEOUT: | |
1456 CONV2RAD_32B(RADIUS_ATTR_IDLE_TIMEOUT, ahdr->avp_value->u32); | |
1457 break; | |
1458 | |
1459 case DIAM_ATTR_LOGIN_IP_HOST: | |
1460 CONV2RAD_STR(RADIUS_ATTR_LOGIN_IP_HOST, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1461 break; | |
1462 | |
1463 case DIAM_ATTR_LOGIN_IPV6_HOST: | |
1464 CONV2RAD_STR(RADIUS_ATTR_LOGIN_IPV6_HOST, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 0); | |
1465 break; | |
1466 | |
1467 case DIAM_ATTR_LOGIN_LAT_GROUP: | |
1468 CONV2RAD_STR(RADIUS_ATTR_LOGIN_LAT_GROUP, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1469 break; | |
1470 | |
1471 case DIAM_ATTR_LOGIN_LAT_NODE: | |
1472 CONV2RAD_STR(RADIUS_ATTR_LOGIN_LAT_NODE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1473 break; | |
1474 | |
1475 case DIAM_ATTR_LOGIN_LAT_PORT: | |
1476 CONV2RAD_STR(RADIUS_ATTR_LOGIN_LAT_PORT, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1477 break; | |
1478 | |
1479 case DIAM_ATTR_LOGIN_LAT_SERVICE: | |
1480 CONV2RAD_STR(RADIUS_ATTR_LOGIN_LAT_SERVICE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1481 break; | |
1482 | |
1483 case DIAM_ATTR_LOGIN_SERVICE: | |
1484 CONV2RAD_32B(RADIUS_ATTR_LOGIN_SERVICE, ahdr->avp_value->u32); | |
1485 break; | |
1486 | |
1487 case DIAM_ATTR_LOGIN_TCP_PORT: | |
1488 CONV2RAD_32B(RADIUS_ATTR_LOGIN_TCP_PORT, ahdr->avp_value->u32); | |
1489 break; | |
1490 | |
1491 /* | |
1492 - If the | |
1493 Multi-Round-Time-Out AVP is present, the value of the AVP MUST | |
1494 be inserted in the RADIUS Session-Timeout AVP. | |
1495 | |
1496 o As described in [NASREQ], if the Result-Code AVP set to | |
1497 DIAMETER_MULTI_ROUND_AUTH and the Multi-Round-Time-Out AVP is | |
1498 present, it is translated to the RADIUS Session-Timeout attribute. | |
1499 */ | |
1500 case DIAM_ATTR_MULTI_ROUND_TIMEOUT: | |
1501 CONV2RAD_32B(RADIUS_ATTR_SESSION_TIMEOUT, ahdr->avp_value->u32); | |
1502 break; | |
1503 | |
1504 case DIAM_ATTR_NAS_FILTER_RULE: | |
1505 /* This is not translatable to RADIUS */ | |
1506 fd_log_debug("[auth.rgwx] Received Diameter answer with non-translatable NAS-Filter-Rule AVP from '%.*s' (session: '%.*s'), ignoring.\n", | |
1507 oh->avp_value->os.len, oh->avp_value->os.data, | |
1508 sid->avp_value->os.len, sid->avp_value->os.data); | |
1509 handled = 0; | |
1510 break; | |
1511 | |
1512 /* NAS-Identifier is not present in answers */ | |
1513 /* NAS-IP-Address is not present in answers */ | |
1514 /* NAS-IPv6-Address is not present in answers */ | |
1515 /* NAS-Port is not present in answers */ | |
1516 /* NAS-Port-Id is not present in answers */ | |
1517 /* NAS-Port-Type is not present in answers */ | |
1518 | |
1519 case DIAM_ATTR_ORIGIN_AAA_PROTOCOL: | |
1520 /* We just remove this AVP */ | |
1521 break; | |
1522 | |
1523 /* Originating-Line-Info is not present in answers */ | |
1524 | |
1525 case DIAM_ATTR_PASSWORD_RETRY: | |
1526 CONV2RAD_32B(RADIUS_ATTR_PASSWORD_RETRY, ahdr->avp_value->u32); | |
1527 break; | |
1528 | |
1529 case DIAM_ATTR_PORT_LIMIT: | |
1530 CONV2RAD_32B(RADIUS_ATTR_PORT_LIMIT, ahdr->avp_value->u32); | |
1531 break; | |
1532 | |
1533 case DIAM_ATTR_PROMPT: | |
1534 CONV2RAD_32B(RADIUS_ATTR_PROMPT, ahdr->avp_value->u32); | |
1535 break; | |
1536 | |
1537 case DIAM_ATTR_QOS_FILTER_RULE: | |
1538 /* This is not translatable to RADIUS */ | |
1539 fd_log_debug("[auth.rgwx] Received Diameter answer with non-translatable QoS-Filter-Rule AVP from '%.*s' (session: '%.*s'), ignoring.\n", | |
1540 oh->avp_value->os.len, oh->avp_value->os.data, | |
1541 sid->avp_value->os.len, sid->avp_value->os.data); | |
1542 handled = 0; | |
1543 break; | |
1544 | |
1545 /* Re-Auth-Request-Type already handled */ | |
1546 | |
1547 case DIAM_ATTR_REPLY_MESSAGE: | |
1548 CONV2RAD_STR(RADIUS_ATTR_REPLY_MESSAGE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1549 break; | |
1550 | |
1551 case DIAM_ATTR_SERVICE_TYPE: | |
1552 CONV2RAD_32B(RADIUS_ATTR_SERVICE_TYPE, ahdr->avp_value->u32); | |
1553 break; | |
1554 | |
1555 case DIAM_ATTR_STATE: | |
1556 CONV2RAD_STR(RADIUS_ATTR_STATE, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 2); | |
1557 break; | |
1558 | |
1559 case DIAM_ATTR_TUNNELING: | |
1560 { | |
1561 #define CONV2RAD_TUN_STR( _attr_, _data_, _len_, _trunc_) { \ | |
1562 size_t __l = (size_t)(_len_); \ | |
1563 size_t __w = (__l > 252) ? 252 : __l; \ | |
1564 size_t __off = 0; \ | |
1565 if ((_trunc_) == 0) { \ | |
1566 CHECK_PARAMS( __l <= 252 ); \ | |
1567 } \ | |
1568 if ((__l > 252) && (_trunc_ == 1)) { \ | |
1569 TRACE_DEBUG(FULL, "Attribute truncated!"); \ | |
1570 __l = 252; \ | |
1571 } \ | |
1572 buf[0] = tuntag; \ | |
1573 memcpy(&buf[1], (_data_), __w); \ | |
1574 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), &buf[0], __w + 1)); \ | |
1575 while (__l -= __w) { \ | |
1576 __off += __w; \ | |
1577 __w = (__l > 253) ? 253 : __l; \ | |
1578 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), (_data_) + __off, __w)); \ | |
1579 } \ | |
1580 } | |
1581 | |
1582 #define CONV2RAD_TUN_32B( _attr_, _data_) { \ | |
1583 uint32_t __v = htonl((uint32_t)(_data_) | (tuntag << 24)); \ | |
1584 CHECK_MALLOC(radius_msg_add_attr(*rad_fw, (_attr_), (uint8_t *)&__v, sizeof(__v))); \ | |
1585 } | |
1586 struct avp *inavp, *innext; | |
1587 tuntag++; | |
1588 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_FIRST_CHILD, &innext, NULL) ); | |
1589 while (innext) { | |
1590 inavp = innext; | |
1591 CHECK_FCT( fd_msg_browse(inavp, MSG_BRW_NEXT, &innext, NULL) ); | |
1592 CHECK_FCT( fd_msg_avp_hdr ( inavp, &ahdr ) ); | |
1593 | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1594 if ( ! (ahdr->avp_flags & AVP_FLAG_VENDOR)) { |
256 | 1595 switch (ahdr->avp_code) { |
1596 case DIAM_ATTR_TUNNEL_TYPE: | |
1597 CONV2RAD_TUN_32B( RADIUS_ATTR_TUNNEL_TYPE, ahdr->avp_value->u32); | |
1598 break; | |
1599 | |
1600 case DIAM_ATTR_TUNNEL_MEDIUM_TYPE: | |
1601 CONV2RAD_TUN_32B( RADIUS_ATTR_TUNNEL_MEDIUM_TYPE, ahdr->avp_value->u32); | |
1602 break; | |
1603 | |
1604 case DIAM_ATTR_TUNNEL_CLIENT_ENDPOINT: | |
1605 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_CLIENT_ENDPOINT, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1606 break; | |
1607 | |
1608 case DIAM_ATTR_TUNNEL_SERVER_ENDPOINT: | |
1609 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_SERVER_ENDPOINT, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1610 break; | |
1611 | |
1612 case DIAM_ATTR_TUNNEL_PREFERENCE: | |
1613 CONV2RAD_TUN_32B( RADIUS_ATTR_TUNNEL_PREFERENCE, ahdr->avp_value->u32); | |
1614 break; | |
1615 | |
1616 case DIAM_ATTR_TUNNEL_CLIENT_AUTH_ID: | |
1617 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_CLIENT_AUTH_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1618 break; | |
1619 | |
1620 case DIAM_ATTR_TUNNEL_SERVER_AUTH_ID: | |
1621 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_SERVER_AUTH_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1622 break; | |
1623 | |
271
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
1624 case DIAM_ATTR_TUNNEL_ASSIGNMENT_ID: |
411314907b43
Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
264
diff
changeset
|
1625 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_ASSIGNMENT_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); |
256 | 1626 break; |
1627 | |
1628 case DIAM_ATTR_TUNNEL_PASSWORD: | |
1629 { | |
1630 /* This AVP must be encoded for RADIUS (similar to radius_msg_add_attr_user_password) | |
1631 0 1 2 3 | |
1632 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
1633 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
1634 | Type | Length | Tag | Salt | |
1635 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
1636 Salt (cont) | String ... | |
1637 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
1638 */ | |
1639 size_t pos; | |
1640 int i; | |
1641 uint8_t * secret; /* S */ | |
1642 size_t secret_len; | |
1643 uint8_t hash[16]; /* b(i) */ | |
1644 const uint8_t *addr[3]; | |
1645 size_t len[3]; | |
1646 | |
1647 /* We need the request authenticator */ | |
1648 CHECK_PARAMS(req_auth); | |
1649 | |
1650 /* Retrieve the shared secret */ | |
1651 CHECK_FCT(rgw_clients_getkey(cli, &secret, &secret_len)); | |
1652 | |
1653 /* Beginning of the buffer */ | |
1654 buf[0] = tuntag; | |
1655 buf[1] = (uint8_t)(lrand48()); /* A (hi bits) */ | |
1656 buf[2] = (uint8_t)(lrand48()); /* A (low bits) */ | |
1657 | |
1658 /* The plain text string P */ | |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1659 CHECK_PARAMS(ahdr->avp_value->os.len < 240); |
256 | 1660 buf[3] = ahdr->avp_value->os.len; |
1661 memcpy(&buf[4], ahdr->avp_value->os.data, ahdr->avp_value->os.len); | |
1662 memset(&buf[4 + ahdr->avp_value->os.len], 0, sizeof(buf) - 4 - ahdr->avp_value->os.len); | |
1663 | |
1664 /* Initial b1 = MD5(S + R + A) */ | |
1665 addr[0] = secret; | |
1666 len[0] = secret_len; | |
1667 addr[1] = req_auth; | |
1668 len[1] = 16; | |
1669 addr[2] = &buf[1]; | |
1670 len[2] = 2; | |
1671 md5_vector(3, addr, len, hash); | |
1672 | |
1673 /* Initial c(1) = p(1) xor b(1) */ | |
1674 for (i = 0; i < 16; i++) { | |
1675 buf[i + 3] ^= hash[i]; | |
1676 } | |
1677 pos = 16; | |
1678 | |
1679 /* loop */ | |
1680 while (pos < ahdr->avp_value->os.len + 1) { | |
1681 addr[0] = secret; | |
1682 len[0] = secret_len; | |
1683 addr[1] = &buf[pos - 13]; | |
1684 len[1] = 16; | |
1685 /* b(i) = MD5( S + c(i-1) */ | |
1686 md5_vector(2, addr, len, hash); | |
1687 | |
1688 /* c(i) = p(i) xor b(i) */ | |
1689 for (i = 0; i < 16; i++) | |
1690 buf[pos + i + 3] ^= hash[i]; | |
1691 | |
1692 pos += 16; | |
1693 } | |
1694 | |
1695 CONV2RAD_STR(RADIUS_ATTR_TUNNEL_PASSWORD, &buf[0], pos + 3, 0); | |
1696 } | |
1697 break; | |
1698 | |
1699 case DIAM_ATTR_TUNNEL_PRIVATE_GROUP_ID: | |
1700 CONV2RAD_TUN_STR(RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1701 break; | |
1702 | |
1703 default: | |
1704 TRACE_DEBUG(FULL, "Ignored unknown AVP inside Tunneling AVP (%d)", ahdr->avp_code); | |
1705 } | |
1706 } else { | |
1707 TRACE_DEBUG(FULL, "Ignored unknown Vendor AVP inside Tunneling AVP (%d, %d)", ahdr->avp_vendor, ahdr->avp_code); | |
1708 } | |
1709 } | |
1710 } | |
1711 break; | |
1712 | |
1713 case DIAM_ATTR_USER_NAME: | |
1714 CONV2RAD_STR(RADIUS_ATTR_USER_NAME, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1715 break; | |
1716 | |
1717 /* User-Password never present in answers */ | |
1718 | |
1719 /* RFC 4072 (AVP in the order of the EAP Command AVP Table) */ | |
1720 /* | |
1721 o Diameter Accounting-EAP-Auth-Method AVPs, if present, are | |
1722 discarded. | |
1723 */ | |
1724 case DIAM_ATTR_ACCOUNTING_EAP_AUTH_METHOD: | |
1725 break; | |
1726 | |
1727 /* | |
1728 o Diameter EAP-Master-Session-Key AVP can be translated to the | |
1729 vendor-specific RADIUS MS-MPPE-Recv-Key and MS-MPPE-Send-Key | |
1730 attributes [RFC2548]. The first up to 32 octets of the key is | |
1731 stored into MS-MPPE-Recv-Key, and the next up to 32 octets (if | |
1732 present) are stored into MS-MPPE-Send-Key. The encryption of this | |
1733 attribute is described in [RFC2548]. | |
1734 */ | |
1735 case DIAM_ATTR_EAP_MASTER_SESSION_KEY: | |
1736 { | |
1737 uint8_t * secret; /* S */ | |
1738 size_t secret_len; | |
1739 size_t recv_len, send_len; | |
1740 | |
1741 /* We need the request authenticator */ | |
1742 CHECK_PARAMS(req_auth); | |
1743 | |
1744 /* Retrieve the shared secret */ | |
1745 CHECK_FCT(rgw_clients_getkey(cli, &secret, &secret_len)); | |
1746 | |
1747 if (ahdr->avp_value->os.len != 64) { | |
1748 TRACE_DEBUG(INFO, "Received EAP-Master-Session-Key attribute with length %d != 64.\n", ahdr->avp_value->os.len) | |
1749 } | |
1750 | |
1751 CHECK_PARAMS(ahdr->avp_value->os.len <= 64); | |
1752 recv_len = ahdr->avp_value->os.len >= 32 ? 32 : ahdr->avp_value->os.len; | |
1753 send_len = ahdr->avp_value->os.len - recv_len; | |
1754 | |
1755 if ( ! radius_msg_add_mppe_keys(*rad_fw, req_auth, secret, secret_len, | |
1756 ahdr->avp_value->os.data + recv_len, send_len, | |
1757 ahdr->avp_value->os.data, recv_len) ) { | |
1758 TRACE_DEBUG(INFO, "Error while converting EAP-Master-Session-Key to RADIUS message"); | |
1759 return ENOMEM; | |
1760 } | |
1761 } | |
1762 break; | |
1763 | |
1764 case DIAM_ATTR_EAP_KEY_NAME: | |
1765 CONV2RAD_STR(RADIUS_ATTR_EAP_KEY_NAME, ahdr->avp_value->os.data, ahdr->avp_value->os.len, 1); | |
1766 break; | |
1767 | |
1768 /* | |
1769 o Diameter EAP-Payload AVP is translated to RADIUS EAP-Message | |
1770 attribute(s). If necessary, the value is split into multiple | |
1771 RADIUS EAP-Message attributes. | |
1772 */ | |
1773 case DIAM_ATTR_EAP_PAYLOAD: | |
1774 if ( ! radius_msg_add_eap(*rad_fw, ahdr->avp_value->os.data, ahdr->avp_value->os.len) ) { | |
1775 TRACE_DEBUG(INFO, "Error while converting EAP payload to RADIUS message"); | |
1776 return ENOMEM; | |
1777 } | |
1778 break; | |
1779 | |
1780 /* | |
1781 o Diameter EAP-Reissued-Payload AVP is translated to a message that | |
1782 contains RADIUS EAP-Message attribute(s), and a RADIUS Error-Cause | |
1783 attribute [RFC3576] with value 202 (decimal), "Invalid EAP Packet | |
1784 (Ignored)" [RFC3579]. | |
1785 */ | |
1786 case DIAM_ATTR_EAP_REISSUED_PAYLOAD: | |
1787 if ( ! radius_msg_add_eap(*rad_fw, ahdr->avp_value->os.data, ahdr->avp_value->os.len) ) { | |
1788 TRACE_DEBUG(INFO, "Error while converting EAP reissued payload to RADIUS message"); | |
1789 return ENOMEM; | |
1790 } | |
1791 | |
1792 if ( ! radius_msg_add_attr_int32(*rad_fw, RADIUS_ATTR_ERROR_CAUSE, 202) ) { | |
1793 TRACE_DEBUG(INFO, "Error while adding Error-Cause attribute in RADIUS message"); | |
1794 return ENOMEM; | |
1795 } | |
1796 break; | |
1797 | |
1798 default: | |
1799 /* Leave the AVP in the message for further treatment */ | |
1800 handled = 0; | |
1801 } | |
1802 } else { | |
1803 /* Vendor-specific AVPs */ | |
1804 switch (ahdr->avp_vendor) { | |
1805 | |
1806 default: /* unknown vendor */ | |
1807 handled = 0; | |
1808 } | |
1809 } | |
1810 | |
1811 if (handled) { | |
1812 CHECK_FCT( fd_msg_free( avp ) ); | |
1813 } | |
1814 } | |
1815 | |
1816 CHECK_FCT( fd_msg_free( asid ) ); | |
1817 CHECK_FCT( fd_msg_free( aoh ) ); | |
1818 free(req_auth); | |
1819 | |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1820 if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) { |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1821 /* Add the auth-application-id required for STR, or 0 if no STR is required */ |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1822 CHECK_FCT( fd_msg_hdr( *diam_ans, &hdr ) ); |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1823 if (sizeof(buf) < (sz = snprintf((char *)buf, sizeof(buf), CLASS_AAI_PREFIX "%u", |
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1824 no_str ? 0 : hdr->msg_appl))) { |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1825 TRACE_DEBUG(INFO, "Data truncated in Class attribute: %s", buf); |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1826 } |
403
26aafbbc1640
Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
1827 CONV2RAD_STR(RADIUS_ATTR_CLASS, buf, sz, 0); |
296
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1828 } |
e11a9f90a65a
Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
273
diff
changeset
|
1829 |
256 | 1830 return 0; |
1831 } | |
1832 | |
1833 /* The exported symbol */ | |
1834 struct rgw_api rgwp_descriptor = { | |
1835 .rgwp_name = "auth", | |
1836 .rgwp_conf_parse = auth_conf_parse, | |
1837 .rgwp_conf_free = auth_conf_free, | |
1838 .rgwp_rad_req = auth_rad_req, | |
1839 .rgwp_diam_ans = auth_diam_ans | |
1840 }; |