git ssb

0+

cel / sslh



Tree: 1b9937b293a932bf394da6623075b35b5e7bd9d2

Files: 1b9937b293a932bf394da6623075b35b5e7bd9d2 / probe.h

2259 bytesRaw
1/* API for probe.c */
2
3#ifndef PROBE_H
4#define PROBE_H
5
6#include "common.h"
7#include "tls.h"
8
9typedef 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
15struct proto;
16typedef int T_PROBE(const char*, int, struct proto*);
17
18/* For each protocol we need: */
19struct 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
27 /* function to probe that protocol; parameters are buffer and length
28 * containing the data to probe, and a pointer to the protocol structure */
29 T_PROBE* probe;
30 /* opaque pointer ; used to pass list of regex to regex probe, or TLSProtocol struct to sni/alpn probe */
31 void* data;
32 struct proto *next; /* pointer to next protocol in list, NULL if last */
33};
34
35/* Returns a pointer to the array of builtin protocols */
36struct proto * get_builtins(void);
37
38/* Returns the number of builtin protocols */
39int get_num_builtins(void);
40
41/* Returns the probe for specified protocol */
42T_PROBE* get_probe(const char* description);
43
44/* Returns the head of the configured protocols */
45struct proto* get_first_protocol(void);
46
47/* Set the list of configured protocols */
48void set_protocol_list(struct proto*);
49
50/* probe_client_protocol
51 *
52 * Read the beginning of data coming from the client connection and check if
53 * it's a known protocol. Then leave the data on the deferred
54 * write buffer of the connection and returns a pointer to the protocol
55 * structure
56 */
57int probe_client_protocol(struct connection *cnx);
58
59/* set the protocol to connect to in case of timeout */
60void set_ontimeout(const char* name);
61
62/* timeout_protocol
63 *
64 * Returns the protocol to connect to in case of timeout
65 */
66struct proto* timeout_protocol(void);
67
68void hexdump(const char*, unsigned int);
69
70#endif
71

Built with git-ssb-web