xref: /titanic_41/usr/src/cmd/ssh/include/packet.h (revision f52e84dfce89ba2ea0ebb6a191b4466da3012efd)
1 /*
2  * Author: Tatu Ylonen <ylo@cs.hut.fi>
3  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4  *                    All rights reserved
5  * Interface for the packet protocol functions.
6  *
7  * As far as I am concerned, the code I have written for this software
8  * can be used freely for any purpose.  Any derived versions of this
9  * software must be clearly marked as such, and if the derived work is
10  * incompatible with the protocol description in the RFC file, it must be
11  * called by a name other than "ssh" or "Secure Shell".
12  */
13 /*
14  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
15  * Use is subject to license terms.
16  */
17 
18 #ifndef	_PACKET_H
19 #define	_PACKET_H
20 
21 /*	$OpenBSD: packet.h,v 1.35 2002/06/19 18:01:00 markus Exp $	*/
22 
23 #pragma ident	"%Z%%M%	%I%	%E% SMI"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 #include <openssl/bn.h>
31 #include "kex.h"
32 
33 #ifdef ALTPRIVSEP
34 /* Monitor-side functions */
35 void	 packet_set_server(void);
36 void	 packet_set_no_monitor(void);
37 void	 packet_set_monitor(int pip_fd);
38 int	 packet_is_server(void);
39 int	 packet_is_monitor(void);
40 void	 packet_set_packet(const void *buf, u_int len);
41 #endif /* ALTPRIVSEP */
42 
43 void     packet_set_connection(int, int);
44 void     packet_set_nonblocking(void);
45 int      packet_get_connection_in(void);
46 int      packet_get_connection_out(void);
47 void     packet_close(void);
48 void	 packet_set_encryption_key(const u_char *, u_int, int);
49 u_int	 packet_get_encryption_key(u_char *);
50 void     packet_set_protocol_flags(u_int);
51 u_int	 packet_get_protocol_flags(void);
52 void     packet_start_compression(int);
53 void     packet_set_interactive(int);
54 int      packet_is_interactive(void);
55 
56 void     packet_start(u_char);
57 void     packet_put_char(int ch);
58 void     packet_put_int(u_int value);
59 void     packet_put_bignum(BIGNUM * value);
60 void     packet_put_bignum2(BIGNUM * value);
61 void     packet_put_string(const void *buf, u_int len);
62 void     packet_put_cstring(const char *str);
63 void     packet_put_ascii_cstring(const char *str);
64 void     packet_put_utf8_cstring(const u_char *str);
65 void     packet_put_raw(const void *buf, u_int len);
66 void     packet_send(void);
67 
68 #if 0
69 /* If these are needed, then get rid of the #if 0 and this comment */
70 void     packet_put_utf8_string(const u_char *buf, u_int len);
71 void     packet_put_ascii_string(const char *str, u_int len);
72 #endif
73 
74 int      packet_read(void);
75 void     packet_read_expect(int type);
76 int      packet_read_poll(void);
77 void     packet_process_incoming(const char *buf, u_int len);
78 int      packet_read_seqnr(u_int32_t *seqnr_p);
79 int      packet_read_poll_seqnr(u_int32_t *seqnr_p);
80 
81 u_int	 packet_get_char(void);
82 u_int	 packet_get_int(void);
83 void     packet_get_bignum(BIGNUM * value);
84 void     packet_get_bignum2(BIGNUM * value);
85 void	*packet_get_raw(u_int *length_ptr);
86 void	*packet_get_string(u_int *length_ptr);
87 char	*packet_get_ascii_cstring();
88 u_char	*packet_get_utf8_cstring();
89 void     packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
90 void     packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
91 
92 void	 set_newkeys(int mode);
93 void	 free_keys(Newkeys *keys);
94 
95 void     packet_write_poll(void);
96 void     packet_write_wait(void);
97 int      packet_have_data_to_write(void);
98 int      packet_not_very_much_data_to_write(void);
99 
100 int	 packet_connection_is_on_socket(void);
101 int	 packet_connection_is_ipv4(void);
102 int	 packet_remaining(void);
103 void	 packet_send_ignore(int);
104 void	 packet_add_padding(u_char);
105 
106 void	 tty_make_modes(int, struct termios *);
107 void	 tty_parse_modes(int, int *);
108 
109 extern int max_packet_size;
110 int      packet_set_maxsize(int);
111 #define  packet_get_maxsize() max_packet_size
112 
113 /* don't allow remaining bytes after the end of the message */
114 #define packet_check_eom() \
115 do { \
116 	int _len = packet_remaining(); \
117 	if (_len > 0) { \
118 		log("Packet integrity error (%d bytes remaining) at %s:%d", \
119 		    _len ,__FILE__, __LINE__); \
120 		packet_disconnect("Packet integrity error."); \
121 	} \
122 } while (0)
123 
124 int	 packet_need_rekeying(void);
125 void     packet_set_rekey_limit(u_int32_t);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* _PACKET_H */
132