Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | #include "coreconfigurator.h" |
Chaehyun Lim | dd32257 | 2015-09-22 22:47:43 +0900 | [diff] [blame] | 2 | #include "wilc_wlan_if.h" |
Glen Lee | 1028e5a | 2015-10-01 16:03:40 +0900 | [diff] [blame] | 3 | #include "wilc_wlan.h" |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 4 | #include <linux/errno.h> |
Chaehyun Lim | e215a87 | 2015-09-30 08:15:41 +0900 | [diff] [blame] | 5 | #include <linux/slab.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 6 | #define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ |
| 7 | BEACON_INTERVAL_LEN + CAP_INFO_LEN) |
| 8 | |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 9 | enum basic_frame_type { |
Stanislav Kholmanskikh | 13994d1 | 2015-06-10 21:57:26 +0300 | [diff] [blame] | 10 | FRAME_TYPE_CONTROL = 0x04, |
| 11 | FRAME_TYPE_DATA = 0x08, |
| 12 | FRAME_TYPE_MANAGEMENT = 0x00, |
| 13 | FRAME_TYPE_RESERVED = 0x0C, |
| 14 | FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 15 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 16 | |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 17 | enum sub_frame_type { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 18 | ASSOC_REQ = 0x00, |
| 19 | ASSOC_RSP = 0x10, |
| 20 | REASSOC_REQ = 0x20, |
| 21 | REASSOC_RSP = 0x30, |
| 22 | PROBE_REQ = 0x40, |
| 23 | PROBE_RSP = 0x50, |
| 24 | BEACON = 0x80, |
| 25 | ATIM = 0x90, |
| 26 | DISASOC = 0xA0, |
| 27 | AUTH = 0xB0, |
| 28 | DEAUTH = 0xC0, |
| 29 | ACTION = 0xD0, |
| 30 | PS_POLL = 0xA4, |
| 31 | RTS = 0xB4, |
| 32 | CTS = 0xC4, |
| 33 | ACK = 0xD4, |
| 34 | CFEND = 0xE4, |
| 35 | CFEND_ACK = 0xF4, |
| 36 | DATA = 0x08, |
| 37 | DATA_ACK = 0x18, |
| 38 | DATA_POLL = 0x28, |
| 39 | DATA_POLL_ACK = 0x38, |
| 40 | NULL_FRAME = 0x48, |
| 41 | CFACK = 0x58, |
| 42 | CFPOLL = 0x68, |
| 43 | CFPOLL_ACK = 0x78, |
| 44 | QOS_DATA = 0x88, |
| 45 | QOS_DATA_ACK = 0x98, |
| 46 | QOS_DATA_POLL = 0xA8, |
| 47 | QOS_DATA_POLL_ACK = 0xB8, |
| 48 | QOS_NULL_FRAME = 0xC8, |
| 49 | QOS_CFPOLL = 0xE8, |
| 50 | QOS_CFPOLL_ACK = 0xF8, |
| 51 | BLOCKACK_REQ = 0x84, |
| 52 | BLOCKACK = 0x94, |
| 53 | FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 54 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 55 | |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 56 | enum info_element_id { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 57 | ISSID = 0, /* Service Set Identifier */ |
| 58 | ISUPRATES = 1, /* Supported Rates */ |
| 59 | IFHPARMS = 2, /* FH parameter set */ |
| 60 | IDSPARMS = 3, /* DS parameter set */ |
| 61 | ICFPARMS = 4, /* CF parameter set */ |
| 62 | ITIM = 5, /* Traffic Information Map */ |
| 63 | IIBPARMS = 6, /* IBSS parameter set */ |
| 64 | ICOUNTRY = 7, /* Country element */ |
| 65 | IEDCAPARAMS = 12, /* EDCA parameter set */ |
| 66 | ITSPEC = 13, /* Traffic Specification */ |
| 67 | ITCLAS = 14, /* Traffic Classification */ |
| 68 | ISCHED = 15, /* Schedule */ |
| 69 | ICTEXT = 16, /* Challenge Text */ |
| 70 | IPOWERCONSTRAINT = 32, /* Power Constraint */ |
| 71 | IPOWERCAPABILITY = 33, /* Power Capability */ |
| 72 | ITPCREQUEST = 34, /* TPC Request */ |
| 73 | ITPCREPORT = 35, /* TPC Report */ |
| 74 | ISUPCHANNEL = 36, /* Supported channel list */ |
| 75 | ICHSWANNOUNC = 37, /* Channel Switch Announcement */ |
| 76 | IMEASUREMENTREQUEST = 38, /* Measurement request */ |
| 77 | IMEASUREMENTREPORT = 39, /* Measurement report */ |
| 78 | IQUIET = 40, /* Quiet element Info */ |
| 79 | IIBSSDFS = 41, /* IBSS DFS */ |
| 80 | IERPINFO = 42, /* ERP Information */ |
| 81 | ITSDELAY = 43, /* TS Delay */ |
| 82 | ITCLASPROCESS = 44, /* TCLAS Processing */ |
| 83 | IHTCAP = 45, /* HT Capabilities */ |
| 84 | IQOSCAP = 46, /* QoS Capability */ |
| 85 | IRSNELEMENT = 48, /* RSN Information Element */ |
| 86 | IEXSUPRATES = 50, /* Extended Supported Rates */ |
| 87 | IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/ |
| 88 | IHTOPERATION = 61, /* HT Information */ |
| 89 | ISECCHOFF = 62, /* Secondary Channel Offeset */ |
| 90 | I2040COEX = 72, /* 20/40 Coexistence IE */ |
| 91 | I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/ |
| 92 | IOBSSSCAN = 74, /* OBSS Scan parameters */ |
| 93 | IEXTCAP = 127, /* Extended capability */ |
| 94 | IWMM = 221, /* WMM parameters */ |
| 95 | IWPAELEMENT = 221, /* WPA Information Element */ |
| 96 | INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 97 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 98 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 99 | static inline u16 get_beacon_period(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 100 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 101 | u16 bcn_per; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 102 | |
| 103 | bcn_per = data[0]; |
| 104 | bcn_per |= (data[1] << 8); |
| 105 | |
| 106 | return bcn_per; |
| 107 | } |
| 108 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 109 | static inline u32 get_beacon_timestamp_lo(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 110 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 111 | u32 time_stamp = 0; |
| 112 | u32 index = MAC_HDR_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 113 | |
| 114 | time_stamp |= data[index++]; |
| 115 | time_stamp |= (data[index++] << 8); |
| 116 | time_stamp |= (data[index++] << 16); |
| 117 | time_stamp |= (data[index] << 24); |
| 118 | |
| 119 | return time_stamp; |
| 120 | } |
| 121 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 122 | static inline u32 get_beacon_timestamp_hi(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 123 | { |
Chaehyun Lim | 8a54d91 | 2015-06-11 14:35:53 +0900 | [diff] [blame] | 124 | u32 time_stamp = 0; |
| 125 | u32 index = (MAC_HDR_LEN + 4); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 126 | |
| 127 | time_stamp |= data[index++]; |
| 128 | time_stamp |= (data[index++] << 8); |
| 129 | time_stamp |= (data[index++] << 16); |
| 130 | time_stamp |= (data[index] << 24); |
| 131 | |
| 132 | return time_stamp; |
| 133 | } |
| 134 | |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 135 | static inline enum sub_frame_type get_sub_type(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 136 | { |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 137 | return ((enum sub_frame_type)(header[0] & 0xFC)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 138 | } |
| 139 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 140 | static inline u8 get_to_ds(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 141 | { |
| 142 | return (header[1] & 0x01); |
| 143 | } |
| 144 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 145 | static inline u8 get_from_ds(u8 *header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 146 | { |
| 147 | return ((header[1] & 0x02) >> 1); |
| 148 | } |
| 149 | |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 150 | static inline void get_address1(u8 *pu8msa, u8 *addr) |
| 151 | { |
| 152 | memcpy(addr, pu8msa + 4, 6); |
| 153 | } |
| 154 | |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 155 | static inline void get_address2(u8 *pu8msa, u8 *addr) |
| 156 | { |
| 157 | memcpy(addr, pu8msa + 10, 6); |
| 158 | } |
| 159 | |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 160 | static inline void get_address3(u8 *pu8msa, u8 *addr) |
| 161 | { |
| 162 | memcpy(addr, pu8msa + 16, 6); |
| 163 | } |
| 164 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 165 | static inline void get_BSSID(u8 *data, u8 *bssid) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 166 | { |
| 167 | if (get_from_ds(data) == 1) |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 168 | get_address2(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 169 | else if (get_to_ds(data) == 1) |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 170 | get_address1(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 171 | else |
Glen Lee | b57f9f3 | 2015-11-05 18:51:23 +0900 | [diff] [blame] | 172 | get_address3(data, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 173 | } |
| 174 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 175 | static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 176 | { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 177 | u8 len = 0; |
| 178 | u8 i = 0; |
| 179 | u8 j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 180 | |
| 181 | len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + |
| 182 | CAP_INFO_LEN + 1]; |
| 183 | j = MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + |
| 184 | CAP_INFO_LEN + 2; |
| 185 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 186 | if (len >= MAX_SSID_LEN) |
| 187 | len = 0; |
| 188 | |
| 189 | for (i = 0; i < len; i++, j++) |
| 190 | ssid[i] = data[j]; |
| 191 | |
| 192 | ssid[len] = '\0'; |
| 193 | |
| 194 | *p_ssid_len = len; |
| 195 | } |
| 196 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 197 | static inline u16 get_cap_info(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 198 | { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 199 | u16 cap_info = 0; |
| 200 | u16 index = MAC_HDR_LEN; |
Tony Cho | 9dd2f77 | 2015-10-02 14:22:03 +0900 | [diff] [blame] | 201 | enum sub_frame_type st; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 202 | |
| 203 | st = get_sub_type(data); |
| 204 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 205 | if ((st == BEACON) || (st == PROBE_RSP)) |
| 206 | index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN; |
| 207 | |
| 208 | cap_info = data[index]; |
| 209 | cap_info |= (data[index + 1] << 8); |
| 210 | |
| 211 | return cap_info; |
| 212 | } |
| 213 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 214 | static inline u16 get_assoc_resp_cap_info(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 215 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 216 | u16 cap_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 217 | |
| 218 | cap_info = data[0]; |
| 219 | cap_info |= (data[1] << 8); |
| 220 | |
| 221 | return cap_info; |
| 222 | } |
| 223 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 224 | static inline u16 get_asoc_status(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 225 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 226 | u16 asoc_status; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 227 | |
| 228 | asoc_status = data[3]; |
| 229 | asoc_status = (asoc_status << 8) | data[2]; |
| 230 | |
| 231 | return asoc_status; |
| 232 | } |
| 233 | |
Chaehyun Lim | 9af382b | 2015-09-16 20:11:27 +0900 | [diff] [blame] | 234 | static inline u16 get_asoc_id(u8 *data) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 235 | { |
Amitoj Kaur Chawla | b5c84cd | 2015-10-15 13:49:47 +0530 | [diff] [blame] | 236 | u16 asoc_id; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 237 | |
| 238 | asoc_id = data[4]; |
| 239 | asoc_id |= (data[5] << 8); |
| 240 | |
| 241 | return asoc_id; |
| 242 | } |
| 243 | |
Leo Kim | 6c25d7c | 2016-01-28 16:13:37 +0900 | [diff] [blame] | 244 | static u8 *get_tim_elm(u8 *pu8msa, u16 rx_len, u16 tag_param_offset) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 245 | { |
Leo Kim | c8a0638 | 2016-01-28 16:13:38 +0900 | [diff] [blame] | 246 | u16 index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 247 | |
Leo Kim | c8a0638 | 2016-01-28 16:13:38 +0900 | [diff] [blame] | 248 | index = tag_param_offset; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 249 | |
Leo Kim | c8a0638 | 2016-01-28 16:13:38 +0900 | [diff] [blame] | 250 | while (index < (rx_len - FCS_LEN)) { |
| 251 | if (pu8msa[index] == ITIM) |
| 252 | return &pu8msa[index]; |
| 253 | index += (IE_HDR_LEN + pu8msa[index + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 254 | } |
| 255 | |
Ronit Halder | 0e04f3f | 2015-09-14 11:03:34 +0530 | [diff] [blame] | 256 | return NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 257 | } |
| 258 | |
Leo Kim | e1a9db8 | 2016-01-28 16:13:36 +0900 | [diff] [blame] | 259 | static u8 get_current_channel_802_11n(u8 *pu8msa, u16 rx_len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 260 | { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 261 | u16 index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 262 | |
| 263 | index = TAG_PARAM_OFFSET; |
Leo Kim | e1a9db8 | 2016-01-28 16:13:36 +0900 | [diff] [blame] | 264 | while (index < (rx_len - FCS_LEN)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 265 | if (pu8msa[index] == IDSPARMS) |
Stanislav Kholmanskikh | cea3b20 | 2015-06-10 21:57:25 +0300 | [diff] [blame] | 266 | return pu8msa[index + 2]; |
Aybuke Ozdemir | 86e4180 | 2015-10-17 15:25:34 +0300 | [diff] [blame] | 267 | index += pu8msa[index + 1] + IE_HDR_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 268 | } |
| 269 | |
Leo Kim | 43b36e4 | 2016-01-28 16:13:35 +0900 | [diff] [blame] | 270 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 271 | } |
| 272 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 273 | s32 wilc_parse_network_info(u8 *msg_buffer, |
| 274 | struct network_info **ret_network_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 275 | { |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 276 | struct network_info *network_info = NULL; |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 277 | u8 msg_type = 0; |
| 278 | u8 msg_id = 0; |
| 279 | u16 msg_len = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 280 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 281 | u16 wid_id = (u16)WID_NIL; |
| 282 | u16 wid_len = 0; |
| 283 | u8 *wid_val = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 284 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 285 | msg_type = msg_buffer[0]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 286 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 287 | if ('N' != msg_type) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 288 | PRINT_ER("Received Message format incorrect.\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 289 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 290 | } |
| 291 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 292 | msg_id = msg_buffer[1]; |
| 293 | msg_len = MAKE_WORD16(msg_buffer[2], msg_buffer[3]); |
| 294 | wid_id = MAKE_WORD16(msg_buffer[4], msg_buffer[5]); |
| 295 | wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]); |
| 296 | wid_val = &msg_buffer[8]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 297 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 298 | { |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 299 | u8 *msa = NULL; |
Leo Kim | e1a9db8 | 2016-01-28 16:13:36 +0900 | [diff] [blame] | 300 | u16 rx_len = 0; |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 301 | u8 *tim_elm = NULL; |
| 302 | u8 *ies = NULL; |
| 303 | u16 ies_len = 0; |
| 304 | u8 index = 0; |
| 305 | u32 tsf_lo; |
| 306 | u32 tsf_hi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 307 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 308 | network_info = kzalloc(sizeof(*network_info), GFP_KERNEL); |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 309 | if (!network_info) |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 310 | return -ENOMEM; |
| 311 | |
Leo Kim | 5c23a29 | 2016-02-04 18:24:11 +0900 | [diff] [blame] | 312 | network_info->rssi = wid_val[0]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 313 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 314 | msa = &wid_val[1]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 315 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 316 | rx_len = wid_len - 1; |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame^] | 317 | network_info->cap_info = get_cap_info(msa); |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 318 | network_info->u32Tsf = get_beacon_timestamp_lo(msa); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 319 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 320 | tsf_lo = get_beacon_timestamp_lo(msa); |
| 321 | tsf_hi = get_beacon_timestamp_hi(msa); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 322 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 323 | network_info->u64Tsf = tsf_lo | ((u64)tsf_hi << 32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 324 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 325 | get_ssid(msa, network_info->au8ssid, &network_info->u8SsidLen); |
| 326 | get_BSSID(msa, network_info->au8bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 327 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 328 | network_info->u8channel = get_current_channel_802_11n(msa, |
Leo Kim | e1a9db8 | 2016-01-28 16:13:36 +0900 | [diff] [blame] | 329 | rx_len + FCS_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 330 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 331 | index = MAC_HDR_LEN + TIME_STAMP_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 332 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 333 | network_info->u16BeaconPeriod = get_beacon_period(msa + index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 334 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 335 | index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 336 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 337 | tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index); |
| 338 | if (tim_elm) |
| 339 | network_info->u8DtimPeriod = tim_elm[3]; |
| 340 | ies = &msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN]; |
| 341 | ies_len = rx_len - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 342 | |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 343 | if (ies_len > 0) { |
| 344 | network_info->pu8IEs = kmemdup(ies, ies_len, |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 345 | GFP_KERNEL); |
| 346 | if (!network_info->pu8IEs) |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 347 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 348 | } |
Leo Kim | e509681 | 2016-02-04 18:15:43 +0900 | [diff] [blame] | 349 | network_info->u16IEsLen = ies_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 350 | } |
| 351 | |
Leo Kim | 5fd5e1e | 2016-02-04 18:15:42 +0900 | [diff] [blame] | 352 | *ret_network_info = network_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 353 | |
Chaehyun Lim | 74a443e | 2015-09-22 22:47:45 +0900 | [diff] [blame] | 354 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 355 | } |
| 356 | |
Leo Kim | 946a9dd | 2016-02-04 18:15:45 +0900 | [diff] [blame] | 357 | s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, |
Leo Kim | 40d96e1 | 2016-02-04 18:24:08 +0900 | [diff] [blame] | 358 | struct connect_resp_info **ret_connect_resp_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 359 | { |
Leo Kim | 40d96e1 | 2016-02-04 18:24:08 +0900 | [diff] [blame] | 360 | struct connect_resp_info *connect_resp_info = NULL; |
Leo Kim | ebd7a9b | 2016-02-04 18:15:46 +0900 | [diff] [blame] | 361 | u16 assoc_resp_len = 0; |
| 362 | u8 *ies = NULL; |
| 363 | u16 ies_len = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 364 | |
Leo Kim | 40d96e1 | 2016-02-04 18:24:08 +0900 | [diff] [blame] | 365 | connect_resp_info = kzalloc(sizeof(*connect_resp_info), GFP_KERNEL); |
Leo Kim | ebd7a9b | 2016-02-04 18:15:46 +0900 | [diff] [blame] | 366 | if (!connect_resp_info) |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 367 | return -ENOMEM; |
| 368 | |
Leo Kim | ebd7a9b | 2016-02-04 18:15:46 +0900 | [diff] [blame] | 369 | assoc_resp_len = (u16)buffer_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 370 | |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 371 | connect_resp_info->status = get_asoc_status(buffer); |
| 372 | if (connect_resp_info->status == SUCCESSFUL_STATUSCODE) { |
| 373 | connect_resp_info->capability = get_assoc_resp_cap_info(buffer); |
| 374 | connect_resp_info->assoc_id = get_asoc_id(buffer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 375 | |
Leo Kim | ebd7a9b | 2016-02-04 18:15:46 +0900 | [diff] [blame] | 376 | ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; |
| 377 | ies_len = assoc_resp_len - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 378 | |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 379 | connect_resp_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); |
| 380 | if (!connect_resp_info->ies) |
Chaehyun Lim | a78d9a3 | 2015-08-17 11:05:15 +0900 | [diff] [blame] | 381 | return -ENOMEM; |
| 382 | |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 383 | connect_resp_info->ies_len = ies_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 384 | } |
| 385 | |
Leo Kim | ebd7a9b | 2016-02-04 18:15:46 +0900 | [diff] [blame] | 386 | *ret_connect_resp_info = connect_resp_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 387 | |
Leo Kim | 66d77cb | 2016-02-04 18:15:44 +0900 | [diff] [blame] | 388 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 389 | } |