diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2019-01-19 21:45:32 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2019-01-19 21:45:32 +0000 |
commit | 2835a25ac8f4b8dc28d8f904c53e39a35ece2277 (patch) | |
tree | 80e9c624c931da6a0746b93f312b58747bdb9c4b /usr.bin/ssh | |
parent | c13a8e4fc99e498936ad59bc82f0b6fa782119d1 (diff) |
remove last traces of old packet API!
with & ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/Makefile.inc | 3 | ||||
-rw-r--r-- | usr.bin/ssh/dispatch.h | 9 | ||||
-rw-r--r-- | usr.bin/ssh/opacket.c | 289 | ||||
-rw-r--r-- | usr.bin/ssh/opacket.h | 153 |
4 files changed, 2 insertions, 452 deletions
diff --git a/usr.bin/ssh/Makefile.inc b/usr.bin/ssh/Makefile.inc index c568ffc079a..b60640b569e 100644 --- a/usr.bin/ssh/Makefile.inc +++ b/usr.bin/ssh/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.60 2018/07/18 11:34:04 dtucker Exp $ +# $OpenBSD: Makefile.inc,v 1.61 2019/01/19 21:45:31 djm Exp $ .include <bsd.own.mk> @@ -105,7 +105,6 @@ SRCS_PROT+= channels.c SRCS_PROT+= crc32.c SRCS_PROT+= monitor_fdpass.c SRCS_PROT+= nchan.c -SRCS_PROT+= opacket.c SRCS_PROT+= ttymodes.c SRCS_UTL+= addrmatch.c diff --git a/usr.bin/ssh/dispatch.h b/usr.bin/ssh/dispatch.h index 17a6f3db633..a22d7749feb 100644 --- a/usr.bin/ssh/dispatch.h +++ b/usr.bin/ssh/dispatch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.h,v 1.14 2017/05/31 07:00:13 markus Exp $ */ +/* $OpenBSD: dispatch.h,v 1.15 2019/01/19 21:45:31 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -46,11 +46,4 @@ void ssh_dispatch_range(struct ssh *, u_int, u_int, dispatch_fn *); int ssh_dispatch_run(struct ssh *, int, volatile sig_atomic_t *); void ssh_dispatch_run_fatal(struct ssh *, int, volatile sig_atomic_t *); -#define dispatch_init(dflt) \ - ssh_dispatch_init(active_state, (dflt)) -#define dispatch_range(from, to, fn) \ - ssh_dispatch_range(active_state, (from), (to), (fn)) -#define dispatch_set(type, fn) \ - ssh_dispatch_set(active_state, (type), (fn)) - #endif diff --git a/usr.bin/ssh/opacket.c b/usr.bin/ssh/opacket.c deleted file mode 100644 index 7de0f9cd911..00000000000 --- a/usr.bin/ssh/opacket.c +++ /dev/null @@ -1,289 +0,0 @@ -/* $OpenBSD: opacket.c,v 1.9 2019/01/19 21:33:14 djm Exp $ */ -/* Written by Markus Friedl. Placed in the public domain. */ - -#include "ssherr.h" -#include "packet.h" -#include "opacket.h" /* XXX */ -#include "log.h" - -struct ssh *active_state, *backup_state; - -/* Map old to new API */ - -void -ssh_packet_start(struct ssh *ssh, u_char type) -{ - int r; - - if ((r = sshpkt_start(ssh, type)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_char(struct ssh *ssh, int value) -{ - u_char ch = value; - int r; - - if ((r = sshpkt_put_u8(ssh, ch)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_int(struct ssh *ssh, u_int value) -{ - int r; - - if ((r = sshpkt_put_u32(ssh, value)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_int64(struct ssh *ssh, u_int64_t value) -{ - int r; - - if ((r = sshpkt_put_u64(ssh, value)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_string(struct ssh *ssh, const void *buf, u_int len) -{ - int r; - - if ((r = sshpkt_put_string(ssh, buf, len)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_cstring(struct ssh *ssh, const char *str) -{ - int r; - - if ((r = sshpkt_put_cstring(ssh, str)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_raw(struct ssh *ssh, const void *buf, u_int len) -{ - int r; - - if ((r = sshpkt_put(ssh, buf, len)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - - -#ifdef WITH_OPENSSL -void -ssh_packet_put_bignum2(struct ssh *ssh, BIGNUM * value) -{ - int r; - - if ((r = sshpkt_put_bignum2(ssh, value)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_put_ecpoint(struct ssh *ssh, const EC_GROUP *curve, - const EC_POINT *point) -{ - int r; - - if ((r = sshpkt_put_ec(ssh, point, curve)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} -#endif /* WITH_OPENSSL */ - -void -ssh_packet_send(struct ssh *ssh) -{ - int r; - - if ((r = sshpkt_send(ssh)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -u_int -ssh_packet_get_char(struct ssh *ssh) -{ - u_char ch; - int r; - - if ((r = sshpkt_get_u8(ssh, &ch)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - return ch; -} - -u_int -ssh_packet_get_int(struct ssh *ssh) -{ - u_int val; - int r; - - if ((r = sshpkt_get_u32(ssh, &val)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - return val; -} - -u_int64_t -ssh_packet_get_int64(struct ssh *ssh) -{ - u_int64_t val; - int r; - - if ((r = sshpkt_get_u64(ssh, &val)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - return val; -} - - -#ifdef WITH_OPENSSL -void -ssh_packet_get_bignum2(struct ssh *ssh, BIGNUM * value) -{ - int r; - - if ((r = sshpkt_get_bignum2(ssh, value)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} - -void -ssh_packet_get_ecpoint(struct ssh *ssh, const EC_GROUP *curve, EC_POINT *point) -{ - int r; - - if ((r = sshpkt_get_ec(ssh, point, curve)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); -} -#endif /* WITH_OPENSSL */ - -void * -ssh_packet_get_string(struct ssh *ssh, u_int *length_ptr) -{ - int r; - size_t len; - u_char *val; - - if ((r = sshpkt_get_string(ssh, &val, &len)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - if (length_ptr != NULL) - *length_ptr = (u_int)len; - return val; -} - -const void * -ssh_packet_get_string_ptr(struct ssh *ssh, u_int *length_ptr) -{ - int r; - size_t len; - const u_char *val; - - if ((r = sshpkt_get_string_direct(ssh, &val, &len)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - if (length_ptr != NULL) - *length_ptr = (u_int)len; - return val; -} - -char * -ssh_packet_get_cstring(struct ssh *ssh, u_int *length_ptr) -{ - int r; - size_t len; - char *val; - - if ((r = sshpkt_get_cstring(ssh, &val, &len)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); - if (length_ptr != NULL) - *length_ptr = (u_int)len; - return val; -} - -/* Old API, that had to be reimplemented */ - -void -packet_set_connection(int fd_in, int fd_out) -{ - active_state = ssh_packet_set_connection(active_state, fd_in, fd_out); - if (active_state == NULL) - fatal("%s: ssh_packet_set_connection failed", __func__); -} - -u_int -packet_get_char(void) -{ - return (ssh_packet_get_char(active_state)); -} - -u_int -packet_get_int(void) -{ - return (ssh_packet_get_int(active_state)); -} - -int -packet_read_seqnr(u_int32_t *seqnr) -{ - u_char type; - int r; - - if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) - sshpkt_fatal(active_state, r, "%s", __func__); - return type; -} - -int -packet_read_poll_seqnr(u_int32_t *seqnr) -{ - u_char type; - int r; - - if ((r = ssh_packet_read_poll_seqnr(active_state, &type, seqnr))) - sshpkt_fatal(active_state, r, "%s", __func__); - return type; -} - -void -packet_close(void) -{ - ssh_packet_close(active_state); - active_state = NULL; -} - -void -packet_process_incoming(const char *buf, u_int len) -{ - int r; - - if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0) - sshpkt_fatal(active_state, r, "%s", __func__); -} - -void -packet_write_wait(void) -{ - int r; - - if ((r = ssh_packet_write_wait(active_state)) != 0) - sshpkt_fatal(active_state, r, "%s", __func__); -} - -void -packet_write_poll(void) -{ - int r; - - if ((r = ssh_packet_write_poll(active_state)) != 0) - sshpkt_fatal(active_state, r, "%s", __func__); -} - -void -packet_read_expect(int expected_type) -{ - int r; - - if ((r = ssh_packet_read_expect(active_state, expected_type)) != 0) - sshpkt_fatal(active_state, r, "%s", __func__); -} diff --git a/usr.bin/ssh/opacket.h b/usr.bin/ssh/opacket.h deleted file mode 100644 index c6e51248feb..00000000000 --- a/usr.bin/ssh/opacket.h +++ /dev/null @@ -1,153 +0,0 @@ -/* $OpenBSD: opacket.h,v 1.13 2018/07/06 09:03:02 sf Exp $ */ -#ifndef _OPACKET_H -/* Written by Markus Friedl. Placed in the public domain. */ - -/* Map old to new API */ -void ssh_packet_start(struct ssh *, u_char); -void ssh_packet_put_char(struct ssh *, int ch); -void ssh_packet_put_int(struct ssh *, u_int value); -void ssh_packet_put_int64(struct ssh *, u_int64_t value); -void ssh_packet_put_bignum2(struct ssh *, BIGNUM * value); -void ssh_packet_put_ecpoint(struct ssh *, const EC_GROUP *, const EC_POINT *); -void ssh_packet_put_string(struct ssh *, const void *buf, u_int len); -void ssh_packet_put_cstring(struct ssh *, const char *str); -void ssh_packet_put_raw(struct ssh *, const void *buf, u_int len); -void ssh_packet_send(struct ssh *); - -u_int ssh_packet_get_char(struct ssh *); -u_int ssh_packet_get_int(struct ssh *); -u_int64_t ssh_packet_get_int64(struct ssh *); -void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value); -void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *); -void *ssh_packet_get_string(struct ssh *, u_int *length_ptr); -char *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr); - -/* don't allow remaining bytes after the end of the message */ -#define ssh_packet_check_eom(ssh) \ -do { \ - int _len = ssh_packet_remaining(ssh); \ - if (_len > 0) { \ - logit("Packet integrity error (%d bytes remaining) at %s:%d", \ - _len ,__FILE__, __LINE__); \ - ssh_packet_disconnect(ssh, \ - "Packet integrity error."); \ - } \ -} while (0) - -/* old API */ -void packet_close(void); -u_int packet_get_char(void); -u_int packet_get_int(void); -void packet_set_connection(int, int); -int packet_read_seqnr(u_int32_t *); -int packet_read_poll_seqnr(u_int32_t *); -void packet_process_incoming(const char *buf, u_int len); -void packet_write_wait(void); -void packet_write_poll(void); -void packet_read_expect(int expected_type); -#define packet_set_timeout(timeout, count) \ - ssh_packet_set_timeout(active_state, (timeout), (count)) -#define packet_connection_is_on_socket() \ - ssh_packet_connection_is_on_socket(active_state) -#define packet_set_nonblocking() \ - ssh_packet_set_nonblocking(active_state) -#define packet_get_connection_in() \ - ssh_packet_get_connection_in(active_state) -#define packet_get_connection_out() \ - ssh_packet_get_connection_out(active_state) -#define packet_set_protocol_flags(protocol_flags) \ - ssh_packet_set_protocol_flags(active_state, (protocol_flags)) -#define packet_get_protocol_flags() \ - ssh_packet_get_protocol_flags(active_state) -#define packet_start(type) \ - ssh_packet_start(active_state, (type)) -#define packet_put_char(value) \ - ssh_packet_put_char(active_state, (value)) -#define packet_put_int(value) \ - ssh_packet_put_int(active_state, (value)) -#define packet_put_int64(value) \ - ssh_packet_put_int64(active_state, (value)) -#define packet_put_string( buf, len) \ - ssh_packet_put_string(active_state, (buf), (len)) -#define packet_put_cstring(str) \ - ssh_packet_put_cstring(active_state, (str)) -#define packet_put_raw(buf, len) \ - ssh_packet_put_raw(active_state, (buf), (len)) -#define packet_put_bignum2(value) \ - ssh_packet_put_bignum2(active_state, (value)) -#define packet_send() \ - ssh_packet_send(active_state) -#define packet_read() \ - ssh_packet_read(active_state) -#define packet_get_int64() \ - ssh_packet_get_int64(active_state) -#define packet_get_bignum2(value) \ - ssh_packet_get_bignum2(active_state, (value)) -#define packet_remaining() \ - ssh_packet_remaining(active_state) -#define packet_get_string(length_ptr) \ - ssh_packet_get_string(active_state, (length_ptr)) -#define packet_get_string_ptr(length_ptr) \ - ssh_packet_get_string_ptr(active_state, (length_ptr)) -#define packet_get_cstring(length_ptr) \ - ssh_packet_get_cstring(active_state, (length_ptr)) -#define packet_send_debug(fmt, args...) \ - ssh_packet_send_debug(active_state, (fmt), ##args) -#define packet_disconnect(fmt, args...) \ - ssh_packet_disconnect(active_state, (fmt), ##args) -#define packet_have_data_to_write() \ - ssh_packet_have_data_to_write(active_state) -#define packet_not_very_much_data_to_write() \ - ssh_packet_not_very_much_data_to_write(active_state) -#define packet_set_interactive(interactive, qos_interactive, qos_bulk) \ - ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk)) -#define packet_is_interactive() \ - ssh_packet_is_interactive(active_state) -#define packet_set_maxsize(s) \ - ssh_packet_set_maxsize(active_state, (s)) -#define packet_inc_alive_timeouts() \ - ssh_packet_inc_alive_timeouts(active_state) -#define packet_set_alive_timeouts(ka) \ - ssh_packet_set_alive_timeouts(active_state, (ka)) -#define packet_get_maxsize() \ - ssh_packet_get_maxsize(active_state) -#define packet_add_padding(pad) \ - sshpkt_add_padding(active_state, (pad)) -#define packet_send_ignore(nbytes) \ - ssh_packet_send_ignore(active_state, (nbytes)) -#define packet_set_server() \ - ssh_packet_set_server(active_state) -#define packet_set_authenticated() \ - ssh_packet_set_authenticated(active_state) -#define packet_get_input() \ - ssh_packet_get_input(active_state) -#define packet_get_output() \ - ssh_packet_get_output(active_state) -#define packet_check_eom() \ - ssh_packet_check_eom(active_state) -#define set_newkeys(mode) \ - ssh_set_newkeys(active_state, (mode)) -#define packet_get_state(m) \ - ssh_packet_get_state(active_state, m) -#define packet_set_state(m) \ - ssh_packet_set_state(active_state, m) -#define packet_get_raw(lenp) \ - sshpkt_ptr(active_state, lenp) -#define packet_get_ecpoint(c,p) \ - ssh_packet_get_ecpoint(active_state, c, p) -#define packet_put_ecpoint(c,p) \ - ssh_packet_put_ecpoint(active_state, c, p) -#define packet_get_rekey_timeout() \ - ssh_packet_get_rekey_timeout(active_state) -#define packet_set_rekey_limits(x,y) \ - ssh_packet_set_rekey_limits(active_state, x, y) -#define packet_get_bytes(x,y) \ - ssh_packet_get_bytes(active_state, x, y) -#define packet_set_mux() \ - ssh_packet_set_mux(active_state) -#define packet_get_mux() \ - ssh_packet_get_mux(active_state) -#define packet_clear_keys() \ - ssh_packet_clear_keys(active_state) - -#endif /* _OPACKET_H */ |