blob: f92fe586efb5eef39de165746eb73bb67221b0a3 [file] [log] [blame]
sf@openbsd.orgf28a4d52018-07-06 09:03:02 +00001/* $OpenBSD: opacket.h,v 1.13 2018/07/06 09:03:02 sf Exp $ */
markus@openbsd.org091c3022015-01-19 19:52:16 +00002#ifndef _OPACKET_H
3/* Written by Markus Friedl. Placed in the public domain. */
4
5/* Map old to new API */
6void ssh_packet_start(struct ssh *, u_char);
7void ssh_packet_put_char(struct ssh *, int ch);
8void ssh_packet_put_int(struct ssh *, u_int value);
9void ssh_packet_put_int64(struct ssh *, u_int64_t value);
markus@openbsd.org091c3022015-01-19 19:52:16 +000010void 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 *);
markus@openbsd.org091c3022015-01-19 19:52:16 +000020void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value);
21void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *);
22void *ssh_packet_get_string(struct ssh *, u_int *length_ptr);
23char *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr);
24
25/* don't allow remaining bytes after the end of the message */
26#define ssh_packet_check_eom(ssh) \
27do { \
28 int _len = ssh_packet_remaining(ssh); \
29 if (_len > 0) { \
30 logit("Packet integrity error (%d bytes remaining) at %s:%d", \
31 _len ,__FILE__, __LINE__); \
32 ssh_packet_disconnect(ssh, \
33 "Packet integrity error."); \
34 } \
35} while (0)
36
37/* old API */
38void packet_close(void);
39u_int packet_get_char(void);
40u_int packet_get_int(void);
markus@openbsd.org091c3022015-01-19 19:52:16 +000041void packet_set_connection(int, int);
42int packet_read_seqnr(u_int32_t *);
43int packet_read_poll_seqnr(u_int32_t *);
djm@openbsd.orgfae7bbe2015-01-28 21:15:47 +000044void packet_process_incoming(const char *buf, u_int len);
djm@openbsd.org4509b5d2015-01-30 01:13:33 +000045void packet_write_wait(void);
46void packet_write_poll(void);
47void packet_read_expect(int expected_type);
markus@openbsd.org091c3022015-01-19 19:52:16 +000048#define packet_set_timeout(timeout, count) \
49 ssh_packet_set_timeout(active_state, (timeout), (count))
50#define packet_connection_is_on_socket() \
51 ssh_packet_connection_is_on_socket(active_state)
52#define packet_set_nonblocking() \
53 ssh_packet_set_nonblocking(active_state)
54#define packet_get_connection_in() \
55 ssh_packet_get_connection_in(active_state)
56#define packet_get_connection_out() \
57 ssh_packet_get_connection_out(active_state)
58#define packet_set_protocol_flags(protocol_flags) \
59 ssh_packet_set_protocol_flags(active_state, (protocol_flags))
60#define packet_get_protocol_flags() \
61 ssh_packet_get_protocol_flags(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +000062#define packet_start(type) \
63 ssh_packet_start(active_state, (type))
64#define packet_put_char(value) \
65 ssh_packet_put_char(active_state, (value))
66#define packet_put_int(value) \
67 ssh_packet_put_int(active_state, (value))
68#define packet_put_int64(value) \
69 ssh_packet_put_int64(active_state, (value))
70#define packet_put_string( buf, len) \
71 ssh_packet_put_string(active_state, (buf), (len))
72#define packet_put_cstring(str) \
73 ssh_packet_put_cstring(active_state, (str))
74#define packet_put_raw(buf, len) \
75 ssh_packet_put_raw(active_state, (buf), (len))
markus@openbsd.org091c3022015-01-19 19:52:16 +000076#define packet_put_bignum2(value) \
77 ssh_packet_put_bignum2(active_state, (value))
78#define packet_send() \
79 ssh_packet_send(active_state)
80#define packet_read() \
81 ssh_packet_read(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +000082#define packet_get_int64() \
83 ssh_packet_get_int64(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +000084#define packet_get_bignum2(value) \
85 ssh_packet_get_bignum2(active_state, (value))
86#define packet_remaining() \
87 ssh_packet_remaining(active_state)
88#define packet_get_string(length_ptr) \
89 ssh_packet_get_string(active_state, (length_ptr))
90#define packet_get_string_ptr(length_ptr) \
91 ssh_packet_get_string_ptr(active_state, (length_ptr))
92#define packet_get_cstring(length_ptr) \
93 ssh_packet_get_cstring(active_state, (length_ptr))
Darren Tuckerdcc89972015-02-24 12:30:59 +110094void packet_send_debug(const char *, ...)
95 __attribute__((format(printf, 1, 2)));
96void packet_disconnect(const char *, ...)
97 __attribute__((format(printf, 1, 2)))
98 __attribute__((noreturn));
markus@openbsd.org091c3022015-01-19 19:52:16 +000099#define packet_have_data_to_write() \
100 ssh_packet_have_data_to_write(active_state)
101#define packet_not_very_much_data_to_write() \
102 ssh_packet_not_very_much_data_to_write(active_state)
103#define packet_set_interactive(interactive, qos_interactive, qos_bulk) \
104 ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk))
105#define packet_is_interactive() \
106 ssh_packet_is_interactive(active_state)
107#define packet_set_maxsize(s) \
108 ssh_packet_set_maxsize(active_state, (s))
109#define packet_inc_alive_timeouts() \
110 ssh_packet_inc_alive_timeouts(active_state)
111#define packet_set_alive_timeouts(ka) \
112 ssh_packet_set_alive_timeouts(active_state, (ka))
113#define packet_get_maxsize() \
114 ssh_packet_get_maxsize(active_state)
115#define packet_add_padding(pad) \
116 sshpkt_add_padding(active_state, (pad))
117#define packet_send_ignore(nbytes) \
118 ssh_packet_send_ignore(active_state, (nbytes))
markus@openbsd.org091c3022015-01-19 19:52:16 +0000119#define packet_set_server() \
120 ssh_packet_set_server(active_state)
121#define packet_set_authenticated() \
122 ssh_packet_set_authenticated(active_state)
123#define packet_get_input() \
124 ssh_packet_get_input(active_state)
125#define packet_get_output() \
126 ssh_packet_get_output(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +0000127#define packet_check_eom() \
128 ssh_packet_check_eom(active_state)
129#define set_newkeys(mode) \
130 ssh_set_newkeys(active_state, (mode))
131#define packet_get_state(m) \
132 ssh_packet_get_state(active_state, m)
133#define packet_set_state(m) \
134 ssh_packet_set_state(active_state, m)
markus@openbsd.org091c3022015-01-19 19:52:16 +0000135#define packet_get_raw(lenp) \
136 sshpkt_ptr(active_state, lenp)
137#define packet_get_ecpoint(c,p) \
138 ssh_packet_get_ecpoint(active_state, c, p)
139#define packet_put_ecpoint(c,p) \
140 ssh_packet_put_ecpoint(active_state, c, p)
141#define packet_get_rekey_timeout() \
142 ssh_packet_get_rekey_timeout(active_state)
143#define packet_set_rekey_limits(x,y) \
144 ssh_packet_set_rekey_limits(active_state, x, y)
145#define packet_get_bytes(x,y) \
146 ssh_packet_get_bytes(active_state, x, y)
markus@openbsd.org8d057842016-09-30 09:19:13 +0000147#define packet_set_mux() \
148 ssh_packet_set_mux(active_state)
149#define packet_get_mux() \
150 ssh_packet_get_mux(active_state)
markus@openbsd.org1e0cdf82017-05-31 08:09:45 +0000151#define packet_clear_keys() \
152 ssh_packet_clear_keys(active_state)
markus@openbsd.org091c3022015-01-19 19:52:16 +0000153
154#endif /* _OPACKET_H */