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