aboutsummaryrefslogtreecommitdiffstats
path: root/src/wps/wps.h
blob: c4459b5307c5ea1ccefb17e099b17fa24869f015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Wi-Fi Protected Setup
 * Copyright (c) 2007, Jouni Malinen <j@w1.fi>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Alternatively, this software may be distributed under the terms of BSD
 * license.
 *
 * See README and COPYING for more details.
 */

#ifndef WPS_H
#define WPS_H

enum wsc_op_code {
	WSC_Start = 0x01,
	WSC_ACK = 0x02,
	WSC_NACK = 0x03,
	WSC_MSG = 0x04,
	WSC_Done = 0x05,
	WSC_FRAG_ACK = 0x06
};

struct wps_registrar;

struct wps_config {
	int authenticator;
	struct wps_registrar *registrar; /* NULL for Enrollee */
	const u8 *enrollee_mac_addr; /* NULL for Registrar */
	const u8 *pin; /* Enrollee Device Password (NULL for Registrar) */
	size_t pin_len;
	const u8 *uuid; /* 128-bit Enrollee UUID (NULL for Registrar) */
};

struct wps_data * wps_init(const struct wps_config *cfg);

void wps_deinit(struct wps_data *data);

enum wps_process_res {
	WPS_DONE, WPS_CONTINUE, WPS_FAILURE, WPS_PENDING
};
enum wps_process_res wps_process_msg(struct wps_data *wps, u8 op_code,
				     const struct wpabuf *msg);

struct wpabuf * wps_get_msg(struct wps_data *wps, u8 *op_code);


struct wps_registrar_config {
	int wps_state;
	const u8 *uuid;
	const u8 *ssid;
	size_t ssid_len;
	u16 encr_types; /* bit field of WPS_ENCR_* */
	u16 auth_types; /* bit field of WPS_AUTH_* */
	const u8 *network_key; /* or NULL to generate per-device PSK */
	size_t network_key_len;

	int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk,
			  size_t psk_len);
	void *cb_ctx;
};

struct wps_registrar *
wps_registrar_init(const struct wps_registrar_config *cfg);
void wps_registrar_deinit(struct wps_registrar *reg);
int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *uuid,
			  const u8 *pin, size_t pin_len);

#endif /* WPS_H */