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