nmsg  0.11.2
input.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015 by Farsight Security, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NMSG_INPUT_H
18 #define NMSG_INPUT_H
19 
54 typedef enum {
55  nmsg_input_type_stream, /*%< NMSG payloads from file or socket */
56  nmsg_input_type_pcap, /*%< pcap packets from file or interface */
57  nmsg_input_type_pres, /*%< presentation form */
58  nmsg_input_type_callback,
59  nmsg_input_type_json, /*%< JSON form */
61 
69 nmsg_input_t
70 nmsg_input_open_file(int fd);
71 
79 nmsg_input_t
80 nmsg_input_open_sock(int fd);
81 
89 nmsg_input_t
90 nmsg_input_open_xs(void *s);
91 
119 nmsg_input_t
120 nmsg_input_open_xs_endpoint(void *xs_ctx, const char *ep);
121 
134 nmsg_input_t
136 
149 nmsg_input_t
151 
162 nmsg_input_t
163 nmsg_input_open_pres(int fd, nmsg_msgmod_t msgmod);
164 
172 nmsg_input_t
173 nmsg_input_open_json(int fd);
174 
186 nmsg_input_t
187 nmsg_input_open_pcap(nmsg_pcap_t pcap, nmsg_msgmod_t msgmod);
188 
196 nmsg_res
197 nmsg_input_close(nmsg_input_t *input);
198 
215 nmsg_res
216 nmsg_input_loop(nmsg_input_t input, int count, nmsg_cb_message cb, void *user);
217 
223 void
224 nmsg_input_breakloop(nmsg_input_t input);
225 
240 nmsg_res
241 nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg);
242 
269 nmsg_res
270 nmsg_input_read_null(nmsg_input_t input, uint8_t *buf, size_t buf_len,
271  struct timespec *ts, nmsg_message_t **msg, size_t *n_msg);
272 
287 void
288 nmsg_input_set_filter_msgtype(nmsg_input_t input,
289  unsigned vid, unsigned msgtype);
290 
300 nmsg_res
301 nmsg_input_set_filter_msgtype_byname(nmsg_input_t input,
302  const char *vname, const char *mname);
303 
313 void
314 nmsg_input_set_filter_source(nmsg_input_t input, unsigned source);
315 
325 void
326 nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_);
327 
337 void
338 nmsg_input_set_filter_group(nmsg_input_t input, unsigned group);
339 
351 nmsg_res
352 nmsg_input_set_blocking_io(nmsg_input_t input, bool flag);
353 
369 nmsg_res
370 nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate);
371 
383 nmsg_res
384 nmsg_input_set_verify_seqsrc(nmsg_input_t input, bool verify);
385 
399 nmsg_res
400 nmsg_input_get_count_container_received(nmsg_input_t input, uint64_t *count);
401 
416 nmsg_res
417 nmsg_input_get_count_container_dropped(nmsg_input_t input, uint64_t *count);
418 
419 #endif /* NMSG_INPUT_H */
nmsg_input_type
An enum identifying the underlying implementation of an nmsg_input_t object.
Definition: input.h:54
nmsg_input_t nmsg_input_open_xs_endpoint(void *xs_ctx, const char *ep)
Create an XS socket and initialize a new NMSG stream input from it.
presentation form
Definition: input.h:57
void nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_)
Set an operator filter for input NMSG payloads.
nmsg_res
nmsg result code
Definition: res.h:25
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.
nmsg_input_t nmsg_input_open_json(int fd)
Initialize a new NMSG JSON form input from a file descriptor.
nmsg_res nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate)
Set the target ingress byte rate for a stream input.
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.
nmsg_res nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg)
Read one NMSG message from an input stream.
nmsg_res nmsg_input_set_blocking_io(nmsg_input_t input, bool flag)
Configure non-blocking I/O for a stream input.
JSON form.
Definition: input.h:59
nmsg_input_t nmsg_input_open_null(void)
Initialize a new "null source" NMSG stream input.
nmsg_res(* nmsg_cb_message_read)(nmsg_message_t *msg, void *user)
Callback function for generating nmsg messages.
Definition: nmsg.h:94
void nmsg_input_set_filter_group(nmsg_input_t input, unsigned group)
Set a group filter for input NMSG payloads.
pcap packets from file or interface
Definition: input.h:56
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_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_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_input_t nmsg_input_open_xs(void *s)
Initialize a new NMSG stream input from an XS socket source.
nmsg_input_t nmsg_input_open_callback(nmsg_cb_message_read cb, void *user)
Initialize a new nmsg input closure.
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 ...
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.
nmsg_input_t nmsg_input_open_sock(int fd)
Initialize a new NMSG stream input from a datagram socket source.
void(* nmsg_cb_message)(nmsg_message_t msg, void *user)
Callback function for processing nmsg messages.
Definition: nmsg.h:78
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_close(nmsg_input_t *input)
Close an nmsg_input_t object and release all associated resources.
void nmsg_input_breakloop(nmsg_input_t input)
Break out of an nmsg_input_loop() early.
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.
void nmsg_input_set_filter_source(nmsg_input_t input, unsigned source)
Set a source filter for input NMSG payloads.
nmsg_input_t nmsg_input_open_file(int fd)
Initialize a new NMSG stream input from a byte-stream file source.
NMSG payloads from file or socket.
Definition: input.h:55