15b9c547cSRui Paulo /* 25b9c547cSRui Paulo * HTTP wrapper 35b9c547cSRui Paulo * Copyright (c) 2012-2013, Qualcomm Atheros, Inc. 45b9c547cSRui Paulo * 55b9c547cSRui Paulo * This software may be distributed under the terms of the BSD license. 65b9c547cSRui Paulo * See README for more details. 75b9c547cSRui Paulo */ 85b9c547cSRui Paulo 95b9c547cSRui Paulo #ifndef HTTP_UTILS_H 105b9c547cSRui Paulo #define HTTP_UTILS_H 115b9c547cSRui Paulo 125b9c547cSRui Paulo struct http_ctx; 135b9c547cSRui Paulo 145b9c547cSRui Paulo struct http_othername { 155b9c547cSRui Paulo char *oid; 165b9c547cSRui Paulo u8 *data; 175b9c547cSRui Paulo size_t len; 185b9c547cSRui Paulo }; 195b9c547cSRui Paulo 205b9c547cSRui Paulo #define HTTP_MAX_CERT_LOGO_HASH 32 215b9c547cSRui Paulo 225b9c547cSRui Paulo struct http_logo { 235b9c547cSRui Paulo char *alg_oid; 245b9c547cSRui Paulo u8 *hash; 255b9c547cSRui Paulo size_t hash_len; 265b9c547cSRui Paulo char *uri; 275b9c547cSRui Paulo }; 285b9c547cSRui Paulo 295b9c547cSRui Paulo struct http_cert { 305b9c547cSRui Paulo char **dnsname; 31c1d255d3SCy Schubert size_t num_dnsname; 325b9c547cSRui Paulo struct http_othername *othername; 33c1d255d3SCy Schubert size_t num_othername; 345b9c547cSRui Paulo struct http_logo *logo; 35c1d255d3SCy Schubert size_t num_logo; 36*a90b9d01SCy Schubert const char *url; 375b9c547cSRui Paulo }; 385b9c547cSRui Paulo 395b9c547cSRui Paulo int soap_init_client(struct http_ctx *ctx, const char *address, 405b9c547cSRui Paulo const char *ca_fname, const char *username, 415b9c547cSRui Paulo const char *password, const char *client_cert, 425b9c547cSRui Paulo const char *client_key); 435b9c547cSRui Paulo int soap_reinit_client(struct http_ctx *ctx); 445b9c547cSRui Paulo xml_node_t * soap_send_receive(struct http_ctx *ctx, xml_node_t *node); 455b9c547cSRui Paulo 465b9c547cSRui Paulo struct http_ctx * http_init_ctx(void *upper_ctx, struct xml_node_ctx *xml_ctx); 475b9c547cSRui Paulo void http_ocsp_set(struct http_ctx *ctx, int val); 485b9c547cSRui Paulo void http_deinit_ctx(struct http_ctx *ctx); 495b9c547cSRui Paulo 505b9c547cSRui Paulo int http_download_file(struct http_ctx *ctx, const char *url, 515b9c547cSRui Paulo const char *fname, const char *ca_fname); 525b9c547cSRui Paulo char * http_post(struct http_ctx *ctx, const char *url, const char *data, 535b9c547cSRui Paulo const char *content_type, const char *ext_hdr, 545b9c547cSRui Paulo const char *ca_fname, 555b9c547cSRui Paulo const char *username, const char *password, 565b9c547cSRui Paulo const char *client_cert, const char *client_key, 575b9c547cSRui Paulo size_t *resp_len); 585b9c547cSRui Paulo void http_set_cert_cb(struct http_ctx *ctx, 595b9c547cSRui Paulo int (*cb)(void *ctx, struct http_cert *cert), 605b9c547cSRui Paulo void *cb_ctx); 615b9c547cSRui Paulo const char * http_get_err(struct http_ctx *ctx); 625b9c547cSRui Paulo void http_parse_x509_certificate(struct http_ctx *ctx, const char *fname); 635b9c547cSRui Paulo 645b9c547cSRui Paulo #endif /* HTTP_UTILS_H */ 65