2013-07-10 17:15:38 -04:00
|
|
|
/* API for probe.c */
|
|
|
|
|
|
|
|
#ifndef __PROBE_H_
|
|
|
|
#define __PROBE_H_
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2013-09-23 18:30:33 -04:00
|
|
|
typedef enum {
|
2013-09-28 15:33:25 -04:00
|
|
|
PROBE_NEXT, /* Enough data, probe failed -- it's some other protocol */
|
|
|
|
PROBE_MATCH, /* Enough data, probe successful -- it's the current protocol */
|
|
|
|
PROBE_AGAIN, /* Not enough data for this probe, try again with more data */
|
2013-09-23 18:30:33 -04:00
|
|
|
} probe_result;
|
|
|
|
|
2013-07-10 17:15:38 -04:00
|
|
|
struct proto;
|
|
|
|
typedef int T_PROBE(const char*, int, struct proto*);
|
|
|
|
|
|
|
|
/* For each protocol we need: */
|
|
|
|
struct proto {
|
|
|
|
const char* description; /* a string that says what it is (for logging and command-line parsing) */
|
|
|
|
const char* service; /* service name to do libwrap checks */
|
|
|
|
struct addrinfo *saddr; /* list of addresses to try and switch that protocol */
|
|
|
|
|
|
|
|
/* function to probe that protocol; parameters are buffer and length
|
|
|
|
* containing the data to probe, and a pointer to the protocol structure */
|
|
|
|
T_PROBE* probe;
|
|
|
|
void* data; /* opaque pointer ; used to pass list of regex to regex probe */
|
|
|
|
struct proto *next; /* pointer to next protocol in list, NULL if last */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Returns a pointer to the array of builtin protocols */
|
|
|
|
struct proto * get_builtins(void);
|
|
|
|
|
|
|
|
/* Returns the number of builtin protocols */
|
|
|
|
int get_num_builtins(void);
|
|
|
|
|
|
|
|
/* Returns the probe for specified protocol */
|
|
|
|
T_PROBE* get_probe(const char* description);
|
|
|
|
|
|
|
|
/* Returns the head of the configured protocols */
|
|
|
|
struct proto* get_first_protocol(void);
|
|
|
|
|
|
|
|
/* Set the list of configured protocols */
|
|
|
|
void set_protocol_list(struct proto*);
|
|
|
|
|
|
|
|
/* probe_client_protocol
|
|
|
|
*
|
|
|
|
* Read the beginning of data coming from the client connection and check if
|
2013-09-23 18:30:38 -04:00
|
|
|
* it's a known protocol. Then leave the data on the deferred
|
2013-07-10 17:15:38 -04:00
|
|
|
* write buffer of the connection and returns a pointer to the protocol
|
|
|
|
* structure
|
|
|
|
*/
|
2013-09-23 18:30:34 -04:00
|
|
|
int probe_client_protocol(struct connection *cnx);
|
2013-07-10 17:15:38 -04:00
|
|
|
|
2013-07-10 17:19:33 -04:00
|
|
|
/* set the protocol to connect to in case of timeout */
|
|
|
|
void set_ontimeout(const char* name);
|
|
|
|
|
2013-07-10 17:15:38 -04:00
|
|
|
/* timeout_protocol
|
|
|
|
*
|
|
|
|
* Returns the protocol to connect to in case of timeout
|
|
|
|
*/
|
|
|
|
struct proto* timeout_protocol(void);
|
|
|
|
|
2013-07-10 17:19:33 -04:00
|
|
|
void hexdump(const char*, unsigned int);
|
|
|
|
|
2013-07-10 17:15:38 -04:00
|
|
|
#endif
|