1285031Sdes#ifndef _OPACKET_H 2285031Sdes/* Written by Markus Friedl. Placed in the public domain. */ 3285031Sdes 4285031Sdes/* Map old to new API */ 5285031Sdesvoid ssh_packet_start(struct ssh *, u_char); 6285031Sdesvoid ssh_packet_put_char(struct ssh *, int ch); 7285031Sdesvoid ssh_packet_put_int(struct ssh *, u_int value); 8285031Sdesvoid ssh_packet_put_int64(struct ssh *, u_int64_t value); 9285031Sdesvoid ssh_packet_put_bignum(struct ssh *, BIGNUM * value); 10285031Sdesvoid ssh_packet_put_bignum2(struct ssh *, BIGNUM * value); 11285031Sdesvoid ssh_packet_put_ecpoint(struct ssh *, const EC_GROUP *, const EC_POINT *); 12285031Sdesvoid ssh_packet_put_string(struct ssh *, const void *buf, u_int len); 13285031Sdesvoid ssh_packet_put_cstring(struct ssh *, const char *str); 14285031Sdesvoid ssh_packet_put_raw(struct ssh *, const void *buf, u_int len); 15285031Sdesvoid ssh_packet_send(struct ssh *); 16285031Sdes 17285031Sdesu_int ssh_packet_get_char(struct ssh *); 18285031Sdesu_int ssh_packet_get_int(struct ssh *); 19285031Sdesu_int64_t ssh_packet_get_int64(struct ssh *); 20285031Sdesvoid ssh_packet_get_bignum(struct ssh *, BIGNUM * value); 21285031Sdesvoid ssh_packet_get_bignum2(struct ssh *, BIGNUM * value); 22285031Sdesvoid ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *); 23285031Sdesvoid *ssh_packet_get_string(struct ssh *, u_int *length_ptr); 24285031Sdeschar *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr); 25285031Sdes 26285031Sdes/* don't allow remaining bytes after the end of the message */ 27285031Sdes#define ssh_packet_check_eom(ssh) \ 28285031Sdesdo { \ 29285031Sdes int _len = ssh_packet_remaining(ssh); \ 30285031Sdes if (_len > 0) { \ 31285031Sdes logit("Packet integrity error (%d bytes remaining) at %s:%d", \ 32285031Sdes _len ,__FILE__, __LINE__); \ 33285031Sdes ssh_packet_disconnect(ssh, \ 34285031Sdes "Packet integrity error."); \ 35285031Sdes } \ 36285031Sdes} while (0) 37285031Sdes 38285031Sdes/* old API */ 39285031Sdesvoid packet_close(void); 40285031Sdesu_int packet_get_char(void); 41285031Sdesu_int packet_get_int(void); 42285031Sdesvoid packet_set_connection(int, int); 43285031Sdesint packet_read_seqnr(u_int32_t *); 44285031Sdesint packet_read_poll_seqnr(u_int32_t *); 45285031Sdesvoid packet_process_incoming(const char *buf, u_int len); 46285031Sdesvoid packet_write_wait(void); 47285031Sdesvoid packet_write_poll(void); 48285031Sdesvoid packet_read_expect(int expected_type); 49285031Sdes#define packet_set_timeout(timeout, count) \ 50285031Sdes ssh_packet_set_timeout(active_state, (timeout), (count)) 51285031Sdes#define packet_connection_is_on_socket() \ 52285031Sdes ssh_packet_connection_is_on_socket(active_state) 53285031Sdes#define packet_set_nonblocking() \ 54285031Sdes ssh_packet_set_nonblocking(active_state) 55285031Sdes#define packet_get_connection_in() \ 56285031Sdes ssh_packet_get_connection_in(active_state) 57285031Sdes#define packet_get_connection_out() \ 58285031Sdes ssh_packet_get_connection_out(active_state) 59285031Sdes#define packet_set_protocol_flags(protocol_flags) \ 60285031Sdes ssh_packet_set_protocol_flags(active_state, (protocol_flags)) 61285031Sdes#define packet_get_protocol_flags() \ 62285031Sdes ssh_packet_get_protocol_flags(active_state) 63285031Sdes#define packet_start_compression(level) \ 64285031Sdes ssh_packet_start_compression(active_state, (level)) 65285031Sdes#define packet_set_encryption_key(key, keylen, number) \ 66285031Sdes ssh_packet_set_encryption_key(active_state, (key), (keylen), (number)) 67285031Sdes#define packet_start(type) \ 68285031Sdes ssh_packet_start(active_state, (type)) 69285031Sdes#define packet_put_char(value) \ 70285031Sdes ssh_packet_put_char(active_state, (value)) 71285031Sdes#define packet_put_int(value) \ 72285031Sdes ssh_packet_put_int(active_state, (value)) 73285031Sdes#define packet_put_int64(value) \ 74285031Sdes ssh_packet_put_int64(active_state, (value)) 75285031Sdes#define packet_put_string( buf, len) \ 76285031Sdes ssh_packet_put_string(active_state, (buf), (len)) 77285031Sdes#define packet_put_cstring(str) \ 78285031Sdes ssh_packet_put_cstring(active_state, (str)) 79285031Sdes#define packet_put_raw(buf, len) \ 80285031Sdes ssh_packet_put_raw(active_state, (buf), (len)) 81285031Sdes#define packet_put_bignum(value) \ 82285031Sdes ssh_packet_put_bignum(active_state, (value)) 83285031Sdes#define packet_put_bignum2(value) \ 84285031Sdes ssh_packet_put_bignum2(active_state, (value)) 85285031Sdes#define packet_send() \ 86285031Sdes ssh_packet_send(active_state) 87285031Sdes#define packet_read() \ 88285031Sdes ssh_packet_read(active_state) 89285031Sdes#define packet_get_int64() \ 90285031Sdes ssh_packet_get_int64(active_state) 91285031Sdes#define packet_get_bignum(value) \ 92285031Sdes ssh_packet_get_bignum(active_state, (value)) 93285031Sdes#define packet_get_bignum2(value) \ 94285031Sdes ssh_packet_get_bignum2(active_state, (value)) 95285031Sdes#define packet_remaining() \ 96285031Sdes ssh_packet_remaining(active_state) 97285031Sdes#define packet_get_string(length_ptr) \ 98285031Sdes ssh_packet_get_string(active_state, (length_ptr)) 99285031Sdes#define packet_get_string_ptr(length_ptr) \ 100285031Sdes ssh_packet_get_string_ptr(active_state, (length_ptr)) 101285031Sdes#define packet_get_cstring(length_ptr) \ 102285031Sdes ssh_packet_get_cstring(active_state, (length_ptr)) 103285031Sdesvoid packet_send_debug(const char *, ...) 104285031Sdes __attribute__((format(printf, 1, 2))); 105285031Sdesvoid packet_disconnect(const char *, ...) 106285031Sdes __attribute__((format(printf, 1, 2))) 107285031Sdes __attribute__((noreturn)); 108285031Sdes#define packet_have_data_to_write() \ 109285031Sdes ssh_packet_have_data_to_write(active_state) 110285031Sdes#define packet_not_very_much_data_to_write() \ 111285031Sdes ssh_packet_not_very_much_data_to_write(active_state) 112285031Sdes#define packet_set_interactive(interactive, qos_interactive, qos_bulk) \ 113285031Sdes ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk)) 114285031Sdes#define packet_is_interactive() \ 115285031Sdes ssh_packet_is_interactive(active_state) 116285031Sdes#define packet_set_maxsize(s) \ 117285031Sdes ssh_packet_set_maxsize(active_state, (s)) 118285031Sdes#define packet_inc_alive_timeouts() \ 119285031Sdes ssh_packet_inc_alive_timeouts(active_state) 120285031Sdes#define packet_set_alive_timeouts(ka) \ 121285031Sdes ssh_packet_set_alive_timeouts(active_state, (ka)) 122285031Sdes#define packet_get_maxsize() \ 123285031Sdes ssh_packet_get_maxsize(active_state) 124285031Sdes#define packet_add_padding(pad) \ 125285031Sdes sshpkt_add_padding(active_state, (pad)) 126285031Sdes#define packet_send_ignore(nbytes) \ 127285031Sdes ssh_packet_send_ignore(active_state, (nbytes)) 128285031Sdes#define packet_set_server() \ 129285031Sdes ssh_packet_set_server(active_state) 130285031Sdes#define packet_set_authenticated() \ 131285031Sdes ssh_packet_set_authenticated(active_state) 132285031Sdes#define packet_get_input() \ 133285031Sdes ssh_packet_get_input(active_state) 134285031Sdes#define packet_get_output() \ 135285031Sdes ssh_packet_get_output(active_state) 136285031Sdes#define packet_set_compress_hooks(ctx, allocfunc, freefunc) \ 137285031Sdes ssh_packet_set_compress_hooks(active_state, ctx, \ 138285031Sdes allocfunc, freefunc); 139285031Sdes#define packet_check_eom() \ 140285031Sdes ssh_packet_check_eom(active_state) 141285031Sdes#define set_newkeys(mode) \ 142285031Sdes ssh_set_newkeys(active_state, (mode)) 143285031Sdes#define packet_get_state(m) \ 144285031Sdes ssh_packet_get_state(active_state, m) 145285031Sdes#define packet_set_state(m) \ 146285031Sdes ssh_packet_set_state(active_state, m) 147285031Sdes#define packet_get_raw(lenp) \ 148285031Sdes sshpkt_ptr(active_state, lenp) 149285031Sdes#define packet_get_ecpoint(c,p) \ 150285031Sdes ssh_packet_get_ecpoint(active_state, c, p) 151285031Sdes#define packet_put_ecpoint(c,p) \ 152285031Sdes ssh_packet_put_ecpoint(active_state, c, p) 153285031Sdes#define packet_get_rekey_timeout() \ 154285031Sdes ssh_packet_get_rekey_timeout(active_state) 155285031Sdes#define packet_set_rekey_limits(x,y) \ 156285031Sdes ssh_packet_set_rekey_limits(active_state, x, y) 157285031Sdes#define packet_get_bytes(x,y) \ 158285031Sdes ssh_packet_get_bytes(active_state, x, y) 159285031Sdes 160285031Sdes#endif /* _OPACKET_H */ 161