Start stubbing out patty/ax25.h

This commit is contained in:
XANTRONIX Development 2015-07-20 22:33:59 -05:00
parent 4ce6d1e38e
commit bca3daeeb4
3 changed files with 48 additions and 2 deletions

View file

@ -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 */

View file

@ -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

36
src/ax25.c Normal file
View file

@ -0,0 +1,36 @@
#include <string.h>
#include <patty/ax25.h>
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);
}