connection.h 1.39 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
#include "compat.h"
Karl Heyes's avatar
Karl Heyes committed
19 20 21
#include "httpp/httpp.h"
#include "thread/thread.h"
#include "net/sock.h"
22

23
struct _client_tag;
24
struct source_tag;
25

Jack Moffitt's avatar
Jack Moffitt committed
26 27
typedef 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
    int sock;
35
    int serversock;
36
    int error;
Jack Moffitt's avatar
Jack Moffitt committed
37

38 39
    char *ip;
    char *host;
40

Jack Moffitt's avatar
Jack Moffitt committed
41 42 43 44 45 46
} connection_t;

void connection_initialize(void);
void connection_shutdown(void);
void connection_accept_loop(void);
void connection_close(connection_t *con);
47
connection_t *connection_create (sock_t sock, sock_t serversock, char *ip);
48
int connection_complete_source (struct source_tag *source);
49

50
int connection_check_source_pass(http_parser_t *parser, const char *mount);
51 52 53
int connection_check_relay_pass(http_parser_t *parser);
int connection_check_admin_pass(http_parser_t *parser);

54
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
55 56

#endif  /* __CONNECTION_H__ */