1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/* Interface for HTTP functions
*
* Copyright (C) 2003-2004 Narcis Ilisei <inarcis2002@hotpop.com>
* Copyright (C) 2010-2021 Joachim Wiberg <troglobit@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef INADYN_HTTP_H_
#define INADYN_HTTP_H_
#include "config.h"
#if defined(CONFIG_OPENSSL)
#include <openssl/conf.h>
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/tls1.h>
#include <openssl/err.h>
#elif defined(CONFIG_MBEDTLS)
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/entropy.h>
#include <mbedtls/net_sockets.h>
#include <mbedtls/ssl.h>
#elif defined(CONFIG_GNUTLS)
#include <gnutls/gnutls.h>
#endif
#include "error.h"
#include "os.h"
#include "tcp.h"
#define HTTP_DEFAULT_TIMEOUT 10000 /* msec */
#define HTTP_DEFAULT_PORT 80
#define HTTPS_DEFAULT_PORT 443
typedef struct {
tcp_sock_t tcp;
int ssl_enabled;
#if defined(ENABLE_SSL)
#if defined(CONFIG_OPENSSL)
SSL *ssl;
SSL_CTX *ssl_ctx;
#elif defined(CONFIG_MBEDTLS)
mbedtls_ssl_context ssl;
mbedtls_net_context server_fd;
mbedtls_ssl_config conf;
mbedtls_x509_crt cacert;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_context entropy;
#else
gnutls_session_t ssl;
#endif
#endif
int initialized;
int connected;
} http_t;
typedef struct {
char *req;
int req_len;
char *rsp;
int rsp_len;
int max_rsp_len;
char *rsp_body;
int status;
char status_desc[256];
} http_trans_t;
int http_construct (http_t *client);
int http_destruct (http_t *client, int num);
int http_init (http_t *client, char *msg, int force);
int http_exit (http_t *client);
int http_transaction (http_t *client, http_trans_t *trans);
int http_status_valid (int status);
int http_set_port (http_t *client, int porg);
int http_get_port (http_t *client, int *port);
int http_set_remote_name (http_t *client, const char *name);
int http_get_remote_name (http_t *client, const char **name);
int http_set_remote_timeout (http_t *client, int timeout);
int http_get_remote_timeout (http_t *client, int *timeout);
#endif /* INADYN_HTTP_H_ */
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
|