connection.h 1.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
Philipp Schafft's avatar
Philipp Schafft committed
11
 * Copyright 2014,      Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
12 13
 */

Jack Moffitt's avatar
Jack Moffitt committed
14 15 16
#ifndef __CONNECTION_H__
#define __CONNECTION_H__

17
#include <sys/types.h>
Michael Smith's avatar
Michael Smith committed
18
#include <time.h>
19 20 21 22 23
#ifdef HAVE_OPENSSL
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif

24
#include "compat.h"
Marvin Scholz's avatar
Marvin Scholz committed
25 26 27
#include "common/httpp/httpp.h"
#include "common/thread/thread.h"
#include "common/net/sock.h"
28

29
struct _client_tag;
30
struct source_tag;
31
struct ice_config_tag;
32

Jack Moffitt's avatar
Jack Moffitt committed
33 34
typedef struct connection_tag
{
35
    unsigned long id;
Jack Moffitt's avatar
Jack Moffitt committed
36

37
    time_t con_time;
38
    time_t discon_time;
39
    uint64_t sent_bytes;
Jack Moffitt's avatar
Jack Moffitt committed
40

41 42
    sock_t sock;
    sock_t serversock;
43
    int error;
Jack Moffitt's avatar
Jack Moffitt committed
44

45
#ifdef HAVE_OPENSSL
46
    SSL *ssl; /* SSL handler */
47 48 49 50
#endif
    int (*send)(struct connection_tag *handle, const void *buf, size_t len);
    int (*read)(struct connection_tag *handle, void *buf, size_t len);

51
    char *ip;
Jack Moffitt's avatar
Jack Moffitt committed
52 53 54 55 56
} connection_t;

void connection_initialize(void);
void connection_shutdown(void);
void connection_accept_loop(void);
57
int connection_setup_sockets(struct ice_config_tag *config);
Jack Moffitt's avatar
Jack Moffitt committed
58
void connection_close(connection_t *con);
59 60
connection_t *connection_create(sock_t sock, sock_t serversock, char *ip);
int connection_complete_source(struct source_tag *source, int response);
61
void connection_queue(connection_t *con);
62
void connection_uses_ssl(connection_t *con);
63

64 65
ssize_t connection_read_bytes(connection_t *con, void *buf, size_t len);

66
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
67 68

#endif  /* __CONNECTION_H__ */