diff --git a/include/patty/ax25/address.h b/include/patty/ax25/address.h index ed501a6..3919830 100644 --- a/include/patty/ax25/address.h +++ b/include/patty/ax25/address.h @@ -16,4 +16,8 @@ typedef struct _patty_ax25_address { }; } patty_ax25_address; +patty_ax25_address *patty_ax25_address_create(const char *callsign, int ssid); + +void patty_ax25_address_destroy(patty_ax25_address *address); + #endif /* _PATTY_AX25_ADDRESS_H */ diff --git a/src/Makefile b/src/Makefile index 51567cb..1fa89e3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,9 +8,10 @@ CFLAGS = $(CGFLAGS) -fPIC -Wall -O2 -I$(INCLUDE_PATH) LDFLAGS = HEADERS = kiss.h ax25.h ax25/if.h ax25/macros.h ax25/proto.h \ - ax25/frame.h list.h hash.h dict.h + ax25/address.h ax25/frame.h list.h hash.h dict.h -OBJS = kiss.o ax25.o if.o frame.o list.o hash.o dict.o test.o +OBJS = kiss.o ax25.o if.o address.o frame.o list.o hash.o dict.o \ + test.o PROGRAM = test diff --git a/src/address.c b/src/address.c new file mode 100644 index 0000000..c4a4c9f --- /dev/null +++ b/src/address.c @@ -0,0 +1,28 @@ +#include +#include +#include + +#include + +patty_ax25_address *patty_ax25_address_create(const char *callsign, int ssid) { + patty_ax25_address *addr; + + if ((addr = malloc(sizeof(*addr))) == NULL) { + goto error_malloc_addr; + } + + strncpy(addr->callsign, callsign, sizeof(addr->callsign)); + + addr->ssid = ssid; + addr->last = 0; + addr->c = 0; + + return addr; + +error_malloc_addr: + return NULL; +} + +void patty_ax25_address_destroy(patty_ax25_address *address) { + free(address); +}