ax25.h
Go to the documentation of this file.00001
00046 #ifndef NET_AX25_H
00047 #define NET_AX25_H
00048
00049 #include "cfg/cfg_ax25.h"
00050
00051 #include <cfg/compiler.h>
00052 #include <kern/kfile.h>
00053
00057 #define AX25_MIN_FRAME_LEN 18
00058
00063 #define AX25_CRC_CORRECT 0xF0B8
00064
00065 struct AX25Msg;
00066
00070 typedef void (*ax25_callback_t)(struct AX25Msg *msg);
00071
00072
00076 typedef struct AX25Ctx
00077 {
00078 uint8_t buf[CONFIG_AX25_FRAME_BUF_LEN];
00079 KFile *ch;
00080 size_t frm_len;
00081 uint16_t crc_in;
00082 uint16_t crc_out;
00083 ax25_callback_t hook;
00084 bool sync;
00085 bool escape;
00086 } AX25Ctx;
00087
00088
00092 typedef struct AX25Call
00093 {
00094 char call[6];
00095 uint8_t ssid;
00096 } AX25Call;
00097
00103 #define AX25_CALL(str, id) {.call = (str), .ssid = (id) }
00104
00108 #define AX25_MAX_RPT 8
00109
00110
00115 typedef struct AX25Msg
00116 {
00117 AX25Call src;
00118 AX25Call dst;
00119 #if CONFIG_AX25_RPT_LST
00120 AX25Call rpt_lst[AX25_MAX_RPT];
00121 uint8_t rpt_cnt;
00122 #endif
00123 uint16_t ctrl;
00124 uint8_t pid;
00125 const uint8_t *info;
00126 size_t len;
00127 } AX25Msg;
00128
00129 #define AX25_CTRL_UI 0x03
00130 #define AX25_PID_NOLAYER3 0xF0
00131
00138 #define HDLC_FLAG 0x7E
00139 #define HDLC_RESET 0x7F
00140 #define AX25_ESC 0x1B
00141
00142
00143
00162 #define AX25_PATH(dst, src, ...) { dst, src, ## __VA_ARGS__ }
00163
00164 void ax25_poll(AX25Ctx *ctx);
00165 void ax25_sendVia(AX25Ctx *ctx, const AX25Call *path, size_t path_len, const void *_buf, size_t len);
00166
00179 #define ax25_send(ctx, dst, src, buf, len) ax25_sendVia(ctx, ({static AX25Call __path[]={dst, src}; __path;}), 2, buf, len)
00180 void ax25_init(AX25Ctx *ctx, KFile *channel, ax25_callback_t hook);
00181
00182 void ax25_print(KFile *ch, const AX25Msg *msg);
00183
00184 int ax25_testSetup(void);
00185 int ax25_testTearDown(void);
00186 int ax25_testRun(void);
00187
00188 #endif