Skip to content

Commit 646b2aa

Browse files
committed
feat: add legacy option in collector options
1 parent 2e3d0f4 commit 646b2aa

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

src/listening_worker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct listener_thread_input
1919
uint parser_queue_size; /* Size of parser queue in bytes */
2020
uint monitoring_delay; /* Monitoring frequence in seconds */
2121
bool msg_dst_ip; /* IP packet dst IP parsed */
22+
bool legacy_proto; /* Legacy UDP-notif protocol */
2223
};
2324

2425
struct parse_worker

src/parsing_worker.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ int parser(struct parser_thread_input *in)
7575
struct segment_buffer *segment_buff = in->segment_buff;
7676
int max_malloc_errs = 3;
7777
unyte_seg_counters_t *counters = in->counters;
78+
79+
unyte_seg_met_t *(*parse_with_metadata_func)(char *, unyte_min_t *);
80+
if (in->legacy_proto)
81+
parse_with_metadata_func = &parse_with_metadata;
82+
else
83+
parse_with_metadata_func = &parse_with_metadata;
84+
7885
while (1)
7986
{
8087
void *queue_bef = unyte_udp_queue_read(in->input);
@@ -85,7 +92,7 @@ int parser(struct parser_thread_input *in)
8592
continue;
8693
}
8794
unyte_min_t *queue_data = (unyte_min_t *)queue_bef;
88-
unyte_seg_met_t *parsed_segment = parse_with_metadata(queue_data->buffer, queue_data);
95+
unyte_seg_met_t *parsed_segment = (*parse_with_metadata_func)(queue_data->buffer, queue_data);
8996

9097
if (parsed_segment == NULL)
9198
return -1;

src/parsing_worker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct parser_thread_input
1313
struct segment_buffer *segment_buff;
1414
unyte_seg_counters_t *counters;
1515
int monitoring_running;
16+
bool legacy_proto;
1617
};
1718

1819
/**

src/unyte_udp_collector.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ unyte_udp_collector_t *unyte_udp_create_listener(
9191
uint nb_parsers,
9292
uint parsers_q_size,
9393
uint monitoring_delay,
94-
bool msg_dst_ip)
94+
bool msg_dst_ip,
95+
bool legacy)
9596
{
9697
pthread_t *udpListener = (pthread_t *)malloc(sizeof(pthread_t));
9798
struct listener_thread_input *listener_input = (struct listener_thread_input *)malloc(sizeof(struct listener_thread_input));
@@ -111,6 +112,7 @@ unyte_udp_collector_t *unyte_udp_create_listener(
111112
listener_input->parser_queue_size = parsers_q_size;
112113
listener_input->monitoring_delay = monitoring_delay;
113114
listener_input->msg_dst_ip = msg_dst_ip;
115+
listener_input->legacy_proto = legacy;
114116

115117
/*Threaded UDP listener*/
116118
pthread_create(udpListener, NULL, t_listener, (void *)listener_input);
@@ -141,7 +143,7 @@ unyte_udp_collector_t *unyte_udp_start_collector(unyte_udp_options_t *options)
141143
/* Return struct */
142144
unyte_udp_collector_t *collector = unyte_udp_create_listener(
143145
output_queue, monitoring_queue, conn, options->recvmmsg_vlen, options->nb_parsers,
144-
options->parsers_queue_size, options->monitoring_delay, options->msg_dst_ip);
146+
options->parsers_queue_size, options->monitoring_delay, options->msg_dst_ip, options->legacy);
145147

146148
if (collector == NULL)
147149
{

src/unyte_udp_collector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct
3030
// monitoring
3131
uint monitoring_queue_size; // monitoring queue size
3232
uint monitoring_delay; // monitoring queue frequence in seconds
33+
bool legacy; // legacy udp-notif: draft-ietf-netconf-udp-pub-channel-05
3334
} unyte_udp_options_t;
3435

3536
/**

0 commit comments

Comments
 (0)