http-utils.h revision 303975
168349Sobrien/*
268349Sobrien * HTTP wrapper
368349Sobrien * Copyright (c) 2012-2013, Qualcomm Atheros, Inc.
468349Sobrien *
568349Sobrien * This software may be distributed under the terms of the BSD license.
668349Sobrien * See README for more details.
768349Sobrien */
868349Sobrien
968349Sobrien#ifndef HTTP_UTILS_H
1068349Sobrien#define HTTP_UTILS_H
1168349Sobrien
1268349Sobrienstruct http_ctx;
1368349Sobrien
1468349Sobrienstruct http_othername {
1568349Sobrien	char *oid;
1668349Sobrien	u8 *data;
1768349Sobrien	size_t len;
1880588Sobrien};
1980588Sobrien
2068349Sobrien#define HTTP_MAX_CERT_LOGO_HASH 32
2168349Sobrien
2268349Sobrienstruct http_logo {
2368349Sobrien	char *alg_oid;
2468349Sobrien	u8 *hash;
2568349Sobrien	size_t hash_len;
2668349Sobrien	char *uri;
2768349Sobrien};
2868349Sobrien
2968349Sobrienstruct http_cert {
3068349Sobrien	char **dnsname;
3168349Sobrien	unsigned int num_dnsname;
3268349Sobrien	struct http_othername *othername;
3368349Sobrien	unsigned int num_othername;
3468349Sobrien	struct http_logo *logo;
3568349Sobrien	unsigned int num_logo;
3668349Sobrien};
3768349Sobrien
3868349Sobrienint soap_init_client(struct http_ctx *ctx, const char *address,
3968349Sobrien		     const char *ca_fname, const char *username,
4068349Sobrien		     const char *password, const char *client_cert,
4168349Sobrien		     const char *client_key);
4268349Sobrienint soap_reinit_client(struct http_ctx *ctx);
4368349Sobrienxml_node_t * soap_send_receive(struct http_ctx *ctx, xml_node_t *node);
4468349Sobrien
4568349Sobrienstruct http_ctx * http_init_ctx(void *upper_ctx, struct xml_node_ctx *xml_ctx);
4668349Sobrienvoid http_ocsp_set(struct http_ctx *ctx, int val);
4768349Sobrienvoid http_deinit_ctx(struct http_ctx *ctx);
4868349Sobrien
4968349Sobrienint http_download_file(struct http_ctx *ctx, const char *url,
5068349Sobrien		       const char *fname, const char *ca_fname);
5168349Sobrienchar * http_post(struct http_ctx *ctx, const char *url, const char *data,
5268349Sobrien		 const char *content_type, const char *ext_hdr,
5368349Sobrien		 const char *ca_fname,
5468349Sobrien		 const char *username, const char *password,
5568349Sobrien		 const char *client_cert, const char *client_key,
5668349Sobrien		 size_t *resp_len);
5768349Sobrienvoid http_set_cert_cb(struct http_ctx *ctx,
5868349Sobrien		      int (*cb)(void *ctx, struct http_cert *cert),
5968349Sobrien		      void *cb_ctx);
6068349Sobrienconst char * http_get_err(struct http_ctx *ctx);
6168349Sobrienvoid http_parse_x509_certificate(struct http_ctx *ctx, const char *fname);
6268349Sobrien
6368349Sobrien#endif /* HTTP_UTILS_H */
6468349Sobrien