From bca3daeeb436c1689dcf480daa36c327ddc7ad09 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 20 Jul 2015 22:33:59 -0500 Subject: [PATCH] Start stubbing out patty/ax25.h --- include/patty/ax25.h | 12 +++++++++++- src/Makefile | 2 +- src/ax25.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/ax25.c diff --git a/include/patty/ax25.h b/include/patty/ax25.h index 5c3844e..14d992c 100644 --- a/include/patty/ax25.h +++ b/include/patty/ax25.h @@ -50,11 +50,16 @@ typedef struct _patty_ax25 { patty_dict * links; /* Key: Integer link descriptor */ } patty_ax25; -void patty_ax25_init(patty_ax25 *ax25); +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_each_if(patty_ax25 *ax25, + int (*callback)(patty_ax25_if *, void *), void *ctx); + int patty_ax25_get_if(patty_ax25 *ax25, const char *name); int patty_ax25_destroy_if(patty_ax25 *ax25, int iface); @@ -74,4 +79,9 @@ int patty_ax25_recv(patty_ax25 *ax25, int iface, patty_ax25_frame *frame); int patty_ax25_send(patty_ax25 *ax25, int iface, const patty_ax25_frame *frame); +ssize_t patty_ax25_read(patty_ax25 *ax25, int link, void *data, size_t len); + +ssize_t patty_ax25_write(patty_ax25 *ax25, int link, + const void *data, size_t len); + #endif /* _PATTY_AX25_IF */ diff --git a/src/Makefile b/src/Makefile index dc382ec..169a040 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,7 +10,7 @@ LDFLAGS = HEADERS = kiss.h ax25.h ax25/macros.h ax25/proto.h ax25/frame.h \ hash.h dict.h -OBJS = kiss.o frame.o hash.o dict.o test.o +OBJS = kiss.o ax25.o frame.o hash.o dict.o test.o PROGRAM = test diff --git a/src/ax25.c b/src/ax25.c new file mode 100644 index 0000000..4334acb --- /dev/null +++ b/src/ax25.c @@ -0,0 +1,36 @@ +#include + +#include + +int patty_ax25_init(patty_ax25 *ax25) { + memset(ax25, '\0', sizeof(*ax25)); + + if ((ax25->ax25_ifs = patty_dict_new()) == NULL) { + goto error_dict_new_ax25_ifs; + } + + if ((ax25->ports = patty_dict_new()) == NULL) { + goto error_dict_new_ports; + } + + if ((ax25->links = patty_dict_new()) == NULL) { + goto error_dict_new_links; + } + + return 0; + +error_dict_new_links: + patty_dict_destroy(ax25->ports); + +error_dict_new_ports: + patty_dict_destroy(ax25->ax25_ifs); + +error_dict_new_ax25_ifs: + return -1; +} + +void patty_ax25_finish(patty_ax25 *ax25) { + patty_dict_destroy(ax25->links); + patty_dict_destroy(ax25->ports); + patty_dict_destroy(ax25->ax25_ifs); +}