1 /*
2  * HTTP wrapper
3  * Copyright (c) 2012-2013, Qualcomm Atheros, Inc.
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef HTTP_UTILS_H
10 #define HTTP_UTILS_H
11 
12 struct http_ctx;
13 
14 struct http_othername {
15 	char *oid;
16 	u8 *data;
17 	size_t len;
18 };
19 
20 #define HTTP_MAX_CERT_LOGO_HASH 32
21 
22 struct http_logo {
23 	char *alg_oid;
24 	u8 *hash;
25 	size_t hash_len;
26 	char *uri;
27 };
28 
29 struct http_cert {
30 	char **dnsname;
31 	unsigned int num_dnsname;
32 	struct http_othername *othername;
33 	unsigned int num_othername;
34 	struct http_logo *logo;
35 	unsigned int num_logo;
36 };
37 
38 int soap_init_client(struct http_ctx *ctx, const char *address,
39 		     const char *ca_fname, const char *username,
40 		     const char *password, const char *client_cert,
41 		     const char *client_key);
42 int soap_reinit_client(struct http_ctx *ctx);
43 xml_node_t * soap_send_receive(struct http_ctx *ctx, xml_node_t *node);
44 
45 struct http_ctx * http_init_ctx(void *upper_ctx, struct xml_node_ctx *xml_ctx);
46 void http_ocsp_set(struct http_ctx *ctx, int val);
47 void http_deinit_ctx(struct http_ctx *ctx);
48 
49 int http_download_file(struct http_ctx *ctx, const char *url,
50 		       const char *fname, const char *ca_fname);
51 char * http_post(struct http_ctx *ctx, const char *url, const char *data,
52 		 const char *content_type, const char *ext_hdr,
53 		 const char *ca_fname,
54 		 const char *username, const char *password,
55 		 const char *client_cert, const char *client_key,
56 		 size_t *resp_len);
57 void http_set_cert_cb(struct http_ctx *ctx,
58 		      int (*cb)(void *ctx, struct http_cert *cert),
59 		      void *cb_ctx);
60 const char * http_get_err(struct http_ctx *ctx);
61 void http_parse_x509_certificate(struct http_ctx *ctx, const char *fname);
62 
63 #endif /* HTTP_UTILS_H */
64