From 65c9d4f30b232dfd0273c35109bfed812b27fb13 Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Thu, 14 Apr 2022 09:41:32 +0200 Subject: [PATCH] #71 mac-modifier Add new configuration option to modify third byte of the access session MAC address. --- code/bngblaster/src/bbl_config.c | 8 ++++++++ code/bngblaster/src/bbl_ctx.h | 1 + code/bngblaster/src/bbl_session.c | 2 +- docsrc/sources/configuration/interfaces.rst | 5 ++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/code/bngblaster/src/bbl_config.c b/code/bngblaster/src/bbl_config.c index a675ee5f..895efd81 100644 --- a/code/bngblaster/src/bbl_config.c +++ b/code/bngblaster/src/bbl_config.c @@ -1801,6 +1801,14 @@ json_parse_config(json_t *root, bbl_ctx_s *ctx) { if (json_is_boolean(value)) { ctx->pcap.include_streams = json_boolean_value(value); } + value = json_object_get(section, "mac-modifier"); + if (json_is_number(value)) { + if(json_number_value(value) < 0 || json_number_value(value) > UINT8_MAX) { + fprintf(stderr, "Config error: Invalid value for interfaces->mac-modifier\n"); + return false; + } + ctx->config.mac_modifier = json_number_value(value); + } /* Network Interface Configuration Section */ sub = json_object_get(section, "network"); diff --git a/code/bngblaster/src/bbl_ctx.h b/code/bngblaster/src/bbl_ctx.h index 9654346e..a44a151a 100644 --- a/code/bngblaster/src/bbl_ctx.h +++ b/code/bngblaster/src/bbl_ctx.h @@ -144,6 +144,7 @@ typedef struct bbl_ctx_ /* Config options */ struct { bool interface_lock_force; + uint8_t mac_modifier; uint64_t tx_interval; /* TX interval in nsec */ uint64_t rx_interval; /* RX interval in nsec */ diff --git a/code/bngblaster/src/bbl_session.c b/code/bngblaster/src/bbl_session.c index 2c7a74f0..f6d48b4a 100644 --- a/code/bngblaster/src/bbl_session.c +++ b/code/bngblaster/src/bbl_session.c @@ -560,7 +560,7 @@ bbl_sessions_init(bbl_ctx_s *ctx) /* Set client OUI to locally administered */ session->client_mac[0] = 0x02; session->client_mac[1] = 0x00; - session->client_mac[2] = 0x00; + session->client_mac[2] = ctx->config.mac_modifier; /* Use session identifier for remaining bytes */ session->client_mac[3] = i>>16; session->client_mac[4] = i>>8; diff --git a/docsrc/sources/configuration/interfaces.rst b/docsrc/sources/configuration/interfaces.rst index a097529c..1c61748a 100644 --- a/docsrc/sources/configuration/interfaces.rst +++ b/docsrc/sources/configuration/interfaces.rst @@ -30,4 +30,7 @@ - 32 * - `capture-include-streams` - Include traffic streams in capture - - true \ No newline at end of file + - true + * - `mac-modifier` + - Third byte of access session MAC address (0-255) + - 0 \ No newline at end of file