Fix byte order of extended control encode, decode

Fix byte order of extended format control encoding and decoding in the
following src/frame.c functions:

    * patty_ax25_frame_decode_control()

    * patty_ax25_frame_encode_reply_to()
This commit is contained in:
XANTRONIX Development 2020-07-19 22:51:17 -04:00 committed by XANTRONIX Industrial
parent 08c952ae07
commit acce657f63

View file

@ -195,14 +195,13 @@ ssize_t patty_ax25_frame_decode_control(patty_ax25_frame *frame,
break;
case PATTY_AX25_FRAME_EXTENDED:
frame->control = (uint16_t)(buf[offset++] << 8);
frame->control |= (uint16_t)(buf[offset++]);
frame->control = (uint16_t)(buf[offset++]);
if (PATTY_AX25_FRAME_CONTROL_U(frame->control)) {
errno = EIO;
goto error;
if (!PATTY_AX25_FRAME_CONTROL_U(frame->control)) {
frame->control |= (uint16_t)(buf[offset++] << 8);
}
break;
}
if (PATTY_AX25_FRAME_CONTROL_I(frame->control)) {
@ -638,8 +637,11 @@ ssize_t patty_ax25_frame_encode_reply_to(patty_ax25_frame *frame,
break;
case PATTY_AX25_FRAME_EXTENDED:
((uint8_t *)buf)[offset++] = (reply->control & 0xff00) >> 8;
((uint8_t *)buf)[offset++] = reply->control & 0xf00ff;
((uint8_t *)buf)[offset++] = reply->control & 0x00ff;
if (!PATTY_AX25_FRAME_CONTROL_U(reply->control)) {
((uint8_t *)buf)[offset++] = (reply->control & 0xff00) >> 8;
}
break;
}