diff --git a/Makefile b/Makefile index de77f4f..b867009 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ -# stub - - -.PHONY: all regenerate-asn1 +.PHONY: all regenerate-asn1 clean all: - exit 1 + $(MAKE) -C asn1-compiled + $(MAKE) -C src regenerate-asn1: rm -f asn1-compiled/* (cd asn1-compiled && asn1c -fskeletons-copy ../asn1/tcap.asn) + ln -s ../asn1/Makefile.compiled asn1-compiled/Makefile + +clean: + $(MAKE) -C asn1-compiled lib-clean + $(MAKE) -C src clean diff --git a/asn1-compiled/Makefile b/asn1-compiled/Makefile new file mode 120000 index 0000000..1328844 --- /dev/null +++ b/asn1-compiled/Makefile @@ -0,0 +1 @@ +../asn1/Makefile.compiled \ No newline at end of file diff --git a/asn1/Makefile.compiled b/asn1/Makefile.compiled new file mode 100644 index 0000000..0e10178 --- /dev/null +++ b/asn1/Makefile.compiled @@ -0,0 +1,17 @@ +.PHONY: all lib clean lib-clean + +LIBNAME=libtcap-asn.a + +CFLAGS=-g -Wall -O3 + +lib: $(LIBNAME) + +include Makefile.am.sample + +LIB_OBJS=${ASN_MODULE_SOURCES:.c=.o} + +$(LIBNAME): $(LIB_OBJS) + ar cr $(LIBNAME) $(LIB_OBJS) + +lib-clean: clean + rm -f $(LIBNAME) diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..45d62d8 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +*.sw? diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..6cf7af6 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,21 @@ +LIBNAME=libtcap +VERSION=0 + +CC=gcc +CFLAGS=-I../asn1-compiled -g -Wall -O3 -fPIC +LDFLAGS=-O3 -shared -fPIC -Wl,-soname,$(LIBNAME).so.$(VERSION) + +OBJS=tcap.o + + +.PHONY: all clean + + +all: $(LIBNAME).so + +$(LIBNAME).so: $(OBJS) ../asn1-compiled/libtcap-asn.a + $(CC) -o $@ $(OBJS) $(LDFLAGS) + +clean: + rm -f $(OBJS) + rm -f $(LIBNAME).so diff --git a/src/tcap.c b/src/tcap.c new file mode 100644 index 0000000..1d851c8 --- /dev/null +++ b/src/tcap.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "TCMessage.h" + + + + +TCMessage_t *tcap_decode(const char *buf, size_t len) { + TCMessage_t *ret = NULL; + asn_dec_rval_t rv; + + rv = ber_decode(0, &asn_DEF_TCMessage, (void **) &ret, buf, len); + + if (rv.code == RC_OK) + return ret; + + asn_DEF_TCMessage.free_struct(&asn_DEF_TCMessage, ret, 0); + return NULL; +}