Patch for the AX.25 module to provide support for
the has-been-repeated flag in received frames.
This flag is set using the high bit (0x80) of the SSID byte for each
call sign in the path. The patch attached here checks for this flag
when parsing incoming packets, and (per suggestion from Francesco)
stores the flag bit-mapped to a single byte added to the AX25 context.
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4640
38d2e660-2303-0410-9eaa-
f027e97ec537
#include <string.h> //memset, memcmp
#include <ctype.h> //isalnum, toupper
#include <string.h> //memset, memcmp
#include <ctype.h> //isalnum, toupper
+#if CONFIG_AX25_RPT_LST
+ #define AX25_SET_REPEATED(msg, idx, val) \
+ do \
+ { \
+ if (val) \
+ (msg)->rpt_flags |= BV(idx) ; \
+ else \
+ (msg)->rpt_flags &= ~BV(idx) ; \
+ } while(0)
+#endif
+
#define DECODE_CALL(buf, addr) \
for (unsigned i = 0; i < sizeof((addr)); i++) \
{ \
#define DECODE_CALL(buf, addr) \
for (unsigned i = 0; i < sizeof((addr)); i++) \
{ \
{
DECODE_CALL(buf, msg.rpt_lst[msg.rpt_cnt].call);
msg.rpt_lst[msg.rpt_cnt].ssid = (*buf >> 1) & 0x0F;
{
DECODE_CALL(buf, msg.rpt_lst[msg.rpt_cnt].call);
msg.rpt_lst[msg.rpt_cnt].ssid = (*buf >> 1) & 0x0F;
- LOG_INFO("RPT%d[%.6s-%d]\n", msg.rpt_cnt, msg.rpt_lst[msg.rpt_cnt].call, msg.rpt_lst[msg.rpt_cnt].ssid);
+ AX25_SET_REPEATED(&msg, msg.rpt_cnt, (*buf & 0x80));
+
+ LOG_INFO("RPT%d[%.6s-%d]%c\n", msg.rpt_cnt,
+ msg.rpt_lst[msg.rpt_cnt].call,
+ msg.rpt_lst[msg.rpt_cnt].ssid,
+ (AX25_REPEATED(&msg, msg.rpt_cnt) ? '*' : ' '));
}
#else
while (!(*buf++ & 0x01))
}
#else
while (!(*buf++ & 0x01))
for (unsigned i = 0; i < sizeof(addr->call) - len; i++)
ax25_putchar(ctx, ' ' << 1);
for (unsigned i = 0; i < sizeof(addr->call) - len; i++)
ax25_putchar(ctx, ' ' << 1);
+ /* The bit7 "has-been-repeated" flag is not implemented here */
/* Bits6:5 should be set to 1 for all SSIDs (0x60) */
/* The bit0 of last call SSID should be set to 1 */
uint8_t ssid = 0x60 | (addr->ssid << 1) | (last ? 0x01 : 0);
/* Bits6:5 should be set to 1 for all SSIDs (0x60) */
/* The bit0 of last call SSID should be set to 1 */
uint8_t ssid = 0x60 | (addr->ssid << 1) | (last ? 0x01 : 0);
{
kfile_putc(',', ch);
print_call(ch, &msg->rpt_lst[i]);
{
kfile_putc(',', ch);
print_call(ch, &msg->rpt_lst[i]);
- // TODO: add * to the trasmitting digi
+ /* Print a '*' if packet has already been transmitted
+ * by this repeater */
+ if (AX25_REPEATED(msg, i))
+ kfile_putc('*', ch);
*/
#define AX25_MAX_RPT 8
*/
#define AX25_MAX_RPT 8
+/*
+ * Has to be lesser than 8 in order to fit in one byte
+ * change AX25Msg.rpt_flags if you need more repeaters.
+ */
+STATIC_ASSERT(AX25_MAX_RPT <= 8);
#if CONFIG_AX25_RPT_LST
AX25Call rpt_lst[AX25_MAX_RPT]; ///< List of repeaters
uint8_t rpt_cnt; ///< Number of repeaters in this message
#if CONFIG_AX25_RPT_LST
AX25Call rpt_lst[AX25_MAX_RPT]; ///< List of repeaters
uint8_t rpt_cnt; ///< Number of repeaters in this message
+ uint8_t rpt_flags; ///< Has-been-repeated flags for each repeater (bit-mapped)
+ #define AX25_REPEATED(msg, idx) ((msg)->rpt_flags & BV(idx))
#endif
uint16_t ctrl; ///< AX25 control field
uint8_t pid; ///< AX25 PID field
#endif
uint16_t ctrl; ///< AX25 control field
uint8_t pid; ///< AX25 PID field
size_t len; ///< Payload length
} AX25Msg;
size_t len; ///< Payload length
} AX25Msg;
#define AX25_CTRL_UI 0x03
#define AX25_PID_NOLAYER3 0xF0
#define AX25_CTRL_UI 0x03
#define AX25_PID_NOLAYER3 0xF0