From 7da95eac5feee1fce652e9f70e5be44a743ae0f9 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 13:54:48 +0200 Subject: [PATCH 01/12] feat: change generator id to observation domain id in api and remove deprecated files --- README.md | 4 +- deprecated/2_makefile | 83 ------------------------- deprecated/mine_install.sh | 57 ----------------- deprecated/uninstall.sh | 47 -------------- examples/client_interface_bind_socket.c | 2 +- examples/client_legacy_proto.c | 2 +- examples/client_sample.c | 2 +- examples/client_socket.c | 2 +- examples/eBPF/client_ebpf_user.c | 2 +- src/unyte_udp_utils.c | 2 +- src/unyte_udp_utils.h | 2 +- 11 files changed, 9 insertions(+), 196 deletions(-) delete mode 100644 deprecated/2_makefile delete mode 100755 deprecated/mine_install.sh delete mode 100755 deprecated/uninstall.sh diff --git a/README.md b/README.md index 273b8d5..9f36820 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ int main() printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // AF_INET for IPv4 or AF_INET6 for IPv6 printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family); // AF_INET for IPv4 or AF_INET6 for IPv6 @@ -105,7 +105,7 @@ typedef struct unyte_segment_with_metadata - `uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message);` : dentifier to indicate the encoding type used for the Notification Message - `uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message);` : length of the message header in octets - `uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message);` : total length of the message within one UDP datagram, measured in octets, including the message header -- `uint32_t unyte_udp_get_generator_id(unyte_seg_met_t *message);` : observation domain id of the message +- `uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message);` : observation domain id of the message - `uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message);` : message id of the message - `struct sockaddr_storage * unyte_udp_get_src(unyte_seg_met_t *message);` : source IP and port of the message. Could be IPv4 or IPv6. - `struct sockaddr_storage * unyte_udp_get_dest_addr(unyte_seg_met_t *message);` : collector address. Could be IPv4 or IPv6. diff --git a/deprecated/2_makefile b/deprecated/2_makefile deleted file mode 100644 index f37b6a2..0000000 --- a/deprecated/2_makefile +++ /dev/null @@ -1,83 +0,0 @@ -###### GCC options ###### -CC=gcc -# LDFLAGS=-g -L./ -lunyte-udp-notif -LDFLAGS=-g -CFLAGS=-Wextra -Wall -ansi -g -std=c11 -D_GNU_SOURCE -fPIC - -## TCMALLOCFLAGS for tcmalloc -TCMALLOCFLAGS=-ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -TCMALLOCFLAGS= - -## For test third parties lib -USE_LIB=$(shell pkg-config --cflags --libs unyte-udp-notif) -USE_LIB= - -###### c-collector source code ###### -SDIR=src -ODIR=obj -_OBJS=hexdump.o listening_worker.o unyte_udp_utils.o unyte_udp_queue.o parsing_worker.o unyte_udp_collector.o segmentation_buffer.o cleanup_worker.o unyte_sender.o monitoring_worker.o -OBJS=$(patsubst %,$(ODIR)/%,$(_OBJS)) - -###### c-collector source headers ###### -_DEPS=hexdump.h listening_worker.h unyte_udp_utils.h unyte_udp_queue.h parsing_worker.h unyte_udp_collector.h segmentation_buffer.h cleanup_worker.h unyte_sender.h monitoring_worker.h -DEPS=$(patsubst %,$(SDIR)/%,$(_DEPS)) - -###### c-collector examples ###### -SAMPLES_DIR=samples -SAMPLES_ODIR=samples/obj - -###### c-collector test files ###### -TDIR=test - -BINS=client_sample sender_sample sender_json client_monitoring -TESTBINS=test_malloc test_queue test_seg test_listener test_version - -all: libunyte-udp-notif.so $(BINS) - -$(ODIR)/%.o: $(SDIR)/%.c $(DEPS) - $(CC) -c -o $@ $< $(CFLAGS) - -$(SAMPLES_ODIR)/%.o: $(SAMPLES_DIR)/%.c - $(CC) -c -o $@ $< $(CFLAGS) - -libunyte-udp-notif.so: $(OBJS) - $(CC) -shared -o libunyte-udp-notif.so $(OBJS) - -client_sample: $(SAMPLES_ODIR)/client_sample.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -sender_sample: $(SAMPLES_ODIR)/sender_sample.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -sender_json: $(SAMPLES_ODIR)/sender_json.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -client_monitoring: $(SAMPLES_ODIR)/client_monitoring.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -## own test files -test_listener: $(TDIR)/test_listener.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -test_seg: $(TDIR)/test_segmentation.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -test_queue: $(TDIR)/test_queue.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -test_malloc: $(TDIR)/test_malloc.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -test_version: $(TDIR)/test_version.o $(OBJS) - $(CC) -pthread -o $@ $^ $(LDFLAGS) - -install: libunyte-udp-notif.so - ./install.sh - -uninstall: - ./uninstall.sh - -build: libunyte-udp-notif.so - -clean: - rm $(ODIR)/*.o $(SAMPLES_ODIR)/*.o $(TDIR)/*.o $(BINS) $(TESTBINS) libunyte-udp-notif.so diff --git a/deprecated/mine_install.sh b/deprecated/mine_install.sh deleted file mode 100755 index f3fa39a..0000000 --- a/deprecated/mine_install.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -INSTALL_DIR=/usr/local -LIB_DIR=lib -H_DIR=include -PKG_DIR=/usr/lib/pkgconfig - -export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig - -if [ "$EUID" -ne 0 ] -then - echo "Please run as root." - exit 1 -fi - -echo "Building and installing unyte shared lib in: $INSTALL_DIR/$LIB_DIR" - -make build - -echo "Moving build file to $INSTALL_DIR/$LIB_DIR" -cp libunyte-udp-notif.so $INSTALL_DIR/$LIB_DIR - -if [ $? -ne 0 ] -then - echo "Could not move shared lib to $INSTALL_DIR/$LIB_DIR" >&2 - echo "Try sudo" - exit 1 -fi - -if [ ! -d "$INSTALL_DIR/$H_DIR/unyte-udp-notif" ] -then - echo "Creating $INSTALL_DIR/$H_DIR/unyte-udp-notif directory" - mkdir -p $INSTALL_DIR/$H_DIR/unyte-udp-notif -fi - -echo "Copying headers to $INSTALL_DIR/$H_DIR/unyte-udp-notif" -cp src/*.h $INSTALL_DIR/$H_DIR/unyte-udp-notif - -if [ $? -ne 0 ] -then - echo "Error copying headers" >&2 - echo "Try sudo" - exit 1 -fi - -echo "Copying pkg-config file to $PKG_DIR" -sed -e "s/<>/${INSTALL_DIR//\//\\/}/g" -e "s/<>/$H_DIR/g" -e "s/<>/$LIB_DIR/g" unyte-pkg.pc > unyte-udp-notif.pc -cp unyte-udp-notif.pc $PKG_DIR/unyte-udp-notif.pc - -if [ $? -ne 0 ] -then - echo "Error copying pkg-config file to $PKG_DIR" >&2 - echo "Try sudo" - exit 1 -fi - -ldconfig diff --git a/deprecated/uninstall.sh b/deprecated/uninstall.sh deleted file mode 100755 index f5eebff..0000000 --- a/deprecated/uninstall.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -INSTALL_DIR=/usr/local -LIB_DIR=lib -H_DIR=include -PKG_DIR=/usr/lib/pkgconfig - -if [ "$EUID" -ne 0 ] -then - echo "Please run as root." - exit 1 -fi - -echo "Removing $INSTALL_DIR/$LIB_DIR/libunyte-udp-notif.so" -rm $INSTALL_DIR/$LIB_DIR/libunyte-udp-notif.so - -if [ $? -ne 0 ] -then - echo "Could not remove shared lib from $INSTALL_DIR/$LIB_DIR" >&2 - echo "Try sudo" - exit 1 -fi - -if [ -d "$INSTALL_DIR/$H_DIR/unyte-udp-notif" ] -then - echo "Removing $INSTALL_DIR/$H_DIR/unyte-udp-notif directory" - rm -r $INSTALL_DIR/$H_DIR/unyte-udp-notif -fi - -if [ $? -ne 0 ] -then - echo "Error Removing headers" >&2 - echo "Try sudo" - exit 1 -fi - -echo "Removing pkg-config file $PKG_DIR/unyte-udp-notif.pc" -rm $PKG_DIR/unyte-udp-notif.pc - -if [ $? -ne 0 ] -then - echo "Error removing pkg-config file to $PKG_DIR" >&2 - echo "Try sudo" - exit 1 -fi - -echo "/!\ You should remove the LD_LIBRARY_PATH manually from your .bashrc" diff --git a/examples/client_interface_bind_socket.c b/examples/client_interface_bind_socket.c index ef9d370..c4c4077 100644 --- a/examples/client_interface_bind_socket.c +++ b/examples/client_interface_bind_socket.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - // printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); // printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); // printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family); diff --git a/examples/client_legacy_proto.c b/examples/client_legacy_proto.c index 66f51fe..964dfa3 100644 --- a/examples/client_legacy_proto.c +++ b/examples/client_legacy_proto.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); // printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg) == NULL ? 0 : unyte_udp_get_dest_addr(seg)->ss_family); // NULL if options.msg_dst_ip is set to false (default) diff --git a/examples/client_sample.c b/examples/client_sample.c index 7d73d35..f3d1f18 100644 --- a/examples/client_sample.c +++ b/examples/client_sample.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - // printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); // printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); // printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg) == NULL ? 0 : unyte_udp_get_dest_addr(seg)->ss_family); // NULL if options.msg_dst_ip is set to false (default) diff --git a/examples/client_socket.c b/examples/client_socket.c index 211edd8..d79fbf8 100644 --- a/examples/client_socket.c +++ b/examples/client_socket.c @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - // printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); // printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); // printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family); diff --git a/examples/eBPF/client_ebpf_user.c b/examples/eBPF/client_ebpf_user.c index 706be53..b61996e 100644 --- a/examples/eBPF/client_ebpf_user.c +++ b/examples/eBPF/client_ebpf_user.c @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); - // printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg)); + // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); // printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg)); // printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family); diff --git a/src/unyte_udp_utils.c b/src/unyte_udp_utils.c index cb41599..8e673b5 100644 --- a/src/unyte_udp_utils.c +++ b/src/unyte_udp_utils.c @@ -699,7 +699,7 @@ uint8_t unyte_udp_get_space(unyte_seg_met_t *message) { return message->header-> uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message) { return message->header->encoding_type; } uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message) { return message->header->header_length; } uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message) { return message->header->message_length; } -uint32_t unyte_udp_get_generator_id(unyte_seg_met_t *message) { return message->header->generator_id; } +uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message) { return message->header->generator_id; } uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message) { return message->header->message_id; } struct sockaddr_storage *unyte_udp_get_src(unyte_seg_met_t *message) { return message->metadata->src; } struct sockaddr_storage *unyte_udp_get_dest_addr(unyte_seg_met_t *message) { return message->metadata->dest; } diff --git a/src/unyte_udp_utils.h b/src/unyte_udp_utils.h index 59bef23..98c0a2c 100644 --- a/src/unyte_udp_utils.h +++ b/src/unyte_udp_utils.h @@ -189,7 +189,7 @@ uint8_t unyte_udp_get_space(unyte_seg_met_t *message); uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message); uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message); uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message); -uint32_t unyte_udp_get_generator_id(unyte_seg_met_t *message); +uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message); uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message); struct sockaddr_storage *unyte_udp_get_src(unyte_seg_met_t *message); struct sockaddr_storage *unyte_udp_get_dest_addr(unyte_seg_met_t *message); From da169ec57ccdbb76a9b240da81168d970bdcf205 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 13:57:39 +0200 Subject: [PATCH 02/12] feat: change encoding type to media type in api --- README.md | 6 +++--- examples/client_interface_bind_socket.c | 2 +- examples/client_legacy_proto.c | 2 +- examples/client_sample.c | 2 +- examples/client_socket.c | 2 +- examples/eBPF/client_ebpf_user.c | 2 +- src/unyte_udp_utils.c | 2 +- src/unyte_udp_utils.h | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9f36820..377faa0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The collector allows to read and parse UDP-notif protocol messages from a ip/por The api is in `unyte_udp_collector.h`: - `int unyte_udp_create_socket(char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates and binds a socket to an address and port. -- `int unyte_udp_create_interface_bound_socket(char *interface, char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates a socket, binds it to an interface using SO_BINDTODEVICE option and binds it to an adress and port. +- `int unyte_udp_create_interface_bound_socket(char *interface, char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates a socket, binds it to an interface using SO_BINDTODEVICE option and binds it to an address and port. - `unyte_udp_collector_t *unyte_udp_start_collector(unyte_udp_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector. It accepts a struct with different options: socketfd of the socket to listen to, recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)... - `void *unyte_udp_queue_read(unyte_udp_queue_t *queue)` from `unyte_udp_queue.h` : read from a queue a struct with all the message buffer and metadata. - `int unyte_udp_free_all(unyte_seg_met_t *seg)` from `unyte_udp_collector.h`: free all struct used on a message received. @@ -62,7 +62,7 @@ int main() // TODO: Process the UDP-notif message here printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); @@ -102,7 +102,7 @@ typedef struct unyte_segment_with_metadata ##### Getters for segments data - `uint8_t unyte_udp_get_version(unyte_seg_met_t *message);` : encoding version - `uint8_t unyte_udp_get_space(unyte_seg_met_t *message);` : space of encoding version -- `uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message);` : dentifier to indicate the encoding type used for the Notification Message +- `uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message);` : dentifier to indicate the media type used for the Notification Message - `uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message);` : length of the message header in octets - `uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message);` : total length of the message within one UDP datagram, measured in octets, including the message header - `uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message);` : observation domain id of the message diff --git a/examples/client_interface_bind_socket.c b/examples/client_interface_bind_socket.c index c4c4077..8acf110 100644 --- a/examples/client_interface_bind_socket.c +++ b/examples/client_interface_bind_socket.c @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); // printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + // printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); diff --git a/examples/client_legacy_proto.c b/examples/client_legacy_proto.c index 964dfa3..ecd3371 100644 --- a/examples/client_legacy_proto.c +++ b/examples/client_legacy_proto.c @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); diff --git a/examples/client_sample.c b/examples/client_sample.c index f3d1f18..dedf65b 100644 --- a/examples/client_sample.c +++ b/examples/client_sample.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); // printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + // printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); diff --git a/examples/client_socket.c b/examples/client_socket.c index d79fbf8..4b4b9a0 100644 --- a/examples/client_socket.c +++ b/examples/client_socket.c @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); // printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + // printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); diff --git a/examples/eBPF/client_ebpf_user.c b/examples/eBPF/client_ebpf_user.c index b61996e..e9ed00b 100644 --- a/examples/eBPF/client_ebpf_user.c +++ b/examples/eBPF/client_ebpf_user.c @@ -176,7 +176,7 @@ int main(int argc, char *argv[]) // printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg)); // printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg)); - // printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg)); + // printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg)); // printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg)); // printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg)); // printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg)); diff --git a/src/unyte_udp_utils.c b/src/unyte_udp_utils.c index 8e673b5..009e3c7 100644 --- a/src/unyte_udp_utils.c +++ b/src/unyte_udp_utils.c @@ -696,7 +696,7 @@ int unyte_udp_create_interface_bound_socket(char *interface, char *address, char uint8_t unyte_udp_get_version(unyte_seg_met_t *message) { return message->header->version; } uint8_t unyte_udp_get_space(unyte_seg_met_t *message) { return message->header->space; } -uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message) { return message->header->encoding_type; } +uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message) { return message->header->encoding_type; } uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message) { return message->header->header_length; } uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message) { return message->header->message_length; } uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message) { return message->header->generator_id; } diff --git a/src/unyte_udp_utils.h b/src/unyte_udp_utils.h index 98c0a2c..5657725 100644 --- a/src/unyte_udp_utils.h +++ b/src/unyte_udp_utils.h @@ -186,7 +186,7 @@ uint options_total_bytes(unyte_option_t *options); uint8_t unyte_udp_get_version(unyte_seg_met_t *message); uint8_t unyte_udp_get_space(unyte_seg_met_t *message); -uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message); +uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message); uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message); uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message); uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message); From aa1a298d5d769ba30807b49526ad57afe33965aa Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:08:12 +0200 Subject: [PATCH 03/12] feat: migrate generator_id to observation id in structs --- README.md | 18 +++++++++--------- examples/client_monitoring.c | 2 +- examples/sender_cbor.c | 2 +- examples/sender_custom_encoding.c | 2 +- examples/sender_json.c | 2 +- examples/sender_json_bind_interface.c | 2 +- examples/sender_sample.c | 2 +- src/listening_worker.c | 4 ++-- src/monitoring_worker.c | 6 +++--- src/monitoring_worker.h | 4 ++-- src/parsing_worker.c | 12 ++++++------ src/unyte_udp_utils.c | 24 ++++++++++++------------ src/unyte_udp_utils.h | 6 +++--- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 377faa0..450c731 100644 --- a/README.md +++ b/README.md @@ -166,16 +166,16 @@ The message to send have the following structure: ```c typedef struct unyte_message { - uint used_mtu; // MTU to use for cutting the message to segments - void *buffer; // pointer to buffer to send - uint buffer_len; // length of the buffer to send + uint used_mtu; // MTU to use for cutting the message to segments + void *buffer; // pointer to buffer to send + uint buffer_len; // length of the buffer to send // UDP-notif - uint8_t version : 3; // UDP-notif protocol version - uint8_t space : 1; // UDP-notif protocol space - uint8_t encoding_type : 4; // UDP-notif protocol encoding type - uint32_t generator_id; // UDP-notif protocol observation domain id - uint32_t message_id; // UDP-notif protocol message id + uint8_t version : 3; // UDP-notif protocol version + uint8_t space : 1; // UDP-notif protocol space + uint8_t encoding_type : 4; // UDP-notif protocol encoding type + uint32_t observation_domain_id; // UDP-notif protocol observation domain id + uint32_t message_id; // UDP-notif protocol message id } unyte_message_t; ``` @@ -213,7 +213,7 @@ int main() message->version = 0; message->space = 0; message->encoding_type = UNYTE_ENCODING_JSON; // json but sending string - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 200; // If set to 0, the default mtu set on options is used, else, this one is used diff --git a/examples/client_monitoring.c b/examples/client_monitoring.c index 148dba4..7d31e24 100644 --- a/examples/client_monitoring.c +++ b/examples/client_monitoring.c @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) // Getters // printf("Thread id: %ld\n", unyte_udp_get_thread_id(counter)); // printf("Thread type: %d\n", unyte_udp_get_th_type(counter)); - // printf("Generator id: %d\n", unyte_udp_get_gen_id(counter)); + // printf("Observation domain id: %d\n", unyte_udp_get_od_id(counter)); // printf("Last msg id: %d\n", unyte_udp_get_last_msg_id(counter)); // printf("Received OK: %d\n", unyte_udp_get_received_seg(counter)); // printf("Dropped: %d\n", unyte_udp_get_dropped_seg(counter)); diff --git a/examples/sender_cbor.c b/examples/sender_cbor.c index 43ec525..fcaead6 100644 --- a/examples/sender_cbor.c +++ b/examples/sender_cbor.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) message->version = 0; message->space = UNYTE_SPACE_STANDARD; message->encoding_type = UNYTE_ENCODING_CBOR; // sending CBOR - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured message->options = NULL; // no custom options sent diff --git a/examples/sender_custom_encoding.c b/examples/sender_custom_encoding.c index 9ccb43f..68db6f7 100644 --- a/examples/sender_custom_encoding.c +++ b/examples/sender_custom_encoding.c @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) message->version = 0; message->space = UNYTE_SPACE_NON_STANDARD; // Custom space message->encoding_type = 4; // Custom encoding type - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_json.c b/examples/sender_json.c index f3711b9..972fd8c 100644 --- a/examples/sender_json.c +++ b/examples/sender_json.c @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) message->version = 0; message->space = UNYTE_SPACE_STANDARD; message->encoding_type = UNYTE_ENCODING_JSON; - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured message->options = NULL; // no custom options sent diff --git a/examples/sender_json_bind_interface.c b/examples/sender_json_bind_interface.c index bc9c20d..1a2f277 100644 --- a/examples/sender_json_bind_interface.c +++ b/examples/sender_json_bind_interface.c @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) message->version = 0; message->space = UNYTE_SPACE_STANDARD; message->encoding_type = UNYTE_ENCODING_JSON; - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured message->options = NULL; // no custom options sent diff --git a/examples/sender_sample.c b/examples/sender_sample.c index c775e14..7163f25 100644 --- a/examples/sender_sample.c +++ b/examples/sender_sample.c @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) message->version = 0; message->space = 0; message->encoding_type = 1; // json but sending string - message->generator_id = 1000; + message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 200; // use other than default configured message->options = NULL; diff --git a/src/listening_worker.c b/src/listening_worker.c index 0da5215..7fe0543 100644 --- a/src/listening_worker.c +++ b/src/listening_worker.c @@ -332,9 +332,9 @@ int listener(struct listener_thread_input *in) return -1; } /* Dispatching by modulo on threads */ - uint32_t seg_gid = seg->generator_id; + uint32_t seg_gid = seg->observation_domain_id; uint32_t seg_mid = seg->message_id; - int ret = unyte_udp_queue_write((parsers + (seg->generator_id % in->nb_parsers))->queue, seg); + int ret = unyte_udp_queue_write((parsers + (seg->observation_domain_id % in->nb_parsers))->queue, seg); // if ret == -1 --> queue is full, we discard message if (ret < 0) { diff --git a/src/monitoring_worker.c b/src/monitoring_worker.c index c1d4e08..9de15d6 100644 --- a/src/monitoring_worker.c +++ b/src/monitoring_worker.c @@ -204,7 +204,7 @@ void unyte_udp_print_counters(unyte_udp_sum_counter_t *counter, FILE *std) { fprintf(std, "th_id:%10lu|gen_id:%5u|type: %15s|received:%7u|dropped:%7u|reordered:%5u|last_msg_id:%9u\n", counter->thread_id, - counter->generator_id, + counter->observation_domain_id, counter->type == PARSER_WORKER ? "PARSER_WORKER" : "LISTENER_WORKER", counter->segments_received, counter->segments_dropped, @@ -237,7 +237,7 @@ unyte_udp_sum_counter_t *get_summary(unyte_gid_counter_t *gid_counter, pthread_t printf("get_summary(): Malloc error\n"); return NULL; } - summary->generator_id = gid_counter->generator_id; + summary->observation_domain_id = gid_counter->generator_id; summary->last_message_id = gid_counter->last_message_id; summary->segments_received = gid_counter->segments_received; summary->segments_dropped = gid_counter->segments_dropped; @@ -327,7 +327,7 @@ void unyte_udp_free_seg_counters(unyte_seg_counters_t *counter, uint nb_counter) // Getters pthread_t unyte_udp_get_thread_id(unyte_udp_sum_counter_t *counter) { return counter->thread_id; } -uint32_t unyte_udp_get_gen_id(unyte_udp_sum_counter_t *counter) { return counter->generator_id; } +uint32_t unyte_udp_get_od_id(unyte_udp_sum_counter_t *counter) { return counter->observation_domain_id; } uint32_t unyte_udp_get_last_msg_id(unyte_udp_sum_counter_t *counter) { return counter->last_message_id; } uint32_t unyte_udp_get_received_seg(unyte_udp_sum_counter_t *counter) { return counter->segments_received; } uint32_t unyte_udp_get_dropped_seg(unyte_udp_sum_counter_t *counter) { return counter->segments_dropped; } diff --git a/src/monitoring_worker.h b/src/monitoring_worker.h index 9ffa949..e9c75a0 100644 --- a/src/monitoring_worker.h +++ b/src/monitoring_worker.h @@ -45,7 +45,7 @@ typedef struct seg_counters typedef struct counter_summary { pthread_t thread_id; - uint32_t generator_id; + uint32_t observation_domain_id; uint32_t last_message_id; uint32_t segments_received; uint32_t segments_dropped; @@ -79,7 +79,7 @@ void unyte_udp_free_seg_counters(unyte_seg_counters_t *counters, uint nb_counter // Getters pthread_t unyte_udp_get_thread_id(unyte_udp_sum_counter_t *counter); -uint32_t unyte_udp_get_gen_id(unyte_udp_sum_counter_t *counter); +uint32_t unyte_udp_get_od_id(unyte_udp_sum_counter_t *counter); uint32_t unyte_udp_get_last_msg_id(unyte_udp_sum_counter_t *counter); uint32_t unyte_udp_get_received_seg(unyte_udp_sum_counter_t *counter); uint32_t unyte_udp_get_dropped_seg(unyte_udp_sum_counter_t *counter); diff --git a/src/parsing_worker.c b/src/parsing_worker.c index dc963c2..239f742 100644 --- a/src/parsing_worker.c +++ b/src/parsing_worker.c @@ -105,7 +105,7 @@ int parser(struct parser_thread_input *in) // Not segmented message if (!is_segmented) { - uint32_t gid = parsed_segment->header->generator_id; + uint32_t gid = parsed_segment->header->observation_domain_id; uint32_t mid = parsed_segment->header->message_id; int ret = unyte_udp_queue_write(in->output, parsed_segment); // ret == -1 queue already full, segment discarded @@ -126,7 +126,7 @@ int parser(struct parser_thread_input *in) else { int insert_res = insert_segment(segment_buff, - parsed_segment->header->generator_id, + parsed_segment->header->observation_domain_id, parsed_segment->header->message_id, parsed_segment->header->f_num, parsed_segment->header->f_last, @@ -152,7 +152,7 @@ int parser(struct parser_thread_input *in) // completed message if (insert_res == 1 || insert_res == -2) { - struct message_segment_list_cell *msg_seg_list = get_segment_list(segment_buff, parsed_segment->header->generator_id, parsed_segment->header->message_id); + struct message_segment_list_cell *msg_seg_list = get_segment_list(segment_buff, parsed_segment->header->observation_domain_id, parsed_segment->header->message_id); char *complete_msg = reassemble_payload(msg_seg_list); unyte_seg_met_t *parsed_msg = create_assembled_msg(complete_msg, parsed_segment, msg_seg_list->total_payload_byte_size, msg_seg_list->options_head, msg_seg_list->options_length); @@ -166,18 +166,18 @@ int parser(struct parser_thread_input *in) if (ret < 0) { if (in->monitoring_running) - unyte_udp_update_dropped_segment(counters, parsed_segment->header->generator_id, parsed_segment->header->message_id); + unyte_udp_update_dropped_segment(counters, parsed_segment->header->observation_domain_id, parsed_segment->header->message_id); // printf("3.losing message on output queue\n"); //TODO: syslog drop package + count unyte_udp_free_all(parsed_msg); } else if (in->monitoring_running) { - unyte_udp_update_received_segment(counters, parsed_segment->header->generator_id, parsed_segment->header->message_id); + unyte_udp_update_received_segment(counters, parsed_segment->header->observation_domain_id, parsed_segment->header->message_id); } clear_and_cleanup_buffer: - clear_segment_list(segment_buff, parsed_segment->header->generator_id, parsed_segment->header->message_id); + clear_segment_list(segment_buff, parsed_segment->header->observation_domain_id, parsed_segment->header->message_id); segment_buff->count--; } diff --git a/src/unyte_udp_utils.c b/src/unyte_udp_utils.c index 009e3c7..d93587e 100644 --- a/src/unyte_udp_utils.c +++ b/src/unyte_udp_utils.c @@ -57,7 +57,7 @@ unyte_min_t *minimal_parse(char *segment, struct sockaddr_storage *source, struc return NULL; } - um->generator_id = ntohl(deserialize_uint32((char *)segment, 4)); + um->observation_domain_id = ntohl(deserialize_uint32((char *)segment, 4)); um->message_id = ntohl(deserialize_uint32((char *)segment, 8)); um->buffer = segment; @@ -87,7 +87,7 @@ unyte_seg_met_t *parse_with_metadata(char *segment, unyte_min_t *um) header->encoding_type = (segment[0] & ET_MASK); header->header_length = segment[1]; header->message_length = ntohs(deserialize_uint16((char *)segment, 2)); - header->generator_id = ntohl(deserialize_uint32((char *)segment, 4)); + header->observation_domain_id = ntohl(deserialize_uint32((char *)segment, 4)); header->message_id = ntohl(deserialize_uint32((char *)segment, 8)); header->options = options_head; @@ -188,7 +188,7 @@ unyte_seg_met_t *parse_with_metadata_legacy(char *segment, unyte_min_t *um) header->encoding_type = get_encoding_IANA_ET_from_legacy((segment[1] & ET_MASK)); header->header_length = HEADER_BYTES; header->message_length = ntohs(deserialize_uint16((char *)segment, 2)); - header->generator_id = ntohl(deserialize_uint32((char *)segment, 4)); + header->observation_domain_id = ntohl(deserialize_uint32((char *)segment, 4)); header->message_id = ntohl(deserialize_uint32((char *)segment, 8)); header->options = options_head; @@ -231,7 +231,7 @@ unyte_seg_met_t *parse_with_metadata_legacy(char *segment, unyte_min_t *um) unyte_seg_met_t *copy_unyte_seg_met_headers(unyte_seg_met_t *dest, unyte_seg_met_t *src) { dest->header->encoding_type = src->header->encoding_type; - dest->header->generator_id = src->header->generator_id; + dest->header->observation_domain_id = src->header->observation_domain_id; dest->header->header_length = src->header->header_length; dest->header->message_id = src->header->message_id; dest->header->message_length = src->header->message_length; @@ -263,7 +263,7 @@ void print_udp_notif_header(unyte_header_t *header, FILE *std) fprintf(std, "Encoding: %u\n", header->encoding_type); fprintf(std, "Header length: %u\n", header->header_length); fprintf(std, "Message length: %u\n", header->message_length); - fprintf(std, "Generator ID: %u\n", header->generator_id); + fprintf(std, "Observation domain ID: %u\n", header->observation_domain_id); fprintf(std, "Mesage ID: %u\n", header->message_id); // Header contains options @@ -399,7 +399,7 @@ struct unyte_segmented_msg *build_message(unyte_message_t *message, uint mtu) memcpy(current_seg->payload, message->buffer, message->buffer_len); - current_seg->header->generator_id = message->generator_id; + current_seg->header->observation_domain_id = message->observation_domain_id; current_seg->header->message_id = message->message_id; current_seg->header->space = message->space; current_seg->header->version = message->version; @@ -433,7 +433,7 @@ struct unyte_segmented_msg *build_message(unyte_message_t *message, uint mtu) printf("Malloc failed \n"); return NULL; } - current_seg->header->generator_id = message->generator_id; + current_seg->header->observation_domain_id = message->observation_domain_id; current_seg->header->message_id = message->message_id; current_seg->header->space = message->space; current_seg->header->version = message->version; @@ -485,10 +485,10 @@ unsigned char *serialize_message(unyte_seg_met_t *msg) parsed_bytes[3] = (packet_size); // observation id - parsed_bytes[4] = (msg->header->generator_id >> 24); - parsed_bytes[5] = (msg->header->generator_id >> 16); - parsed_bytes[6] = (msg->header->generator_id >> 8); - parsed_bytes[7] = (msg->header->generator_id); + parsed_bytes[4] = (msg->header->observation_domain_id >> 24); + parsed_bytes[5] = (msg->header->observation_domain_id >> 16); + parsed_bytes[6] = (msg->header->observation_domain_id >> 8); + parsed_bytes[7] = (msg->header->observation_domain_id); // message id parsed_bytes[8] = (msg->header->message_id >> 24); parsed_bytes[9] = (msg->header->message_id >> 16); @@ -699,7 +699,7 @@ uint8_t unyte_udp_get_space(unyte_seg_met_t *message) { return message->header-> uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message) { return message->header->encoding_type; } uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message) { return message->header->header_length; } uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message) { return message->header->message_length; } -uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message) { return message->header->generator_id; } +uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message) { return message->header->observation_domain_id; } uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message) { return message->header->message_id; } struct sockaddr_storage *unyte_udp_get_src(unyte_seg_met_t *message) { return message->metadata->src; } struct sockaddr_storage *unyte_udp_get_dest_addr(unyte_seg_met_t *message) { return message->metadata->dest; } diff --git a/src/unyte_udp_utils.h b/src/unyte_udp_utils.h index 5657725..1cd3bfc 100644 --- a/src/unyte_udp_utils.h +++ b/src/unyte_udp_utils.h @@ -27,7 +27,7 @@ typedef struct unyte_header uint8_t encoding_type : 4; uint8_t header_length : 8; uint16_t message_length; - uint32_t generator_id; + uint32_t observation_domain_id; uint32_t message_id; /* Segmentation options */ @@ -58,7 +58,7 @@ typedef struct unyte_segment_with_metadata typedef struct unyte_minimal { /* Dispatching informations */ - uint32_t generator_id; + uint32_t observation_domain_id; uint32_t message_id; /* Serialized datas */ @@ -99,7 +99,7 @@ typedef struct unyte_message uint8_t version : 3; uint8_t space : 1; uint8_t encoding_type : 4; - uint32_t generator_id; + uint32_t observation_domain_id; uint32_t message_id; // Custom options From 2a8577d5b92f145d87f2be5d24cee6b8041bfd5a Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:13:50 +0200 Subject: [PATCH 04/12] feat: migrate generator_id to observation id in structs (2) --- src/monitoring_worker.c | 44 +++++++++++++++++++-------------------- src/monitoring_worker.h | 4 ++-- src/segmentation_buffer.c | 12 +++++------ src/segmentation_buffer.h | 2 +- src/unyte_udp_defaults.h | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/monitoring_worker.c b/src/monitoring_worker.c index 9de15d6..e479c80 100644 --- a/src/monitoring_worker.c +++ b/src/monitoring_worker.c @@ -6,34 +6,34 @@ #include "unyte_udp_defaults.h" // TODO: new hashkey function + prepend unyte -uint32_t hash_key(uint32_t gid) +uint32_t hash_key(uint32_t odid) { - return (gid) % GID_COUNTERS; + return (odid) % GID_COUNTERS; } /** * Initialize element unyte_gid_counter_t */ -void init_gid_counter(unyte_gid_counter_t *gid_counters) +void init_gid_counter(unyte_gid_counter_t *odid_counters) { - unyte_gid_counter_t *cur = gid_counters; + unyte_gid_counter_t *cur = odid_counters; cur->segments_received = 0; cur->segments_dropped = 0; cur->segments_reordered = 0; cur->last_message_id = 0; - cur->generator_id = 0; + cur->observation_domain_id = 0; cur->next = NULL; } /** - * Reinitialize the counter for the element *gid_counter + * Reinitialize the counter for the element *odid_counter */ -void reinit_gid_counters(unyte_gid_counter_t *gid_counter) +void reinit_odid_counters(unyte_gid_counter_t *odid_counter) { - gid_counter->last_message_id = 0; - gid_counter->segments_received = 0; - gid_counter->segments_dropped = 0; - gid_counter->segments_reordered = 0; + odid_counter->last_message_id = 0; + odid_counter->segments_received = 0; + odid_counter->segments_dropped = 0; + odid_counter->segments_reordered = 0; } /** @@ -108,7 +108,7 @@ unyte_gid_counter_t *get_gid_counter(unyte_seg_counters_t *counters, uint32_t gi while (cur->next != NULL) { cur = cur->next; - if (cur->generator_id == gid) + if (cur->observation_domain_id == gid) return cur; } // Creates a new one on last element of linear probing linked list @@ -116,7 +116,7 @@ unyte_gid_counter_t *get_gid_counter(unyte_seg_counters_t *counters, uint32_t gi // Malloc failed if (cur->next == NULL) return NULL; - cur->next->generator_id = gid; + cur->next->observation_domain_id = gid; cur->next->segments_received = 0; cur->next->segments_dropped = 0; cur->next->segments_reordered = 0; @@ -129,7 +129,7 @@ unyte_gid_counter_t *get_gid_counter(unyte_seg_counters_t *counters, uint32_t gi printf("Malloc failed.\n"); } // add gid to active gids - counters->active_gids[counters->active_gids_length].generator_id = gid; + counters->active_gids[counters->active_gids_length].observation_domain_id = gid; counters->active_gids[counters->active_gids_length].active = 0; counters->active_gids_length += 1; return cur->next; @@ -147,7 +147,7 @@ void remove_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) next_counter = cur->next; if (next_counter != NULL) { - if (next_counter->generator_id == gid) + if (next_counter->observation_domain_id == gid) { unyte_gid_counter_t *to_remove = next_counter; unyte_gid_counter_t *precedent = cur; @@ -159,12 +159,12 @@ void remove_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) } for (uint i = 0; i < counters->active_gids_length; i++) { - if (counters->active_gids[i].generator_id == gid) + if (counters->active_gids[i].observation_domain_id == gid) { // Reordering array to reduce size for (uint o = i + 1; o < counters->active_gids_length; o++) { - counters->active_gids[i].generator_id = counters->active_gids[o].generator_id; + counters->active_gids[i].observation_domain_id = counters->active_gids[o].observation_domain_id; counters->active_gids[i].active = counters->active_gids[o].active; } counters->active_gids_length -= 1; @@ -237,7 +237,7 @@ unyte_udp_sum_counter_t *get_summary(unyte_gid_counter_t *gid_counter, pthread_t printf("get_summary(): Malloc error\n"); return NULL; } - summary->observation_domain_id = gid_counter->generator_id; + summary->observation_domain_id = gid_counter->observation_domain_id; summary->last_message_id = gid_counter->last_message_id; summary->segments_received = gid_counter->segments_received; summary->segments_dropped = gid_counter->segments_dropped; @@ -264,7 +264,7 @@ void *t_monitoring_unyte_udp(void *in) // seg_counter_cur->active_gids is the indexed generator ids received for (uint y = 0; y < active_gids; y++) { - unyte_gid_counter_t *cur_gid_counter = get_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].generator_id); + unyte_gid_counter_t *cur_gid_counter = get_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].observation_domain_id); // if non-zero values, clone stats and send to queue if (gid_counter_has_values(cur_gid_counter)) { @@ -272,14 +272,14 @@ void *t_monitoring_unyte_udp(void *in) if (summary != NULL) { unyte_udp_queue_destructive_write(output_queue, summary); - reinit_gid_counters(cur_gid_counter); + reinit_odid_counters(cur_gid_counter); } seg_counter_cur->active_gids[y].active = 0; } // if generator id has zeros-values and read GID_TIME_TO_LIVE, remove structs from thread stats else if (seg_counter_cur->active_gids[y].active == GID_TIME_TO_LIVE) { - remove_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].generator_id); + remove_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].observation_domain_id); } // counters are zero and read < GID_TIME_TO_LIVE, send to queue and active++ else @@ -288,7 +288,7 @@ void *t_monitoring_unyte_udp(void *in) if (summary != NULL) { unyte_udp_queue_destructive_write(output_queue, summary); - reinit_gid_counters(cur_gid_counter); + reinit_odid_counters(cur_gid_counter); } seg_counter_cur->active_gids[y].active += 1; } diff --git a/src/monitoring_worker.h b/src/monitoring_worker.h index e9c75a0..bbbeaf3 100644 --- a/src/monitoring_worker.h +++ b/src/monitoring_worker.h @@ -14,14 +14,14 @@ typedef enum typedef struct active_gid { - uint32_t generator_id; // generator id / observation id + uint32_t observation_domain_id; // generator id / observation id int active; // if > GID_TIME_TO_LIVE gen_id considered not receiving anymore } active_gid_t; // linear probing typedef struct gid_counter { - uint32_t generator_id; + uint32_t observation_domain_id; uint32_t segments_received; uint32_t segments_dropped; uint32_t segments_reordered; diff --git a/src/segmentation_buffer.c b/src/segmentation_buffer.c index 34c40f3..f00d23b 100644 --- a/src/segmentation_buffer.c +++ b/src/segmentation_buffer.c @@ -229,12 +229,12 @@ struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, u void print_segment_list_header(struct message_segment_list_cell *head) { - printf("Segment list: gid %d mid %d current size %d total size %d\n", head->gid, head->mid, head->current_size, head->total_size); + printf("Segment list: odid %d mid %d current size %d total size %d\n", head->odid, head->mid, head->current_size, head->total_size); } void print_segment_list_int(struct message_segment_list_cell *head) { - printf("Segment list: gid %d mid %d current size %d total size %d\n", head->gid, head->mid, head->current_size, head->total_size); + printf("Segment list: odid %d mid %d current size %d total size %d\n", head->odid, head->mid, head->current_size, head->total_size); struct message_segment_list_cell *cur = head; while (cur->next != NULL) { @@ -245,7 +245,7 @@ void print_segment_list_int(struct message_segment_list_cell *head) void print_segment_list_string(struct message_segment_list_cell *head) { - printf("Segment list: gid %d mid %d current size %d total size %d\n", head->gid, head->mid, head->current_size, head->total_size); + printf("Segment list: odid %d mid %d current size %d total size %d\n", head->odid, head->mid, head->current_size, head->total_size); struct message_segment_list_cell *cur = head; while (cur->next != NULL) { @@ -254,12 +254,12 @@ void print_segment_list_string(struct message_segment_list_cell *head) } } -struct message_segment_list_cell *create_message_segment_list(uint32_t gid, uint32_t mid) +struct message_segment_list_cell *create_message_segment_list(uint32_t odid, uint32_t mid) { struct message_segment_list_cell *res = malloc(sizeof(struct message_segment_list_cell)); if (res == NULL) return NULL; - res->gid = gid; + res->odid = odid; res->mid = mid; res->current_size = 0; res->total_size = 0; @@ -318,7 +318,7 @@ int clear_collision_list(struct segment_buffer *buf, struct collision_list_cell { res++; temp = cur->next; - clear_segment_list(buf, cur->head->gid, cur->head->mid); + clear_segment_list(buf, cur->head->odid, cur->head->mid); cur = temp; } free(head); diff --git a/src/segmentation_buffer.h b/src/segmentation_buffer.h index 12ae087..405a9c6 100644 --- a/src/segmentation_buffer.h +++ b/src/segmentation_buffer.h @@ -18,7 +18,7 @@ struct message_segment_list_cell uint32_t total_size; // total segments for a complete message, 0 if unknown uint32_t current_size; // present segments in a list uint32_t total_payload_byte_size; // sum of segments size for this segment list - uint32_t gid; // generator_id, observation_domain_id in scapy + uint32_t odid; // observation_domain_id in scapy uint32_t mid; // message_id, segment_id in scapy uint32_t seqnum; // ordered by seqnum void *content; diff --git a/src/unyte_udp_defaults.h b/src/unyte_udp_defaults.h index adc3e1c..33f4762 100644 --- a/src/unyte_udp_defaults.h +++ b/src/unyte_udp_defaults.h @@ -17,7 +17,7 @@ // monitoring_worker #define GID_COUNTERS 10 // hashmap modulo #define ACTIVE_GIDS 500 // how many active gids do we are waiting for -#define GID_TIME_TO_LIVE 4 // times monitoring thread consider generator_id active without stats +#define GID_TIME_TO_LIVE 4 // times monitoring thread consider observation_domain_id active without stats // Segmentation_buffer parameters | not settable by the user #define SIZE_BUF 10000 // size of buffer From 58b0bec0f4581fd35119cefdf5681ec12d1f3444 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:30:02 +0200 Subject: [PATCH 05/12] feat: migrate generator_id to observation id in structs (3) --- README.md | 2 +- src/listening_worker.c | 4 +- src/monitoring_worker.c | 176 +++++++++++++++++++-------------------- src/monitoring_worker.h | 22 ++--- src/unyte_udp_defaults.h | 4 +- 5 files changed, 104 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 450c731..116a49f 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ typedef struct uint monitoring_delay; // monitoring queue frequence in seconds. Default: 5 seconds } unyte_udp_options_t; ``` -The thread will every `monitoring_delay` seconds send all generators id's counters. +The thread will every `monitoring_delay` seconds send all observation domain id's counters. ##### Type of threads The threads types are defined in `monitoring_worker.h`: diff --git a/src/listening_worker.c b/src/listening_worker.c index 7fe0543..273eed1 100644 --- a/src/listening_worker.c +++ b/src/listening_worker.c @@ -133,12 +133,12 @@ int create_parse_worker(struct parse_worker *parser, struct listener_thread_inpu for (uint i = 0; i < ACTIVE_GIDS; i++) { - (parser_input->counters->active_gids + i)->active = 0; + (parser_input->counters->active_odids + i)->active = 0; } parser_input->monitoring_running = monitoring_running; - if (parser_input->segment_buff == NULL || parser_input->counters->active_gids == NULL) + if (parser_input->segment_buff == NULL || parser_input->counters->active_odids == NULL) { printf("Create segment buffer failed.\n"); return -1; diff --git a/src/monitoring_worker.c b/src/monitoring_worker.c index e479c80..8d9145d 100644 --- a/src/monitoring_worker.c +++ b/src/monitoring_worker.c @@ -8,15 +8,15 @@ // TODO: new hashkey function + prepend unyte uint32_t hash_key(uint32_t odid) { - return (odid) % GID_COUNTERS; + return (odid) % ODID_COUNTERS; } /** - * Initialize element unyte_gid_counter_t + * Initialize element unyte_odid_counter_t */ -void init_gid_counter(unyte_gid_counter_t *odid_counters) +void init_odid_counter(unyte_odid_counter_t *odid_counters) { - unyte_gid_counter_t *cur = odid_counters; + unyte_odid_counter_t *cur = odid_counters; cur->segments_received = 0; cur->segments_dropped = 0; cur->segments_reordered = 0; @@ -28,7 +28,7 @@ void init_gid_counter(unyte_gid_counter_t *odid_counters) /** * Reinitialize the counter for the element *odid_counter */ -void reinit_odid_counters(unyte_gid_counter_t *odid_counter) +void reinit_odid_counters(unyte_odid_counter_t *odid_counter) { odid_counter->last_message_id = 0; odid_counter->segments_received = 0; @@ -37,28 +37,28 @@ void reinit_odid_counters(unyte_gid_counter_t *odid_counter) } /** - * Initialize active generators id index array. + * Initialize active obervation domain id index array. */ -int init_active_gid_index(unyte_seg_counters_t *counters) +int init_active_odid_index(unyte_seg_counters_t *counters) { - counters->active_gids = (active_gid_t *)malloc(sizeof(active_gid_t) * ACTIVE_GIDS); - if (counters->active_gids == NULL) + counters->active_odids = (active_odid_t *)malloc(sizeof(active_odid_t) * ACTIVE_GIDS); + if (counters->active_odids == NULL) return -1; - counters->active_gids_length = 0; - counters->active_gids_max_length = ACTIVE_GIDS; + counters->active_odids_length = 0; + counters->active_odids_max_length = ACTIVE_GIDS; return 0; } /** * Resize active generators id index array if it is full */ -int resize_active_gid_index(unyte_seg_counters_t *counters) +int resize_active_odid_index(unyte_seg_counters_t *counters) { - active_gid_t *new_active_gid = (active_gid_t *)realloc(counters->active_gids, sizeof(active_gid_t) * (counters->active_gids_max_length + ACTIVE_GIDS)); + active_odid_t *new_active_gid = (active_odid_t *)realloc(counters->active_odids, sizeof(active_odid_t) * (counters->active_odids_max_length + ACTIVE_GIDS)); if (new_active_gid == NULL) return -1; - counters->active_gids = new_active_gid; - counters->active_gids_max_length = counters->active_gids_max_length + ACTIVE_GIDS; + counters->active_odids = new_active_gid; + counters->active_odids_max_length = counters->active_odids_max_length + ACTIVE_GIDS; return 0; } @@ -76,17 +76,17 @@ unyte_seg_counters_t *unyte_udp_init_counters(uint nb_threads) unyte_seg_counters_t *cur = counters; for (uint i = 0; i < nb_threads; i++) { - cur->gid_counters = malloc(sizeof(unyte_gid_counter_t) * GID_COUNTERS); - if (cur->gid_counters == NULL) + cur->odid_counters = malloc(sizeof(unyte_odid_counter_t) * ODID_COUNTERS); + if (cur->odid_counters == NULL) { printf("Malloc failed\n"); return NULL; } - for (uint o = 0; o < GID_COUNTERS; o++) + for (uint o = 0; o < ODID_COUNTERS; o++) { - init_gid_counter(cur->gid_counters + o); + init_odid_counter(cur->odid_counters + o); } - if (init_active_gid_index(cur) < 0) + if (init_active_odid_index(cur) < 0) { printf("Malloc failed\n"); return NULL; @@ -97,51 +97,51 @@ unyte_seg_counters_t *unyte_udp_init_counters(uint nb_threads) } /** - * Returns existant gid_counter if exists, creates a new one if not existant - * Saves the gid on a indexed array (active_gids) + * Returns existant odid_counter if exists, creates a new one if not existant + * Saves the gid on a indexed array (active_odids) */ -unyte_gid_counter_t *get_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) +unyte_odid_counter_t *get_odid_counter(unyte_seg_counters_t *counters, uint32_t odid) { // get hashmap element from global counters hashmap - unyte_gid_counter_t *cur = counters->gid_counters + hash_key(gid); + unyte_odid_counter_t *cur = counters->odid_counters + hash_key(odid); // get element : linear probing while (cur->next != NULL) { cur = cur->next; - if (cur->observation_domain_id == gid) + if (cur->observation_domain_id == odid) return cur; } // Creates a new one on last element of linear probing linked list - cur->next = (unyte_gid_counter_t *)malloc(sizeof(unyte_gid_counter_t)); + cur->next = (unyte_odid_counter_t *)malloc(sizeof(unyte_odid_counter_t)); // Malloc failed if (cur->next == NULL) return NULL; - cur->next->observation_domain_id = gid; + cur->next->observation_domain_id = odid; cur->next->segments_received = 0; cur->next->segments_dropped = 0; cur->next->segments_reordered = 0; cur->next->last_message_id = 0; cur->next->next = NULL; // resize active generators id index array if it is full - if (counters->active_gids_length + 1 >= counters->active_gids_max_length) + if (counters->active_odids_length + 1 >= counters->active_odids_max_length) { - if (resize_active_gid_index(counters) < 0) + if (resize_active_odid_index(counters) < 0) printf("Malloc failed.\n"); } // add gid to active gids - counters->active_gids[counters->active_gids_length].observation_domain_id = gid; - counters->active_gids[counters->active_gids_length].active = 0; - counters->active_gids_length += 1; + counters->active_odids[counters->active_odids_length].observation_domain_id = odid; + counters->active_odids[counters->active_odids_length].active = 0; + counters->active_odids_length += 1; return cur->next; } /** * Removes a gid from the linked list unyte_seg_counters_t and removes the gid from indexed array */ -void remove_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) +void remove_odid_counter(unyte_seg_counters_t *counters, uint32_t gid) { - unyte_gid_counter_t *cur = counters->gid_counters + hash_key(gid); - unyte_gid_counter_t *next_counter; + unyte_odid_counter_t *cur = counters->odid_counters + hash_key(gid); + unyte_odid_counter_t *next_counter; while (cur != NULL) { next_counter = cur->next; @@ -149,25 +149,25 @@ void remove_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) { if (next_counter->observation_domain_id == gid) { - unyte_gid_counter_t *to_remove = next_counter; - unyte_gid_counter_t *precedent = cur; + unyte_odid_counter_t *to_remove = next_counter; + unyte_odid_counter_t *precedent = cur; precedent->next = next_counter->next; free(to_remove); } } cur = cur->next; } - for (uint i = 0; i < counters->active_gids_length; i++) + for (uint i = 0; i < counters->active_odids_length; i++) { - if (counters->active_gids[i].observation_domain_id == gid) + if (counters->active_odids[i].observation_domain_id == gid) { // Reordering array to reduce size - for (uint o = i + 1; o < counters->active_gids_length; o++) + for (uint o = i + 1; o < counters->active_odids_length; o++) { - counters->active_gids[i].observation_domain_id = counters->active_gids[o].observation_domain_id; - counters->active_gids[i].active = counters->active_gids[o].active; + counters->active_odids[i].observation_domain_id = counters->active_odids[o].observation_domain_id; + counters->active_odids[i].active = counters->active_odids[o].active; } - counters->active_gids_length -= 1; + counters->active_odids_length -= 1; break; } } @@ -175,28 +175,28 @@ void remove_gid_counter(unyte_seg_counters_t *counters, uint32_t gid) void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid) { - unyte_gid_counter_t *gid_counter = get_gid_counter(counters, last_gid); - if (gid_counter == NULL) + unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_gid); + if (odid_counter == NULL) printf("Malloc failed\n"); else { - gid_counter->segments_dropped++; - gid_counter->last_message_id = last_mid; + odid_counter->segments_dropped++; + odid_counter->last_message_id = last_mid; } } void unyte_udp_update_received_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid) { - unyte_gid_counter_t *gid_counter = get_gid_counter(counters, last_gid); - if (gid_counter == NULL) + unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_gid); + if (odid_counter == NULL) printf("Malloc failed\n"); else { - gid_counter->segments_received++; - if (last_mid < gid_counter->last_message_id) - gid_counter->segments_reordered++; + odid_counter->segments_received++; + if (last_mid < odid_counter->last_message_id) + odid_counter->segments_reordered++; else - gid_counter->last_message_id = last_mid; + odid_counter->last_message_id = last_mid; } } @@ -213,22 +213,22 @@ void unyte_udp_print_counters(unyte_udp_sum_counter_t *counter, FILE *std) } /** - * Checks if *gid_counter has valid values to clone + * Checks if *odid_counter has valid values to clone */ -bool gid_counter_has_values(unyte_gid_counter_t *gid_counter) +bool odid_counter_has_values(unyte_odid_counter_t *odid_counter) { - return (gid_counter != NULL) && !(gid_counter->last_message_id == 0 && - gid_counter->segments_received == 0 && - gid_counter->segments_dropped == 0 && - gid_counter->segments_reordered == 0); + return (odid_counter != NULL) && !(odid_counter->last_message_id == 0 && + odid_counter->segments_received == 0 && + odid_counter->segments_dropped == 0 && + odid_counter->segments_reordered == 0); } /** - * Clone *gid_counter to send to user client + * Clone *odid_counter to send to user client */ -unyte_udp_sum_counter_t *get_summary(unyte_gid_counter_t *gid_counter, pthread_t th_id, thread_type_t type) +unyte_udp_sum_counter_t *get_summary(unyte_odid_counter_t *odid_counter, pthread_t th_id, thread_type_t type) { - if (gid_counter == NULL) + if (odid_counter == NULL) return NULL; unyte_udp_sum_counter_t *summary = (unyte_udp_sum_counter_t *)malloc(sizeof(unyte_udp_sum_counter_t)); @@ -237,11 +237,11 @@ unyte_udp_sum_counter_t *get_summary(unyte_gid_counter_t *gid_counter, pthread_t printf("get_summary(): Malloc error\n"); return NULL; } - summary->observation_domain_id = gid_counter->observation_domain_id; - summary->last_message_id = gid_counter->last_message_id; - summary->segments_received = gid_counter->segments_received; - summary->segments_dropped = gid_counter->segments_dropped; - summary->segments_reordered = gid_counter->segments_reordered; + summary->observation_domain_id = odid_counter->observation_domain_id; + summary->last_message_id = odid_counter->last_message_id; + summary->segments_received = odid_counter->segments_received; + summary->segments_dropped = odid_counter->segments_dropped; + summary->segments_reordered = odid_counter->segments_reordered; summary->thread_id = th_id; summary->type = type; return summary; @@ -259,38 +259,38 @@ void *t_monitoring_unyte_udp(void *in) for (uint i = 0; i < input->nb_counters; i++) { seg_counter_cur = (input->counters + i); - uint active_gids = seg_counter_cur->active_gids_length; + uint active_odids = seg_counter_cur->active_odids_length; // every generator id read on the worker thread - // seg_counter_cur->active_gids is the indexed generator ids received - for (uint y = 0; y < active_gids; y++) + // seg_counter_cur->active_odids is the indexed generator ids received + for (uint y = 0; y < active_odids; y++) { - unyte_gid_counter_t *cur_gid_counter = get_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].observation_domain_id); + unyte_odid_counter_t *cur_odid_counter = get_odid_counter(seg_counter_cur, seg_counter_cur->active_odids[y].observation_domain_id); // if non-zero values, clone stats and send to queue - if (gid_counter_has_values(cur_gid_counter)) + if (odid_counter_has_values(cur_odid_counter)) { - unyte_udp_sum_counter_t *summary = get_summary(cur_gid_counter, seg_counter_cur->thread_id, seg_counter_cur->type); + unyte_udp_sum_counter_t *summary = get_summary(cur_odid_counter, seg_counter_cur->thread_id, seg_counter_cur->type); if (summary != NULL) { unyte_udp_queue_destructive_write(output_queue, summary); - reinit_odid_counters(cur_gid_counter); + reinit_odid_counters(cur_odid_counter); } - seg_counter_cur->active_gids[y].active = 0; + seg_counter_cur->active_odids[y].active = 0; } - // if generator id has zeros-values and read GID_TIME_TO_LIVE, remove structs from thread stats - else if (seg_counter_cur->active_gids[y].active == GID_TIME_TO_LIVE) + // if generator id has zeros-values and read ODID_TIME_TO_LIVE, remove structs from thread stats + else if (seg_counter_cur->active_odids[y].active == ODID_TIME_TO_LIVE) { - remove_gid_counter(seg_counter_cur, seg_counter_cur->active_gids[y].observation_domain_id); + remove_odid_counter(seg_counter_cur, seg_counter_cur->active_odids[y].observation_domain_id); } - // counters are zero and read < GID_TIME_TO_LIVE, send to queue and active++ + // counters are zero and read < ODID_TIME_TO_LIVE, send to queue and active++ else { - unyte_udp_sum_counter_t *summary = get_summary(cur_gid_counter, seg_counter_cur->thread_id, seg_counter_cur->type); + unyte_udp_sum_counter_t *summary = get_summary(cur_odid_counter, seg_counter_cur->thread_id, seg_counter_cur->type); if (summary != NULL) { unyte_udp_queue_destructive_write(output_queue, summary); - reinit_odid_counters(cur_gid_counter); + reinit_odid_counters(cur_odid_counter); } - seg_counter_cur->active_gids[y].active += 1; + seg_counter_cur->active_odids[y].active += 1; } } } @@ -305,13 +305,13 @@ void unyte_udp_free_seg_counters(unyte_seg_counters_t *counter, uint nb_counter) { for (uint i = 0; i < nb_counter; i++) { - free((counter + i)->active_gids); - unyte_gid_counter_t *cur_gid = (counter + i)->gid_counters; - for (uint o = 0; o < GID_COUNTERS; o++) + free((counter + i)->active_odids); + unyte_odid_counter_t *cur_gid = (counter + i)->odid_counters; + for (uint o = 0; o < ODID_COUNTERS; o++) { - unyte_gid_counter_t *head = (cur_gid + o); - unyte_gid_counter_t *cur_counter = head->next; - unyte_gid_counter_t *tmp; + unyte_odid_counter_t *head = (cur_gid + o); + unyte_odid_counter_t *cur_counter = head->next; + unyte_odid_counter_t *tmp; while (cur_counter != NULL) { tmp = cur_counter->next; diff --git a/src/monitoring_worker.h b/src/monitoring_worker.h index bbbeaf3..bc0991c 100644 --- a/src/monitoring_worker.h +++ b/src/monitoring_worker.h @@ -15,28 +15,28 @@ typedef enum typedef struct active_gid { uint32_t observation_domain_id; // generator id / observation id - int active; // if > GID_TIME_TO_LIVE gen_id considered not receiving anymore -} active_gid_t; + int active; // if > ODID_TIME_TO_LIVE observation_domain_id considered not receiving anymore +} active_odid_t; // linear probing -typedef struct gid_counter +typedef struct odid_counter { uint32_t observation_domain_id; uint32_t segments_received; uint32_t segments_dropped; uint32_t segments_reordered; uint32_t last_message_id; - struct gid_counter *next; -} unyte_gid_counter_t; + struct odid_counter *next; +} unyte_odid_counter_t; typedef struct seg_counters { - pthread_t thread_id; // thread id - unyte_gid_counter_t *gid_counters; // hashmap array of n unyte_gid_counter_t - thread_type_t type; // type of thread: PARSER_WORKER | LISTENER_WORKER - active_gid_t *active_gids; // active generator ids array - uint active_gids_length; // active generator used - uint active_gids_max_length; // active_gids max array length. Used to resize if active_gids is full + pthread_t thread_id; // thread id + unyte_odid_counter_t *odid_counters; // hashmap array of n unyte_odid_counter_t + thread_type_t type; // type of thread: PARSER_WORKER | LISTENER_WORKER + active_odid_t *active_odids; // active observation domain ids array + uint active_odids_length; // active observation domain used + uint active_odids_max_length; // active_gids max array length. Used to resize if active_gids is full } unyte_seg_counters_t; /** diff --git a/src/unyte_udp_defaults.h b/src/unyte_udp_defaults.h index 33f4762..53b8baa 100644 --- a/src/unyte_udp_defaults.h +++ b/src/unyte_udp_defaults.h @@ -15,9 +15,9 @@ #define CLEANUP_FLAG_CRON 1000 // clean up cron in milliseconds // monitoring_worker -#define GID_COUNTERS 10 // hashmap modulo +#define ODID_COUNTERS 10 // hashmap modulo #define ACTIVE_GIDS 500 // how many active gids do we are waiting for -#define GID_TIME_TO_LIVE 4 // times monitoring thread consider observation_domain_id active without stats +#define ODID_TIME_TO_LIVE 4 // times monitoring thread consider observation_domain_id active without stats // Segmentation_buffer parameters | not settable by the user #define SIZE_BUF 10000 // size of buffer From edfb4a902626e7bd28a4daece2696f72ff42e633 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:39:12 +0200 Subject: [PATCH 06/12] feat: migrate generator_id to observation id in structs (4) --- src/listening_worker.c | 6 +++--- src/monitoring_worker.c | 44 +++++++++++++++++++-------------------- src/monitoring_worker.h | 12 +++++------ src/parsing_worker.c | 6 +++--- src/segmentation_buffer.c | 40 +++++++++++++++++------------------ src/segmentation_buffer.h | 18 ++++++++-------- src/unyte_udp_defaults.h | 2 +- test/test_segmentation.c | 14 ++++++------- 8 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/listening_worker.c b/src/listening_worker.c index 273eed1..855a877 100644 --- a/src/listening_worker.c +++ b/src/listening_worker.c @@ -332,7 +332,7 @@ int listener(struct listener_thread_input *in) return -1; } /* Dispatching by modulo on threads */ - uint32_t seg_gid = seg->observation_domain_id; + uint32_t seg_odid = seg->observation_domain_id; uint32_t seg_mid = seg->message_id; int ret = unyte_udp_queue_write((parsers + (seg->observation_domain_id % in->nb_parsers))->queue, seg); // if ret == -1 --> queue is full, we discard message @@ -340,12 +340,12 @@ int listener(struct listener_thread_input *in) { // printf("1.losing message on parser queue\n"); if (monitoring->running) - unyte_udp_update_dropped_segment(listener_counter, seg_gid, seg_mid); + unyte_udp_update_dropped_segment(listener_counter, seg_odid, seg_mid); free(seg->buffer); free(seg); } else if (monitoring->running) - unyte_udp_update_received_segment(listener_counter, seg_gid, seg_mid); + unyte_udp_update_received_segment(listener_counter, seg_odid, seg_mid); } else free(messages[i].msg_hdr.msg_iov->iov_base); diff --git a/src/monitoring_worker.c b/src/monitoring_worker.c index 8d9145d..f8bbc68 100644 --- a/src/monitoring_worker.c +++ b/src/monitoring_worker.c @@ -50,14 +50,14 @@ int init_active_odid_index(unyte_seg_counters_t *counters) } /** - * Resize active generators id index array if it is full + * Resize active observation domain id index array if it is full */ int resize_active_odid_index(unyte_seg_counters_t *counters) { - active_odid_t *new_active_gid = (active_odid_t *)realloc(counters->active_odids, sizeof(active_odid_t) * (counters->active_odids_max_length + ACTIVE_GIDS)); - if (new_active_gid == NULL) + active_odid_t *new_active_odid = (active_odid_t *)realloc(counters->active_odids, sizeof(active_odid_t) * (counters->active_odids_max_length + ACTIVE_GIDS)); + if (new_active_odid == NULL) return -1; - counters->active_odids = new_active_gid; + counters->active_odids = new_active_odid; counters->active_odids_max_length = counters->active_odids_max_length + ACTIVE_GIDS; return 0; } @@ -98,7 +98,7 @@ unyte_seg_counters_t *unyte_udp_init_counters(uint nb_threads) /** * Returns existant odid_counter if exists, creates a new one if not existant - * Saves the gid on a indexed array (active_odids) + * Saves the odid on a indexed array (active_odids) */ unyte_odid_counter_t *get_odid_counter(unyte_seg_counters_t *counters, uint32_t odid) { @@ -122,13 +122,13 @@ unyte_odid_counter_t *get_odid_counter(unyte_seg_counters_t *counters, uint32_t cur->next->segments_reordered = 0; cur->next->last_message_id = 0; cur->next->next = NULL; - // resize active generators id index array if it is full + // resize active observation domain id index array if it is full if (counters->active_odids_length + 1 >= counters->active_odids_max_length) { if (resize_active_odid_index(counters) < 0) printf("Malloc failed.\n"); } - // add gid to active gids + // add odid to active odids counters->active_odids[counters->active_odids_length].observation_domain_id = odid; counters->active_odids[counters->active_odids_length].active = 0; counters->active_odids_length += 1; @@ -136,18 +136,18 @@ unyte_odid_counter_t *get_odid_counter(unyte_seg_counters_t *counters, uint32_t } /** - * Removes a gid from the linked list unyte_seg_counters_t and removes the gid from indexed array + * Removes a odid from the linked list unyte_seg_counters_t and removes the odid from indexed array */ -void remove_odid_counter(unyte_seg_counters_t *counters, uint32_t gid) +void remove_odid_counter(unyte_seg_counters_t *counters, uint32_t odid) { - unyte_odid_counter_t *cur = counters->odid_counters + hash_key(gid); + unyte_odid_counter_t *cur = counters->odid_counters + hash_key(odid); unyte_odid_counter_t *next_counter; while (cur != NULL) { next_counter = cur->next; if (next_counter != NULL) { - if (next_counter->observation_domain_id == gid) + if (next_counter->observation_domain_id == odid) { unyte_odid_counter_t *to_remove = next_counter; unyte_odid_counter_t *precedent = cur; @@ -159,7 +159,7 @@ void remove_odid_counter(unyte_seg_counters_t *counters, uint32_t gid) } for (uint i = 0; i < counters->active_odids_length; i++) { - if (counters->active_odids[i].observation_domain_id == gid) + if (counters->active_odids[i].observation_domain_id == odid) { // Reordering array to reduce size for (uint o = i + 1; o < counters->active_odids_length; o++) @@ -173,9 +173,9 @@ void remove_odid_counter(unyte_seg_counters_t *counters, uint32_t gid) } } -void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid) +void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t last_odid, uint32_t last_mid) { - unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_gid); + unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_odid); if (odid_counter == NULL) printf("Malloc failed\n"); else @@ -185,9 +185,9 @@ void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t l } } -void unyte_udp_update_received_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid) +void unyte_udp_update_received_segment(unyte_seg_counters_t *counters, uint32_t last_odid, uint32_t last_mid) { - unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_gid); + unyte_odid_counter_t *odid_counter = get_odid_counter(counters, last_odid); if (odid_counter == NULL) printf("Malloc failed\n"); else @@ -260,8 +260,8 @@ void *t_monitoring_unyte_udp(void *in) { seg_counter_cur = (input->counters + i); uint active_odids = seg_counter_cur->active_odids_length; - // every generator id read on the worker thread - // seg_counter_cur->active_odids is the indexed generator ids received + // every observation domain id read on the worker thread + // seg_counter_cur->active_odids is the indexed observation domain ids received for (uint y = 0; y < active_odids; y++) { unyte_odid_counter_t *cur_odid_counter = get_odid_counter(seg_counter_cur, seg_counter_cur->active_odids[y].observation_domain_id); @@ -276,7 +276,7 @@ void *t_monitoring_unyte_udp(void *in) } seg_counter_cur->active_odids[y].active = 0; } - // if generator id has zeros-values and read ODID_TIME_TO_LIVE, remove structs from thread stats + // if observation domain id has zeros-values and read ODID_TIME_TO_LIVE, remove structs from thread stats else if (seg_counter_cur->active_odids[y].active == ODID_TIME_TO_LIVE) { remove_odid_counter(seg_counter_cur, seg_counter_cur->active_odids[y].observation_domain_id); @@ -306,10 +306,10 @@ void unyte_udp_free_seg_counters(unyte_seg_counters_t *counter, uint nb_counter) for (uint i = 0; i < nb_counter; i++) { free((counter + i)->active_odids); - unyte_odid_counter_t *cur_gid = (counter + i)->odid_counters; + unyte_odid_counter_t *cur_odid = (counter + i)->odid_counters; for (uint o = 0; o < ODID_COUNTERS; o++) { - unyte_odid_counter_t *head = (cur_gid + o); + unyte_odid_counter_t *head = (cur_odid + o); unyte_odid_counter_t *cur_counter = head->next; unyte_odid_counter_t *tmp; while (cur_counter != NULL) @@ -320,7 +320,7 @@ void unyte_udp_free_seg_counters(unyte_seg_counters_t *counter, uint nb_counter) } free(cur_counter); } - free(cur_gid); + free(cur_odid); } free(counter); } diff --git a/src/monitoring_worker.h b/src/monitoring_worker.h index bc0991c..001afdf 100644 --- a/src/monitoring_worker.h +++ b/src/monitoring_worker.h @@ -12,10 +12,10 @@ typedef enum LISTENER_WORKER } thread_type_t; -typedef struct active_gid +typedef struct active_odid { - uint32_t observation_domain_id; // generator id / observation id - int active; // if > ODID_TIME_TO_LIVE observation_domain_id considered not receiving anymore + uint32_t observation_domain_id; // observation id + int active; // if > ODID_TIME_TO_LIVE observation_domain_id considered not receiving anymore } active_odid_t; // linear probing @@ -36,7 +36,7 @@ typedef struct seg_counters thread_type_t type; // type of thread: PARSER_WORKER | LISTENER_WORKER active_odid_t *active_odids; // active observation domain ids array uint active_odids_length; // active observation domain used - uint active_odids_max_length; // active_gids max array length. Used to resize if active_gids is full + uint active_odids_max_length; // active_odids max array length. Used to resize if active_odids is full } unyte_seg_counters_t; /** @@ -67,12 +67,12 @@ unyte_seg_counters_t *unyte_udp_init_counters(uint nb_threads); /** * Updates counters with a dropped segment */ -void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid); +void unyte_udp_update_dropped_segment(unyte_seg_counters_t *counters, uint32_t last_odid, uint32_t last_mid); /** * Updates counters with a received segment */ -void unyte_udp_update_received_segment(unyte_seg_counters_t *counters, uint32_t last_gid, uint32_t last_mid); +void unyte_udp_update_received_segment(unyte_seg_counters_t *counters, uint32_t last_odid, uint32_t last_mid); void *t_monitoring_unyte_udp(void *in); void unyte_udp_print_counters(unyte_udp_sum_counter_t *counter, FILE *std); void unyte_udp_free_seg_counters(unyte_seg_counters_t *counters, uint nb_counter); diff --git a/src/parsing_worker.c b/src/parsing_worker.c index 239f742..5227a1d 100644 --- a/src/parsing_worker.c +++ b/src/parsing_worker.c @@ -105,21 +105,21 @@ int parser(struct parser_thread_input *in) // Not segmented message if (!is_segmented) { - uint32_t gid = parsed_segment->header->observation_domain_id; + uint32_t odid = parsed_segment->header->observation_domain_id; uint32_t mid = parsed_segment->header->message_id; int ret = unyte_udp_queue_write(in->output, parsed_segment); // ret == -1 queue already full, segment discarded if (ret < 0) { if (in->monitoring_running) - unyte_udp_update_dropped_segment(counters, gid, mid); + unyte_udp_update_dropped_segment(counters, odid, mid); // printf("2.losing message on output queue\n"); //TODO: syslog drop package + count unyte_udp_free_all(parsed_segment); } else if (in->monitoring_running) { - unyte_udp_update_received_segment(counters, gid, mid); + unyte_udp_update_received_segment(counters, odid, mid); } } // Segmented message diff --git a/src/segmentation_buffer.c b/src/segmentation_buffer.c index f00d23b..148a430 100644 --- a/src/segmentation_buffer.c +++ b/src/segmentation_buffer.c @@ -40,9 +40,9 @@ char *reassemble_payload(struct message_segment_list_cell *msg_seg_list) return complete_msg; } -uint32_t hashKey(uint32_t gid, uint32_t mid) +uint32_t hashKey(uint32_t odid, uint32_t mid) { - return (gid ^ mid) % SIZE_BUF; + return (odid ^ mid) % SIZE_BUF; } /** @@ -84,9 +84,9 @@ int append_options(struct message_segment_list_cell *head, unyte_option_t *optio return 0; } -int insert_segment(struct segment_buffer *buf, uint32_t gid, uint32_t mid, uint32_t seqnum, int last, uint32_t payload_size, void *content, unyte_option_t *options) +int insert_segment(struct segment_buffer *buf, uint32_t odid, uint32_t mid, uint32_t seqnum, int last, uint32_t payload_size, void *content, unyte_option_t *options) { - uint32_t hk = hashKey(gid, mid); + uint32_t hk = hashKey(odid, mid); if (buf->hash_array[hk] == NULL) { buf->hash_array[hk] = malloc(sizeof(struct collision_list_cell)); @@ -97,7 +97,7 @@ int insert_segment(struct segment_buffer *buf, uint32_t gid, uint32_t mid, uint3 struct collision_list_cell *head = buf->hash_array[hk]; struct collision_list_cell *cur = head; - while (cur->next != NULL && (cur->next->gid != gid || cur->next->mid != mid)) + while (cur->next != NULL && (cur->next->odid != odid || cur->next->mid != mid)) { cur = cur->next; } @@ -106,9 +106,9 @@ int insert_segment(struct segment_buffer *buf, uint32_t gid, uint32_t mid, uint3 cur->next = malloc(sizeof(struct collision_list_cell)); if (cur->next == NULL) return -3; - cur->next->gid = gid; + cur->next->odid = odid; cur->next->mid = mid; - cur->next->head = create_message_segment_list(gid, mid); + cur->next->head = create_message_segment_list(odid, mid); if (cur->next->head == NULL) return -3; buf->count++; @@ -200,9 +200,9 @@ int insert_into_msl(struct message_segment_list_cell *head, uint32_t seqnum, int } } -struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, uint32_t gid, uint32_t mid) +struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, uint32_t odid, uint32_t mid) { - uint32_t hk = hashKey(gid, mid); + uint32_t hk = hashKey(odid, mid); // If there is no message at the request hashvalue, we don't have that segment list if (buf->hash_array[hk] == NULL) { @@ -210,11 +210,11 @@ struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, u } struct collision_list_cell *cur = buf->hash_array[hk]; - while (cur->next != NULL && (cur->next->gid != gid || cur->next->mid != mid)) + while (cur->next != NULL && (cur->next->odid != odid || cur->next->mid != mid)) { cur = cur->next; } - /*If we walked the collision list and could not find a cell with correct gid and mid, we don't have + /*If we walked the collision list and could not find a cell with correct odid and mid, we don't have that semgent list */ if (cur->next == NULL) { @@ -222,7 +222,7 @@ struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, u } else { - /*if we stopped before cur->next is NULL, the next cell has the requested gid and mid value */ + /*if we stopped before cur->next is NULL, the next cell has the requested odid and mid value */ return cur->next->head; } } @@ -354,23 +354,23 @@ void print_collision_list_int(struct collision_list_cell *cell) } } -int clear_segment_list(struct segment_buffer *buf, uint32_t gid, uint32_t mid) +int clear_segment_list(struct segment_buffer *buf, uint32_t odid, uint32_t mid) { - uint32_t hk = hashKey(gid, mid); + uint32_t hk = hashKey(odid, mid); if (buf->hash_array[hk] == NULL) { return -1; } struct collision_list_cell *cur = buf->hash_array[hk]; struct collision_list_cell *next = cur->next; - while (next != NULL && ((next->gid != gid) || next->mid != mid)) + while (next != NULL && ((next->odid != odid) || next->mid != mid)) { next = next->next; cur = cur->next; } if (next == NULL) return -1; - //if next is not NULL, that means we stopped before the end so gid and mid of cur->next are the ones to delete. So we bypass cur->next from cur-> and free the content of cur->next + //if next is not NULL, that means we stopped before the end so odid and mid of cur->next are the ones to delete. So we bypass cur->next from cur-> and free the content of cur->next cur->next = next->next; clear_msl(next->head); free(next); @@ -407,13 +407,13 @@ void cleanup_seg_buff(struct segment_buffer *buf, int cleanup_pass_size) { if (next->head->to_clean_up == 0) { - // printf("Message is old (%d|%d)\n", next->gid, next->mid); + // printf("Message is old (%d|%d)\n", next->odid, next->mid); next->head->to_clean_up = 1; next = next->next; } else { - // printf("Message is to be cleaned (%d|%d)\n", next->gid, next->mid); + // printf("Message is to be cleaned (%d|%d)\n", next->odid, next->mid); struct collision_list_cell *t = next->next; if (next->head->timestamp == 0) { @@ -421,8 +421,8 @@ void cleanup_seg_buff(struct segment_buffer *buf, int cleanup_pass_size) } if ((now - next->head->timestamp) > EXPIRE_MSG) { - // printf("Actually clearing message (%d|%d) %ld\n", next->gid, next->mid, next->head->timestamp); - clear_segment_list(buf, next->gid, next->mid); + // printf("Actually clearing message (%d|%d) %ld\n", next->odid, next->mid, next->head->timestamp); + clear_segment_list(buf, next->odid, next->mid); next = t; buf->count--; } diff --git a/src/segmentation_buffer.h b/src/segmentation_buffer.h index 405a9c6..7d5e4aa 100644 --- a/src/segmentation_buffer.h +++ b/src/segmentation_buffer.h @@ -10,7 +10,7 @@ #include "unyte_udp_defaults.h" /** - * total_size, current_size, gid, mid, only relevant for header cell + * total_size, current_size, odid, mid, only relevant for header cell * seqnum, content only relevant for non header cell */ struct message_segment_list_cell @@ -32,11 +32,11 @@ struct message_segment_list_cell }; /** - * gid, id, seglist only relevant for non header cell + * odid, id, seglist only relevant for non header cell */ struct collision_list_cell { - uint32_t gid; + uint32_t odid; uint32_t mid; struct message_segment_list_cell *head; struct collision_list_cell *next; @@ -87,24 +87,24 @@ char *reassemble_payload(struct message_segment_list_cell *); * returns -2 if a content was already present and message is complete * returns -3 if a memory allocation failed */ -int insert_segment(struct segment_buffer *buf, uint32_t gid, uint32_t mid, uint32_t seqnum, int last, uint32_t payload_size, void *content, unyte_option_t *options); +int insert_segment(struct segment_buffer *buf, uint32_t odid, uint32_t mid, uint32_t seqnum, int last, uint32_t payload_size, void *content, unyte_option_t *options); // Segment buffer management /** * Retrieve the header cell of a segment list for a given message */ -struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, uint32_t gid, uint32_t mid); +struct message_segment_list_cell *get_segment_list(struct segment_buffer *buf, uint32_t odid, uint32_t mid); /** * Clear a list of segments */ -int clear_segment_list(struct segment_buffer *buf, uint32_t gid, uint32_t mid); +int clear_segment_list(struct segment_buffer *buf, uint32_t odid, uint32_t mid); /** * Hash function used on segmentation buffer hashmap - * uint32_t gid: generator id / observation domain id + * uint32_t odid: observation domain id * uint32_t mid: message id */ -uint32_t hashKey(uint32_t gid, uint32_t mid); +uint32_t hashKey(uint32_t odid, uint32_t mid); // Print functions void print_segment_list_header(struct message_segment_list_cell *head); @@ -124,7 +124,7 @@ void clear_msl(struct message_segment_list_cell *head); /** * Initialise a message segment list */ -struct message_segment_list_cell *create_message_segment_list(uint32_t gid, uint32_t mid); +struct message_segment_list_cell *create_message_segment_list(uint32_t odid, uint32_t mid); /** * Clean segmentation buffer messages. diff --git a/src/unyte_udp_defaults.h b/src/unyte_udp_defaults.h index 53b8baa..f908572 100644 --- a/src/unyte_udp_defaults.h +++ b/src/unyte_udp_defaults.h @@ -16,7 +16,7 @@ // monitoring_worker #define ODID_COUNTERS 10 // hashmap modulo -#define ACTIVE_GIDS 500 // how many active gids do we are waiting for +#define ACTIVE_GIDS 500 // how many active odids do we are waiting for #define ODID_TIME_TO_LIVE 4 // times monitoring thread consider observation_domain_id active without stats // Segmentation_buffer parameters | not settable by the user diff --git a/test/test_segmentation.c b/test/test_segmentation.c index 16484e3..3a4fdf1 100644 --- a/test/test_segmentation.c +++ b/test/test_segmentation.c @@ -8,16 +8,16 @@ void test_segment_lists() { //Create list - uint32_t gid = 1; + uint32_t odid = 1; uint32_t mid = 2; - struct message_segment_list_cell *seglist = create_message_segment_list(gid, mid); + struct message_segment_list_cell *seglist = create_message_segment_list(odid, mid); printf("Seglist @ %p\n", seglist); printf("Clearing\n"); clear_msl(seglist); printf("Done %p\n", seglist); - seglist = create_message_segment_list(gid, mid); + seglist = create_message_segment_list(odid, mid); //Add a new cell that is last in an empty list, seqnum 0 int cont = 1; @@ -32,10 +32,10 @@ void test_segment_lists() clear_msl(seglist); printf("Done %p\n", seglist); - gid = 3; + odid = 3; mid = 4; - struct message_segment_list_cell *seglist2 = create_message_segment_list(gid, mid); + struct message_segment_list_cell *seglist2 = create_message_segment_list(odid, mid); printf("Seglist @ %p\n", seglist2); //Add a new cell that is not last in an empty list, seqnum 0 @@ -80,7 +80,7 @@ void test_segment_lists() printf("\n"); - struct message_segment_list_cell *seglist3 = create_message_segment_list(gid, mid); + struct message_segment_list_cell *seglist3 = create_message_segment_list(odid, mid); printf("Seglist @ %p\n", seglist3); int cont10 = 0; @@ -117,7 +117,7 @@ void test_segment_buffers() } print_segment_buffer_int(buf); - /*int insert_segment(struct segment_buffer* buf, uint32_t gid, uint32_t mid, uint32_t seqnum, int last, void* content);*/ + /*int insert_segment(struct segment_buffer* buf, uint32_t odid, uint32_t mid, uint32_t seqnum, int last, void* content);*/ clear_segment_list(buf, 1, 2); printf("Cleared list from 1,2\n"); From d4a2bbdab32efdd897942eeedc26bc5c1c52e2cf Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:50:45 +0200 Subject: [PATCH 07/12] feat: migrate generator_id to observation id in structs (5) --- examples/sender_json.c | 4 ++-- src/listening_worker.c | 2 +- src/monitoring_worker.c | 8 ++++---- src/unyte_udp_defaults.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/sender_json.c b/examples/sender_json.c index 972fd8c..4feb1f9 100644 --- a/examples/sender_json.c +++ b/examples/sender_json.c @@ -57,8 +57,8 @@ int main(int argc, char *argv[]) struct unyte_sender_socket *sender_sk = unyte_start_sender(&options); - struct buffer_to_send *bf_send = read_json_file(200); // resources/json-200.json - // struct buffer_to_send *bf_send = read_json_file(8950); // resources/json-8950.json + // struct buffer_to_send *bf_send = read_json_file(200); // resources/json-200.json + struct buffer_to_send *bf_send = read_json_file(8950); // resources/json-8950.json unyte_message_t *message = (unyte_message_t *)malloc(sizeof(unyte_message_t)); message->buffer = bf_send->buffer; diff --git a/src/listening_worker.c b/src/listening_worker.c index 855a877..1224bd9 100644 --- a/src/listening_worker.c +++ b/src/listening_worker.c @@ -131,7 +131,7 @@ int create_parse_worker(struct parse_worker *parser, struct listener_thread_inpu parser_input->counters->type = PARSER_WORKER; parser_input->legacy_proto = in->legacy_proto; - for (uint i = 0; i < ACTIVE_GIDS; i++) + for (uint i = 0; i < ACTIVE_ODIDS; i++) { (parser_input->counters->active_odids + i)->active = 0; } diff --git a/src/monitoring_worker.c b/src/monitoring_worker.c index f8bbc68..a318d87 100644 --- a/src/monitoring_worker.c +++ b/src/monitoring_worker.c @@ -41,11 +41,11 @@ void reinit_odid_counters(unyte_odid_counter_t *odid_counter) */ int init_active_odid_index(unyte_seg_counters_t *counters) { - counters->active_odids = (active_odid_t *)malloc(sizeof(active_odid_t) * ACTIVE_GIDS); + counters->active_odids = (active_odid_t *)malloc(sizeof(active_odid_t) * ACTIVE_ODIDS); if (counters->active_odids == NULL) return -1; counters->active_odids_length = 0; - counters->active_odids_max_length = ACTIVE_GIDS; + counters->active_odids_max_length = ACTIVE_ODIDS; return 0; } @@ -54,11 +54,11 @@ int init_active_odid_index(unyte_seg_counters_t *counters) */ int resize_active_odid_index(unyte_seg_counters_t *counters) { - active_odid_t *new_active_odid = (active_odid_t *)realloc(counters->active_odids, sizeof(active_odid_t) * (counters->active_odids_max_length + ACTIVE_GIDS)); + active_odid_t *new_active_odid = (active_odid_t *)realloc(counters->active_odids, sizeof(active_odid_t) * (counters->active_odids_max_length + ACTIVE_ODIDS)); if (new_active_odid == NULL) return -1; counters->active_odids = new_active_odid; - counters->active_odids_max_length = counters->active_odids_max_length + ACTIVE_GIDS; + counters->active_odids_max_length = counters->active_odids_max_length + ACTIVE_ODIDS; return 0; } diff --git a/src/unyte_udp_defaults.h b/src/unyte_udp_defaults.h index f908572..0bc555a 100644 --- a/src/unyte_udp_defaults.h +++ b/src/unyte_udp_defaults.h @@ -16,7 +16,7 @@ // monitoring_worker #define ODID_COUNTERS 10 // hashmap modulo -#define ACTIVE_GIDS 500 // how many active odids do we are waiting for +#define ACTIVE_ODIDS 500 // how many active odids do we are waiting for #define ODID_TIME_TO_LIVE 4 // times monitoring thread consider observation_domain_id active without stats // Segmentation_buffer parameters | not settable by the user From c2ab2c65954b0f293f8a3eb397ef9a94b17074c2 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 14:58:38 +0200 Subject: [PATCH 08/12] feat: change encoding type to mediatype --- README.md | 12 ++++++------ examples/sender_cbor.c | 2 +- examples/sender_custom_encoding.c | 4 ++-- examples/sender_json.c | 2 +- examples/sender_json_bind_interface.c | 2 +- examples/sender_sample.c | 2 +- src/unyte_udp_constants.h | 12 ++++++------ src/unyte_udp_utils.c | 18 +++++++++--------- src/unyte_udp_utils.h | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 116a49f..c3093d6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # C-Collector for UDP-notif -Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-04](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04). +Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-06](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-06). ## Compiling and installing project See [INSTALL](INSTALL.md) @@ -100,8 +100,8 @@ typedef struct unyte_segment_with_metadata } unyte_seg_met_t; ``` ##### Getters for segments data -- `uint8_t unyte_udp_get_version(unyte_seg_met_t *message);` : encoding version -- `uint8_t unyte_udp_get_space(unyte_seg_met_t *message);` : space of encoding version +- `uint8_t unyte_udp_get_version(unyte_seg_met_t *message);` : header encoding version +- `uint8_t unyte_udp_get_space(unyte_seg_met_t *message);` : space of media type version - `uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message);` : dentifier to indicate the media type used for the Notification Message - `uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message);` : length of the message header in octets - `uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message);` : total length of the message within one UDP datagram, measured in octets, including the message header @@ -155,7 +155,7 @@ Limitations of udp-pub-channel-05: - Same output `struct unyte_seg_met_t` is given to the user. - Flags from the protocol are not parsed. - No options are possible and thus no segmentation is supported -- The encoding type identifiers are taken from the IANA instead of the draft to maintain consistency in the different pipelines. IANA codes could be checked in the main [draft](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04#section-9). +- The media type identifiers are taken from the IANA instead of the draft to maintain consistency in the different pipelines. IANA codes could be checked in the main [draft](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04#section-9). - Google protobuf is returned as RESERVED(0) encoding type. ### Usage of the sender @@ -173,7 +173,7 @@ typedef struct unyte_message // UDP-notif uint8_t version : 3; // UDP-notif protocol version uint8_t space : 1; // UDP-notif protocol space - uint8_t encoding_type : 4; // UDP-notif protocol encoding type + uint8_t media_type : 4; // UDP-notif protocol media type uint32_t observation_domain_id; // UDP-notif protocol observation domain id uint32_t message_id; // UDP-notif protocol message id } unyte_message_t; @@ -212,7 +212,7 @@ int main() // UDP-notif message->version = 0; message->space = 0; - message->encoding_type = UNYTE_ENCODING_JSON; // json but sending string + message->media_type = UNYTE_MEDIATYPE_JSON; // json but sending string message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 200; // If set to 0, the default mtu set on options is used, else, this one is used diff --git a/examples/sender_cbor.c b/examples/sender_cbor.c index fcaead6..21744c4 100644 --- a/examples/sender_cbor.c +++ b/examples/sender_cbor.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->encoding_type = UNYTE_ENCODING_CBOR; // sending CBOR + message->media_type = UNYTE_MEDIATYPE_CBOR; // sending CBOR message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_custom_encoding.c b/examples/sender_custom_encoding.c index 68db6f7..ad0d14b 100644 --- a/examples/sender_custom_encoding.c +++ b/examples/sender_custom_encoding.c @@ -65,8 +65,8 @@ int main(int argc, char *argv[]) message->buffer_len = bf_send->buffer_len; // UDP-notif message->version = 0; - message->space = UNYTE_SPACE_NON_STANDARD; // Custom space - message->encoding_type = 4; // Custom encoding type + message->space = UNYTE_SPACE_NON_STANDARD; // Custom space + message->media_type = 4; // Custom encoding type message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_json.c b/examples/sender_json.c index 4feb1f9..8491bbe 100644 --- a/examples/sender_json.c +++ b/examples/sender_json.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->encoding_type = UNYTE_ENCODING_JSON; + message->media_type = UNYTE_MEDIATYPE_JSON; message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_json_bind_interface.c b/examples/sender_json_bind_interface.c index 1a2f277..c74bf57 100644 --- a/examples/sender_json_bind_interface.c +++ b/examples/sender_json_bind_interface.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->encoding_type = UNYTE_ENCODING_JSON; + message->media_type = UNYTE_MEDIATYPE_JSON; message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_sample.c b/examples/sender_sample.c index 7163f25..1321631 100644 --- a/examples/sender_sample.c +++ b/examples/sender_sample.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = 0; - message->encoding_type = 1; // json but sending string + message->media_type = 1; // json but sending string message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 200; // use other than default configured diff --git a/src/unyte_udp_constants.h b/src/unyte_udp_constants.h index ee8d48f..e2ed0bf 100644 --- a/src/unyte_udp_constants.h +++ b/src/unyte_udp_constants.h @@ -5,11 +5,11 @@ #define UNYTE_SPACE_STANDARD 0 #define UNYTE_SPACE_NON_STANDARD 1 -// Supported encoding TODO: to be defined in IANA -#define UNYTE_ENCODING_RESERVED 0 -#define UNYTE_ENCODING_JSON 1 -#define UNYTE_ENCODING_XML 2 -#define UNYTE_ENCODING_CBOR 3 +// Supported media type TODO: to be defined in IANA +#define UNYTE_MEDIATYPE_RESERVED 0 +#define UNYTE_MEDIATYPE_JSON 1 +#define UNYTE_MEDIATYPE_XML 2 +#define UNYTE_MEDIATYPE_CBOR 3 // Supported encoding in legacy draft: draft-ietf-netconf-udp-pub-channel-05 #define UNYTE_LEGACY_ENCODING_GPB 0 @@ -22,7 +22,7 @@ #define UNYTE_TYPE_SEGMENTATION 1 #define UNYTE_TYPE_PRIVATE_ENCODING 2 -static const int LEGACY_ET_TO_IANA[] = {UNYTE_ENCODING_RESERVED, UNYTE_ENCODING_CBOR, UNYTE_ENCODING_JSON, UNYTE_ENCODING_XML}; +static const int LEGACY_ET_TO_IANA[] = {UNYTE_MEDIATYPE_RESERVED, UNYTE_MEDIATYPE_CBOR, UNYTE_MEDIATYPE_JSON, UNYTE_MEDIATYPE_XML}; static const int SUPPORTED_ET_LEN = sizeof(LEGACY_ET_TO_IANA) / sizeof(int); #endif diff --git a/src/unyte_udp_utils.c b/src/unyte_udp_utils.c index d93587e..e3f026b 100644 --- a/src/unyte_udp_utils.c +++ b/src/unyte_udp_utils.c @@ -84,7 +84,7 @@ unyte_seg_met_t *parse_with_metadata(char *segment, unyte_min_t *um) header->version = segment[0] >> 5; header->space = (segment[0] & SPACE_MASK); - header->encoding_type = (segment[0] & ET_MASK); + header->media_type = (segment[0] & ET_MASK); header->header_length = segment[1]; header->message_length = ntohs(deserialize_uint16((char *)segment, 2)); header->observation_domain_id = ntohl(deserialize_uint32((char *)segment, 4)); @@ -167,7 +167,7 @@ int get_encoding_IANA_ET_from_legacy(uint8_t legacy_ET) { // TODO: error ? if (legacy_ET > SUPPORTED_ET_LEN) - return UNYTE_ENCODING_RESERVED; + return UNYTE_MEDIATYPE_RESERVED; return LEGACY_ET_TO_IANA[legacy_ET]; } @@ -185,7 +185,7 @@ unyte_seg_met_t *parse_with_metadata_legacy(char *segment, unyte_min_t *um) header->version = segment[0] >> 4; header->space = 0; // arbitrary - header->encoding_type = get_encoding_IANA_ET_from_legacy((segment[1] & ET_MASK)); + header->media_type = get_encoding_IANA_ET_from_legacy((segment[1] & ET_MASK)); header->header_length = HEADER_BYTES; header->message_length = ntohs(deserialize_uint16((char *)segment, 2)); header->observation_domain_id = ntohl(deserialize_uint32((char *)segment, 4)); @@ -230,7 +230,7 @@ unyte_seg_met_t *parse_with_metadata_legacy(char *segment, unyte_min_t *um) */ unyte_seg_met_t *copy_unyte_seg_met_headers(unyte_seg_met_t *dest, unyte_seg_met_t *src) { - dest->header->encoding_type = src->header->encoding_type; + dest->header->media_type = src->header->media_type; dest->header->observation_domain_id = src->header->observation_domain_id; dest->header->header_length = src->header->header_length; dest->header->message_id = src->header->message_id; @@ -260,7 +260,7 @@ void print_udp_notif_header(unyte_header_t *header, FILE *std) fprintf(std, "\n###### Unyte header ######\n"); fprintf(std, "Version: %u\n", header->version); fprintf(std, "Space: %u\n", header->space); - fprintf(std, "Encoding: %u\n", header->encoding_type); + fprintf(std, "Media type: %u\n", header->media_type); fprintf(std, "Header length: %u\n", header->header_length); fprintf(std, "Message length: %u\n", header->message_length); fprintf(std, "Observation domain ID: %u\n", header->observation_domain_id); @@ -403,7 +403,7 @@ struct unyte_segmented_msg *build_message(unyte_message_t *message, uint mtu) current_seg->header->message_id = message->message_id; current_seg->header->space = message->space; current_seg->header->version = message->version; - current_seg->header->encoding_type = message->encoding_type; + current_seg->header->media_type = message->media_type; current_seg->header->header_length = HEADER_BYTES + options_header_bytes; current_seg->header->message_length = message->buffer_len; current_seg->header->options = options_header; @@ -437,7 +437,7 @@ struct unyte_segmented_msg *build_message(unyte_message_t *message, uint mtu) current_seg->header->message_id = message->message_id; current_seg->header->space = message->space; current_seg->header->version = message->version; - current_seg->header->encoding_type = message->encoding_type; + current_seg->header->media_type = message->media_type; current_seg->header->message_length = bytes_to_send; current_seg->header->header_length = HEADER_BYTES + UNYTE_SEGMENTATION_OPTION_LEN; @@ -478,7 +478,7 @@ unsigned char *serialize_message(unyte_seg_met_t *msg) packet_size += UNYTE_SEGMENTATION_OPTION_LEN; } unsigned char *parsed_bytes = (unsigned char *)malloc(packet_size); - parsed_bytes[0] = (((msg->header->version << 5) + (msg->header->space << 4) + (msg->header->encoding_type))); + parsed_bytes[0] = (((msg->header->version << 5) + (msg->header->space << 4) + (msg->header->media_type))); parsed_bytes[1] = msg->header->header_length; // message length parsed_bytes[2] = ((packet_size) >> 8); @@ -696,7 +696,7 @@ int unyte_udp_create_interface_bound_socket(char *interface, char *address, char uint8_t unyte_udp_get_version(unyte_seg_met_t *message) { return message->header->version; } uint8_t unyte_udp_get_space(unyte_seg_met_t *message) { return message->header->space; } -uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message) { return message->header->encoding_type; } +uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message) { return message->header->media_type; } uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message) { return message->header->header_length; } uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message) { return message->header->message_length; } uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message) { return message->header->observation_domain_id; } diff --git a/src/unyte_udp_utils.h b/src/unyte_udp_utils.h index 1cd3bfc..e7bdc2e 100644 --- a/src/unyte_udp_utils.h +++ b/src/unyte_udp_utils.h @@ -24,7 +24,7 @@ typedef struct unyte_header { uint8_t version : 3; uint8_t space : 1; - uint8_t encoding_type : 4; + uint8_t media_type : 4; uint8_t header_length : 8; uint16_t message_length; uint32_t observation_domain_id; @@ -98,7 +98,7 @@ typedef struct unyte_message // UDP-notif uint8_t version : 3; uint8_t space : 1; - uint8_t encoding_type : 4; + uint8_t media_type : 4; uint32_t observation_domain_id; uint32_t message_id; From f4ed6e60ca3a1746ece5a4937cc01b4d66bbe9af Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 15:00:57 +0200 Subject: [PATCH 09/12] feat: add Alex mail into LICENCE --- LICENSE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index e297fde..193f30e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,9 @@ Copyright (c) 2020 Unyte Project members -Authors Tom Sampic, Axel Rosensthiel, Alex Huang, Pierre Francois, Stéphane Frénot +Authors Tom Sampic, Axel Rosensthiel, Alex Huang Feng, Pierre Francois, Stéphane Frénot WIRED Team Telecommunications Department INSA Lyon -contact: +contact: ; Permission to use, copy, modify, and distribute this software for any @@ -20,4 +20,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. This code is an implementation of a collector for UDP-Notif messages as defined in -draft-ietf-netconf-udp-notif-01 +draft-ietf-netconf-udp-notif-06 From c91b6e2fa04643ae8b572f46c1f95da7e481483b Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 15:50:55 +0200 Subject: [PATCH 10/12] feat: removed deprecated pkg file --- unyte-pkg.pc | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 unyte-pkg.pc diff --git a/unyte-pkg.pc b/unyte-pkg.pc deleted file mode 100644 index fda5e89..0000000 --- a/unyte-pkg.pc +++ /dev/null @@ -1,10 +0,0 @@ -prefix=<> -exec_prefix=${prefix} -includedir=${prefix}/<> -libdir=${exec_prefix}/<> - -Name: unyte-udp-notif -Description: Unyte UDP-notif protocol library -Version: 0.4.0 -Cflags: -I${includedir}/unyte-udp-notif -Libs: -L${libdir} -lunyte-udp-notif From 1fb5124746ba9c5bcb2b7024cfa8aa099e50ec42 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 16:48:09 +0200 Subject: [PATCH 11/12] feat: add YANG to encoding constants --- README.md | 2 +- examples/sender_cbor.c | 2 +- examples/sender_json.c | 2 +- examples/sender_json_bind_interface.c | 2 +- src/unyte_udp_constants.h | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c3093d6..402e183 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ int main() // UDP-notif message->version = 0; message->space = 0; - message->media_type = UNYTE_MEDIATYPE_JSON; // json but sending string + message->media_type = UNYTE_MEDIATYPE_YANG_JSON; // json but sending string message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 200; // If set to 0, the default mtu set on options is used, else, this one is used diff --git a/examples/sender_cbor.c b/examples/sender_cbor.c index 21744c4..7a8b4d5 100644 --- a/examples/sender_cbor.c +++ b/examples/sender_cbor.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->media_type = UNYTE_MEDIATYPE_CBOR; // sending CBOR + message->media_type = UNYTE_MEDIATYPE_YANG_CBOR; // sending CBOR message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_json.c b/examples/sender_json.c index 8491bbe..ead5eb5 100644 --- a/examples/sender_json.c +++ b/examples/sender_json.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->media_type = UNYTE_MEDIATYPE_JSON; + message->media_type = UNYTE_MEDIATYPE_YANG_JSON; message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/examples/sender_json_bind_interface.c b/examples/sender_json_bind_interface.c index c74bf57..2b811f7 100644 --- a/examples/sender_json_bind_interface.c +++ b/examples/sender_json_bind_interface.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) // UDP-notif message->version = 0; message->space = UNYTE_SPACE_STANDARD; - message->media_type = UNYTE_MEDIATYPE_JSON; + message->media_type = UNYTE_MEDIATYPE_YANG_JSON; message->observation_domain_id = 1000; message->message_id = 2147483669; message->used_mtu = 0; // use default configured diff --git a/src/unyte_udp_constants.h b/src/unyte_udp_constants.h index e2ed0bf..cbccdf2 100644 --- a/src/unyte_udp_constants.h +++ b/src/unyte_udp_constants.h @@ -7,9 +7,9 @@ // Supported media type TODO: to be defined in IANA #define UNYTE_MEDIATYPE_RESERVED 0 -#define UNYTE_MEDIATYPE_JSON 1 -#define UNYTE_MEDIATYPE_XML 2 -#define UNYTE_MEDIATYPE_CBOR 3 +#define UNYTE_MEDIATYPE_YANG_JSON 1 +#define UNYTE_MEDIATYPE_YANG_XML 2 +#define UNYTE_MEDIATYPE_YANG_CBOR 3 // Supported encoding in legacy draft: draft-ietf-netconf-udp-pub-channel-05 #define UNYTE_LEGACY_ENCODING_GPB 0 @@ -22,7 +22,7 @@ #define UNYTE_TYPE_SEGMENTATION 1 #define UNYTE_TYPE_PRIVATE_ENCODING 2 -static const int LEGACY_ET_TO_IANA[] = {UNYTE_MEDIATYPE_RESERVED, UNYTE_MEDIATYPE_CBOR, UNYTE_MEDIATYPE_JSON, UNYTE_MEDIATYPE_XML}; +static const int LEGACY_ET_TO_IANA[] = {UNYTE_MEDIATYPE_RESERVED, UNYTE_MEDIATYPE_YANG_CBOR, UNYTE_MEDIATYPE_YANG_JSON, UNYTE_MEDIATYPE_YANG_XML}; static const int SUPPORTED_ET_LEN = sizeof(LEGACY_ET_TO_IANA) / sizeof(int); #endif From 2c798a22007f5c9369a674e95ebf13a0583e30b6 Mon Sep 17 00:00:00 2001 From: Alex Huang Feng Date: Wed, 25 May 2022 16:53:07 +0200 Subject: [PATCH 12/12] feat: bump version to 0.6.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8e6bd7b..079ed8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.2-git \ No newline at end of file +0.6.0-git \ No newline at end of file