19
19
#include "common/ieee802_11_defs.h"
20
20
#include "radius/radius.h"
21
21
#include "radius/radius_client.h"
22
+ #ifdef CONFIG_SONIC_RADIUS
23
+ #include "radius/radius_attr_parse.h"
24
+ #endif
22
25
#include "eap_server/eap.h"
23
26
#include "eap_common/eap_wsc_common.h"
24
27
#include "eapol_auth/eapol_auth_sm.h"
@@ -460,6 +463,7 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
460
463
return -1 ;
461
464
}
462
465
466
+ #ifndef CONFIG_SONIC_RADIUS
463
467
if (sta -> flags & WLAN_STA_PREAUTH ) {
464
468
os_strlcpy (buf , "IEEE 802.11i Pre-Authentication" ,
465
469
sizeof (buf ));
@@ -487,6 +491,7 @@ static int add_common_radius_sta_attr(struct hostapd_data *hapd,
487
491
return -1 ;
488
492
}
489
493
}
494
+ #endif
490
495
491
496
if ((hapd -> conf -> wpa & 2 ) &&
492
497
!hapd -> conf -> disable_pmksa_caching &&
@@ -565,8 +570,13 @@ int add_common_radius_attr(struct hostapd_data *hapd,
565
570
return -1 ;
566
571
}
567
572
573
+ #ifdef CONFIG_SONIC_RADIUS
574
+ len = os_snprintf (buf , sizeof (buf ), RADIUS_802_1X_ADDR_FORMAT ,
575
+ MAC2STR (hapd -> own_addr ));
576
+ #else
568
577
len = os_snprintf (buf , sizeof (buf ), RADIUS_802_1X_ADDR_FORMAT ":" ,
569
578
MAC2STR (hapd -> own_addr ));
579
+ #endif
570
580
os_memcpy (& buf [len ], hapd -> conf -> ssid .ssid ,
571
581
hapd -> conf -> ssid .ssid_len );
572
582
len += hapd -> conf -> ssid .ssid_len ;
@@ -708,7 +718,13 @@ void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
708
718
wpa_printf (MSG_INFO , "Could not add User-Name" );
709
719
goto fail ;
710
720
}
711
-
721
+ #ifdef CONFIG_SONIC_RADIUS
722
+ else {
723
+ memset (sta -> attr_info .userName ,'\0' , sizeof (sta -> attr_info .userName ));
724
+ strncpy (sta -> attr_info .userName , sm -> identity , sm -> identity_len );
725
+ sta -> attr_info .userNameLen = sm -> identity_len ;
726
+ }
727
+ #endif
712
728
if (add_common_radius_attr (hapd , hapd -> conf -> radius_auth_req_attr , sta ,
713
729
msg ) < 0 )
714
730
goto fail ;
@@ -1183,6 +1199,19 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
1183
1199
sta -> eapol_sm -> eapolLogoff = true;
1184
1200
sta -> eapol_sm -> dot1xAuthEapolLogoffFramesRx ++ ;
1185
1201
eap_server_clear_identity (sta -> eapol_sm -> eap );
1202
+
1203
+ #ifdef CONFIG_SONIC_HOSTAPD
1204
+ hostapd_logger (hapd , sta -> addr , HOSTAPD_MODULE_IEEE8021X ,
1205
+ HOSTAPD_LEVEL_DEBUG ,
1206
+ "sending client_disconnect for EAPOL-Logoff from STA" );
1207
+ /* Inform PAC */
1208
+ if (0 != hostapd_drv_auth_resp_send (hapd , hapd -> conf -> iface , sta -> addr , "client_disconnected" , NULL ))
1209
+ {
1210
+ hostapd_logger (hapd , sta -> addr , HOSTAPD_MODULE_IEEE8021X ,
1211
+ HOSTAPD_LEVEL_DEBUG ,
1212
+ "sending client_disconnect for EAPOL-Logoff from STA not successful" );
1213
+ }
1214
+ #endif
1186
1215
break ;
1187
1216
1188
1217
case IEEE802_1X_TYPE_EAPOL_KEY :
@@ -2006,6 +2035,14 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
2006
2035
break ;
2007
2036
#endif /* CONFIG_NO_VLAN */
2008
2037
2038
+ #ifdef CONFIG_SONIC_RADIUS
2039
+ if (0 != radiusClientAcceptProcess (msg , & sta -> attr_info ))
2040
+ {
2041
+ wpa_printf (MSG_DEBUG , "radiusClientAcceptProcess failed \n" );
2042
+ }
2043
+ #endif
2044
+
2045
+ #ifndef CONFIG_SONIC_RADIUS
2009
2046
sta -> session_timeout_set = !!session_timeout_set ;
2010
2047
os_get_reltime (& sta -> session_timeout );
2011
2048
sta -> session_timeout .sec += session_timeout ;
@@ -2018,6 +2055,7 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
2018
2055
ap_sta_session_timeout (hapd , sta , session_timeout );
2019
2056
else
2020
2057
ap_sta_no_session_timeout (hapd , sta );
2058
+ #endif
2021
2059
2022
2060
sm -> eap_if -> aaaSuccess = true;
2023
2061
override_eapReq = 1 ;
@@ -2110,6 +2148,11 @@ void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta)
2110
2148
MAC2STR (sta -> addr ));
2111
2149
2112
2150
sm -> eap_if -> portEnabled = false;
2151
+ #ifdef CONFIG_SONIC_RADIUS
2152
+ /* Invoke driver to inform PAC */
2153
+ hostapd_drv_auth_resp_send (hapd , hapd -> conf -> iface , sta -> addr ,
2154
+ "auth_timeout" , (void * ) sta );
2155
+ #endif
2113
2156
ap_sta_disconnect (hapd , sta , sta -> addr ,
2114
2157
WLAN_REASON_PREV_AUTH_NOT_VALID );
2115
2158
}
@@ -2998,5 +3041,16 @@ static void ieee802_1x_finished(struct hostapd_data *hapd,
2998
3041
* EAPOL authentication to be started to complete connection.
2999
3042
*/
3000
3043
ap_sta_delayed_1x_auth_fail_disconnect (hapd , sta );
3001
- }
3044
+
3045
+ #ifdef CONFIG_SONIC_HOSTAPD
3046
+ /* Invoke driver to inform PAC */
3047
+ hostapd_drv_auth_resp_send (hapd , hapd -> conf -> iface , sta -> addr , "auth_fail" , (void * ) sta );
3048
+ #endif
3049
+ }
3050
+ #ifdef CONFIG_SONIC_HOSTAPD
3051
+ else {
3052
+ /* Invoke driver to inform PAC */
3053
+ hostapd_drv_auth_resp_send (hapd , hapd -> conf -> iface , sta -> addr , "auth_success" , (void * ) sta );
3054
+ }
3055
+ #endif
3002
3056
}
0 commit comments