Hmm! Getting somewhere maybe
This commit is contained in:
parent
bca3daeeb4
commit
86b099bd58
4 changed files with 56 additions and 4 deletions
|
@ -13,6 +13,9 @@
|
|||
|
||||
#define PATTY_AX25_IF_OPT_TYPE_MASK 0x1f
|
||||
|
||||
#define PATTY_AX25_IF_OPT_TYPE(n) \
|
||||
((n) & PATTY_AX25_IF_OPT_TYPE_MASK)
|
||||
|
||||
enum patty_ax25_if_type {
|
||||
PATTY_AX25_IF_UNKNOWN = 0x00,
|
||||
PATTY_AX25_IF_KISS_TNC_TTY = 0x01,
|
||||
|
@ -40,8 +43,6 @@ typedef struct _patty_ax25_if {
|
|||
patty_kiss_tnc * tnc;
|
||||
patty_ax25_stats stats;
|
||||
patty_dict * ports;
|
||||
|
||||
char name[8];
|
||||
} patty_ax25_if;
|
||||
|
||||
typedef struct _patty_ax25 {
|
||||
|
@ -54,8 +55,7 @@ int patty_ax25_init(patty_ax25 *ax25);
|
|||
|
||||
void patty_ax25_finish(patty_ax25 *ax25);
|
||||
|
||||
int patty_ax25_create_if(patty_ax25 *ax25, const char *name,
|
||||
int opts, void *info);
|
||||
int patty_ax25_create_if(patty_ax25 *ax25, int opts, void *info);
|
||||
|
||||
int patty_ax25_each_if(patty_ax25 *ax25,
|
||||
int (*callback)(patty_ax25_if *, void *), void *ctx);
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#define PATTY_KISS_TFEND 0xdc
|
||||
#define PATTY_KISS_TFESC 0xdd
|
||||
|
||||
#define PATTY_KISS_BUFSZ 2048
|
||||
|
||||
#define PATTY_KISS_COMMAND_PORT(cmd) \
|
||||
((cmd & 0xf0) >> 4)
|
||||
|
||||
|
|
47
src/ax25.c
47
src/ax25.c
|
@ -1,5 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <patty/dict.h>
|
||||
#include <patty/kiss.h>
|
||||
#include <patty/ax25.h>
|
||||
|
||||
int patty_ax25_init(patty_ax25 *ax25) {
|
||||
|
@ -34,3 +38,46 @@ void patty_ax25_finish(patty_ax25 *ax25) {
|
|||
patty_dict_destroy(ax25->ports);
|
||||
patty_dict_destroy(ax25->ax25_ifs);
|
||||
}
|
||||
|
||||
static int create_if_tnc(patty_ax25 *ax25, const char *device) {
|
||||
patty_ax25_if *iface;
|
||||
|
||||
if ((iface = malloc(sizeof(*iface))) == NULL) {
|
||||
goto error_malloc_iface;
|
||||
}
|
||||
|
||||
memset(iface, '\0', sizeof(*iface));
|
||||
|
||||
if ((iface->ports = patty_dict_new()) == NULL) {
|
||||
goto error_dict_new_ports;
|
||||
}
|
||||
|
||||
if ((iface->tnc = patty_kiss_tnc_open(device, PATTY_KISS_BUFSZ)) == NULL) {
|
||||
goto error_kiss_tnc_open;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error_kiss_tnc_open:
|
||||
patty_dict_destroy(iface->ports);
|
||||
|
||||
error_dict_new_ports:
|
||||
free(iface);
|
||||
|
||||
error_malloc_iface:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int patty_ax25_create_if(patty_ax25 *ax25, int opts, void *info) {
|
||||
switch (PATTY_AX25_IF_OPT_TYPE(opts)) {
|
||||
case PATTY_AX25_IF_KISS_TNC_TTY: {
|
||||
return create_if_tnc(ax25, (const char *)info);
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ enum kiss_flags {
|
|||
};
|
||||
|
||||
struct _patty_kiss_tnc {
|
||||
const char * device;
|
||||
|
||||
int fd;
|
||||
int dropped;
|
||||
void * frame;
|
||||
|
@ -44,6 +46,7 @@ patty_kiss_tnc *patty_kiss_tnc_open(const char *device, size_t bufsz) {
|
|||
}
|
||||
|
||||
tnc->dropped = 0;
|
||||
tnc->device = device;
|
||||
tnc->bufsz = bufsz;
|
||||
tnc->buflen = 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue