connection.h 1.54 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 24
struct _client_tag;

Jack Moffitt's avatar
Jack Moffitt committed
25 26
typedef struct connection_tag
{
27
    unsigned long id;
Jack Moffitt's avatar
Jack Moffitt committed
28

29 30
    time_t con_time;
    uint64_t sent_bytes;
Jack Moffitt's avatar
Jack Moffitt committed
31

Michael Smith's avatar
Michael Smith committed
32

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

37 38
    char *ip;
    char *host;
Michael Smith's avatar
Michael Smith committed
39 40 41 42

    /* For 'fake' connections */
    int event_number;
    void *event;
Jack Moffitt's avatar
Jack Moffitt committed
43 44 45 46 47 48
} connection_t;

void connection_initialize(void);
void connection_shutdown(void);
void connection_accept_loop(void);
void connection_close(connection_t *con);
49
connection_t *create_connection(sock_t sock, sock_t serversock, char *ip);
50 51
int connection_create_source(struct _client_tag *client, connection_t *con, 
        http_parser_t *parser, char *mount);
52

Michael Smith's avatar
Michael Smith committed
53 54
void connection_inject_event(int eventnum, void *event_data);

55 56 57 58
int connection_check_source_pass(http_parser_t *parser, char *mount);
int connection_check_relay_pass(http_parser_t *parser);
int connection_check_admin_pass(http_parser_t *parser);

59
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
60 61

#endif  /* __CONNECTION_H__ */