13c260e60Schristos /* 23c260e60Schristos * HTTP wrapper 33c260e60Schristos * Copyright (c) 2012-2013, Qualcomm Atheros, Inc. 43c260e60Schristos * 53c260e60Schristos * This software may be distributed under the terms of the BSD license. 63c260e60Schristos * See README for more details. 73c260e60Schristos */ 83c260e60Schristos 93c260e60Schristos #ifndef HTTP_UTILS_H 103c260e60Schristos #define HTTP_UTILS_H 113c260e60Schristos 123c260e60Schristos struct http_ctx; 133c260e60Schristos 143c260e60Schristos struct http_othername { 153c260e60Schristos char *oid; 163c260e60Schristos u8 *data; 173c260e60Schristos size_t len; 183c260e60Schristos }; 193c260e60Schristos 203c260e60Schristos #define HTTP_MAX_CERT_LOGO_HASH 32 213c260e60Schristos 223c260e60Schristos struct http_logo { 233c260e60Schristos char *alg_oid; 243c260e60Schristos u8 *hash; 253c260e60Schristos size_t hash_len; 263c260e60Schristos char *uri; 273c260e60Schristos }; 283c260e60Schristos 293c260e60Schristos struct http_cert { 303c260e60Schristos char **dnsname; 31*bb618362Schristos size_t num_dnsname; 323c260e60Schristos struct http_othername *othername; 33*bb618362Schristos size_t num_othername; 343c260e60Schristos struct http_logo *logo; 35*bb618362Schristos size_t num_logo; 36*bb618362Schristos const char *url; 373c260e60Schristos }; 383c260e60Schristos 393c260e60Schristos int soap_init_client(struct http_ctx *ctx, const char *address, 403c260e60Schristos const char *ca_fname, const char *username, 413c260e60Schristos const char *password, const char *client_cert, 423c260e60Schristos const char *client_key); 433c260e60Schristos int soap_reinit_client(struct http_ctx *ctx); 443c260e60Schristos xml_node_t * soap_send_receive(struct http_ctx *ctx, xml_node_t *node); 453c260e60Schristos 463c260e60Schristos struct http_ctx * http_init_ctx(void *upper_ctx, struct xml_node_ctx *xml_ctx); 473c260e60Schristos void http_ocsp_set(struct http_ctx *ctx, int val); 483c260e60Schristos void http_deinit_ctx(struct http_ctx *ctx); 493c260e60Schristos 503c260e60Schristos int http_download_file(struct http_ctx *ctx, const char *url, 513c260e60Schristos const char *fname, const char *ca_fname); 523c260e60Schristos char * http_post(struct http_ctx *ctx, const char *url, const char *data, 533c260e60Schristos const char *content_type, const char *ext_hdr, 543c260e60Schristos const char *ca_fname, 553c260e60Schristos const char *username, const char *password, 563c260e60Schristos const char *client_cert, const char *client_key, 573c260e60Schristos size_t *resp_len); 583c260e60Schristos void http_set_cert_cb(struct http_ctx *ctx, 593c260e60Schristos int (*cb)(void *ctx, struct http_cert *cert), 603c260e60Schristos void *cb_ctx); 613c260e60Schristos const char * http_get_err(struct http_ctx *ctx); 623c260e60Schristos void http_parse_x509_certificate(struct http_ctx *ctx, const char *fname); 633c260e60Schristos 643c260e60Schristos #endif /* HTTP_UTILS_H */ 65