nmsg 1.3.0
input.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 DomainTools LLC
3 * Copyright (c) 2008-2015, 2017-2019 by Farsight Security, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NMSG_INPUT_H
19#define NMSG_INPUT_H
20
55typedef enum {
56 nmsg_input_type_stream, /*%< NMSG payloads from file or socket */
57 nmsg_input_type_pcap, /*%< pcap packets from file or interface */
58 nmsg_input_type_pres, /*%< presentation form */
59 nmsg_input_type_callback,
60 nmsg_input_type_json, /*%< JSON form */
61 nmsg_input_type_kafka_json, /*%< NMSG payloads from Kafka in JSON form */
63
71nmsg_input_t
73
81nmsg_input_t
83
91nmsg_input_t
93
121nmsg_input_t
122nmsg_input_open_zmq_endpoint(void *zmq_ctx, const char *ep);
123
146nmsg_input_t
148
161nmsg_input_t
163
176nmsg_input_t
178
189nmsg_input_t
190nmsg_input_open_pres(int fd, nmsg_msgmod_t msgmod);
191
201nmsg_input_t
203
214nmsg_input_t
215nmsg_input_open_kafka_json(const char *address);
216
217
229nmsg_input_t
230nmsg_input_open_pcap(nmsg_pcap_t pcap, nmsg_msgmod_t msgmod);
231
240nmsg_input_close(nmsg_input_t *input);
241
259nmsg_input_loop(nmsg_input_t input, int count, nmsg_cb_message cb, void *user);
260
266void
267nmsg_input_breakloop(nmsg_input_t input);
268
284nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg);
285
313nmsg_input_read_null(nmsg_input_t input, uint8_t *buf, size_t buf_len,
314 struct timespec *ts, nmsg_message_t **msg, size_t *n_msg);
315
330void
332 unsigned vid, unsigned msgtype);
333
345 const char *vname, const char *mname);
346
356void
357nmsg_input_set_filter_source(nmsg_input_t input, unsigned source);
358
368void
369nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_);
370
380void
381nmsg_input_set_filter_group(nmsg_input_t input, unsigned group);
382
395nmsg_input_set_blocking_io(nmsg_input_t input, bool flag);
396
413nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate);
414
429nmsg_input_set_verify_seqsrc(nmsg_input_t input, bool verify);
430
445nmsg_input_get_count_container_received(nmsg_input_t input, uint64_t *count);
446
462nmsg_input_get_count_container_dropped(nmsg_input_t input, uint64_t *count);
463
464#endif /* NMSG_INPUT_H */
nmsg_input_t nmsg_input_open_zmq(void *s)
Initialize a new NMSG stream input from a ZMQ socket source.
nmsg_res nmsg_input_get_count_container_received(nmsg_input_t input, uint64_t *count)
For UDP datagram socket nmsg_input_t objects, retrieve the total number of NMSG containers that have ...
nmsg_res nmsg_input_set_filter_msgtype_byname(nmsg_input_t input, const char *vname, const char *mname)
Filter an nmsg_input_t for a given vendor ID / message type.
void nmsg_input_set_filter_group(nmsg_input_t input, unsigned group)
Set a group filter for input NMSG payloads.
nmsg_res nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg)
Read one NMSG message from an input stream.
nmsg_input_t nmsg_input_open_pres(int fd, nmsg_msgmod_t msgmod)
Initialize a new NMSG presentation form input from a file descriptor.
nmsg_res nmsg_input_set_verify_seqsrc(nmsg_input_t input, bool verify)
Enable or disable seqsrc verification on an NMSG stream nmsg_input_t object.
void nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_)
Set an operator filter for input NMSG payloads.
nmsg_input_t nmsg_input_open_kafka_json(const char *address)
Initialize a new NMSG JSON form input from a Kafka broker.
nmsg_res nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate)
Set the target ingress byte rate for a stream input.
void nmsg_input_set_filter_source(nmsg_input_t input, unsigned source)
Set a source filter for input NMSG payloads.
nmsg_input_type
An enum identifying the underlying implementation of an nmsg_input_t object.
Definition: input.h:55
@ nmsg_input_type_kafka_json
NMSG payloads from Kafka in JSON form.
Definition: input.h:61
@ nmsg_input_type_json
JSON form.
Definition: input.h:60
@ nmsg_input_type_pcap
pcap packets from file or interface
Definition: input.h:57
@ nmsg_input_type_stream
NMSG payloads from file or socket.
Definition: input.h:56
@ nmsg_input_type_pres
presentation form
Definition: input.h:58
nmsg_input_t nmsg_input_open_kafka_endpoint(const char *ep)
Create a Kafka consumer and initialize a new NMSG stream input from it.
nmsg_res nmsg_input_set_blocking_io(nmsg_input_t input, bool flag)
Configure non-blocking I/O for a stream input.
nmsg_input_t nmsg_input_open_zmq_endpoint(void *zmq_ctx, const char *ep)
Create an ZMQ socket and initialize a new NMSG stream input from it.
nmsg_input_t nmsg_input_open_pcap(nmsg_pcap_t pcap, nmsg_msgmod_t msgmod)
Initialize a new NMSG pcap input from a pcap descriptor.
nmsg_res nmsg_input_get_count_container_dropped(nmsg_input_t input, uint64_t *count)
For UDP datagram socket nmsg_input_t objects, retrieve the total number of NMSG containers that been ...
nmsg_res nmsg_input_read_null(nmsg_input_t input, uint8_t *buf, size_t buf_len, struct timespec *ts, nmsg_message_t **msg, size_t *n_msg)
Read zero, one, or more NMSG messages from a "null source" input.
nmsg_input_t nmsg_input_open_callback(nmsg_cb_message_read cb, void *user)
Initialize a new nmsg input closure.
nmsg_res nmsg_input_close(nmsg_input_t *input)
Close an nmsg_input_t object and release all associated resources.
void nmsg_input_set_filter_msgtype(nmsg_input_t input, unsigned vid, unsigned msgtype)
Filter an nmsg_input_t for a given vendor ID / message type.
void nmsg_input_breakloop(nmsg_input_t input)
Break out of an nmsg_input_loop() early.
nmsg_res nmsg_input_loop(nmsg_input_t input, int count, nmsg_cb_message cb, void *user)
Loop over an input stream and call a user-provided function for each payload.
nmsg_input_t nmsg_input_open_null(void)
Initialize a new "null source" NMSG stream input.
nmsg_input_t nmsg_input_open_sock(int fd)
Initialize a new NMSG stream input from a datagram socket source.
nmsg_input_t nmsg_input_open_file(int fd)
Initialize a new NMSG stream input from a byte-stream file source.
nmsg_input_t nmsg_input_open_json(int fd)
Initialize a new NMSG JSON form input from a file descriptor.
nmsg_res(* nmsg_cb_message_read)(nmsg_message_t *msg, void *user)
Callback function for generating nmsg messages.
Definition: nmsg.h:96
void(* nmsg_cb_message)(nmsg_message_t msg, void *user)
Callback function for processing nmsg messages.
Definition: nmsg.h:80
nmsg_res
nmsg result code
Definition: res.h:25