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