|
|
@ -7,36 +7,70 @@ |
|
|
|
#ifndef F2B_COMMANDS_H_ |
|
|
|
#ifndef F2B_COMMANDS_H_ |
|
|
|
#define F2B_COMMANDS_H_ |
|
|
|
#define F2B_COMMANDS_H_ |
|
|
|
|
|
|
|
|
|
|
|
/* yes, i know about LINE_MAX */ |
|
|
|
/**
|
|
|
|
|
|
|
|
* @file |
|
|
|
|
|
|
|
* This header contains definition of control commands and routines |
|
|
|
|
|
|
|
* for work with data buffer of control message |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Maximum length of input line in client |
|
|
|
|
|
|
|
* @note yes, i know about LINE_MAX |
|
|
|
|
|
|
|
*/ |
|
|
|
#define INPUT_LINE_MAX 256 |
|
|
|
#define INPUT_LINE_MAX 256 |
|
|
|
|
|
|
|
/** Maximum count of data pieces in control message data buf */ |
|
|
|
#define CMD_TOKENS_MAX 6 |
|
|
|
#define CMD_TOKENS_MAX 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** control command type */ |
|
|
|
enum f2b_cmd_type { |
|
|
|
enum f2b_cmd_type { |
|
|
|
CMD_NONE = 0, |
|
|
|
CMD_NONE = 0, /**< unset */ |
|
|
|
CMD_RESP, |
|
|
|
CMD_RESP, /**< response of command */ |
|
|
|
CMD_HELP, |
|
|
|
CMD_HELP, /**< show help for commands (used internally by client) */ |
|
|
|
CMD_PING = 8, |
|
|
|
CMD_PING = 8, /**< check connection */ |
|
|
|
CMD_STATUS, |
|
|
|
CMD_STATUS, /**< show general status of f2b daemon */ |
|
|
|
CMD_ROTATE, |
|
|
|
CMD_ROTATE, /**< reopen logfile. works only if set `logdest = file` */ |
|
|
|
CMD_RELOAD, |
|
|
|
CMD_RELOAD, /**< reload all jails */ |
|
|
|
CMD_SHUTDOWN, |
|
|
|
CMD_SHUTDOWN, /**< gracefull shutdown */ |
|
|
|
CMD_JAIL_STATUS = 16, |
|
|
|
/* jail commands */ |
|
|
|
CMD_JAIL_SET, |
|
|
|
CMD_JAIL_STATUS = 16, /**< show status of given jail */ |
|
|
|
CMD_JAIL_IP_STATUS, |
|
|
|
CMD_JAIL_SET, /**< set parameter of given jail */ |
|
|
|
CMD_JAIL_IP_BAN, |
|
|
|
CMD_JAIL_IP_STATUS, /**< show status of given ip */ |
|
|
|
CMD_JAIL_IP_RELEASE, |
|
|
|
CMD_JAIL_IP_BAN, /**< force ban given ip */ |
|
|
|
CMD_JAIL_FILTER_STATS, |
|
|
|
CMD_JAIL_IP_RELEASE, /**< force unban given ip */ |
|
|
|
CMD_JAIL_FILTER_RELOAD, |
|
|
|
CMD_JAIL_FILTER_STATS, /**< show stats of fileter matches */ |
|
|
|
CMD_MAX_NUMBER, |
|
|
|
CMD_JAIL_FILTER_RELOAD, /**< reload filter patterns from file */ |
|
|
|
|
|
|
|
CMD_MAX_NUMBER, /**< placeholder */ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Print to stdout help for defined commands |
|
|
|
|
|
|
|
*/ |
|
|
|
void f2b_cmd_help(); |
|
|
|
void f2b_cmd_help(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Try to parse user input |
|
|
|
|
|
|
|
* @param buf Buffer of control message for storing parsed args |
|
|
|
|
|
|
|
* @param bufsize Size of buffer size above |
|
|
|
|
|
|
|
* @param src Line with user input |
|
|
|
|
|
|
|
* @returns @a CMD_NONE if parsing fails, or cmd type less than @a CMD_MAX_NUMBER on success |
|
|
|
|
|
|
|
*/ |
|
|
|
enum f2b_cmd_type |
|
|
|
enum f2b_cmd_type |
|
|
|
f2b_cmd_parse (char *buf, size_t bufsize, const char *src); |
|
|
|
f2b_cmd_parse(char *buf, size_t bufsize, const char *src); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Append data piece to data buffer of control message |
|
|
|
|
|
|
|
* @param buf Buffer of control message for storing parsed args |
|
|
|
|
|
|
|
* @param bufsize Size of buffer size above |
|
|
|
|
|
|
|
* @param arg Piece to append |
|
|
|
|
|
|
|
*/ |
|
|
|
void |
|
|
|
void |
|
|
|
f2b_cmd_append_arg(char *buf, size_t bufsize, const char *arg); |
|
|
|
f2b_cmd_append_arg(char *buf, size_t bufsize, const char *arg); |
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Checks is args count match given command type |
|
|
|
|
|
|
|
* @param type Command type |
|
|
|
|
|
|
|
* @param argc Args count |
|
|
|
|
|
|
|
* @returns true if matches, false if not |
|
|
|
|
|
|
|
*/ |
|
|
|
bool |
|
|
|
bool |
|
|
|
f2b_cmd_check_argc(enum f2b_cmd_type type, int argc); |
|
|
|
f2b_cmd_check_argc(enum f2b_cmd_type type, int argc); |
|
|
|
|
|
|
|
|
|
|
|