ax25.h File Reference

Simple AX25 data link layer implementation. More...

#include "cfg/cfg_ax25.h"
#include <cfg/compiler.h>
#include <kern/kfile.h>

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)   ({ static const AX25Call _call = { .call = (str), .ssid = (id) }; &_call; })
 Create an AX25Call structure on the fly and return its pointer.
#define AX25_MAX_RPT   8
 Maximum number of Repeaters in a AX25 message.
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_send (AX25Ctx *ctx, const AX25Call *dst, const AX25Call *src, const void *_buf, size_t len)
 Send an AX25 frame on the channel.
void ax25_init (AX25Ctx *ctx, KFile *channel, ax25_callback_t hook)
 Init the AX25 protocol decoder.

Detailed Description

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.

Version:
$Id$
Author:
Francesco Sacchi <batt@develer.com>

Definition in file ax25.h.


Define Documentation

#define AX25_CALL ( str,
id   )     ({ static const AX25Call _call = { .call = (str), .ssid = (id) }; &_call; })

Create an AX25Call structure on the fly and return its pointer.

Parameters:
str callsign, can be 6 characters or shorter.
id ssid associated with the callsign.

Definition at line 103 of file ax25.h.


Function Documentation

void ax25_init ( AX25Ctx ctx,
KFile channel,
ax25_callback_t  hook 
)

Init the AX25 protocol decoder.

Parameters:
ctx AX25 context to init.
channel Used to gain access to the physical medium
hook Callback function called when a message is received

Definition at line 264 of file ax25.c.

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.

Parameters:
ctx AX25 context to operate on.

Definition at line 125 of file ax25.c.

void ax25_send ( AX25Ctx ctx,
const AX25Call dst,
const AX25Call src,
const void *  _buf,
size_t  len 
)

Send an AX25 frame on the channel.

Parameters:
ctx AX25 context to operate on.
dst the destination callsign for the frame,
See also:
AX25_CALL for a handy way to create a callsign on the fly.
Parameters:
src the source callsign for the frame,
See also:
AX25_CALL for a handy way to create a callsign on the fly.
Parameters:
_buf payload buffer.
len length of the payload.

Definition at line 224 of file ax25.c.