From 44abf20e982a95a371bf2f20d5d69fd8a99e9e60 Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Mon, 22 Mar 2021 19:25:51 +0100 Subject: [PATCH] Add multicast-traffic-tos support --- docs/config.md | 1 + src/bbl.c | 2 ++ src/bbl.h | 1 + src/bbl_config.c | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/docs/config.md b/docs/config.md index 9b494c00..36080bb1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -453,6 +453,7 @@ Attribute | Description | Default `view-duration` | Define the view duration in seconds | 0 (disabled) `send-multicast-traffic` | Generate multicast traffic | false `multicast-traffic-length` | Multicast traffic IP length | 76 +`multicast-traffic-tos` | Multicast traffic TOS priority | 0 Per default join and leave requests are send using dedicated reports. The option `combined-leave-join` allows the combination of leave and join records within a single IGMPv3 report using multiple group records. diff --git a/src/bbl.c b/src/bbl.c index 5dad4ef2..84ce3183 100644 --- a/src/bbl.c +++ b/src/bbl.c @@ -143,6 +143,7 @@ bbl_add_multicast_packets (bbl_ctx_s *ctx, bbl_interface_s *interface) ip.src = source; ip.dst = htobe32(group); ip.ttl = 64; + ip.tos = ctx->config.multicast_traffic_tos; ip.protocol = PROTOCOL_IPV4_UDP; ip.next = &udp; udp.src = BBL_UDP_PORT; @@ -154,6 +155,7 @@ bbl_add_multicast_packets (bbl_ctx_s *ctx, bbl_interface_s *interface) } bbl.type = BBL_TYPE_MULTICAST; bbl.direction = BBL_DIRECTION_DOWN; + bbl.tos = ctx->config.multicast_traffic_tos; bbl.mc_source = ip.src; bbl.mc_group = ip.dst ; if(encode_ethernet(buf, &len, ð) != PROTOCOL_SUCCESS) { diff --git a/src/bbl.h b/src/bbl.h index de289888..8d788eb2 100644 --- a/src/bbl.h +++ b/src/bbl.h @@ -538,6 +538,7 @@ typedef struct bbl_ctx_ /* Multicast Traffic */ bool send_multicast_traffic; + uint8_t multicast_traffic_tos; uint16_t multicast_traffic_len; /* Session Traffic */ diff --git a/src/bbl_config.c b/src/bbl_config.c index 22850b64..ca93c09e 100644 --- a/src/bbl_config.c +++ b/src/bbl_config.c @@ -543,6 +543,10 @@ json_parse_config (json_t *root, bbl_ctx_s *ctx) { fprintf(stderr, "JSON config error: Invalid value for igmp->multicast-traffic-length (max 1500)\n"); } } + value = json_object_get(section, "multicast-traffic-tos"); + if (json_is_number(value)) { + ctx->config.multicast_traffic_tos = json_number_value(value); + } } /* Access Line Configuration */