25#include "libssh/priv.h"
26#include "libssh/callbacks.h"
27#include "libssh/kex.h"
28#include "libssh/packet.h"
29#include "libssh/pcap.h"
30#include "libssh/auth.h"
31#include "libssh/channels.h"
32#include "libssh/poll.h"
33#include "libssh/config.h"
34#include "libssh/misc.h"
37enum ssh_session_state_e {
38 SSH_SESSION_STATE_NONE=0,
39 SSH_SESSION_STATE_CONNECTING,
40 SSH_SESSION_STATE_SOCKET_CONNECTED,
41 SSH_SESSION_STATE_BANNER_RECEIVED,
42 SSH_SESSION_STATE_INITIAL_KEX,
43 SSH_SESSION_STATE_KEXINIT_RECEIVED,
45 SSH_SESSION_STATE_AUTHENTICATING,
46 SSH_SESSION_STATE_AUTHENTICATED,
47 SSH_SESSION_STATE_ERROR,
48 SSH_SESSION_STATE_DISCONNECTED
54 DH_STATE_REQUEST_SENT,
56 DH_STATE_NEWKEYS_SENT,
60enum ssh_pending_call_e {
61 SSH_PENDING_CALL_NONE = 0,
62 SSH_PENDING_CALL_CONNECT,
63 SSH_PENDING_CALL_AUTH_NONE,
64 SSH_PENDING_CALL_AUTH_PASSWORD,
65 SSH_PENDING_CALL_AUTH_OFFER_PUBKEY,
66 SSH_PENDING_CALL_AUTH_PUBKEY,
67 SSH_PENDING_CALL_AUTH_AGENT,
68 SSH_PENDING_CALL_AUTH_KBDINT_INIT,
69 SSH_PENDING_CALL_AUTH_KBDINT_SEND,
70 SSH_PENDING_CALL_AUTH_GSSAPI_MIC
74#define SSH_SESSION_FLAG_BLOCKING 0x0001
77#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
80#define SSH_SESSION_FLAG_NO_MORE_SESSIONS 0x0004
85#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
89#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
91#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
95#define SSH_TIMEOUT_INFINITE -1
97#define SSH_TIMEOUT_USER -2
99#define SSH_TIMEOUT_DEFAULT -3
101#define SSH_TIMEOUT_NONBLOCKING 0
105#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
106#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
107#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
108#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
111#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
112#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
113#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
114#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
115#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
119#define SSH_EXT_NEGOTIATION 0x01
121#define SSH_EXT_SIG_RSA_SHA256 0x02
122#define SSH_EXT_SIG_RSA_SHA512 0x04
125struct ssh_common_struct {
126 struct error_struct error;
131struct ssh_session_struct {
132 struct ssh_common_struct common;
133 struct ssh_socket_struct *socket;
142 struct ssh_timestamp last_rekey_time;
157 char *peer_discon_msg;
158 char *disconnect_message;
159 ssh_buffer in_buffer;
161 ssh_buffer out_buffer;
162 struct ssh_list *out_queue;
167 enum ssh_pending_call_e pending_call_state;
168 enum ssh_session_state_e session_state;
169 enum ssh_packet_state_e packet_state;
170 enum ssh_dh_state_e dh_handshake_state;
171 enum ssh_channel_request_state_e global_req_state;
172 struct ssh_agent_state_struct *agent_state;
175 struct ssh_auth_auto_state_struct *auto_state;
176 enum ssh_auth_service_state_e service_state;
177 enum ssh_auth_state_e state;
178 uint32_t supported_methods;
179 uint32_t current_method;
186 bool send_first_kex_follows;
196 bool first_kex_follows_guess_wrong;
198 ssh_buffer in_hashbuf;
199 ssh_buffer out_hashbuf;
200 struct ssh_crypto_struct *current_crypto;
202 struct ssh_crypto_struct *next_crypto;
204 struct ssh_list *channels;
209 struct ssh_kbdint_struct *kbdint;
210 struct ssh_gssapi_struct *gssapi;
218 enum ssh_keytypes_e hostkey;
219 enum ssh_digest_e hostkey_digest;
223 struct ssh_list *ssh_message_list;
224 int (*ssh_message_callback)(
struct ssh_session_struct *session,
225 ssh_message msg,
void *userdata);
226 void *ssh_message_callback_data;
228 void (*ssh_connection_callback)(
struct ssh_session_struct *session);
229 struct ssh_packet_callbacks_struct default_packet_callbacks;
230 struct ssh_list *packet_callbacks;
232 ssh_poll_ctx default_poll_ctx;
235 ssh_pcap_context pcap_ctx;
238 struct ssh_list *identity;
239 struct ssh_list *identity_non_exp;
240 struct ssh_list *certificate;
241 struct ssh_list *certificate_non_exp;
247 char *global_knownhosts;
248 char *wanted_methods[SSH_KEX_METHODS];
249 char *pubkey_accepted_types;
254 unsigned long timeout;
255 unsigned long timeout_usec;
258 int StrictHostKeyChecking;
259 char compressionlevel;
260 char *gss_server_identity;
261 char *gss_client_identity;
262 int gss_delegate_creds;
266 bool config_processed;
267 uint8_t options_seen[SOC_MAX];
271 bool identities_only;
276 ssh_counter socket_counter;
277 ssh_counter raw_counter;
285typedef int (*ssh_termination_function)(
void *user);
286int ssh_handle_packets(ssh_session session,
int timeout);
287int ssh_handle_packets_termination(ssh_session session,
289 ssh_termination_function fct,
291void ssh_socket_exception_callback(
int code,
int errno_code,
void *user);
Definition callbacks.h:165
Definition callbacks.h:332
Definition callbacks.h:409