Files: b9885401050ad27d9fa13ffa67d5e43441f495c0 / probe.h
2130 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 | |
24 | /* function to probe that protocol; parameters are buffer and length |
25 | * containing the data to probe, and a pointer to the protocol structure */ |
26 | T_PROBE* probe; |
27 | void* data; /* opaque pointer ; used to pass list of regex to regex probe, or sni hostnames to sni probe */ |
28 | struct proto *next; /* pointer to next protocol in list, NULL if last */ |
29 | }; |
30 | |
31 | /* Returns a pointer to the array of builtin protocols */ |
32 | struct proto * get_builtins(void); |
33 | |
34 | /* Returns the number of builtin protocols */ |
35 | int get_num_builtins(void); |
36 | |
37 | /* Returns the probe for specified protocol */ |
38 | T_PROBE* get_probe(const char* description); |
39 | |
40 | /* Returns the head of the configured protocols */ |
41 | struct proto* get_first_protocol(void); |
42 | |
43 | /* Set the list of configured protocols */ |
44 | void set_protocol_list(struct proto*); |
45 | |
46 | /* probe_client_protocol |
47 | * |
48 | * Read the beginning of data coming from the client connection and check if |
49 | * it's a known protocol. Then leave the data on the deferred |
50 | * write buffer of the connection and returns a pointer to the protocol |
51 | * structure |
52 | */ |
53 | int probe_client_protocol(struct connection *cnx); |
54 | |
55 | /* set the protocol to connect to in case of timeout */ |
56 | void set_ontimeout(const char* name); |
57 | |
58 | /* timeout_protocol |
59 | * |
60 | * Returns the protocol to connect to in case of timeout |
61 | */ |
62 | struct proto* timeout_protocol(void); |
63 | |
64 | void hexdump(const char*, unsigned int); |
65 | |
66 | |
67 |
Built with git-ssb-web