Ignore:
Timestamp:
2015-04-23T23:40:14Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dcba819
Parents:
09044cb
Message:

pre-merge coding style cleanup and code review

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ieee80211/include/ieee80211_private.h

    r09044cb r8a64320e  
    2727 */
    2828
    29 /** 
     29/**
    3030 * @addtogroup libieee80211
    3131 * @{
     
    3333
    3434/** @file ieee80211.h
    35  * 
     35 *
    3636 * Internal IEEE 802.11 header that should not be included.
    3737 */
    3838
    39 #ifndef LIBNET_IEEE80211_PRIVATE_H
    40 #define LIBNET_IEEE80211_PRIVATE_H
     39#ifndef LIB_IEEE80211_PRIVATE_H
     40#define LIB_IEEE80211_PRIVATE_H
    4141
    4242#include <fibril_synch.h>
     
    4444#include <ddf/driver.h>
    4545#include <sys/types.h>
    46 
    4746#include <ieee80211/ieee80211.h>
    4847#include "ieee80211.h"
    4948
    50 /* Timeout in us for waiting to authentication/association response. */
    51 #define AUTH_TIMEOUT 200000
    52 
    53 /* Timeout in us for waiting to finish 4-way handshake process. */
    54 #define HANDSHAKE_TIMEOUT 5000000
    55 
    56 /* Scanning period. */
    57 #define SCAN_PERIOD_USEC 35000000
    58 
    59 /* Time to wait for beacons on channel. */
    60 #define SCAN_CHANNEL_WAIT_USEC 200000
    61 
    62 /* Max time to keep scan result. */
    63 #define MAX_KEEP_SCAN_SPAN_SEC 120
    64 
    65 /* Security bit in capability info field. */
    66 #define CAP_SECURITY 0x10
    67 
    68 /* Protocol type used in EAPOL frames. */
    69 #define ETH_TYPE_PAE 0x888E
    70 
    71 /* WPA OUI used in vendor specific IE. */
    72 #define WPA_OUI 0x0050F201
    73 
    74 /* GTK OUI used in vendor specific IE. */
    75 #define GTK_OUI 0x000FAC01
    76 
    77 /* Max PTK key length. */
    78 #define MAX_PTK_LENGTH 64
    79 
    80 /* Max GTK key length. */
    81 #define MAX_GTK_LENGTH 64
    82 
    83 /* KEK offset inside PTK. */
    84 #define KEK_OFFSET 16
    85 
    86 /* TK offset inside PTK. */
    87 #define TK_OFFSET 32
    88 
    89 /* Length of Michael MIC code used in TKIP security suite. */
    90 #define MIC_LENGTH 8
    91 
    92 /*
    93  * Length of data to be encrypted by PRF function:
    94  * NONCE + SNONCE (2 * 32) + DEST_MAC + SOURCE_MAC (2 * ETH_ADDR)
     49/** Timeout in us for waiting to authentication/association response. */
     50#define AUTH_TIMEOUT  200000
     51
     52/** Timeout in us for waiting to finish 4-way handshake process. */
     53#define HANDSHAKE_TIMEOUT  5000000
     54
     55/** Scanning period. */
     56#define SCAN_PERIOD_USEC  35000000
     57
     58/** Time to wait for beacons on channel. */
     59#define SCAN_CHANNEL_WAIT_USEC  200000
     60
     61/** Max time to keep scan result. */
     62#define MAX_KEEP_SCAN_SPAN_SEC  120
     63
     64/** Security bit in capability info field. */
     65#define CAP_SECURITY  0x10
     66
     67/** Protocol type used in EAPOL frames. */
     68#define ETH_TYPE_PAE  0x888e
     69
     70/** WPA OUI used in vendor specific IE. */
     71#define WPA_OUI  0x0050f201
     72
     73/** GTK OUI used in vendor specific IE. */
     74#define GTK_OUI  0x000fac01
     75
     76/** Max PTK key length. */
     77#define MAX_PTK_LENGTH  64
     78
     79/** Max GTK key length. */
     80#define MAX_GTK_LENGTH  64
     81
     82/** KEK offset inside PTK. */
     83#define KEK_OFFSET  16
     84
     85/** TK offset inside PTK. */
     86#define TK_OFFSET  32
     87
     88/** Length of Michael MIC code used in TKIP security suite. */
     89#define MIC_LENGTH  8
     90
     91/** Length of data to be encrypted by PRF function.
     92 *
     93 * NONCE + SNONCE (2 * 32) + DEST_MAC + SOURCE_MAC (2 * ETH_ADDR)
     94 *
    9595 */
    96 #define PRF_CRYPT_DATA_LENGTH 2*32 + 2*ETH_ADDR
    97 
    98 /* Special room in header reserved for encryption. */
     96#define PRF_CRYPT_DATA_LENGTH  (2 * 32 + 2 * ETH_ADDR)
     97
     98/** Special room in header reserved for encryption. */
    9999typedef enum {
    100100        IEEE80211_TKIP_HEADER_LENGTH = 8,
     
    184184/** IEEE 802.11 information element types. */
    185185typedef enum {
    186         IEEE80211_SSID_IE = 0,          /**< Target SSID. */
    187         IEEE80211_RATES_IE = 1,         /**< Supported data rates. */
    188         IEEE80211_CHANNEL_IE = 3,       /**< Current channel number. */
    189         IEEE80211_CHALLENGE_IE = 16,    /**< Challenge text. */
    190         IEEE80211_RSN_IE = 48,          /**< RSN. */
    191         IEEE80211_EXT_RATES_IE = 50,    /**< Extended data rates. */
    192         IEEE80211_VENDOR_IE = 221       /**< Vendor specific IE. */
     186        IEEE80211_SSID_IE = 0,        /**< Target SSID. */
     187        IEEE80211_RATES_IE = 1,       /**< Supported data rates. */
     188        IEEE80211_CHANNEL_IE = 3,     /**< Current channel number. */
     189        IEEE80211_CHALLENGE_IE = 16,  /**< Challenge text. */
     190        IEEE80211_RSN_IE = 48,        /**< RSN. */
     191        IEEE80211_EXT_RATES_IE = 50,  /**< Extended data rates. */
     192        IEEE80211_VENDOR_IE = 221     /**< Vendor specific IE. */
    193193} ieee80211_ie_type_t;
    194194
     
    249249        ieee80211_bssid_info_t bssid_info;
    250250       
    251         /** 
     251        /**
    252252         * Flag indicating that data traffic is encrypted by HW key
    253          * that is set up in device. 
     253         * that is set up in device.
    254254         */
    255255        bool using_hw_key;
     
    290290        uint8_t dest_addr[ETH_ADDR];
    291291        uint8_t src_addr[ETH_ADDR];
    292         uint16_t proto;                 /**< Big Endian value! */
    293 } __attribute__((packed)) __attribute__ ((aligned(2)))
    294         eth_header_t;
     292        uint16_t proto;  /**< Big Endian value! */
     293} __attribute__((packed)) __attribute__((aligned(2)))
     294    eth_header_t;
    295295
    296296/** IEEE 802.11 management header structure. */
    297297typedef struct {
    298         uint16_t frame_ctrl;            /**< Little Endian value! */
    299         uint16_t duration_id;           /**< Little Endian value! */
     298        uint16_t frame_ctrl;          /**< Little Endian value! */
     299        uint16_t duration_id;         /**< Little Endian value! */
    300300        uint8_t dest_addr[ETH_ADDR];
    301301        uint8_t src_addr[ETH_ADDR];
    302302        uint8_t bssid[ETH_ADDR];
    303         uint16_t seq_ctrl;              /**< Little Endian value! */
    304 } __attribute__((packed)) __attribute__ ((aligned(2)))
    305         ieee80211_mgmt_header_t;
     303        uint16_t seq_ctrl;            /**< Little Endian value! */
     304} __attribute__((packed)) __attribute__((aligned(2)))
     305    ieee80211_mgmt_header_t;
    306306
    307307/** IEEE 802.11 data header structure. */
    308308typedef struct {
    309         uint16_t frame_ctrl;            /**< Little Endian value! */
    310         uint16_t duration_id;           /**< Little Endian value! */
     309        uint16_t frame_ctrl;         /**< Little Endian value! */
     310        uint16_t duration_id;        /**< Little Endian value! */
    311311        uint8_t address1[ETH_ADDR];
    312312        uint8_t address2[ETH_ADDR];
    313313        uint8_t address3[ETH_ADDR];
    314         uint16_t seq_ctrl;              /**< Little Endian value! */
    315 } __attribute__((packed)) __attribute__ ((aligned(2)))
    316         ieee80211_data_header_t;
     314        uint16_t seq_ctrl;           /**< Little Endian value! */
     315} __attribute__((packed)) __attribute__((aligned(2)))
     316    ieee80211_data_header_t;
    317317
    318318/** IEEE 802.11 information element header. */
     
    320320        uint8_t element_id;
    321321        uint8_t length;
    322 } __attribute__((packed)) __attribute__ ((aligned(2)))
    323         ieee80211_ie_header_t;
     322} __attribute__((packed)) __attribute__((aligned(2)))
     323    ieee80211_ie_header_t;
    324324
    325325/** IEEE 802.11 authentication frame body. */
    326326typedef struct {
    327         uint16_t auth_alg;              /**< Little Endian value! */
    328         uint16_t auth_trans_no;         /**< Little Endian value! */
    329         uint16_t status;                /**< Little Endian value! */
    330 } __attribute__((packed)) __attribute__ ((aligned(2)))
    331         ieee80211_auth_body_t;
     327        uint16_t auth_alg;       /**< Little Endian value! */
     328        uint16_t auth_trans_no;  /**< Little Endian value! */
     329        uint16_t status;         /**< Little Endian value! */
     330} __attribute__((packed)) __attribute__((aligned(2)))
     331    ieee80211_auth_body_t;
    332332
    333333/** IEEE 802.11 deauthentication frame body. */
    334334typedef struct {
    335         uint16_t reason;                /**< Little Endian value! */
    336 } __attribute__((packed)) __attribute__ ((aligned(2)))
    337         ieee80211_deauth_body_t;
     335        uint16_t reason;    /**< Little Endian value! */
     336} __attribute__((packed)) __attribute__((aligned(2)))
     337    ieee80211_deauth_body_t;
    338338
    339339/** IEEE 802.11 association request frame body. */
    340340typedef struct {
    341         uint16_t capability;            /**< Little Endian value! */
    342         uint16_t listen_interval;       /**< Little Endian value! */
    343 } __attribute__((packed)) __attribute__ ((aligned(2)))
    344         ieee80211_assoc_req_body_t;
     341        uint16_t capability;       /**< Little Endian value! */
     342        uint16_t listen_interval;  /**< Little Endian value! */
     343} __attribute__((packed)) __attribute__((aligned(2)))
     344    ieee80211_assoc_req_body_t;
    345345
    346346/** IEEE 802.11 association response frame body. */
    347347typedef struct {
    348         uint16_t capability;            /**< Little Endian value! */
    349         uint16_t status;                /**< Little Endian value! */
    350         uint16_t aid;                   /**< Little Endian value! */
    351 } __attribute__((packed)) __attribute__ ((aligned(2)))
    352         ieee80211_assoc_resp_body_t;
     348        uint16_t capability;  /**< Little Endian value! */
     349        uint16_t status;      /**< Little Endian value! */
     350        uint16_t aid;         /**< Little Endian value! */
     351} __attribute__((packed)) __attribute__((aligned(2)))
     352    ieee80211_assoc_resp_body_t;
    353353
    354354/** IEEE 802.11 beacon frame body start. */
    355355typedef struct {
    356356        uint8_t timestamp[8];
    357         uint16_t beacon_interval;       /**< Little Endian value! */
    358         uint16_t capability;            /**< Little Endian value! */
    359 } __attribute__((packed)) __attribute__ ((aligned(2)))
    360         ieee80211_beacon_start_t;
     357        uint16_t beacon_interval;  /**< Little Endian value! */
     358        uint16_t capability;       /**< Little Endian value! */
     359} __attribute__((packed)) __attribute__((aligned(2)))
     360    ieee80211_beacon_start_t;
    361361
    362362/** IEEE 802.11i EAPOL-Key frame format. */
     
    364364        uint8_t proto_version;
    365365        uint8_t packet_type;
    366         uint16_t body_length;           /**< Big Endian value! */
     366        uint16_t body_length;      /**< Big Endian value! */
    367367        uint8_t descriptor_type;
    368         uint16_t key_info;              /**< Big Endian value! */
    369         uint16_t key_length;            /**< Big Endian value! */
     368        uint16_t key_info;         /**< Big Endian value! */
     369        uint16_t key_length;       /**< Big Endian value! */
    370370        uint8_t key_replay_counter[8];
    371371        uint8_t key_nonce[32];
     
    374374        uint8_t reserved[8];
    375375        uint8_t key_mic[16];
    376         uint16_t key_data_length;       /**< Big Endian value! */
     376        uint16_t key_data_length;  /**< Big Endian value! */
    377377} __attribute__((packed)) ieee80211_eapol_key_frame_t;
    378378
    379379#define ieee80211_scan_result_list_foreach(results, iter) \
    380     list_foreach((results).list, link, ieee80211_scan_result_link_t, (iter))
    381 
    382 static inline void ieee80211_scan_result_list_init(
    383         ieee80211_scan_result_list_t *results)
     380        list_foreach((results).list, link, ieee80211_scan_result_link_t, (iter))
     381
     382static inline void
     383    ieee80211_scan_result_list_init(ieee80211_scan_result_list_t *results)
    384384{
    385385        list_initialize(&results->list);
     
    387387}
    388388
    389 static inline void ieee80211_scan_result_list_remove(
    390         ieee80211_scan_result_list_t *results,
    391         ieee80211_scan_result_link_t *result)
     389static inline void
     390    ieee80211_scan_result_list_remove(ieee80211_scan_result_list_t *results,
     391    ieee80211_scan_result_link_t *result)
    392392{
    393393        list_remove(&result->link);
     
    395395}
    396396
    397 static inline void ieee80211_scan_result_list_append(
    398         ieee80211_scan_result_list_t *results,
    399         ieee80211_scan_result_link_t *result)
     397static inline void
     398    ieee80211_scan_result_list_append(ieee80211_scan_result_list_t *results,
     399    ieee80211_scan_result_link_t *result)
    400400{
    401401        list_append(&result->link, &results->list);
     
    403403}
    404404
    405 extern bool ieee80211_is_fromds_frame(uint16_t frame_ctrl);
    406 extern bool ieee80211_is_tods_frame(uint16_t frame_ctrl);
    407 extern void ieee80211_set_connect_request(ieee80211_dev_t *ieee80211_dev);
    408 extern bool ieee80211_pending_connect_request(ieee80211_dev_t *ieee80211_dev);
    409 extern ieee80211_auth_phase_t ieee80211_get_auth_phase(ieee80211_dev_t
    410         *ieee80211_dev);
    411 extern void ieee80211_set_auth_phase(ieee80211_dev_t *ieee80211_dev,
    412         ieee80211_auth_phase_t auth_phase);
    413 extern int ieee80211_probe_request(ieee80211_dev_t *ieee80211_dev,
    414         char *ssid);
    415 extern int ieee80211_authenticate(ieee80211_dev_t *ieee80211_dev);
    416 extern int ieee80211_associate(ieee80211_dev_t *ieee80211_dev,
    417         char *password);
    418 extern int ieee80211_deauthenticate(ieee80211_dev_t *ieee80211_dev);
    419 
    420 #endif /* LIBN_IEEE80211_H */
     405extern bool ieee80211_is_fromds_frame(uint16_t);
     406extern bool ieee80211_is_tods_frame(uint16_t);
     407extern void ieee80211_set_connect_request(ieee80211_dev_t *);
     408extern bool ieee80211_pending_connect_request(ieee80211_dev_t *);
     409extern ieee80211_auth_phase_t ieee80211_get_auth_phase(ieee80211_dev_t *);
     410extern void ieee80211_set_auth_phase(ieee80211_dev_t *, ieee80211_auth_phase_t);
     411extern int ieee80211_probe_request(ieee80211_dev_t *, char *);
     412extern int ieee80211_authenticate(ieee80211_dev_t *);
     413extern int ieee80211_associate(ieee80211_dev_t *, char *);
     414extern int ieee80211_deauthenticate(ieee80211_dev_t *);
     415
     416#endif
    421417
    422418/** @}
Note: See TracChangeset for help on using the changeset viewer.