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

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

10 11
struct _client_tag;

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

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

19
    int sock;
20
    int serversock;
21
    int error;
Jack Moffitt's avatar
Jack Moffitt committed
22

23 24
    char *ip;
    char *host;
25 26 27 28

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

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

39 40
void connection_inject_event(int eventnum, void *event_data);

41 42 43 44
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);

45
extern rwlock_t _source_shutdown_rwlock;
Jack Moffitt's avatar
Jack Moffitt committed
46 47

#endif  /* __CONNECTION_H__ */