From d876aad77b29f410c9c4218636482cab59504fac Mon Sep 17 00:00:00 2001 From: Håkon Nessjøen Date: Tue, 8 Nov 2011 23:06:39 +0100 Subject: Clean up and bugfix endianess handling --- mactelnet.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'mactelnet.c') diff --git a/mactelnet.c b/mactelnet.c index 288fd3b..ce91d01 100644 --- a/mactelnet.c +++ b/mactelnet.c @@ -16,12 +16,14 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define _BSD_SOURCE #include #include #include #include #include #include +#include #include #include #include @@ -177,11 +179,8 @@ static void send_auth(char *username, char *password) { plen += add_control_packet(&data, MT_CPTYPE_TERM_TYPE, terminal, strlen(terminal)); if (is_a_tty && get_terminal_size(&width, &height) != -1) { -#if BYTE_ORDER == BIG_ENDIAN - /* Seems like Mikrotik are sending data little_endianed? */ - width = ((width & 0xff) << 8) | ((width & 0xff00) >> 8); - height = ((height & 0xff) << 8) | ((height & 0xff00) >> 8); -#endif + width = htole16(width); + height = htole16(height); plen += add_control_packet(&data, MT_CPTYPE_TERM_WIDTH, &width, 2); plen += add_control_packet(&data, MT_CPTYPE_TERM_HEIGHT, &height, 2); } @@ -200,6 +199,8 @@ static void sig_winch(int sig) { /* terminal height/width has changed, inform server */ if (get_terminal_size(&width, &height) != -1) { init_packet(&data, MT_PTYPE_DATA, srcmac, dstmac, sessionkey, outcounter); + width = htole16(width); + height = htole16(height); plen = add_control_packet(&data, MT_CPTYPE_TERM_WIDTH, &width, 2); plen += add_control_packet(&data, MT_CPTYPE_TERM_HEIGHT, &height, 2); outcounter += plen; -- cgit v1.2.3