~ubuntu-branches/ubuntu/vivid/sslh/vivid-proposed

1.1.4 by Guillaume Delacour
Import upstream version 1.13b
1
/* API for probe.c */
2
3
#ifndef __PROBE_H_
4
#define __PROBE_H_
5
6
#include "common.h"
7
1.1.6 by Guillaume Delacour
Import upstream version 1.16
8
typedef enum {
9
    PROBE_NEXT,  /* Enough data, probe failed -- it's some other protocol */
10
    PROBE_MATCH, /* Enough data, probe successful -- it's the current protocol */
11
    PROBE_AGAIN, /* Not enough data for this probe, try again with more data */
12
} probe_result;
13
1.1.4 by Guillaume Delacour
Import upstream version 1.13b
14
struct proto;
15
typedef int T_PROBE(const char*, int, struct proto*);
16
17
/* For each protocol we need: */
18
struct proto {
19
    const char* description;  /* a string that says what it is (for logging and command-line parsing) */
20
    const char* service;      /* service name to do libwrap checks */
21
    struct addrinfo *saddr; /* list of addresses to try and switch that protocol */
22
23
    /* function to probe that protocol; parameters are buffer and length
24
     * containing the data to probe, and a pointer to the protocol structure */
25
    T_PROBE* probe;
26
    void* data;     /* opaque pointer ; used to pass list of regex to regex probe */
27
    struct proto *next; /* pointer to next protocol in list, NULL if last */
28
};
29
30
/* Returns a pointer to the array of builtin protocols */
31
struct proto * get_builtins(void);
32
33
/* Returns the number of builtin protocols */
34
int get_num_builtins(void);
35
36
/* Returns the probe for specified protocol */
37
T_PROBE* get_probe(const char* description);
38
39
/* Returns the head of the configured protocols */
40
struct proto* get_first_protocol(void);
41
42
/* Set the list of configured protocols */
43
void set_protocol_list(struct proto*);
44
45
/* probe_client_protocol
46
 *
47
 * Read the beginning of data coming from the client connection and check if
1.1.6 by Guillaume Delacour
Import upstream version 1.16
48
 * it's a known protocol. Then leave the data on the deferred
1.1.4 by Guillaume Delacour
Import upstream version 1.13b
49
 * write buffer of the connection and returns a pointer to the protocol
50
 * structure
51
 */
1.1.6 by Guillaume Delacour
Import upstream version 1.16
52
int probe_client_protocol(struct connection *cnx);
1.1.4 by Guillaume Delacour
Import upstream version 1.13b
53
1.1.5 by Guillaume Delacour
Import upstream version 1.15
54
/* set the protocol to connect to in case of timeout */
55
void set_ontimeout(const char* name);
56
1.1.4 by Guillaume Delacour
Import upstream version 1.13b
57
/* timeout_protocol
58
 *
59
 * Returns the protocol to connect to in case of timeout
60
 */
61
struct proto* timeout_protocol(void);
62
1.1.5 by Guillaume Delacour
Import upstream version 1.15
63
void hexdump(const char*, unsigned int);
64
1.1.4 by Guillaume Delacour
Import upstream version 1.13b
65
#endif