Loading Makefile +13 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ BUS_PATH = ${LIB_DIR}/bus KINETIC_LIB_NAME = $(PROJECT).$(VERSION) KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(SOCKET99) -I$(VENDOR) \ -I$(THREADPOOL_PATH) -I$(BUS_PATH) -I$(THREADPOOL_PATH) -I$(BUS_PATH) -I${OPENSSL_PATH}/include C_SRC=${LIB_DIR}/*.[ch] $(SOCKET99)/socket99.[ch] $(PROTOBUFC)/protobuf-c/protobuf-c.[ch] Loading @@ -65,6 +65,7 @@ LIB_OBJS = \ $(OUT_DIR)/kinetic_client.o \ $(OUT_DIR)/threadpool.o \ $(OUT_DIR)/bus.o \ $(OUT_DIR)/bus_ssl.o \ $(OUT_DIR)/casq.o \ $(OUT_DIR)/listener.o \ $(OUT_DIR)/sender.o \ Loading Loading @@ -121,7 +122,7 @@ $(OUT_DIR)/threadpool.o: ${LIB_DIR}/threadpool/threadpool.c ${LIB_DIR}/threadpoo $(CC) -o $@ -c $< $(CFLAGS) $(OUT_DIR)/%.o: ${LIB_DIR}/bus/%.c ${LIB_DIR}/bus/%.h $(CC) -o $@ -c $< $(CFLAGS) -I${THREADPOOL_PATH} -I${BUS_PATH} $(CC) -o $@ -c $< $(CFLAGS) -I${THREADPOOL_PATH} -I${BUS_PATH} ${LIB_INCS} ${OUT_DIR}/*.o: src/lib/kinetic_types_internal.h Loading Loading @@ -173,6 +174,14 @@ ${OUT_DIR}/libthreadpool.a: ${LIB_DIR}/threadpool/*.[ch] cp ${LIB_DIR}/threadpool/libthreadpool.a $@ #------------------------------------------------------------------------------- # SSL/TLS Library Options #------------------------------------------------------------------------------- # FIXME: Currently OSX specific, rework before integration. OPENSSL_PATH= /usr/local/Cellar/openssl/1.0.1j_1 #------------------------------------------------------------------------------- # Static and Dynamic Library Build Support #------------------------------------------------------------------------------- Loading Loading @@ -257,7 +266,7 @@ stop_simulator: SYSTEST_SRC = ./test/system SYSTEST_OUT = $(BIN_DIR)/systest SYSTEST_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread SYSTEST_LDFLAGS += -lm -L${OPENSSL_PATH}/lib -lssl -lcrypto $(KINETIC_LIB) -l pthread SYSTEST_WARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wno-missing-field-initializers -Werror=strict-prototypes SYSTEST_CFLAGS += -std=c99 -fPIC -g $(SYSTEST_WARN) $(CDEFS) $(OPTIMIZE) -DTEST UNITY_INC = ./vendor/unity/src Loading Loading @@ -341,7 +350,7 @@ UTILITY = kinetic-c-util UTIL_DIR = ./src/utility UTIL_EXEC = $(BIN_DIR)/$(UTILITY) UTIL_OBJ = $(OUT_DIR)/main.o UTIL_LDFLAGS += -lm -lssl $(KINETIC_LIB) -lcrypto -lpthread UTIL_LDFLAGS += -lm -L${OPENSSL_PATH}/lib -lssl $(KINETIC_LIB) -lcrypto -lpthread $(UTIL_OBJ): $(UTIL_DIR)/main.c $(CC) -c -o $@ $< $(CFLAGS) -I$(PUB_INC) -I$(UTIL_DIR) Loading src/lib/bus/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ LDFLAGS += -L. -lsocket99 -L${LIB_PATH} -lthreadpool BUS_OBJS = \ bus.o \ bus_ssl.o \ casq.o \ listener.o \ sender.o \ Loading src/lib/bus/bus.c +14 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include "listener.h" #include "threadpool.h" #include "bus_internal_types.h" #include "bus_ssl.h" /* Function pointers for pthreads. */ void *listener_mainloop(void *arg); Loading Loading @@ -84,6 +85,8 @@ bool bus_init(bus_config *config, struct bus_result *res) { bus *b = calloc(1, sizeof(*b)); if (b == NULL) { goto cleanup; } if (!bus_ssl_init(b)) { goto cleanup; } b->sink_cb = config->sink_cb; b->unpack_cb = config->unpack_cb; b->unexpected_msg_cb = config->unexpected_msg_cb; Loading Loading @@ -344,7 +347,7 @@ const char *bus_log_event_str(log_event_t event) { } } bool bus_register_socket(struct bus *b, int fd, void *udata) { bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *udata) { /* Register a socket internally with a listener. */ int l_id = listener_id_of_socket(b, fd); Loading @@ -366,10 +369,18 @@ bool bus_register_socket(struct bus *b, int fd, void *udata) { connection_info *ci = malloc(sizeof(*ci)); if (ci == NULL) { goto cleanup; } ci->type = type; ci->fd = fd; ci->to_read_size = 0; ci->udata = udata; if (type == BUS_SOCKET_SSL) { if (!bus_ssl_connect(b, ci)) { free(ci); return false; } } bool res = listener_add_socket(l, ci, pipe_in); if (!res) { goto cleanup; } Loading Loading @@ -493,6 +504,8 @@ void bus_free(bus *b) { pthread_mutex_destroy(&b->log_lock); bus_ssl_free(b); free(b); } Loading src/lib/bus/bus.h +6 −4 Original line number Diff line number Diff line Loading @@ -42,13 +42,15 @@ bool bus_send_request(struct bus *b, bus_user_msg *msg); /* Get the string key for a log event ID. */ const char *bus_log_event_str(log_event_t event); /* Register a socket connected to an endpoint, and data that will be passed * to all interactions on that socket. * * The socket will have request -> response messages with timeouts, as * well as unsolicited status messages. */ bool bus_register_socket(struct bus *b, int fd, void *socket_udata); * well as unsolicited status messages. * * If USES_SSL is true, then the function will block until the initial * SSL/TLS connection handshake has completed. */ bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *socket_udata); /* Begin shutting the system down. Returns true once everything pending * has resolved. */ Loading src/lib/bus/bus_example.c +1 −1 Original line number Diff line number Diff line Loading @@ -411,7 +411,7 @@ static void run_bus(example_state *s, struct bus *b) { open_sockets(s); for (int i = 0; i < s->sockets_used; i++) { bus_register_socket(b, s->sockets[i], s->info[i]); bus_register_socket(b, BUS_SOCKET_PLAIN, s->sockets[i], s->info[i]); } bool should_send = true; Loading Loading
Makefile +13 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ BUS_PATH = ${LIB_DIR}/bus KINETIC_LIB_NAME = $(PROJECT).$(VERSION) KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(SOCKET99) -I$(VENDOR) \ -I$(THREADPOOL_PATH) -I$(BUS_PATH) -I$(THREADPOOL_PATH) -I$(BUS_PATH) -I${OPENSSL_PATH}/include C_SRC=${LIB_DIR}/*.[ch] $(SOCKET99)/socket99.[ch] $(PROTOBUFC)/protobuf-c/protobuf-c.[ch] Loading @@ -65,6 +65,7 @@ LIB_OBJS = \ $(OUT_DIR)/kinetic_client.o \ $(OUT_DIR)/threadpool.o \ $(OUT_DIR)/bus.o \ $(OUT_DIR)/bus_ssl.o \ $(OUT_DIR)/casq.o \ $(OUT_DIR)/listener.o \ $(OUT_DIR)/sender.o \ Loading Loading @@ -121,7 +122,7 @@ $(OUT_DIR)/threadpool.o: ${LIB_DIR}/threadpool/threadpool.c ${LIB_DIR}/threadpoo $(CC) -o $@ -c $< $(CFLAGS) $(OUT_DIR)/%.o: ${LIB_DIR}/bus/%.c ${LIB_DIR}/bus/%.h $(CC) -o $@ -c $< $(CFLAGS) -I${THREADPOOL_PATH} -I${BUS_PATH} $(CC) -o $@ -c $< $(CFLAGS) -I${THREADPOOL_PATH} -I${BUS_PATH} ${LIB_INCS} ${OUT_DIR}/*.o: src/lib/kinetic_types_internal.h Loading Loading @@ -173,6 +174,14 @@ ${OUT_DIR}/libthreadpool.a: ${LIB_DIR}/threadpool/*.[ch] cp ${LIB_DIR}/threadpool/libthreadpool.a $@ #------------------------------------------------------------------------------- # SSL/TLS Library Options #------------------------------------------------------------------------------- # FIXME: Currently OSX specific, rework before integration. OPENSSL_PATH= /usr/local/Cellar/openssl/1.0.1j_1 #------------------------------------------------------------------------------- # Static and Dynamic Library Build Support #------------------------------------------------------------------------------- Loading Loading @@ -257,7 +266,7 @@ stop_simulator: SYSTEST_SRC = ./test/system SYSTEST_OUT = $(BIN_DIR)/systest SYSTEST_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread SYSTEST_LDFLAGS += -lm -L${OPENSSL_PATH}/lib -lssl -lcrypto $(KINETIC_LIB) -l pthread SYSTEST_WARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wno-missing-field-initializers -Werror=strict-prototypes SYSTEST_CFLAGS += -std=c99 -fPIC -g $(SYSTEST_WARN) $(CDEFS) $(OPTIMIZE) -DTEST UNITY_INC = ./vendor/unity/src Loading Loading @@ -341,7 +350,7 @@ UTILITY = kinetic-c-util UTIL_DIR = ./src/utility UTIL_EXEC = $(BIN_DIR)/$(UTILITY) UTIL_OBJ = $(OUT_DIR)/main.o UTIL_LDFLAGS += -lm -lssl $(KINETIC_LIB) -lcrypto -lpthread UTIL_LDFLAGS += -lm -L${OPENSSL_PATH}/lib -lssl $(KINETIC_LIB) -lcrypto -lpthread $(UTIL_OBJ): $(UTIL_DIR)/main.c $(CC) -c -o $@ $< $(CFLAGS) -I$(PUB_INC) -I$(UTIL_DIR) Loading
src/lib/bus/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ LDFLAGS += -L. -lsocket99 -L${LIB_PATH} -lthreadpool BUS_OBJS = \ bus.o \ bus_ssl.o \ casq.o \ listener.o \ sender.o \ Loading
src/lib/bus/bus.c +14 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ #include "listener.h" #include "threadpool.h" #include "bus_internal_types.h" #include "bus_ssl.h" /* Function pointers for pthreads. */ void *listener_mainloop(void *arg); Loading Loading @@ -84,6 +85,8 @@ bool bus_init(bus_config *config, struct bus_result *res) { bus *b = calloc(1, sizeof(*b)); if (b == NULL) { goto cleanup; } if (!bus_ssl_init(b)) { goto cleanup; } b->sink_cb = config->sink_cb; b->unpack_cb = config->unpack_cb; b->unexpected_msg_cb = config->unexpected_msg_cb; Loading Loading @@ -344,7 +347,7 @@ const char *bus_log_event_str(log_event_t event) { } } bool bus_register_socket(struct bus *b, int fd, void *udata) { bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *udata) { /* Register a socket internally with a listener. */ int l_id = listener_id_of_socket(b, fd); Loading @@ -366,10 +369,18 @@ bool bus_register_socket(struct bus *b, int fd, void *udata) { connection_info *ci = malloc(sizeof(*ci)); if (ci == NULL) { goto cleanup; } ci->type = type; ci->fd = fd; ci->to_read_size = 0; ci->udata = udata; if (type == BUS_SOCKET_SSL) { if (!bus_ssl_connect(b, ci)) { free(ci); return false; } } bool res = listener_add_socket(l, ci, pipe_in); if (!res) { goto cleanup; } Loading Loading @@ -493,6 +504,8 @@ void bus_free(bus *b) { pthread_mutex_destroy(&b->log_lock); bus_ssl_free(b); free(b); } Loading
src/lib/bus/bus.h +6 −4 Original line number Diff line number Diff line Loading @@ -42,13 +42,15 @@ bool bus_send_request(struct bus *b, bus_user_msg *msg); /* Get the string key for a log event ID. */ const char *bus_log_event_str(log_event_t event); /* Register a socket connected to an endpoint, and data that will be passed * to all interactions on that socket. * * The socket will have request -> response messages with timeouts, as * well as unsolicited status messages. */ bool bus_register_socket(struct bus *b, int fd, void *socket_udata); * well as unsolicited status messages. * * If USES_SSL is true, then the function will block until the initial * SSL/TLS connection handshake has completed. */ bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *socket_udata); /* Begin shutting the system down. Returns true once everything pending * has resolved. */ Loading
src/lib/bus/bus_example.c +1 −1 Original line number Diff line number Diff line Loading @@ -411,7 +411,7 @@ static void run_bus(example_state *s, struct bus *b) { open_sockets(s); for (int i = 0; i < s->sockets_used; i++) { bus_register_socket(b, s->sockets[i], s->info[i]); bus_register_socket(b, BUS_SOCKET_PLAIN, s->sockets[i], s->info[i]); } bool should_send = true; Loading