connection.h 1.62 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 31
    time_t con_time;
    uint64_t sent_bytes;
Jack Moffitt's avatar
Jack Moffitt committed
32

Michael Smith's avatar
Michael Smith 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 41 42 43

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

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

55 56
void connection_inject_event(int eventnum, void *event_data);

57 58 59 60
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);

61
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
62 63

#endif  /* __CONNECTION_H__ */