connection.h 1.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* 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).
 */

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

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

23
#include "compat.h"
Karl Heyes's avatar
Karl Heyes committed
24 25 26
#include "httpp/httpp.h"
#include "thread/thread.h"
#include "net/sock.h"
27

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

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

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

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

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

50 51
    char *ip;
    char *host;
Michael Smith's avatar
Michael Smith committed
52

Jack Moffitt's avatar
Jack Moffitt committed
53 54 55 56 57
} connection_t;

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

63
int connection_check_pass (http_parser_t *parser, const char *user, const char *pass);
64 65 66
int connection_check_relay_pass(http_parser_t *parser);
int connection_check_admin_pass(http_parser_t *parser);

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

#endif  /* __CONNECTION_H__ */