ifieee80211.c (8f09c33a23320df7b584edd850a6fe83b82d210f) | ifieee80211.c (f280f93df7950572c70e8e923fa0559b1a489b9b) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright 2001 The Aerospace Corporation. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 63 unchanged lines hidden (view full) --- 72#include <net/if_media.h> 73#include <net/route.h> 74 75#include <net80211/ieee80211_ioctl.h> 76#include <net80211/ieee80211_freebsd.h> 77#include <net80211/ieee80211_superg.h> 78#include <net80211/ieee80211_tdma.h> 79#include <net80211/ieee80211_mesh.h> | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright 2001 The Aerospace Corporation. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 63 unchanged lines hidden (view full) --- 72#include <net/if_media.h> 73#include <net/route.h> 74 75#include <net80211/ieee80211_ioctl.h> 76#include <net80211/ieee80211_freebsd.h> 77#include <net80211/ieee80211_superg.h> 78#include <net80211/ieee80211_tdma.h> 79#include <net80211/ieee80211_mesh.h> |
80#include <net80211/ieee80211_wps.h> |
|
80 81#include <assert.h> 82#include <ctype.h> 83#include <err.h> 84#include <errno.h> 85#include <fcntl.h> 86#include <inttypes.h> 87#include <stdio.h> --- 3036 unchanged lines hidden (view full) --- 3124 3125 if (ielen > 2) /* optional capabilities */ 3126 printf(", caps 0x%x", LE_READ_2(ie)); 3127 /* XXXPMKID */ 3128 printf(">"); 3129 } 3130} 3131 | 81 82#include <assert.h> 83#include <ctype.h> 84#include <err.h> 85#include <errno.h> 86#include <fcntl.h> 87#include <inttypes.h> 88#include <stdio.h> --- 3036 unchanged lines hidden (view full) --- 3125 3126 if (ielen > 2) /* optional capabilities */ 3127 printf(", caps 0x%x", LE_READ_2(ie)); 3128 /* XXXPMKID */ 3129 printf(">"); 3130 } 3131} 3132 |
3132/* XXX move to a public include file */ 3133#define IEEE80211_WPS_DEV_PASS_ID 0x1012 3134#define IEEE80211_WPS_SELECTED_REG 0x1041 3135#define IEEE80211_WPS_SETUP_STATE 0x1044 3136#define IEEE80211_WPS_UUID_E 0x1047 3137#define IEEE80211_WPS_VERSION 0x104a 3138 | |
3139#define BE_READ_2(p) \ 3140 ((u_int16_t) \ 3141 ((((const u_int8_t *)(p))[1] ) | \ 3142 (((const u_int8_t *)(p))[0] << 8))) 3143 3144static void 3145printwpsie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) 3146{ --- 5 unchanged lines hidden (view full) --- 3152 "D", /* Default (PIN) */ 3153 "U", /* User-specified */ 3154 "M", /* Machine-specified */ 3155 "K", /* Rekey */ 3156 "P", /* PushButton */ 3157 "R" /* Registrar-specified */ 3158 }; 3159 int n; | 3133#define BE_READ_2(p) \ 3134 ((u_int16_t) \ 3135 ((((const u_int8_t *)(p))[1] ) | \ 3136 (((const u_int8_t *)(p))[0] << 8))) 3137 3138static void 3139printwpsie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) 3140{ --- 5 unchanged lines hidden (view full) --- 3146 "D", /* Default (PIN) */ 3147 "U", /* User-specified */ 3148 "M", /* Machine-specified */ 3149 "K", /* Rekey */ 3150 "P", /* PushButton */ 3151 "R" /* Registrar-specified */ 3152 }; 3153 int n; |
3154 int f; |
|
3160 3161 ie +=6, len -= 4; /* NB: len is payload only */ 3162 3163 /* WPS IE in Beacon and Probe Resp frames have different fields */ 3164 printf("<"); 3165 while (len) { 3166 uint16_t tlv_type = BE_READ_2(ie); 3167 uint16_t tlv_len = BE_READ_2(ie + 2); | 3155 3156 ie +=6, len -= 4; /* NB: len is payload only */ 3157 3158 /* WPS IE in Beacon and Probe Resp frames have different fields */ 3159 printf("<"); 3160 while (len) { 3161 uint16_t tlv_type = BE_READ_2(ie); 3162 uint16_t tlv_len = BE_READ_2(ie + 2); |
3163 uint16_t cfg_mthd; |
|
3168 3169 /* some devices broadcast invalid WPS frames */ 3170 if (tlv_len > len) { 3171 printf("bad frame length tlv_type=0x%02x " 3172 "tlv_len=%d len=%d", tlv_type, tlv_len, 3173 len); 3174 break; 3175 } 3176 3177 ie += 4, len -= 4; 3178 3179 switch (tlv_type) { | 3164 3165 /* some devices broadcast invalid WPS frames */ 3166 if (tlv_len > len) { 3167 printf("bad frame length tlv_type=0x%02x " 3168 "tlv_len=%d len=%d", tlv_type, tlv_len, 3169 len); 3170 break; 3171 } 3172 3173 ie += 4, len -= 4; 3174 3175 switch (tlv_type) { |
3180 case IEEE80211_WPS_VERSION: | 3176 case IEEE80211_WPS_ATTR_VERSION: |
3181 printf("v:%d.%d", *ie >> 4, *ie & 0xf); 3182 break; | 3177 printf("v:%d.%d", *ie >> 4, *ie & 0xf); 3178 break; |
3183 case IEEE80211_WPS_SETUP_STATE: 3184 /* Only 1 and 2 are valid */ 3185 if (*ie == 0 || *ie >= 3) 3186 printf(" state:B"); | 3179 case IEEE80211_WPS_ATTR_AP_SETUP_LOCKED: 3180 printf(" ap_setup:%s", *ie ? "locked" : 3181 "unlocked"); 3182 break; 3183 case IEEE80211_WPS_ATTR_CONFIG_METHODS: 3184 case IEEE80211_WPS_ATTR_SELECTED_REGISTRAR_CONFIG_METHODS: 3185 if (tlv_type == IEEE80211_WPS_ATTR_SELECTED_REGISTRAR_CONFIG_METHODS) 3186 printf(" sel_reg_cfg_mthd:"); |
3187 else | 3187 else |
3188 printf(" st:%s", *ie == 1 ? "N" : "C"); | 3188 printf(" cfg_mthd:" ); 3189 cfg_mthd = BE_READ_2(ie); 3190 f = 0; 3191 for (n = 15; n >= 0; n--) { 3192 if (f) { 3193 printf(","); 3194 f = 0; 3195 } 3196 switch (cfg_mthd & (1 << n)) { 3197 case 0: 3198 break; 3199 case IEEE80211_WPS_CONFIG_USBA: 3200 printf("usba"); 3201 f++; 3202 break; 3203 case IEEE80211_WPS_CONFIG_ETHERNET: 3204 printf("ethernet"); 3205 f++; 3206 break; 3207 case IEEE80211_WPS_CONFIG_LABEL: 3208 printf("label"); 3209 f++; 3210 break; 3211 case IEEE80211_WPS_CONFIG_DISPLAY: 3212 if (!(cfg_mthd & 3213 (IEEE80211_WPS_CONFIG_VIRT_DISPLAY | 3214 IEEE80211_WPS_CONFIG_PHY_DISPLAY))) 3215 { 3216 printf("display"); 3217 f++; 3218 } 3219 break; 3220 case IEEE80211_WPS_CONFIG_EXT_NFC_TOKEN: 3221 printf("ext_nfc_tokenk"); 3222 f++; 3223 break; 3224 case IEEE80211_WPS_CONFIG_INT_NFC_TOKEN: 3225 printf("int_nfc_token"); 3226 f++; 3227 break; 3228 case IEEE80211_WPS_CONFIG_NFC_INTERFACE: 3229 printf("nfc_interface"); 3230 f++; 3231 break; 3232 case IEEE80211_WPS_CONFIG_PUSHBUTTON: 3233 if (!(cfg_mthd & 3234 (IEEE80211_WPS_CONFIG_VIRT_PUSHBUTTON | 3235 IEEE80211_WPS_CONFIG_PHY_PUSHBUTTON))) { 3236 printf("push_button"); 3237 f++; 3238 } 3239 break; 3240 case IEEE80211_WPS_CONFIG_KEYPAD: 3241 printf("keypad"); 3242 f++; 3243 break; 3244 case IEEE80211_WPS_CONFIG_VIRT_PUSHBUTTON: 3245 printf("virtual_push_button"); 3246 f++; 3247 break; 3248 case IEEE80211_WPS_CONFIG_PHY_PUSHBUTTON: 3249 printf("physical_push_button"); 3250 f++; 3251 break; 3252 case IEEE80211_WPS_CONFIG_P2PS: 3253 printf("p2ps"); 3254 f++; 3255 break; 3256 case IEEE80211_WPS_CONFIG_VIRT_DISPLAY: 3257 printf("virtual_display"); 3258 f++; 3259 break; 3260 case IEEE80211_WPS_CONFIG_PHY_DISPLAY: 3261 printf("physical_display"); 3262 f++; 3263 break; 3264 default: 3265 printf("unknown_wps_config<%04x>", 3266 cfg_mthd & (1 << n)); 3267 f++; 3268 break; 3269 } 3270 } |
3189 break; | 3271 break; |
3190 case IEEE80211_WPS_SELECTED_REG: 3191 printf(" sel:%s", *ie ? "T" : "F"); | 3272 case IEEE80211_WPS_ATTR_DEV_NAME: 3273 printf(" device_name:<%.*s>", tlv_len, ie); |
3192 break; | 3274 break; |
3193 case IEEE80211_WPS_DEV_PASS_ID: | 3275 case IEEE80211_WPS_ATTR_DEV_PASSWORD_ID: |
3194 n = LE_READ_2(ie); 3195 if (n < nitems(dev_pass_id)) 3196 printf(" dpi:%s", dev_pass_id[n]); 3197 break; | 3276 n = LE_READ_2(ie); 3277 if (n < nitems(dev_pass_id)) 3278 printf(" dpi:%s", dev_pass_id[n]); 3279 break; |
3198 case IEEE80211_WPS_UUID_E: | 3280 case IEEE80211_WPS_ATTR_MANUFACTURER: 3281 printf(" manufacturer:<%.*s>", tlv_len, ie); 3282 break; 3283 case IEEE80211_WPS_ATTR_MODEL_NAME: 3284 printf(" model_name:<%.*s>", tlv_len, ie); 3285 break; 3286 case IEEE80211_WPS_ATTR_MODEL_NUMBER: 3287 printf(" model_number:<%.*s>", tlv_len, ie); 3288 break; 3289 case IEEE80211_WPS_ATTR_PRIMARY_DEV_TYPE: 3290 printf(" prim_dev:"); 3291 for (n = 0; n < tlv_len; n++) 3292 printf("%02x", ie[n]); 3293 break; 3294 case IEEE80211_WPS_ATTR_RF_BANDS: 3295 printf(" rf:"); 3296 f = 0; 3297 for (n = 7; n >= 0; n--) { 3298 if (f) { 3299 printf(","); 3300 f = 0; 3301 } 3302 switch (*ie & (1 << n)) { 3303 case 0: 3304 break; 3305 case IEEE80211_WPS_RF_BAND_24GHZ: 3306 printf("2.4Ghz"); 3307 f++; 3308 break; 3309 case IEEE80211_WPS_RF_BAND_50GHZ: 3310 printf("5Ghz"); 3311 f++; 3312 break; 3313 case IEEE80211_WPS_RF_BAND_600GHZ: 3314 printf("60Ghz"); 3315 f++; 3316 break; 3317 default: 3318 printf("unknown<%02x>", 3319 *ie & (1 << n)); 3320 f++; 3321 break; 3322 } 3323 } 3324 break; 3325 case IEEE80211_WPS_ATTR_RESPONSE_TYPE: 3326 printf(" resp_type:0x%02x", *ie); 3327 break; 3328 case IEEE80211_WPS_ATTR_SELECTED_REGISTRAR: 3329 printf(" sel:%s", *ie ? "T" : "F"); 3330 break; 3331 case IEEE80211_WPS_ATTR_SERIAL_NUMBER: 3332 printf(" serial_number:<%.*s>", tlv_len, ie); 3333 break; 3334 case IEEE80211_WPS_ATTR_UUID_E: |
3199 printf(" uuid-e:"); 3200 for (n = 0; n < (tlv_len - 1); n++) 3201 printf("%02x-", ie[n]); 3202 printf("%02x", ie[n]); 3203 break; | 3335 printf(" uuid-e:"); 3336 for (n = 0; n < (tlv_len - 1); n++) 3337 printf("%02x-", ie[n]); 3338 printf("%02x", ie[n]); 3339 break; |
3340 case IEEE80211_WPS_ATTR_VENDOR_EXT: 3341 printf(" vendor:"); 3342 for (n = 0; n < tlv_len; n++) 3343 printf("%02x", ie[n]); 3344 break; 3345 case IEEE80211_WPS_ATTR_WPS_STATE: 3346 switch (*ie) { 3347 case IEEE80211_WPS_STATE_NOT_CONFIGURED: 3348 printf(" state:N"); 3349 break; 3350 case IEEE80211_WPS_STATE_CONFIGURED: 3351 printf(" state:C"); 3352 break; 3353 default: 3354 printf(" state:B<%02x>", *ie); 3355 break; 3356 } 3357 break; 3358 default: 3359 printf(" unknown_wps_attr:0x%x", tlv_type); 3360 break; |
|
3204 } 3205 ie += tlv_len, len -= tlv_len; 3206 } 3207 printf(">"); 3208 } 3209} 3210 3211static void --- 136 unchanged lines hidden (view full) --- 3348iswpsoui(const uint8_t *frm) 3349{ 3350 return frm[1] > 3 && LE_READ_4(frm+2) == ((WPS_OUI_TYPE<<24)|WPA_OUI); 3351} 3352 3353static const char * 3354iename(int elemid) 3355{ | 3361 } 3362 ie += tlv_len, len -= tlv_len; 3363 } 3364 printf(">"); 3365 } 3366} 3367 3368static void --- 136 unchanged lines hidden (view full) --- 3505iswpsoui(const uint8_t *frm) 3506{ 3507 return frm[1] > 3 && LE_READ_4(frm+2) == ((WPS_OUI_TYPE<<24)|WPA_OUI); 3508} 3509 3510static const char * 3511iename(int elemid) 3512{ |
3513 static char iename_buf[64]; |
|
3356 switch (elemid) { 3357 case IEEE80211_ELEMID_FHPARMS: return " FHPARMS"; 3358 case IEEE80211_ELEMID_CFPARMS: return " CFPARMS"; 3359 case IEEE80211_ELEMID_TIM: return " TIM"; 3360 case IEEE80211_ELEMID_IBSSPARMS:return " IBSSPARMS"; 3361 case IEEE80211_ELEMID_BSSLOAD: return " BSSLOAD"; 3362 case IEEE80211_ELEMID_CHALLENGE:return " CHALLENGE"; 3363 case IEEE80211_ELEMID_PWRCNSTR: return " PWRCNSTR"; 3364 case IEEE80211_ELEMID_PWRCAP: return " PWRCAP"; 3365 case IEEE80211_ELEMID_TPCREQ: return " TPCREQ"; 3366 case IEEE80211_ELEMID_TPCREP: return " TPCREP"; 3367 case IEEE80211_ELEMID_SUPPCHAN: return " SUPPCHAN"; 3368 case IEEE80211_ELEMID_CSA: return " CSA"; 3369 case IEEE80211_ELEMID_MEASREQ: return " MEASREQ"; 3370 case IEEE80211_ELEMID_MEASREP: return " MEASREP"; 3371 case IEEE80211_ELEMID_QUIET: return " QUIET"; 3372 case IEEE80211_ELEMID_IBSSDFS: return " IBSSDFS"; | 3514 switch (elemid) { 3515 case IEEE80211_ELEMID_FHPARMS: return " FHPARMS"; 3516 case IEEE80211_ELEMID_CFPARMS: return " CFPARMS"; 3517 case IEEE80211_ELEMID_TIM: return " TIM"; 3518 case IEEE80211_ELEMID_IBSSPARMS:return " IBSSPARMS"; 3519 case IEEE80211_ELEMID_BSSLOAD: return " BSSLOAD"; 3520 case IEEE80211_ELEMID_CHALLENGE:return " CHALLENGE"; 3521 case IEEE80211_ELEMID_PWRCNSTR: return " PWRCNSTR"; 3522 case IEEE80211_ELEMID_PWRCAP: return " PWRCAP"; 3523 case IEEE80211_ELEMID_TPCREQ: return " TPCREQ"; 3524 case IEEE80211_ELEMID_TPCREP: return " TPCREP"; 3525 case IEEE80211_ELEMID_SUPPCHAN: return " SUPPCHAN"; 3526 case IEEE80211_ELEMID_CSA: return " CSA"; 3527 case IEEE80211_ELEMID_MEASREQ: return " MEASREQ"; 3528 case IEEE80211_ELEMID_MEASREP: return " MEASREP"; 3529 case IEEE80211_ELEMID_QUIET: return " QUIET"; 3530 case IEEE80211_ELEMID_IBSSDFS: return " IBSSDFS"; |
3531 case IEEE80211_ELEMID_RESERVED_47: 3532 return " RESERVED_47"; 3533 case IEEE80211_ELEMID_MOBILITY_DOMAIN: 3534 return " MOBILITY_DOMAIN"; 3535 case IEEE80211_ELEMID_RRM_ENACAPS: 3536 return " RRM_ENCAPS"; 3537 case IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM: 3538 return " OVERLAP_BSS"; |
|
3373 case IEEE80211_ELEMID_TPC: return " TPC"; 3374 case IEEE80211_ELEMID_CCKM: return " CCKM"; | 3539 case IEEE80211_ELEMID_TPC: return " TPC"; 3540 case IEEE80211_ELEMID_CCKM: return " CCKM"; |
3541 case IEEE80211_ELEMID_EXTCAP: return " EXTCAP"; |
|
3375 } | 3542 } |
3376 return " ???"; | 3543 snprintf(iename_buf, sizeof(iename_buf), " UNKNOWN_ELEMID_%d", 3544 elemid); 3545 return (const char *) iename_buf; |
3377} 3378 3379static void 3380printies(const u_int8_t *vp, int ielen, int maxcols) 3381{ 3382 while (ielen > 0) { 3383 switch (vp[0]) { 3384 case IEEE80211_ELEMID_SSID: --- 2397 unchanged lines hidden --- | 3546} 3547 3548static void 3549printies(const u_int8_t *vp, int ielen, int maxcols) 3550{ 3551 while (ielen > 0) { 3552 switch (vp[0]) { 3553 case IEEE80211_ELEMID_SSID: --- 2397 unchanged lines hidden --- |