Files: 234c0883246ae63530622aff1e575d35b029db60 / probe.h
2405 bytesRaw
1 | /* API for probe.c */ |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | typedef enum { |
10 | PROBE_NEXT, /* Enough data, probe failed -- it's some other protocol */ |
11 | PROBE_MATCH, /* Enough data, probe successful -- it's the current protocol */ |
12 | PROBE_AGAIN, /* Not enough data for this probe, try again with more data */ |
13 | } probe_result; |
14 | |
15 | struct proto; |
16 | typedef int T_PROBE(const char*, int, struct proto*); |
17 | |
18 | /* For each protocol we need: */ |
19 | struct proto { |
20 | const char* description; /* a string that says what it is (for logging and command-line parsing) */ |
21 | const char* service; /* service name to do libwrap checks */ |
22 | struct addrinfo *saddr; /* list of addresses to try and switch that protocol */ |
23 | int log_level; /* 0: No logging of connection |
24 | * 1: Log incoming connection |
25 | */ |
26 | int keepalive; /* 0: No keepalive ; 1: Set Keepalive for this connection */ |
27 | int transparent; /* 0: opaque proxy ; 1: transparent proxy */ |
28 | |
29 | /* function to probe that protocol; parameters are buffer and length |
30 | * containing the data to probe, and a pointer to the protocol structure */ |
31 | T_PROBE* probe; |
32 | /* opaque pointer ; used to pass list of regex to regex probe, or TLSProtocol struct to sni/alpn probe */ |
33 | void* data; |
34 | struct proto *next; /* pointer to next protocol in list, NULL if last */ |
35 | }; |
36 | |
37 | /* Returns a pointer to the array of builtin protocols */ |
38 | struct proto * get_builtins(void); |
39 | |
40 | /* Returns the number of builtin protocols */ |
41 | int get_num_builtins(void); |
42 | |
43 | /* Returns the probe for specified protocol */ |
44 | T_PROBE* get_probe(const char* description); |
45 | |
46 | /* Returns the head of the configured protocols */ |
47 | struct proto* get_first_protocol(void); |
48 | |
49 | /* Set the list of configured protocols */ |
50 | void set_protocol_list(struct proto*); |
51 | |
52 | /* probe_client_protocol |
53 | * |
54 | * Read the beginning of data coming from the client connection and check if |
55 | * it's a known protocol. Then leave the data on the deferred |
56 | * write buffer of the connection and returns a pointer to the protocol |
57 | * structure |
58 | */ |
59 | int probe_client_protocol(struct connection *cnx); |
60 | |
61 | /* set the protocol to connect to in case of timeout */ |
62 | void set_ontimeout(const char* name); |
63 | |
64 | /* timeout_protocol |
65 | * |
66 | * Returns the protocol to connect to in case of timeout |
67 | */ |
68 | struct proto* timeout_protocol(void); |
69 | |
70 | void hexdump(const char*, unsigned int); |
71 | |
72 | |
73 |
Built with git-ssb-web