markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 1 | #ifndef _OPACKET_H |
| 2 | /* Written by Markus Friedl. Placed in the public domain. */ |
| 3 | |
| 4 | /* Map old to new API */ |
| 5 | void ssh_packet_start(struct ssh *, u_char); |
| 6 | void ssh_packet_put_char(struct ssh *, int ch); |
| 7 | void ssh_packet_put_int(struct ssh *, u_int value); |
| 8 | void ssh_packet_put_int64(struct ssh *, u_int64_t value); |
| 9 | void ssh_packet_put_bignum(struct ssh *, BIGNUM * value); |
| 10 | void ssh_packet_put_bignum2(struct ssh *, BIGNUM * value); |
| 11 | void ssh_packet_put_ecpoint(struct ssh *, const EC_GROUP *, const EC_POINT *); |
| 12 | void ssh_packet_put_string(struct ssh *, const void *buf, u_int len); |
| 13 | void ssh_packet_put_cstring(struct ssh *, const char *str); |
| 14 | void ssh_packet_put_raw(struct ssh *, const void *buf, u_int len); |
| 15 | void ssh_packet_send(struct ssh *); |
| 16 | |
| 17 | u_int ssh_packet_get_char(struct ssh *); |
| 18 | u_int ssh_packet_get_int(struct ssh *); |
| 19 | u_int64_t ssh_packet_get_int64(struct ssh *); |
| 20 | void ssh_packet_get_bignum(struct ssh *, BIGNUM * value); |
| 21 | void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value); |
| 22 | void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *); |
| 23 | void *ssh_packet_get_string(struct ssh *, u_int *length_ptr); |
| 24 | char *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) \ |
| 28 | do { \ |
| 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 */ |
| 39 | void packet_close(void); |
| 40 | u_int packet_get_char(void); |
| 41 | u_int packet_get_int(void); |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 42 | void packet_set_connection(int, int); |
| 43 | int packet_read_seqnr(u_int32_t *); |
| 44 | int packet_read_poll_seqnr(u_int32_t *); |
djm@openbsd.org | fae7bbe | 2015-01-28 21:15:47 +0000 | [diff] [blame] | 45 | void packet_process_incoming(const char *buf, u_int len); |
djm@openbsd.org | 4509b5d | 2015-01-30 01:13:33 +0000 | [diff] [blame] | 46 | void packet_write_wait(void); |
| 47 | void packet_write_poll(void); |
| 48 | void packet_read_expect(int expected_type); |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 49 | #define packet_set_timeout(timeout, count) \ |
| 50 | ssh_packet_set_timeout(active_state, (timeout), (count)) |
| 51 | #define packet_connection_is_on_socket() \ |
| 52 | ssh_packet_connection_is_on_socket(active_state) |
| 53 | #define packet_set_nonblocking() \ |
| 54 | ssh_packet_set_nonblocking(active_state) |
| 55 | #define packet_get_connection_in() \ |
| 56 | ssh_packet_get_connection_in(active_state) |
| 57 | #define packet_get_connection_out() \ |
| 58 | ssh_packet_get_connection_out(active_state) |
| 59 | #define packet_set_protocol_flags(protocol_flags) \ |
| 60 | ssh_packet_set_protocol_flags(active_state, (protocol_flags)) |
| 61 | #define packet_get_protocol_flags() \ |
| 62 | ssh_packet_get_protocol_flags(active_state) |
| 63 | #define packet_start_compression(level) \ |
| 64 | ssh_packet_start_compression(active_state, (level)) |
| 65 | #define packet_set_encryption_key(key, keylen, number) \ |
| 66 | ssh_packet_set_encryption_key(active_state, (key), (keylen), (number)) |
| 67 | #define packet_start(type) \ |
| 68 | ssh_packet_start(active_state, (type)) |
| 69 | #define packet_put_char(value) \ |
| 70 | ssh_packet_put_char(active_state, (value)) |
| 71 | #define packet_put_int(value) \ |
| 72 | ssh_packet_put_int(active_state, (value)) |
| 73 | #define packet_put_int64(value) \ |
| 74 | ssh_packet_put_int64(active_state, (value)) |
| 75 | #define packet_put_string( buf, len) \ |
| 76 | ssh_packet_put_string(active_state, (buf), (len)) |
| 77 | #define packet_put_cstring(str) \ |
| 78 | ssh_packet_put_cstring(active_state, (str)) |
| 79 | #define packet_put_raw(buf, len) \ |
| 80 | ssh_packet_put_raw(active_state, (buf), (len)) |
| 81 | #define packet_put_bignum(value) \ |
| 82 | ssh_packet_put_bignum(active_state, (value)) |
| 83 | #define packet_put_bignum2(value) \ |
| 84 | ssh_packet_put_bignum2(active_state, (value)) |
| 85 | #define packet_send() \ |
| 86 | ssh_packet_send(active_state) |
| 87 | #define packet_read() \ |
| 88 | ssh_packet_read(active_state) |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 89 | #define packet_get_int64() \ |
| 90 | ssh_packet_get_int64(active_state) |
| 91 | #define packet_get_bignum(value) \ |
| 92 | ssh_packet_get_bignum(active_state, (value)) |
| 93 | #define packet_get_bignum2(value) \ |
| 94 | ssh_packet_get_bignum2(active_state, (value)) |
| 95 | #define packet_remaining() \ |
| 96 | ssh_packet_remaining(active_state) |
| 97 | #define packet_get_string(length_ptr) \ |
| 98 | ssh_packet_get_string(active_state, (length_ptr)) |
| 99 | #define packet_get_string_ptr(length_ptr) \ |
| 100 | ssh_packet_get_string_ptr(active_state, (length_ptr)) |
| 101 | #define packet_get_cstring(length_ptr) \ |
| 102 | ssh_packet_get_cstring(active_state, (length_ptr)) |
Darren Tucker | dcc8997 | 2015-02-24 12:30:59 +1100 | [diff] [blame] | 103 | void packet_send_debug(const char *, ...) |
| 104 | __attribute__((format(printf, 1, 2))); |
| 105 | void packet_disconnect(const char *, ...) |
| 106 | __attribute__((format(printf, 1, 2))) |
| 107 | __attribute__((noreturn)); |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 108 | #define packet_have_data_to_write() \ |
| 109 | ssh_packet_have_data_to_write(active_state) |
| 110 | #define packet_not_very_much_data_to_write() \ |
| 111 | ssh_packet_not_very_much_data_to_write(active_state) |
| 112 | #define packet_set_interactive(interactive, qos_interactive, qos_bulk) \ |
| 113 | ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk)) |
| 114 | #define packet_is_interactive() \ |
| 115 | ssh_packet_is_interactive(active_state) |
| 116 | #define packet_set_maxsize(s) \ |
| 117 | ssh_packet_set_maxsize(active_state, (s)) |
| 118 | #define packet_inc_alive_timeouts() \ |
| 119 | ssh_packet_inc_alive_timeouts(active_state) |
| 120 | #define packet_set_alive_timeouts(ka) \ |
| 121 | ssh_packet_set_alive_timeouts(active_state, (ka)) |
| 122 | #define packet_get_maxsize() \ |
| 123 | ssh_packet_get_maxsize(active_state) |
| 124 | #define packet_add_padding(pad) \ |
| 125 | sshpkt_add_padding(active_state, (pad)) |
| 126 | #define packet_send_ignore(nbytes) \ |
| 127 | ssh_packet_send_ignore(active_state, (nbytes)) |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 128 | #define packet_set_server() \ |
| 129 | ssh_packet_set_server(active_state) |
| 130 | #define packet_set_authenticated() \ |
| 131 | ssh_packet_set_authenticated(active_state) |
| 132 | #define packet_get_input() \ |
| 133 | ssh_packet_get_input(active_state) |
| 134 | #define packet_get_output() \ |
| 135 | ssh_packet_get_output(active_state) |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 136 | #define packet_check_eom() \ |
| 137 | ssh_packet_check_eom(active_state) |
| 138 | #define set_newkeys(mode) \ |
| 139 | ssh_set_newkeys(active_state, (mode)) |
| 140 | #define packet_get_state(m) \ |
| 141 | ssh_packet_get_state(active_state, m) |
| 142 | #define packet_set_state(m) \ |
| 143 | ssh_packet_set_state(active_state, m) |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 144 | #define packet_get_raw(lenp) \ |
| 145 | sshpkt_ptr(active_state, lenp) |
| 146 | #define packet_get_ecpoint(c,p) \ |
| 147 | ssh_packet_get_ecpoint(active_state, c, p) |
| 148 | #define packet_put_ecpoint(c,p) \ |
| 149 | ssh_packet_put_ecpoint(active_state, c, p) |
| 150 | #define packet_get_rekey_timeout() \ |
| 151 | ssh_packet_get_rekey_timeout(active_state) |
| 152 | #define packet_set_rekey_limits(x,y) \ |
| 153 | ssh_packet_set_rekey_limits(active_state, x, y) |
| 154 | #define packet_get_bytes(x,y) \ |
| 155 | ssh_packet_get_bytes(active_state, x, y) |
markus@openbsd.org | 8d05784 | 2016-09-30 09:19:13 +0000 | [diff] [blame] | 156 | #define packet_set_mux() \ |
| 157 | ssh_packet_set_mux(active_state) |
| 158 | #define packet_get_mux() \ |
| 159 | ssh_packet_get_mux(active_state) |
markus@openbsd.org | 091c302 | 2015-01-19 19:52:16 +0000 | [diff] [blame] | 160 | |
| 161 | #endif /* _OPACKET_H */ |