@@ -51,27 +51,25 @@ pub fn parse_authentication_frame(
51
51
let ( input, auth_seq) = le_u16 ( input) ?;
52
52
let ( input, status_code) = le_u16 ( input) ?;
53
53
54
+ let mut challenge_text = None ;
55
+ let mut station_info = None ;
56
+
54
57
// Parse the optional challenge text, if present
55
- let ( challenge_text, station_info) = if auth_algorithm == 1 {
56
- let ( _, challenge_text) = if input. is_empty ( ) {
57
- ( input, None )
58
- } else {
58
+ if auth_algorithm == 1 && ( auth_seq == 2 || auth_seq == 3 ) {
59
+ // Parse the optional challenge text
60
+ if !input. is_empty ( ) {
59
61
let ( input, length) = le_u16 ( input) ?;
60
- let ( input , text) = take ( length) ( input) ?;
61
- ( input , Some ( text. to_vec ( ) ) )
62
+ let ( _input , text) = take ( length) ( input) ?;
63
+ challenge_text = Some ( text. to_vec ( ) ) ;
62
64
} ;
63
- ( challenge_text, None )
64
65
} else {
65
66
// Parse station info (extended capabilities) if present
66
- let station_info = if input. is_empty ( ) {
67
- None
68
- } else if let Ok ( ( _, info) ) = parse_station_info ( input) {
69
- Some ( info)
70
- } else {
71
- None
72
- } ;
73
- ( None , station_info)
74
- } ;
67
+ if !input. is_empty ( ) {
68
+ if let Ok ( ( _input, info) ) = parse_station_info ( input) {
69
+ station_info = Some ( info) ;
70
+ }
71
+ }
72
+ }
75
73
76
74
Ok ( Frame :: Authentication ( Authentication {
77
75
header,
0 commit comments