connection.h 1.8 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

#include "tls.h"
21

22
#include "icecasttypes.h"
23
#include "compat.h"
Marvin Scholz's avatar
Marvin Scholz committed
24 25
#include "common/thread/thread.h"
#include "common/net/sock.h"
26

27
struct connection_tag {
28
    unsigned long id;
Jack Moffitt's avatar
Jack Moffitt committed
29

30
    time_t con_time;
31
    time_t discon_time;
32
    uint64_t sent_bytes;
Jack Moffitt's avatar
Jack Moffitt committed
33

34 35
    sock_t sock;
    sock_t serversock;
36
    int error;
Jack Moffitt's avatar
Jack Moffitt committed
37

38
    tlsmode_t tlsmode;
39
    tls_t *tls;
40 41
    int (*send)(connection_t *handle, const void *buf, size_t len);
    int (*read)(connection_t *handle, void *buf, size_t len);
42

43 44 45
    void *readbuffer;
    size_t readbufferlen;

46
    char *ip;
47
};
Jack Moffitt's avatar
Jack Moffitt committed
48 49 50

void connection_initialize(void);
void connection_shutdown(void);
51
void connection_reread_config(ice_config_t *config);
Jack Moffitt's avatar
Jack Moffitt committed
52
void connection_accept_loop(void);
53
int connection_setup_sockets(ice_config_t *config);
Jack Moffitt's avatar
Jack Moffitt committed
54
void connection_close(connection_t *con);
55
connection_t *connection_create(sock_t sock, sock_t serversock, char *ip);
56
int connection_complete_source(source_t *source, int response);
57
void connection_queue(connection_t *con);
58
void connection_uses_tls(connection_t *con);
59

60
ssize_t connection_read_bytes(connection_t *con, void *buf, size_t len);
61
int connection_read_put_back(connection_t *con, const void *buf, size_t len);
62

63
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
64 65

#endif  /* __CONNECTION_H__ */