From 5fe656762fa8a198447e6372b6e6c417e0613f36 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 18 Jul 2015 02:41:42 -0500 Subject: [PATCH] At least now, we can discern between commands and responses --- include/patty/ax25.h | 6 ++++++ src/ax25.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/patty/ax25.h b/include/patty/ax25.h index 9f3281b..3a14532 100644 --- a/include/patty/ax25.h +++ b/include/patty/ax25.h @@ -38,6 +38,11 @@ enum patty_ax25_frame_type { PATTY_AX25_FRAME_UNNUMBERED }; +enum patty_ax25_frame_cr { + PATTY_AX25_FRAME_COMMAND, + PATTY_AX25_FRAME_RESPONSE +}; + typedef struct _patty_ax25_address { char callsign[7]; @@ -60,6 +65,7 @@ typedef struct _patty_ax25_frame { enum patty_ax25_version version; enum patty_ax25_frame_type type; + enum patty_ax25_frame_cr cr; uint8_t control; uint8_t proto; diff --git a/src/ax25.c b/src/ax25.c index 3d75a64..bc0ca2a 100644 --- a/src/ax25.c +++ b/src/ax25.c @@ -121,6 +121,20 @@ static ssize_t frame_decode_address(patty_ax25_frame *frame, void *data, off_t s offset += decoded; } + /* + * Determine whether the current frame is a Command or Response, and which + * version of AX.25 this frame adheres to. + */ + if (PATTY_AX25_ADDRESS_SSID_C(frame->src.ssid)) { + frame->cr = PATTY_AX25_FRAME_RESPONSE; + frame->version = PATTY_AX25_ADDRESS_SSID_C(frame->dest.ssid)? + PATTY_AX25_OLD: PATTY_AX25_2_0; + } else { + frame->cr = PATTY_AX25_FRAME_COMMAND; + frame->version = PATTY_AX25_ADDRESS_SSID_C(frame->src.ssid)? + PATTY_AX25_OLD: PATTY_AX25_2_0; + } + /* * If the source address is not the final address in the frame, begin * decoding repeater addresses.