-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathssh-session.h
107 lines (76 loc) · 2.01 KB
/
ssh-session.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
This file is part of macSSH
Copyright 2016 Daniel Machon
SSH program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SSH_SESSION_H
#define SSH_SESSION_H
#include "buffer.h"
#include "build.h"
#include "crypto.h"
#include "ssh-channel.h"
#include "ssh-packet.h"
#define IDENTIFICATION_STRING "SSH-2.0-" SSH_VERSION_STR "\r\n"
struct session;
void session_free();
void session_init(struct session *ses);
void client_session_loop();
void server_session_loop();
void identify();
void read_identification_string();
enum {
DEADBEEF = -1,
NONE = 0,
IDENTIFIED = 1,
HAVE_KEX_INIT = 2,
KEXED = 3,
AUTHED = 4,
REKEX = 5,
SETUP = 6,
};
struct session {
int session_id;
int state;
int sock_in;
int sock_out;
int rx;
int tx;
char remote_id[256];
/*
* Number of kex'es (initial + renegotiation)
*/
int kex_num;
struct crypto *crypto;
struct diffie_hellman *dh;
struct channel *channels;
/*
* Partial read packet. Might be incomplete
* after a read. Is put in ingoing buffer if
* complete.
*/
struct packet *pck_tmp;
int packet_flag;
struct packet pay;
struct buffer *buf_in;
struct buffer *buf_out;
/*
* Some packet handlers
*/
int (*write_packet)(struct packet *pck);
struct packet* (*read_packet)();
void (*process_packet)();
/* Initial identification */
void (*identify)();
/* KEX */
void (*kex_init)();
} ses;
#endif /* SSH_SESSION_H */