nmsg  0.15.1
output.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_OUTPUT_H
18 #define NMSG_OUTPUT_H
19 
38 typedef enum {
39  nmsg_output_type_stream,
40  nmsg_output_type_pres,
41  nmsg_output_type_callback,
42  nmsg_output_type_json,
44 
57 nmsg_output_t
58 nmsg_output_open_file(int fd, size_t bufsz);
59 
73 nmsg_output_t
74 nmsg_output_open_sock(int fd, size_t bufsz);
75 
85 nmsg_output_t
86 nmsg_output_open_xs(void *s, size_t bufsz);
87 
117 nmsg_output_t
118 nmsg_output_open_xs_endpoint(void *xs_ctx, const char *ep, size_t bufsz);
119 
127 nmsg_output_t
128 nmsg_output_open_pres(int fd);
129 
158 nmsg_output_t
159 nmsg_output_open_json(int fd);
160 
173 nmsg_output_t
175 
189 nmsg_res
190 nmsg_output_flush(nmsg_output_t output);
191 
205 nmsg_res
206 nmsg_output_write(nmsg_output_t output, nmsg_message_t msg);
207 
215 nmsg_res
216 nmsg_output_close(nmsg_output_t *output);
217 
228 void
229 nmsg_output_set_buffered(nmsg_output_t output, bool buffered);
230 
245 void
246 nmsg_output_set_filter_msgtype(nmsg_output_t output, unsigned vid, unsigned msgtype);
247 
257 nmsg_res
258 nmsg_output_set_filter_msgtype_byname(nmsg_output_t output,
259  const char *vname, const char *mname);
260 
271 void
272 nmsg_output_set_rate(nmsg_output_t output, nmsg_rate_t rate);
273 
282 void
283 nmsg_output_set_endline(nmsg_output_t output, const char *endline);
284 
295 void
296 nmsg_output_set_source(nmsg_output_t output, unsigned source);
297 
308 void
309 nmsg_output_set_operator(nmsg_output_t output, unsigned operator_);
310 
321 void
322 nmsg_output_set_group(nmsg_output_t output, unsigned group);
323 
331 void
332 nmsg_output_set_zlibout(nmsg_output_t output, bool zlibout);
333 
334 #endif /* NMSG_OUTPUT_H */
nmsg_output_t nmsg_output_open_pres(int fd)
Initialize a new presentation format (ASCII lines) nmsg output.
nmsg_output_t nmsg_output_open_json(int fd)
Initialize a new JSON format nmsg output.
nmsg_res
nmsg result code
Definition: res.h:25
void nmsg_output_set_rate(nmsg_output_t output, nmsg_rate_t rate)
Limit the payload output rate.
void nmsg_output_set_filter_msgtype(nmsg_output_t output, unsigned vid, unsigned msgtype)
Filter an nmsg_output_t for a given vendor ID / message type.
nmsg_output_t nmsg_output_open_xs(void *s, size_t bufsz)
Initialize a new XS socket NMSG output.
void nmsg_output_set_zlibout(nmsg_output_t output, bool zlibout)
Enable or disable zlib compression of output NMSG containers.
nmsg_output_t nmsg_output_open_xs_endpoint(void *xs_ctx, const char *ep, size_t bufsz)
Create an XS socket and initialize a new NMSG stream output from it.
void nmsg_output_set_source(nmsg_output_t output, unsigned source)
Set the 'source' field on all output NMSG payloads.
nmsg_res nmsg_output_write(nmsg_output_t output, nmsg_message_t msg)
Write an nmsg message to an nmsg_output_t object.
nmsg_output_t nmsg_output_open_callback(nmsg_cb_message cb, void *user)
Initialize a new nmsg output closure.
nmsg_res nmsg_output_set_filter_msgtype_byname(nmsg_output_t output, const char *vname, const char *mname)
Filter an nmsg_output_t for a given vendor ID / message type.
nmsg_output_t nmsg_output_open_sock(int fd, size_t bufsz)
Initialize a new datagram socket nmsg output.
void nmsg_output_set_group(nmsg_output_t output, unsigned group)
Set the 'group' field on all output NMSG payloads.
void nmsg_output_set_buffered(nmsg_output_t output, bool buffered)
Make an nmsg_output_t socket output buffered or unbuffered.
nmsg_output_type
An enum identifying the underlying implementation of an nmsg_output_t object.
Definition: output.h:38
void(* nmsg_cb_message)(nmsg_message_t msg, void *user)
Callback function for processing nmsg messages.
Definition: nmsg.h:78
void nmsg_output_set_endline(nmsg_output_t output, const char *endline)
Set the line continuation string for presentation format output.
void nmsg_output_set_operator(nmsg_output_t output, unsigned operator_)
Set the 'operator' field on all output NMSG payloads.
nmsg_res nmsg_output_flush(nmsg_output_t output)
Flush an nmsg_output_t object.
nmsg_res nmsg_output_close(nmsg_output_t *output)
Close an nmsg_output_t object.
nmsg_output_t nmsg_output_open_file(int fd, size_t bufsz)
Initialize a new byte-stream nmsg output.