nmsg  0.9.0
input.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2009 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 
50 #include <nmsg.h>
51 
56 typedef enum {
57  nmsg_input_type_stream, /*%< NMSG payloads from file or socket */
58  nmsg_input_type_pcap, /*%< pcap packets from file or interface */
59  nmsg_input_type_pres, /*%< presentation form */
60  nmsg_input_type_callback
62 
70 nmsg_input_t
71 nmsg_input_open_file(int fd);
72 
80 nmsg_input_t
81 nmsg_input_open_sock(int fd);
82 
90 nmsg_input_t
91 nmsg_input_open_xs(void *s);
92 
120 nmsg_input_t
121 nmsg_input_open_xs_endpoint(void *xs_ctx, const char *ep);
122 
135 nmsg_input_t
137 
150 nmsg_input_t
152 
163 nmsg_input_t
164 nmsg_input_open_pres(int fd, nmsg_msgmod_t msgmod);
165 
177 nmsg_input_t
178 nmsg_input_open_pcap(nmsg_pcap_t pcap, nmsg_msgmod_t msgmod);
179 
187 nmsg_res
188 nmsg_input_close(nmsg_input_t *input);
189 
206 nmsg_res
207 nmsg_input_loop(nmsg_input_t input, int count, nmsg_cb_message cb, void *user);
208 
214 void
215 nmsg_input_breakloop(nmsg_input_t input);
216 
231 nmsg_res
232 nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg);
233 
260 nmsg_res
261 nmsg_input_read_null(nmsg_input_t input, uint8_t *buf, size_t buf_len,
262  struct timespec *ts, nmsg_message_t **msg, size_t *n_msg);
263 
278 void
279 nmsg_input_set_filter_msgtype(nmsg_input_t input,
280  unsigned vid, unsigned msgtype);
281 
291 nmsg_res
292 nmsg_input_set_filter_msgtype_byname(nmsg_input_t input,
293  const char *vname, const char *mname);
294 
304 void
305 nmsg_input_set_filter_source(nmsg_input_t input, unsigned source);
306 
316 void
317 nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_);
318 
328 void
329 nmsg_input_set_filter_group(nmsg_input_t input, unsigned group);
330 
342 nmsg_res
343 nmsg_input_set_blocking_io(nmsg_input_t input, bool flag);
344 
360 nmsg_res
361 nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate);
362 
374 nmsg_res
375 nmsg_input_set_verify_seqsrc(nmsg_input_t input, bool verify);
376 
390 nmsg_res
391 nmsg_input_get_count_container_received(nmsg_input_t input, uint64_t *count);
392 
407 nmsg_res
408 nmsg_input_get_count_container_dropped(nmsg_input_t input, uint64_t *count);
409 
410 #endif /* NMSG_INPUT_H */
nmsg_input_type
An enum identifying the underlying implementation of an nmsg_input_t object.
Definition: input.h:56
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:59
void nmsg_input_set_filter_operator(nmsg_input_t input, unsigned operator_)
Set an operator filter for input NMSG payloads.
Definition: input.c:283
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.
Definition: input.c:335
void(* nmsg_cb_message)(nmsg_message_t msg, void *user)
Callback function for processing nmsg messages.
Definition: nmsg.h:69
Base nmsg support header.
nmsg_res nmsg_input_set_byte_rate(nmsg_input_t input, size_t rate)
Set the target ingress byte rate for a stream input.
Definition: input.c:321
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.
Definition: input.c:256
nmsg_res nmsg_input_read(nmsg_input_t input, nmsg_message_t *msg)
Read one NMSG message from an input stream.
Definition: input.c:211
nmsg_res nmsg_input_set_blocking_io(nmsg_input_t input, bool flag)
Configure non-blocking I/O for a stream input.
Definition: input.c:295
nmsg_input_t nmsg_input_open_null(void)
Initialize a new "null source" NMSG stream input.
Definition: input.c:82
void nmsg_input_set_filter_group(nmsg_input_t input, unsigned group)
Set a group filter for input NMSG payloads.
Definition: input.c:289
pcap packets from file or interface
Definition: input.h:58
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.
Definition: input.c:131
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.
Definition: input.c:216
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 ...
Definition: input.c:343
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.
Definition: input.c:61
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 ...
Definition: input.c:352
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.
Definition: input.c:243
nmsg_input_t nmsg_input_open_sock(int fd)
Initialize a new NMSG stream input from a datagram socket source.
Definition: input.c:36
nmsg_input_t nmsg_input_open_pres(int fd, nmsg_msgmod_t msgmod)
Initialize a new NMSG presentation form input from a file descriptor.
Definition: input.c:95
nmsg_res nmsg_input_close(nmsg_input_t *input)
Close an nmsg_input_t object and release all associated resources.
Definition: input.c:172
void nmsg_input_breakloop(nmsg_input_t input)
Break out of an nmsg_input_loop() early.
Definition: input.c:206
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.
Definition: input.c:277
nmsg_res(* nmsg_cb_message_read)(nmsg_message_t *msg, void *user)
Callback function for generating nmsg messages.
Definition: nmsg.h:85
nmsg_input_t nmsg_input_open_file(int fd)
Initialize a new NMSG stream input from a byte-stream file source.
Definition: input.c:31
NMSG payloads from file or socket.
Definition: input.h:57