]>
Commit | Line | Data |
---|---|---|
ad08c363 JM |
1 | /* |
2 | * Wi-Fi Protected Setup | |
3 | * Copyright (c) 2007, Jouni Malinen <j@w1.fi> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
15 | #ifndef WPS_H | |
16 | #define WPS_H | |
17 | ||
18 | enum wsc_op_code { | |
19 | WSC_Start = 0x01, | |
20 | WSC_ACK = 0x02, | |
21 | WSC_NACK = 0x03, | |
22 | WSC_MSG = 0x04, | |
23 | WSC_Done = 0x05, | |
24 | WSC_FRAG_ACK = 0x06 | |
25 | }; | |
26 | ||
27 | struct wps_registrar; | |
28 | ||
29 | struct wps_credential { | |
30 | u8 ssid[32]; | |
31 | size_t ssid_len; | |
32 | u16 auth_type; | |
33 | u16 encr_type; | |
34 | u8 key_idx; | |
35 | u8 key[64]; | |
36 | size_t key_len; | |
37 | u8 mac_addr[ETH_ALEN]; | |
38 | }; | |
39 | ||
40 | struct wps_config { | |
41 | int authenticator; | |
42 | struct wps_context *wps; | |
43 | struct wps_registrar *registrar; /* NULL for Enrollee */ | |
44 | const u8 *enrollee_mac_addr; /* NULL for Registrar */ | |
45 | const u8 *pin; /* Enrollee Device Password (NULL for Registrar or PBC) | |
46 | */ | |
47 | size_t pin_len; | |
48 | const u8 *uuid; /* 128-bit Enrollee UUID (NULL for Registrar) */ | |
49 | int pbc; | |
ad08c363 JM |
50 | }; |
51 | ||
52 | struct wps_data * wps_init(const struct wps_config *cfg); | |
53 | ||
54 | void wps_deinit(struct wps_data *data); | |
55 | ||
56 | enum wps_process_res { | |
57 | WPS_DONE, WPS_CONTINUE, WPS_FAILURE, WPS_PENDING | |
58 | }; | |
59 | enum wps_process_res wps_process_msg(struct wps_data *wps, u8 op_code, | |
60 | const struct wpabuf *msg); | |
61 | ||
62 | struct wpabuf * wps_get_msg(struct wps_data *wps, u8 *op_code); | |
63 | ||
64 | int wps_is_selected_pbc_registrar(const u8 *buf, size_t len); | |
65 | int wps_is_selected_pin_registrar(const u8 *buf, size_t len); | |
66 | const u8 * wps_get_uuid_e(const u8 *buf, size_t len); | |
67 | ||
68 | ||
69 | struct wps_device_data { | |
70 | u8 mac_addr[ETH_ALEN]; | |
71 | char *device_name; | |
72 | char *manufacturer; | |
73 | char *model_name; | |
74 | char *model_number; | |
75 | char *serial_number; | |
76 | u16 categ; | |
77 | u32 oui; | |
78 | u16 sub_categ; | |
79 | u32 os_version; | |
80 | }; | |
81 | ||
82 | ||
83 | struct wps_registrar_config { | |
84 | int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk, | |
85 | size_t psk_len); | |
86 | int (*set_ie_cb)(void *ctx, const u8 *beacon_ie, size_t beacon_ie_len, | |
87 | const u8 *probe_resp_ie, size_t probe_resp_ie_len); | |
88 | void (*pin_needed_cb)(void *ctx, const u8 *uuid_e, | |
89 | const struct wps_device_data *dev); | |
90 | void *cb_ctx; | |
91 | }; | |
92 | ||
93 | ||
94 | struct wps_context { | |
95 | int ap; | |
96 | struct wps_registrar *registrar; | |
97 | int wps_state; | |
98 | int ap_setup_locked; | |
99 | u8 uuid[16]; | |
100 | u8 ssid[32]; | |
101 | size_t ssid_len; | |
102 | struct wps_device_data dev; | |
103 | u16 config_methods; /* bit field of WPS_CONFIG_* */ | |
104 | u16 encr_types; /* bit field of WPS_ENCR_* */ | |
105 | u16 auth_types; /* bit field of WPS_AUTH_* */ | |
106 | u8 *network_key; /* or NULL to generate per-device PSK */ | |
107 | size_t network_key_len; | |
108 | ||
109 | int (*cred_cb)(void *ctx, const struct wps_credential *cred); | |
110 | void *cb_ctx; | |
111 | }; | |
112 | ||
113 | ||
114 | struct wps_registrar * | |
115 | wps_registrar_init(struct wps_context *wps, | |
116 | const struct wps_registrar_config *cfg); | |
117 | void wps_registrar_deinit(struct wps_registrar *reg); | |
118 | int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *uuid, | |
119 | const u8 *pin, size_t pin_len); | |
120 | int wps_registrar_invalidate_pin(struct wps_registrar *reg, const u8 *uuid); | |
121 | int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid); | |
122 | int wps_registrar_button_pushed(struct wps_registrar *reg); | |
123 | void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr, | |
124 | const struct wpabuf *wps_data); | |
125 | ||
126 | struct wpabuf * wps_enrollee_build_assoc_req_ie(void); | |
127 | struct wpabuf * wps_enrollee_build_probe_req_ie(int pbc, const u8 *uuid); | |
128 | ||
129 | #endif /* WPS_H */ |