diff --git a/daemon/Makefile b/daemon/Makefile index 6e9e24c41..f02cece0d 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -60,7 +60,7 @@ ifeq ($(with_iptables_option),yes) CFLAGS+= $(shell pkg-config --cflags libiptc) CFLAGS+= -DWITH_IPTABLES_OPTION endif -CFLAGS+= -I. -I../kernel-module/ -I../lib/ +CFLAGS+= -I. -I../kernel-module/ -I../lib/ -I../include/ CFLAGS+= -D_GNU_SOURCE ifeq ($(with_transcoding),yes) CFLAGS+= $(shell pkg-config --cflags libavcodec) diff --git a/daemon/aux.h b/include/aux.h similarity index 100% rename from daemon/aux.h rename to include/aux.h diff --git a/daemon/bencode.h b/include/bencode.h similarity index 100% rename from daemon/bencode.h rename to include/bencode.h diff --git a/daemon/call.h b/include/call.h similarity index 100% rename from daemon/call.h rename to include/call.h diff --git a/daemon/crypto.h b/include/crypto.h similarity index 100% rename from daemon/crypto.h rename to include/crypto.h diff --git a/daemon/dtls.h b/include/dtls.h similarity index 99% rename from daemon/dtls.h rename to include/dtls.h index efba1eb2c..2733d1eac 100644 --- a/daemon/dtls.h +++ b/include/dtls.h @@ -24,6 +24,7 @@ struct packet_stream; struct sockaddr_in6; struct poller; +struct stream_fd; diff --git a/daemon/media_socket.h b/include/media_socket.h similarity index 100% rename from daemon/media_socket.h rename to include/media_socket.h diff --git a/daemon/obj.h b/include/obj.h similarity index 100% rename from daemon/obj.h rename to include/obj.h diff --git a/daemon/recording.h b/include/recording.h similarity index 100% rename from daemon/recording.h rename to include/recording.h diff --git a/daemon/rtcp.h b/include/rtcp.h similarity index 100% rename from daemon/rtcp.h rename to include/rtcp.h diff --git a/daemon/rtp.h b/include/rtp.h similarity index 100% rename from daemon/rtp.h rename to include/rtp.h diff --git a/daemon/socket.h b/include/socket.h similarity index 100% rename from daemon/socket.h rename to include/socket.h diff --git a/daemon/statistics.h b/include/statistics.h similarity index 100% rename from daemon/statistics.h rename to include/statistics.h diff --git a/lib/common.Makefile b/lib/common.Makefile index af4b27370..ae63d69a6 100644 --- a/lib/common.Makefile +++ b/lib/common.Makefile @@ -12,11 +12,11 @@ debug: dep: .depend clean: - rm -f $(OBJS) $(TARGET) $(LIBSRCS) $(ADD_CLEAN) .depend core core.* + rm -f $(OBJS) $(TARGET) $(LIBSRCS) $(DAEMONSRCS) $(ADD_CLEAN) .depend core core.* rm -f fix_frame_channel_layout.h fix_frame_channel_layout-test.[co] -.depend: $(SRCS) $(LIBSRCS) Makefile - $(CC) $(CFLAGS) -M $(SRCS) $(LIBSRCS) | sed -e 's/:/ .depend:/' > .depend +.depend: $(SRCS) $(LIBSRCS) $(DAEMONSRCS) Makefile + $(CC) $(CFLAGS) -M $(SRCS) $(LIBSRCS) $(DAEMONSRCS) | sed -e 's/:/ .depend:/' > .depend install: @@ -27,6 +27,11 @@ $(LIBSRCS): $(patsubst %,../lib/%,$(LIBSRCS)) echo '/******** GENERATED FILE ********/' > "$@" cat ../lib/"$@" >> "$@" +$(DAEMONSRCS): $(patsubst %,../daemon/%,$(DAEMONSRCS)) + rm -f "$@" + echo '/******** GENERATED FILE ********/' > "$@" + cat ../daemon/"$@" >> "$@" + resample.c: fix_frame_channel_layout.h fix_frame_channel_layout.h: ../lib/fix_frame_channel_layout-* diff --git a/t/.gitignore b/t/.gitignore index 08cb90708..676e1606f 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -11,3 +11,5 @@ loglib.c resample.c rtplib.c str.c +crypto.c +aes-crypt diff --git a/t/.ycm_extra_conf.py b/t/.ycm_extra_conf.py index 92f5a5a15..85c659d13 100644 --- a/t/.ycm_extra_conf.py +++ b/t/.ycm_extra_conf.py @@ -22,6 +22,7 @@ flags = [ '-pthread', '-I../kernel-module/', '-I../lib/', + '-I../daemon/', '-D_GNU_SOURCE', '-D__DEBUG=1', '-D__YCM=1', diff --git a/t/Makefile b/t/Makefile index 76bf8ea31..756221d4a 100644 --- a/t/Makefile +++ b/t/Makefile @@ -7,7 +7,7 @@ CFLAGS+= -std=c99 CFLAGS+= $(shell pkg-config --cflags glib-2.0) CFLAGS+= $(shell pkg-config --cflags gthread-2.0) CFLAGS+= $(shell pkg-config --cflags openssl) -CFLAGS+= -I. -I../lib/ +CFLAGS+= -I. -I../lib/ -I../kernel-module/ -I../include/ CFLAGS+= -D_GNU_SOURCE ifeq ($(with_transcoding),yes) CFLAGS+= $(shell pkg-config --cflags libavcodec) @@ -32,7 +32,7 @@ LDLIBS+= $(shell pkg-config --libs libswresample) LDLIBS+= $(shell pkg-config --libs libavfilter) endif -SRCS= bitstr-test.c +SRCS= bitstr-test.c aes-crypt.c ifeq ($(with_transcoding),yes) SRCS+= amr-decode-test.c amr-encode-test.c endif @@ -40,7 +40,10 @@ LIBSRCS= loglib.c auxlib.c str.c rtplib.c ifeq ($(with_transcoding),yes) LIBSRCS+= codeclib.c resample.c endif -OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) +DAEMONSRCS= crypto.c +OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(DAEMONSRCS:.c=.o) + +COMMONOBJS= str.o auxlib.o rtplib.o loglib.o include ../lib/common.Makefile @@ -48,7 +51,7 @@ include .depend .PHONY: unit-tests -TESTS= bitstr-test +TESTS= bitstr-test aes-crypt ifeq ($(with_transcoding),yes) TESTS+= amr-decode-test amr-encode-test endif @@ -60,6 +63,8 @@ unit-tests: $(TESTS) bitstr-test: bitstr-test.o -amr-decode-test: amr-decode-test.o codeclib.o str.o auxlib.o resample.o rtplib.o loglib.o +amr-decode-test: amr-decode-test.o $(COMMONOBJS) codeclib.o resample.o + +amr-encode-test: amr-encode-test.o $(COMMONOBJS) codeclib.o resample.o -amr-encode-test: amr-encode-test.o codeclib.o str.o auxlib.o resample.o rtplib.o loglib.o +aes-crypt: aes-crypt.o $(COMMONOBJS) crypto.o diff --git a/tests/t_crypt.c b/t/aes-crypt.c similarity index 98% rename from tests/t_crypt.c rename to t/aes-crypt.c index 2ec710d79..6e72b2bcb 100644 --- a/tests/t_crypt.c +++ b/t/aes-crypt.c @@ -3,6 +3,7 @@ #include "crypto.h" #include "rtplib.h" +#include "log.h" uint8_t test_key[46] = { 0xe1, 0xf9, 0x7a, 0x0d, 0x3e, 0x01, 0x8b, 0xe0, @@ -115,13 +116,13 @@ void srtp_validate (struct crypto_context *c, struct crypto_context *c2, char* m uint8_t *rtcp_plaintext, uint8_t *rtcp_ciphertext) { str payload, hash; - uint8_t o_hash[10]; + char o_hash[10]; - uint8_t srtp_plaintext[38]; - uint8_t srtp_ciphertext[38]; + char srtp_plaintext[38]; + char srtp_ciphertext[38]; - uint8_t srtcp_plaintext[38]; - uint8_t srtcp_ciphertext[38]; + char srtcp_plaintext[38]; + char srtcp_ciphertext[38]; memcpy(srtp_plaintext, plaintext, 28); memcpy(srtp_ciphertext, ciphertext, 38); @@ -198,7 +199,6 @@ error: int main(int argc, char** argv) { str suite; - str s; const struct crypto_suite *c; struct crypto_context ctx, ctx2; diff --git a/tests/Makefile.aes b/tests/Makefile.aes deleted file mode 100644 index 9547dc71d..000000000 --- a/tests/Makefile.aes +++ /dev/null @@ -1,38 +0,0 @@ - -## -## Build daemon/ -## cd tests/ -## make -f Makefile.aes, output is binary t_crypt -## run: ./t_crypt - -CC = gcc - -CPPFLAGS = -I../daemon -I../lib -OBJS_DIR = ../daemon/ - -OBJS = crypto.o log.o loglib.o - -LDLIBS = $(shell pkg-config --libs glib-2.0) -LDLIBS += $(shell pkg-config --libs openssl) - -CFLAGS = -g $(shell pkg-config --cflags glib-2.0) -D_GNU_SOURCE - -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $(shell pkg-config --cflags glib-2.0) -D_GNU_SOURCE $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -all: t_crypt - -sources = t_crypt.c - -include $(sources:.c=.d) - -t_crypt: t_crypt.o - gcc $(LDFLAGS) -o $@ $< $(addprefix $(OBJS_DIR), $(OBJS)) $(LDLIBS) - -.PHONY: clean - -clean: - -rm -f t_crypt t_crypt.o