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