diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45d62d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.sw? diff --git a/Makefile b/Makefile index b867009..344cc9f 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ all: $(MAKE) -C asn1-compiled $(MAKE) -C src + $(MAKE) -C tests regenerate-asn1: rm -f asn1-compiled/* @@ -12,3 +13,4 @@ regenerate-asn1: clean: $(MAKE) -C asn1-compiled lib-clean $(MAKE) -C src clean + $(MAKE) -C tests clean diff --git a/asn1/.gitignore b/asn1/.gitignore new file mode 100644 index 0000000..45d62d8 --- /dev/null +++ b/asn1/.gitignore @@ -0,0 +1 @@ +*.sw? diff --git a/asn1/Makefile.compiled b/asn1/Makefile.compiled index 0e10178..8e873d3 100644 --- a/asn1/Makefile.compiled +++ b/asn1/Makefile.compiled @@ -2,7 +2,7 @@ LIBNAME=libtcap-asn.a -CFLAGS=-g -Wall -O3 +CFLAGS=-g -Wall -O3 -fPIC lib: $(LIBNAME) diff --git a/include/libtcap.h b/include/libtcap.h new file mode 100644 index 0000000..1e1313a --- /dev/null +++ b/include/libtcap.h @@ -0,0 +1,11 @@ +#ifndef _LIBTCAP_H_ +#define _LIBTCAP_H_ + + +#include "TCMessage.h" + + +TCMessage_t *tcap_decode(const char *buf, size_t len); + + +#endif diff --git a/src/.gitignore b/src/.gitignore index 45d62d8..3f05b2d 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1,4 @@ *.sw? +*.so +*.so.0 +*.o diff --git a/src/Makefile b/src/Makefile index 6cf7af6..80d096c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ LIBNAME=libtcap VERSION=0 CC=gcc -CFLAGS=-I../asn1-compiled -g -Wall -O3 -fPIC +CFLAGS=-I../asn1-compiled -I../include -g -Wall -O3 -fPIC LDFLAGS=-O3 -shared -fPIC -Wl,-soname,$(LIBNAME).so.$(VERSION) OBJS=tcap.o @@ -13,9 +13,13 @@ OBJS=tcap.o all: $(LIBNAME).so -$(LIBNAME).so: $(OBJS) ../asn1-compiled/libtcap-asn.a - $(CC) -o $@ $(OBJS) $(LDFLAGS) +$(LIBNAME).so.$(VERSION): $(OBJS) ../asn1-compiled/libtcap-asn.a + $(CC) -o $@ $(OBJS) ../asn1-compiled/libtcap-asn.a $(LDFLAGS) + +$(LIBNAME).so: $(LIBNAME).so.$(VERSION) + ln -s $(LIBNAME).so.$(VERSION) $(LIBNAME).so clean: rm -f $(OBJS) rm -f $(LIBNAME).so + rm -f $(LIBNAME).so.$(VERSION) diff --git a/src/tcap.c b/src/tcap.c index 1d851c8..45ef2ab 100644 --- a/src/tcap.c +++ b/src/tcap.c @@ -1,3 +1,5 @@ +#include "libtcap.h" + #include #include #include diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..45d62d8 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +*.sw? diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..388c6a6 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,9 @@ +.PHONY: all clean + +all: basic + +basic: basic.c ../src/libtcap.so.0 + gcc -Wall -g -I ../include -I../asn1-compiled basic.c -o basic -L../src -ltcap + +clean: + rm -f basic diff --git a/tests/basic.c b/tests/basic.c new file mode 100644 index 0000000..030c753 --- /dev/null +++ b/tests/basic.c @@ -0,0 +1,16 @@ +#include +#include "libtcap.h" + +const char tcap[] = "\x64\x81\x86\x49\x03\x0a\x7e\x71\x6b\x2a\x28\x28\x06\x07\x00\x11\x86\x05\x01\x01\x01\xa0\x1d\x61\x1b\xa1\x0d\x06\x0b\x2a\x81\x76\x82\x15\x01\x01\x01\x01\x00\x01\xa2\x03\x02\x01\x00\xa3\x05\xa1\x03\x02\x01\x00\x6c\x53\xa1\x10\x02\x01\x58\x02\x01\x22\xbf\x33\x07\x83\x05\x31\x30\x30\x32\x34\xa1\x3f\x02\x01\x59\x02\x01\x14\x30\x37\xa0\x0e\x04\x0c\x83\x90\x89\x10\x10\x80\x22\x08\x00\x55\x50\x05\x83\x01\x09\x9a\x22\x30\x20\xa0\x1e\x80\x01\x00\x81\x01\x00\x82\x01\x01\x83\x01\x01\x84\x01\x00\x85\x01\x00\x86\x01\x01\x87\x01\x01\x88\x01\x00\x89\x01\x00"; +const int tcap_len = sizeof(tcap) - 1; + + +int main() { + TCMessage_t *tcm; + + tcm = tcap_decode(tcap, tcap_len); + + printf("%p\n", tcm); + + return 0; +}