X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25.c;h=a4059505b9878c195a3367329dff87ebf3d5900b;hb=e47f203a5648786cd782d921880a77a395570059;hp=68a6ae56d777066356d1ce66bff0473d1a99f862;hpb=74c7bb68260444eee2831f758b1a9296d6d4ac4e;p=bertos.git diff --git a/bertos/net/ax25.c b/bertos/net/ax25.c index 68a6ae56..a4059505 100644 --- a/bertos/net/ax25.c +++ b/bertos/net/ax25.c @@ -54,7 +54,8 @@ #define DECODE_CALL(buf, addr) \ for (unsigned i = 0; i < sizeof((addr)); i++) \ { \ - (addr)[i] = *(buf)++ >> 1; \ + char c = (*(buf)++ >> 1); \ + (addr)[i] = (c == ' ') ? '\x0' : c; \ } static void ax25_decode(AX25Ctx *ctx) @@ -258,6 +259,36 @@ void ax25_sendVia(AX25Ctx *ctx, const AX25Call *path, size_t path_len, const voi kfile_putc(HDLC_FLAG, ctx->ch); } +static void print_call(KFile *ch, const AX25Call *call) +{ + kfile_printf(ch, "%.6s", call->call); + if (call->ssid) + kfile_printf(ch, "-%d", call->ssid); +} + +/** + * Print a AX25 message in TNC-2 packet monitor format. + * \param ch a kfile channel where the message will be printed. + * \param msg the message to be printed. + */ +void ax25_print(KFile *ch, const AX25Msg *msg) +{ + print_call(ch, &msg->src); + kfile_putc('>', ch); + print_call(ch, &msg->dst); + + #if CONFIG_AX25_RPT_LST + for (int i = 0; i < msg->rpt_cnt; i++) + { + kfile_putc(',', ch); + print_call(ch, &msg->rpt_lst[i]); + // TODO: add * to the trasmitting digi + } + #endif + + kfile_printf(ch, ":%.*s\n", msg->len, msg->info); +} + /** * Init the AX25 protocol decoder.