BeRTOS
|
Simple AX25 data link layer implementation. More...
Go to the source code of this file.
Data Structures | |
struct | AX25Ctx |
AX25 Protocol context. More... | |
struct | AX25Call |
AX25 Call sign. More... | |
struct | AX25Msg |
AX25 Message. More... | |
Defines | |
#define | AX25_MIN_FRAME_LEN 18 |
Maximum size of a AX25 frame. | |
#define | AX25_CRC_CORRECT 0xF0B8 |
CRC computation on correct AX25 packets should give this result (don't ask why). | |
#define | AX25_CALL(str, id) {.call = (str), .ssid = (id) } |
Create an AX25Call structure on the fly. | |
#define | AX25_MAX_RPT 8 |
Maximum number of Repeaters in a AX25 message. | |
#define | AX25_PATH(dst, src,...) { dst, src, ## __VA_ARGS__ } |
Declare an AX25 path. | |
#define | ax25_send(ctx, dst, src, buf, len) ax25_sendVia(ctx, ({static AX25Call __path[]={dst, src}; __path;}), 2, buf, len) |
Send an AX25 frame on the channel. | |
HDLC flags. | |
These should be moved in a separated HDLC related file one day... | |
#define | HDLC_FLAG 0x7E |
#define | HDLC_RESET 0x7F |
#define | AX25_ESC 0x1B |
Typedefs | |
typedef void(* | ax25_callback_t )(struct AX25Msg *msg) |
Type for AX25 messages callback. | |
Functions | |
void | ax25_poll (AX25Ctx *ctx) |
Check if there are any AX25 messages to be processed. | |
void | ax25_sendVia (AX25Ctx *ctx, const AX25Call *path, size_t path_len, const void *_buf, size_t len) |
Send an AX25 frame on the channel through a specific path. | |
void | ax25_init (AX25Ctx *ctx, KFile *channel, ax25_callback_t hook) |
Init the AX25 protocol decoder. | |
void | ax25_print (KFile *ch, const AX25Msg *msg) |
Print a AX25 message in TNC-2 packet monitor format. |
Simple AX25 data link layer implementation.
For now, only UI frames without any Layer 3 protocol are handled. This however is enough to send/receive APRS packets.
Definition in file ax25.h.
#define AX25_CALL | ( | str, | |
id | |||
) | {.call = (str), .ssid = (id) } |
#define AX25_PATH | ( | dst, | |
src, | |||
... | |||
) | { dst, src, ## __VA_ARGS__ } |
Declare an AX25 path.
dst | the destination callsign for the path, |
src | the source callsign for the path, |
Additional optional callsigns can be specified at the end of this macro in order to add repeater callsigns or specific unproto paths.
This macro can be used to simply path array declaration. Should be used in this way:
AX25Call path[] = AX25_PATH(AX25_CALL("abcdef", 0), AX25_CALL("ghjklm", 0), AX25_CALL("wide1", 1), AX25_CALL("wide2", 2));
The declared path can then be passed to ax25_sendVia().
#define ax25_send | ( | ctx, | |
dst, | |||
src, | |||
buf, | |||
len | |||
) | ax25_sendVia(ctx, ({static AX25Call __path[]={dst, src}; __path;}), 2, buf, len) |
Send an AX25 frame on the channel.
ctx | AX25 context to operate on. |
dst | the destination callsign for the frame, |
src | the source callsign for the frame, |
buf | payload buffer. |
len | length of the payload. |
void ax25_init | ( | AX25Ctx * | ctx, |
KFile * | channel, | ||
ax25_callback_t | hook | ||
) |
void ax25_poll | ( | AX25Ctx * | ctx | ) |
Check if there are any AX25 messages to be processed.
This function read available characters from the medium and search for any AX25 messages. If a message is found it is decoded and the linked callback executed. This function may be blocking if there are no available chars and the KFile used in ctx to access the medium is configured in blocking mode.
ctx | AX25 context to operate on. |
void ax25_sendVia | ( | AX25Ctx * | ctx, |
const AX25Call * | path, | ||
size_t | path_len, | ||
const void * | _buf, | ||
size_t | len | ||
) |
Send an AX25 frame on the channel through a specific path.
ctx | AX25 context to operate on. |
path | An array of callsigns used as path, |
path_len | callsigns path lenght. |
_buf | payload buffer. |
len | length of the payload. |