connection.h 1.11 KB
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3
#ifndef __CONNECTION_H__
#define __CONNECTION_H__

4
#include <sys/types.h>
Michael Smith's avatar
Michael Smith committed
5
#include <time.h>
6
#include "compat.h"
Karl Heyes's avatar
Karl Heyes committed
7 8 9
#include "httpp/httpp.h"
#include "thread/thread.h"
#include "net/sock.h"
10

11 12
struct _client_tag;

Jack Moffitt's avatar
Jack Moffitt committed
13 14
typedef struct connection_tag
{
15
    unsigned long id;
Jack Moffitt's avatar
Jack Moffitt committed
16

17 18
    time_t con_time;
    uint64_t sent_bytes;
Jack Moffitt's avatar
Jack Moffitt committed
19

Michael Smith's avatar
Michael Smith committed
20

21
    int sock;
22
    int serversock;
23
    int error;
Jack Moffitt's avatar
Jack Moffitt committed
24

25 26
    char *ip;
    char *host;
Michael Smith's avatar
Michael Smith committed
27 28 29 30

    /* For 'fake' connections */
    int event_number;
    void *event;
Jack Moffitt's avatar
Jack Moffitt committed
31 32 33 34 35 36
} connection_t;

void connection_initialize(void);
void connection_shutdown(void);
void connection_accept_loop(void);
void connection_close(connection_t *con);
37
connection_t *create_connection(sock_t sock, sock_t serversock, char *ip);
38 39
int connection_create_source(struct _client_tag *client, connection_t *con, 
        http_parser_t *parser, char *mount);
40

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

43 44 45 46
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);

47
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
48 49

#endif  /* __CONNECTION_H__ */