blob: 9b45b03febe2413c6d5cf29528cd394dfb2bdaab [file] [log] [blame]
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -07001/*
2 * Hotspot 2.0 - OSU client
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -07003 * Copyright (c) 2013-2014, Qualcomm Atheros, Inc.
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -07004 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#ifndef OSU_CLIENT_H
10#define OSU_CLIENT_H
11
12#define SPP_NS_URI "http://www.wi-fi.org/specifications/hotspot2dot0/v1.0/spp"
13
14#define URN_OMA_DM_DEVINFO "urn:oma:mo:oma-dm-devinfo:1.0"
15#define URN_OMA_DM_DEVDETAIL "urn:oma:mo:oma-dm-devdetail:1.0"
16#define URN_HS20_DEVDETAIL_EXT "urn:wfa:mo-ext:hotspot2dot0-devdetail-ext:1.0"
17#define URN_HS20_PPS "urn:wfa:mo:hotspot2dot0-perprovidersubscription:1.0"
18
19
20#define MAX_OSU_VALS 10
21
22struct osu_lang_text {
23 char lang[4];
24 char text[253];
25};
26
27struct hs20_osu_client {
28 struct xml_node_ctx *xml;
29 struct http_ctx *http;
30 int no_reconnect;
31 char pps_fname[300];
32 char *devid;
33 const char *result_file;
34 const char *summary_file;
35 const char *ifname;
36 const char *ca_fname;
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070037 int no_osu_cert_validation; /* for EST operations */
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070038 char *fqdn;
39 char *server_url;
40 struct osu_lang_text friendly_name[MAX_OSU_VALS];
41 size_t friendly_name_count;
42 size_t icon_count;
43 char icon_filename[MAX_OSU_VALS][256];
44 u8 icon_hash[MAX_OSU_VALS][32];
45 int pps_cred_set;
46 int pps_updated;
47 int client_cert_present;
48 char **server_dnsname;
49 size_t server_dnsname_count;
Hai Shalom39ba6fc2019-01-22 12:40:38 -080050 const char *osu_ssid; /* Enforced OSU_SSID for testing purposes */
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070051#define WORKAROUND_OCSP_OPTIONAL 0x00000001
52 unsigned long int workarounds;
Hai Shalomfdcde762020-04-02 11:19:20 -070053 int ignore_tls; /* whether to ignore TLS validation issues with HTTPS
54 * server certificate */
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070055};
56
57
58/* osu_client.c */
59
60void write_result(struct hs20_osu_client *ctx, const char *fmt, ...)
61 __attribute__ ((format (printf, 2, 3)));
62void write_summary(struct hs20_osu_client *ctx, const char *fmt, ...)
63 __attribute__ ((format (printf, 2, 3)));
64
65void debug_dump_node(struct hs20_osu_client *ctx, const char *title,
66 xml_node_t *node);
67int osu_get_certificate(struct hs20_osu_client *ctx, xml_node_t *getcert);
68int hs20_add_pps_mo(struct hs20_osu_client *ctx, const char *uri,
69 xml_node_t *add_mo, char *fname, size_t fname_len);
70void get_user_pw(struct hs20_osu_client *ctx, xml_node_t *pps,
71 const char *alt_loc, char **user, char **pw);
72int update_pps_file(struct hs20_osu_client *ctx, const char *pps_fname,
73 xml_node_t *pps);
74void cmd_set_pps(struct hs20_osu_client *ctx, const char *pps_fname);
75
76
77/* spp_client.c */
78
79void spp_sub_rem(struct hs20_osu_client *ctx, const char *address,
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070080 const char *pps_fname,
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070081 const char *client_cert, const char *client_key,
82 const char *cred_username, const char *cred_password,
83 xml_node_t *pps);
84void spp_pol_upd(struct hs20_osu_client *ctx, const char *address,
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070085 const char *pps_fname,
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070086 const char *client_cert, const char *client_key,
87 const char *cred_username, const char *cred_password,
88 xml_node_t *pps);
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070089int cmd_prov(struct hs20_osu_client *ctx, const char *url);
90int cmd_sim_prov(struct hs20_osu_client *ctx, const char *url);
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070091
92
93/* oma_dm_client.c */
94
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070095int cmd_oma_dm_prov(struct hs20_osu_client *ctx, const char *url);
96int cmd_oma_dm_sim_prov(struct hs20_osu_client *ctx, const char *url);
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070097void oma_dm_sub_rem(struct hs20_osu_client *ctx, const char *address,
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -070098 const char *pps_fname,
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -070099 const char *client_cert, const char *client_key,
100 const char *cred_username, const char *cred_password,
101 xml_node_t *pps);
102void oma_dm_pol_upd(struct hs20_osu_client *ctx, const char *address,
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -0700103 const char *pps_fname,
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -0700104 const char *client_cert, const char *client_key,
105 const char *cred_username, const char *cred_password,
106 xml_node_t *pps);
107void cmd_oma_dm_sub_rem(struct hs20_osu_client *ctx, const char *address,
Dmitry Shmidt6cb1f652014-03-21 10:54:03 -0700108 const char *pps_fname);
Dmitry Shmidtd5dc24e2014-03-12 14:22:04 -0700109void cmd_oma_dm_add(struct hs20_osu_client *ctx, const char *pps_fname,
110 const char *add_fname);
111void cmd_oma_dm_replace(struct hs20_osu_client *ctx, const char *pps_fname,
112 const char *replace_fname);
113
114/* est.c */
115
116int est_load_cacerts(struct hs20_osu_client *ctx, const char *url);
117int est_build_csr(struct hs20_osu_client *ctx, const char *url);
118int est_simple_enroll(struct hs20_osu_client *ctx, const char *url,
119 const char *user, const char *pw);
120
121#endif /* OSU_CLIENT_H */