38
typedef struct ssh_bind_struct SSH_BIND;
39
enum ssh_bind_options_e {
40
SSH_BIND_OPTIONS_BINDADDR,
41
SSH_BIND_OPTIONS_BINDPORT,
42
SSH_BIND_OPTIONS_BINDPORT_STR,
43
SSH_BIND_OPTIONS_HOSTKEY,
44
SSH_BIND_OPTIONS_DSAKEY,
45
SSH_BIND_OPTIONS_RSAKEY,
46
SSH_BIND_OPTIONS_BANNER,
47
SSH_BIND_OPTIONS_LOG_VERBOSITY,
48
SSH_BIND_OPTIONS_LOG_VERBOSITY_STR
51
//typedef struct ssh_bind_struct SSH_BIND;
52
typedef struct ssh_bind_struct* ssh_bind;
41
55
* @brief Creates a new SSH server bind.
43
57
* @return A newly allocated ssh_bind session pointer.
45
SSH_BIND *ssh_bind_new(void);
59
LIBSSH_API ssh_bind ssh_bind_new(void);
48
62
* @brief Set the opitons for the current SSH server bind.
52
66
* @param options The option structure to set.
54
void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
68
LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind,
69
enum ssh_bind_options_e type, const void *value);
57
72
* @brief Start listening to the socket.
59
* @param ssh_bind The ssh server bind to use.
74
* @param ssh_bind_o The ssh server bind to use.
61
76
* @return 0 on success, < 0 on error.
63
int ssh_bind_listen(SSH_BIND *ssh_bind);
78
LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o);
66
81
* @brief Set the session to blocking/nonblocking mode.
68
* @param ssh_bind The ssh server bind to use.
83
* @param ssh_bind_o The ssh server bind to use.
70
85
* @param blocking Zero for nonblocking mode.
72
void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
87
LIBSSH_API void ssh_bind_set_blocking(ssh_bind ssh_bind_o, int blocking);
75
90
* @brief Recover the file descriptor from the session.
77
* @param ssh_bind The ssh server bind to get the fd from.
92
* @param ssh_bind_o The ssh server bind to get the fd from.
79
94
* @return The file descriptor.
81
socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
96
LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o);
84
99
* @brief Set the file descriptor for a session.
86
* @param ssh_bind The ssh server bind to set the fd.
101
* @param ssh_bind_o The ssh server bind to set the fd.
88
* @param fd The file descriptor.
103
* @param fd The file descriptssh_bind B
90
void ssh_bind_set_fd(SSH_BIND *ssh_bind, socket_t fd);
105
LIBSSH_API void ssh_bind_set_fd(ssh_bind ssh_bind_o, socket_t fd);
93
108
* @brief Allow the file descriptor to accept new sessions.
95
* @param ssh_bind The ssh server bind to use.
110
* @param ssh_bind_o The ssh server bind to use.
97
void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind);
112
LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind_o);
100
115
* @brief Accept an incoming ssh connection and initialize the session.
102
* @param ssh_bind The ssh server bind to accept a connection.
117
* @param ssh_bind_o The ssh server bind to accept a connection.
118
* @param session A preallocated ssh session
104
120
* @return A newly allocated ssh session, NULL on error.
106
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
122
LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session);
109
125
* @brief Free a ssh servers bind.
111
* @param ssh_bind The ssh server bind to free.
127
* @param ssh_bind_o The ssh server bind to free.
113
void ssh_bind_free(SSH_BIND *ssh_bind);
129
LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o);
116
132
* @brief Exchange the banner and cryptographic keys.
120
136
* @return 0 on success, < 0 on error.
122
int ssh_accept(SSH_SESSION *session);
138
LIBSSH_API int ssh_accept(ssh_session session);
140
LIBSSH_API int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
126
#define SSH_AUTH_REQUEST 1
127
#define SSH_CHANNEL_REQUEST_OPEN 2
128
#define SSH_CHANNEL_REQUEST 3
130
#define SSH_AUTH_NONE (1<<0)
131
#define SSH_AUTH_PASSWORD (1<<1)
132
#define SSH_AUTH_HOSTBASED (1<<2)
133
#define SSH_AUTH_PUBLICKEY (1<<3)
134
#define SSH_AUTH_KEYBINT (1<<4)
135
#define SSH_AUTH_UNKNOWN 0
137
#define SSH_CHANNEL_SESSION 1
138
#define SSH_CHANNEL_TCPIP 2
139
#define SSH_CHANNEL_X11 3
140
#define SSH_CHANNEL_UNKNOWN 4
142
#define SSH_CHANNEL_REQUEST_PTY 1
143
#define SSH_CHANNEL_REQUEST_EXEC 2
144
#define SSH_CHANNEL_REQUEST_SHELL 3
145
#define SSH_CHANNEL_REQUEST_ENV 4
146
#define SSH_CHANNEL_REQUEST_SUBSYSTEM 5
147
#define SSH_CHANNEL_REQUEST_WINDOW_CHANGE 6
148
#define SSH_CHANNEL_REQUEST_UNKNOWN 7
150
typedef struct ssh_message SSH_MESSAGE;
152
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
153
int ssh_message_type(SSH_MESSAGE *msg);
154
int ssh_message_subtype(SSH_MESSAGE *msg);
155
int ssh_message_reply_default(SSH_MESSAGE *msg);
156
void ssh_message_free(SSH_MESSAGE *msg);
158
char *ssh_message_auth_user(SSH_MESSAGE *msg);
159
char *ssh_message_auth_password(SSH_MESSAGE *msg);
160
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
161
int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
163
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
165
CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg);
166
// returns the TERM env variable
167
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
168
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
169
int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
143
LIBSSH_API int ssh_message_reply_default(ssh_message msg);
145
LIBSSH_API char *ssh_message_auth_user(ssh_message msg);
146
LIBSSH_API char *ssh_message_auth_password(ssh_message msg);
147
LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg);
148
LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
149
LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
150
LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods);
152
LIBSSH_API int ssh_message_service_reply_success(ssh_message msg);
153
LIBSSH_API char *ssh_message_service_service(ssh_message msg);
155
LIBSSH_API void ssh_set_message_callback(ssh_session session,
156
int(*ssh_message_callback)(ssh_session session, ssh_message msg));
158
LIBSSH_API char *ssh_message_channel_request_open_originator(ssh_message msg);
159
LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg);
160
LIBSSH_API char *ssh_message_channel_request_open_destination(ssh_message msg);
161
LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg);
163
LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
165
LIBSSH_API char *ssh_message_channel_request_pty_term(ssh_message msg);
166
LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
167
LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
168
LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
169
LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
171
LIBSSH_API char *ssh_message_channel_request_env_name(ssh_message msg);
172
LIBSSH_API char *ssh_message_channel_request_env_value(ssh_message msg);
174
LIBSSH_API char *ssh_message_channel_request_command(ssh_message msg);
176
LIBSSH_API char *ssh_message_channel_request_subsystem(ssh_message msg);
171
178
#ifdef __cplusplus