-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdeucessh.h
67 lines (52 loc) · 2 KB
/
deucessh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef DEUCE_SSH_H
#define DEUCE_SSH_H
#include <assert.h>
#ifdef __STDC_NO_ATOMICS__
static_assert(0, "stdatomic.h support required");
#endif
#ifdef __STDC_NO_THREADS__
static_assert(0, "threads.h support required");
#endif
#include <inttypes.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <threads.h>
#define DEUCE_SSH_ERROR_NONE 0
#define DEUCE_SSH_ERROR_PARSE -1
#define DEUCE_SSH_ERROR_INVALID -2
#define DEUCE_SSH_ERROR_ALLOC -3
#define DEUCE_SSH_ERROR_INIT -4
#define DEUCE_SSH_ERROR_TERMINATED -5
#define DEUCE_SSH_ERROR_TOOLATE -6
#define DEUCE_SSH_ERROR_TOOMANY -7
#define DEUCE_SSH_ERROR_TOOLONG -8
#define DEUCE_SSH_ERROR_MUST_BE_NULL -9
#define DEUCE_SSH_ERROR_NOMORE -10
typedef struct deuce_ssh_transport_state *deuce_ssh_transport_state_t;
typedef int (*deuce_ssh_transport_io_cb_t)(uint8_t *buf, size_t bufsz, atomic_bool *terminate, void *cbdata);
typedef int (*deuce_ssh_transport_rxline_cb_t)(uint8_t *buf, size_t bufsz, size_t *bytes_received, atomic_bool *terminate, void *cbdata);
typedef int (*deuce_ssh_transport_extra_line_cb_t)(uint8_t *buf, size_t bufsz, void *cbdata);
typedef struct deuce_ssh_session *deuce_ssh_session_t;
#include "ssh-arch.h"
#include "ssh-trans.h"
struct deuce_ssh_session {
/* Global */
mtx_t mtx;
atomic_bool initialized;
atomic_bool terminate;
bool is_server;
/* Transport Remote information */
size_t remote_software_id_string_sz;
char remote_software_id_string[254];
char **remote_languages;
void *tx_cbdata;
void *rx_cbdata;
void *rx_line_cbdata;
void *extra_line_cbdata;
struct deuce_ssh_transport_state trans;
};
int deuce_ssh_session_init(deuce_ssh_session_t sess);
bool deuce_ssh_session_terminate(deuce_ssh_session_t sess);
void deuce_ssh_session_cleanup(deuce_ssh_session_t sess);
int deuce_ssh_transport_set_callbacks(deuce_ssh_transport_io_cb_t tx, deuce_ssh_transport_io_cb_t rx, deuce_ssh_transport_rxline_cb_t rx_line, deuce_ssh_transport_extra_line_cb_t extra_line_cb);
#endif