blob: e563d8d3baeb6631af52f3e6a51ce8bafe882640 [file] [log] [blame]
markus@openbsd.org091c3022015-01-19 19:52:16 +00001#ifndef _OPACKET_H
2/* Written by Markus Friedl. Placed in the public domain. */
3
4/* Map old to new API */
5void ssh_packet_start(struct ssh *, u_char);
6void ssh_packet_put_char(struct ssh *, int ch);
7void ssh_packet_put_int(struct ssh *, u_int value);
8void ssh_packet_put_int64(struct ssh *, u_int64_t value);
9void ssh_packet_put_bignum(struct ssh *, BIGNUM * value);
10void ssh_packet_put_bignum2(struct ssh *, BIGNUM * value);
11void ssh_packet_put_ecpoint(struct ssh *, const EC_GROUP *, const EC_POINT *);
12void ssh_packet_put_string(struct ssh *, const void *buf, u_int len);
13void ssh_packet_put_cstring(struct ssh *, const char *str);
14void ssh_packet_put_raw(struct ssh *, const void *buf, u_int len);
15void ssh_packet_send(struct ssh *);
16
17u_int ssh_packet_get_char(struct ssh *);
18u_int ssh_packet_get_int(struct ssh *);
19u_int64_t ssh_packet_get_int64(struct ssh *);
20void ssh_packet_get_bignum(struct ssh *, BIGNUM * value);
21void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value);
22void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *);
23void *ssh_packet_get_string(struct ssh *, u_int *length_ptr);
24char *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr);
25
26/* don't allow remaining bytes after the end of the message */
27#define ssh_packet_check_eom(ssh) \
28do { \
29 int _len = ssh_packet_remaining(ssh); \
30 if (_len > 0) { \
31 logit("Packet integrity error (%d bytes remaining) at %s:%d", \
32 _len ,__FILE__, __LINE__); \
33 ssh_packet_disconnect(ssh, \
34 "Packet integrity error."); \
35 } \
36} while (0)
37
38/* old API */
39void packet_close(void);
40u_int packet_get_char(void);
41u_int packet_get_int(void);
42void packet_backup_state(void);
43void packet_restore_state(void);
44void packet_set_connection(int, int);
45int packet_read_seqnr(u_int32_t *);
46int packet_read_poll_seqnr(u_int32_t *);
djm@openbsd.orgfae7bbe2015-01-28 21:15:47 +000047void packet_process_incoming(const char *buf, u_int len);
djm@openbsd.org4509b5d2015-01-30 01:13:33 +000048void packet_write_wait(void);
49void packet_write_poll(void);
50void packet_read_expect(int expected_type);
markus@openbsd.org091c3022015-01-19 19:52:16 +000051#define packet_set_timeout(timeout, count) \
52 ssh_packet_set_timeout(active_state, (timeout), (count))
53#define packet_connection_is_on_socket() \
54 ssh_packet_connection_is_on_socket(active_state)
55#define packet_set_nonblocking() \
56 ssh_packet_set_nonblocking(active_state)
57#define packet_get_connection_in() \
58 ssh_packet_get_connection_in(active_state)
59#define packet_get_connection_out() \
60 ssh_packet_get_connection_out(active_state)
61#define packet_set_protocol_flags(protocol_flags) \
62 ssh_packet_set_protocol_flags(active_state, (protocol_flags))
63#define packet_get_protocol_flags() \
64 ssh_packet_get_protocol_flags(active_state)
65#define packet_start_compression(level) \
66 ssh_packet_start_compression(active_state, (level))
67#define packet_set_encryption_key(key, keylen, number) \
68 ssh_packet_set_encryption_key(active_state, (key), (keylen), (number))
69#define packet_start(type) \
70 ssh_packet_start(active_state, (type))
71#define packet_put_char(value) \
72 ssh_packet_put_char(active_state, (value))
73#define packet_put_int(value) \
74 ssh_packet_put_int(active_state, (value))
75#define packet_put_int64(value) \
76 ssh_packet_put_int64(active_state, (value))
77#define packet_put_string( buf, len) \
78 ssh_packet_put_string(active_state, (buf), (len))
79#define packet_put_cstring(str) \
80 ssh_packet_put_cstring(active_state, (str))
81#define packet_put_raw(buf, len) \
82 ssh_packet_put_raw(active_state, (buf), (len))
83#define packet_put_bignum(value) \
84 ssh_packet_put_bignum(active_state, (value))
85#define packet_put_bignum2(value) \
86 ssh_packet_put_bignum2(active_state, (value))
87#define packet_send() \
88 ssh_packet_send(active_state)
89#define packet_read() \
90 ssh_packet_read(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +000091#define packet_get_int64() \
92 ssh_packet_get_int64(active_state)
93#define packet_get_bignum(value) \
94 ssh_packet_get_bignum(active_state, (value))
95#define packet_get_bignum2(value) \
96 ssh_packet_get_bignum2(active_state, (value))
97#define packet_remaining() \
98 ssh_packet_remaining(active_state)
99#define packet_get_string(length_ptr) \
100 ssh_packet_get_string(active_state, (length_ptr))
101#define packet_get_string_ptr(length_ptr) \
102 ssh_packet_get_string_ptr(active_state, (length_ptr))
103#define packet_get_cstring(length_ptr) \
104 ssh_packet_get_cstring(active_state, (length_ptr))
105#define packet_send_debug(fmt, args...) \
106 ssh_packet_send_debug(active_state, (fmt), ##args)
107#define packet_disconnect(fmt, args...) \
108 ssh_packet_disconnect(active_state, (fmt), ##args)
markus@openbsd.org091c3022015-01-19 19:52:16 +0000109#define packet_have_data_to_write() \
110 ssh_packet_have_data_to_write(active_state)
111#define packet_not_very_much_data_to_write() \
112 ssh_packet_not_very_much_data_to_write(active_state)
113#define packet_set_interactive(interactive, qos_interactive, qos_bulk) \
114 ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk))
115#define packet_is_interactive() \
116 ssh_packet_is_interactive(active_state)
117#define packet_set_maxsize(s) \
118 ssh_packet_set_maxsize(active_state, (s))
119#define packet_inc_alive_timeouts() \
120 ssh_packet_inc_alive_timeouts(active_state)
121#define packet_set_alive_timeouts(ka) \
122 ssh_packet_set_alive_timeouts(active_state, (ka))
123#define packet_get_maxsize() \
124 ssh_packet_get_maxsize(active_state)
125#define packet_add_padding(pad) \
126 sshpkt_add_padding(active_state, (pad))
127#define packet_send_ignore(nbytes) \
128 ssh_packet_send_ignore(active_state, (nbytes))
129#define packet_need_rekeying() \
130 ssh_packet_need_rekeying(active_state)
131#define packet_set_rekey_limit(bytes) \
132 ssh_packet_set_rekey_limit(active_state, (bytes))
133#define packet_set_server() \
134 ssh_packet_set_server(active_state)
135#define packet_set_authenticated() \
136 ssh_packet_set_authenticated(active_state)
137#define packet_get_input() \
138 ssh_packet_get_input(active_state)
139#define packet_get_output() \
140 ssh_packet_get_output(active_state)
141#define packet_set_compress_hooks(ctx, allocfunc, freefunc) \
142 ssh_packet_set_compress_hooks(active_state, ctx, \
143 allocfunc, freefunc);
144#define packet_check_eom() \
145 ssh_packet_check_eom(active_state)
146#define set_newkeys(mode) \
147 ssh_set_newkeys(active_state, (mode))
148#define packet_get_state(m) \
149 ssh_packet_get_state(active_state, m)
150#define packet_set_state(m) \
151 ssh_packet_set_state(active_state, m)
152#if 0
153#define get_remote_ipaddr() \
154 ssh_remote_ipaddr(active_state)
155#endif
156#define packet_get_raw(lenp) \
157 sshpkt_ptr(active_state, lenp)
158#define packet_get_ecpoint(c,p) \
159 ssh_packet_get_ecpoint(active_state, c, p)
160#define packet_put_ecpoint(c,p) \
161 ssh_packet_put_ecpoint(active_state, c, p)
162#define packet_get_rekey_timeout() \
163 ssh_packet_get_rekey_timeout(active_state)
164#define packet_set_rekey_limits(x,y) \
165 ssh_packet_set_rekey_limits(active_state, x, y)
166#define packet_get_bytes(x,y) \
167 ssh_packet_get_bytes(active_state, x, y)
168
169#endif /* _OPACKET_H */