Home | History | Annotate | Line # | Download | only in utils
      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 	size_t num_dnsname;
     32 	struct http_othername *othername;
     33 	size_t num_othername;
     34 	struct http_logo *logo;
     35 	size_t num_logo;
     36 	const char *url;
     37 };
     38 
     39 int soap_init_client(struct http_ctx *ctx, const char *address,
     40 		     const char *ca_fname, const char *username,
     41 		     const char *password, const char *client_cert,
     42 		     const char *client_key);
     43 int soap_reinit_client(struct http_ctx *ctx);
     44 xml_node_t * soap_send_receive(struct http_ctx *ctx, xml_node_t *node);
     45 
     46 struct http_ctx * http_init_ctx(void *upper_ctx, struct xml_node_ctx *xml_ctx);
     47 void http_ocsp_set(struct http_ctx *ctx, int val);
     48 void http_deinit_ctx(struct http_ctx *ctx);
     49 
     50 int http_download_file(struct http_ctx *ctx, const char *url,
     51 		       const char *fname, const char *ca_fname);
     52 char * http_post(struct http_ctx *ctx, const char *url, const char *data,
     53 		 const char *content_type, const char *ext_hdr,
     54 		 const char *ca_fname,
     55 		 const char *username, const char *password,
     56 		 const char *client_cert, const char *client_key,
     57 		 size_t *resp_len);
     58 void http_set_cert_cb(struct http_ctx *ctx,
     59 		      int (*cb)(void *ctx, struct http_cert *cert),
     60 		      void *cb_ctx);
     61 const char * http_get_err(struct http_ctx *ctx);
     62 void http_parse_x509_certificate(struct http_ctx *ctx, const char *fname);
     63 
     64 #endif /* HTTP_UTILS_H */
     65