connection.h 3.42 KB
Newer Older
1
/* connection.h
Niels Möller's avatar
Niels Möller committed
2
3
4
 *
 */

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* lsh, an implementation of the ssh protocol
 *
 * Copyright (C) 1998 Niels Möller
 *
 * This 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 2 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, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

24
25
#ifndef LSH_CONNECTION_H_INCLUDED
#define LSH_CONNECTION_H_INCLUDED
Niels Möller's avatar
Niels Möller committed
26

27
#include "abstract_io.h"
28
#include "abstract_compress.h"
29
#include "resource.h"
Niels Möller's avatar
Niels Möller committed
30
#include "randomness.h"
31

32
33
34
/* Forward declaration */
struct ssh_connection;

35
36
37
38
#define CLASS_DECLARE
#include "connection.h.x"
#undef CLASS_DECLARE

39
40
41
/* This is almost a write handler; difference is that it gets an extra
 * argument with a connection object. */

42
43
44
45
46
47
48
49
/* CLASS:
   (class
     (name packet_handler)
     (vars
       (handler method int
               "struct ssh_connection *connection"
	       "struct lsh_string *packet")))
*/
50
51
52
53

#define HANDLE_PACKET(closure, connection, packet) \
((closure)->handler((closure), (connection), (packet)))

Niels Möller's avatar
Niels Möller committed
54
55
#define CONNECTION_SERVER 0
#define CONNECTION_CLIENT 1
56
57
58
59
60
61

/* CLASS:
   (class
     (name ssh_connection)
     (super abstract_write)
     (vars
62
       ; Sent and received version strings
63
64
65
66
       (client_version string)
       (server_version string)
       (session_id string)

67
68
69
70
       ; Cleanup
       (resources object resource_list)
       
       ; Receiving
71
72
73
       (rec_max_packet simple UINT32)
       (rec_mac    object mac_instance)
       (rec_crypto object crypto_instance)
74
       (rec_compress object compress_instance)
75
76
77
78
79
80
81
82

       ; Sending 
       (raw   object abstract_write)  ; Socket connected to the other end 
       (write object abstract_write)  ; Where to send packets through the
                                      ; pipeline.

       (send_mac object mac_instance)
       (send_crypto object crypto_instance)
83
       (send_compress object compress_instance)
84
85
86
87
88
89
90
91
92
93
94
95
96

       ; Key exchange 
       (kex_state simple int)
  
       ; (simple make_kexinit make_kexinit)

       (kexinits array (object kexinit) 2)
       ;;;  struct kexinit *kexinits[2];
       (literal_kexinits array (string) 2)
       ;;; struct lsh_string *literal_kexinits[2];

       ; Negotiated algorithms
       (newkeys object newkeys_info)
Niels Möller's avatar
Niels Möller committed
97
  
98
99
       ; Table of all known message types 
       (dispatch array (object packet_handler) "0x100");
100
101
102
       
       ; Table of all opened channels
       (channels object channel_table)
103
104
105
106
107
108
109
110
111
112
113

       ; Shared handlers 
       (ignore object packet_handler)
       (unimplemented object packet_handler)
       (fail object packet_handler)

       ; (provides_privacy simple int)
       ; (provides_integrity simple int)
       ))
*/

114
struct ssh_connection *make_ssh_connection(struct packet_handler *kex_handler);
Niels Möller's avatar
Niels Möller committed
115
116
117
void connection_init_io(struct ssh_connection *connection,
			struct abstract_write *raw,
			struct randomness *r);
118

119
120
struct packet_handler *make_fail_handler(void);
struct packet_handler *make_unimplemented_handler(void);  
121

122
#endif /* LSH_CONNECTION_H_INCLUDED */