16 #define LIBCLI_VERSION_MAJOR 1
17 #define LIBCLI_VERISON_MINOR 9
18 #define LIBCLI_VERISON_REVISION 7
19 #define LIBCLI_VERSION ((LIBCLI_VERSION_MAJOR << 16) | (LIBCLI_VERSION_MINOR << 8) | LIBCLI_VERSION_REVISION)
24 #define CLI_ERROR_ARG -3
26 #define MAX_HISTORY 256
28 #define PRIVILEGE_UNPRIVILEGED 0
29 #define PRIVILEGE_PRIVILEGED 15
34 #define LIBCLI_HAS_ENABLE 1
37 #define PRINT_FILTERED 0x01
38 #define PRINT_BUFFERED 0x02
40 #define CLI_MAX_LINE_LENGTH 4096
41 #define CLI_MAX_LINE_WORDS 128
123 void cli_print(
struct cli_def *cli,
const char *format, ...) __attribute__((format (printf, 2, 3)));
124 void cli_bufprint(struct
cli_def *cli, const
char *format, ...) __attribute__((format (printf, 2, 3)));
126 void cli_error(struct
cli_def *cli, const
char *format, ...) __attribute__((format (printf, 2, 3)));
void(* print_callback)(struct cli_def *cli, const char *string)
Definition: net_cli.h:61
int telnet_protocol
Definition: net_cli.h:73
int(* idle_timeout_callback)(struct cli_def *)
Definition: net_cli.h:71
unsigned int unique_len
Definition: net_cli.h:90
struct cli_command * next
Definition: net_cli.h:94
void cli_regular(struct cli_def *cli, int(*callback)(struct cli_def *cli))
Adds a callback function which will be called every second that a user is connected to the cli...
Definition: net_cli.c:1387
int cli_file(struct cli_def *cli, FILE *fh, int privilege, int mode)
This reads and processes every line read from f as if it were entered at the console.
Definition: net_cli.c:2487
int privilege
Definition: net_cli.h:92
void cli_set_context(struct cli_def *cli, void *context)
Definition: net_cli.c:2930
void void cli_print_callback(struct cli_def *cli, void(*callback)(struct cli_def *, const char *))
Whenever cli_print() or cli_error() is called, the output generally goes to the user.
Definition: net_cli.c:2907
int cli_done(struct cli_def *cli)
This is optional, but it's a good idea to call this when you are finished with libcli.
Definition: net_cli.c:841
int mode
Definition: net_cli.h:58
struct cli_filter * next
Definition: net_cli.h:84
time_t last_action
Definition: net_cli.h:72
int(* regular_callback)(struct cli_def *cli)
Definition: net_cli.h:47
char * promptchar
Definition: net_cli.h:54
struct cli_filter * filters
Definition: net_cli.h:60
void cli_set_auth_callback(struct cli_def *cli, int(*auth_callback)(const char *, const char *))
Enables or disables callback based authentication.
Definition: net_cli.c:213
int state
Definition: net_cli.h:59
struct cli_command * parent
Definition: net_cli.h:96
char * modestring
Definition: net_cli.h:56
void cli_set_enable_callback(struct cli_def *cli, int(*enable_callback)(const char *))
Just like cli_set_auth_callback, this takes a pointer to a callback function to authorize privileged ...
Definition: net_cli.c:226
int(* auth_callback)(const char *, const char *)
Definition: net_cli.h:46
int privilege
Definition: net_cli.h:57
struct timeval timeout_tm
Definition: net_cli.h:69
void * user_context
Definition: net_cli.h:74
struct unp * users
Definition: net_cli.h:50
#define MAX_HISTORY
Definition: net_cli.h:26
unsigned buf_size
Definition: net_cli.h:68
void cli_error(struct cli_def *cli, const char *format,...) __attribute__((format(printf
char * history[MAX_HISTORY]
Definition: net_cli.h:52
void cli_free_history(struct cli_def *cli)
Clear history array.
Definition: net_cli.c:914
char * command
Definition: net_cli.h:88
int system
Definition: net_cli.h:97
char * buffer
Definition: net_cli.h:67
void cli_deny_user(struct cli_def *cli, const char *username)
Removes username/password from the list of allowed users.
Definition: net_cli.c:302
int cli_run_command(struct cli_def *cli, const char *command)
Definition: net_cli.c:1235
void * service
Definition: net_cli.h:65
int cli_set_privilege(struct cli_def *cli, int privilege)
Definition: net_cli.c:398
int cli_loop(struct cli_def *cli, int sockfd)
The main loop of the command-line environment.
Definition: net_cli.c:2349
int(* enable_callback)(const char *)
Definition: net_cli.h:48
void cli_set_idle_timeout_callback(struct cli_def *cli, unsigned int seconds, int(*callback)(struct cli_def *))
Definition: net_cli.c:2920
struct cli_command * children
Definition: net_cli.h:95
struct cli_command * commands
Definition: net_cli.h:45
char * banner
Definition: net_cli.h:49
int(* callback)(struct cli_def *, const char *, char **, int)
Definition: net_cli.h:89
int cli_unregister_command(struct cli_def *cli, const char *command)
Remove a command command and all children.
Definition: net_cli.c:581
int debug_regular
Definition: net_cli.h:78
void cli_allow_enable(struct cli_def *cli, const char *password)
This will allow a static password to be used for the enable command.
Definition: net_cli.c:285
void * cli_get_context(struct cli_def *cli)
Definition: net_cli.c:2934
char * enable_password
Definition: net_cli.h:51
KSNet event manager functions data.
Definition: ev_mgr.h:245
void cli_reprompt(struct cli_def *cli)
Definition: net_cli.c:1368
void cli_set_promptchar(struct cli_def *cli, const char *promptchar)
Definition: net_cli.c:353
void cli_regular_interval(struct cli_def *cli, int seconds)
Definition: net_cli.c:1393
char * hostname
Definition: net_cli.h:55
void * data
Definition: net_cli.h:83
void cli_set_banner(struct cli_def *cli, const char *banner)
Sets the greeting that clients will be presented with when they connect.
Definition: net_cli.c:333
struct cli_command * cli_register_command(struct cli_def *cli, struct cli_command *parent, const char *command, int(*callback)(struct cli_def *, const char *, char **, int), int privilege, int mode, const char *help)
time_t idle_timeout
Definition: net_cli.h:70
char * commandname
Definition: net_cli.h:66
int mode
Definition: net_cli.h:93
ksnetEvMgrClass * ke
Definition: net_cli.h:76
void void cli_bufprint(struct cli_def *cli, const char *format,...) __attribute__((format(printf
void cli_set_hostname(struct cli_def *cli, const char *hostname)
Sets the hostname to be displayed as the first part of the prompt.
Definition: net_cli.c:346
void cli_print(struct cli_def *cli, const char *format,...) __attribute__((format(printf
unsigned int regular_count
Definition: net_cli.h:77
void cli_set_modestring(struct cli_def *cli, const char *modestring)
Definition: net_cli.c:412
struct cli_def * cli_init(ksnetEvMgrClass *ke)
CLI Initialize.
Definition: net_cli.c:756
void * conn
Definition: net_cli.h:64
void cli_telnet_protocol(struct cli_def *cli, int telnet_protocol)
Definition: net_cli.c:2926
void cli_set_idle_timeout(struct cli_def *cli, unsigned int seconds)
Definition: net_cli.c:2912
void cli_allow_user(struct cli_def *cli, const char *username, const char *password)
Enables internal authentication, and adds username/password to the list of allowed users...
Definition: net_cli.c:242
int(* filter)(struct cli_def *cli, const char *string, void *data)
Definition: net_cli.h:82
void void void cli_vabufprint(struct cli_def *cli, const char *format, va_list ap)
Definition: net_cli.c:2603
int completion_callback
Definition: net_cli.h:44
int cli_set_configmode(struct cli_def *cli, int mode, const char *config_desc)
This will set the configuration mode.
Definition: net_cli.c:433
char showprompt
Definition: net_cli.h:53
FILE * client
Definition: net_cli.h:62
char * help
Definition: net_cli.h:91