NAME
Net::Nmsg::Output - Perl interface for nmsg outputs
SYNOPSIS
use Net::Nmsg::Input;
use Net::Nmsg::Output;
my $in = Net::Nmsg::Input->open('input.nmsg');
my $out = Net::Nmsg::Output->open('output.nmsg');
my $c = 0;
while (my $msg = <$in>) {
print "got message $c $msg\n";
$out->write($msg);
++$c;
}
# alternatively:
my $cb = sub {
print "got message $c ", shift, "\n"
$out->write($msg);
++$c;
};
$in->loop($cb);
DESCRIPTION
Net::Nmsg::Output provides the perl interface for the Net::Nmsg::XS::output extension.
CONSTRUCTORS
- open($spec, %options)
-
Creates and opens new output object. The output can be specified as a file name or handle, callback reference, or socket.
Options, where applicable, also apply to the more specific open calls detailed further below. Available options:
- filter_vendor
- filter_msgtype
-
Restricts the output to messages of the given vendor and msgtype. Both are required if filtering is desired.
- source
- operator
- group
-
Set the source, operator, and group fields on outputs (nmsg only)
- buffered_io
-
Control whether or not the output socket is buffered (default: 1).
- zlibout
-
Enable or disable zlib compression of output (nmsg only)
- rate
- freq
-
Limit the payload output rate
- bufsz
-
Set the buffer size for the output (the default value is based on whether the output is a file or socket)
- broadcast
-
Set broadcast mode (socket only)
- sndbuf
-
Set send buffer size (socket only)
- endline
-
Set the line ending character for presentation outputs.
- open_file($spec, %options)
-
Opens an output in nmsg format, as specified by file name or file handle.
- open_json($spec, %options)
-
Opens an output in JSON format, as specified by file name or file handle.
- open_sock($spec, %options)
-
Opens an output socket as specified by "host/port" or socket handle. The host and port can also be provided as separate arguments.
- open_pres($spec, %options)
-
Opens an output in presentation format, as specified by file name or file handle. The 'filter_vendor' and 'filter_msgtype' options are required.
- open_cb($callback)
-
Opens a callback output using the provided code reference. The callback will be invoked with a Net::Nmsg::Msg reference each time a message is 'written' to the output.
ACCESSORS
- set_msgtype($vendor, $msgtype)
- get_msgtype
- set_source($source)
- get_source()
- set_operator($operator)
- get_operator()
- set_group($group)
- get_group()
- set_rate($rate, $freq)
- get_rate()
- set_buffered_io($bool)
- get_buffered_io()
- set_zlibout($bool)
- get_zlibout()
- set_endline($eol)
- get_endline()
- get_bufsz()
METHODS
SEE ALSO
Net::Nmsg, Net::Nmsg::IO, Net::Nmsg::Input, Net::Nmsg::Msg, nmsgtool(1)
AUTHOR
Matthew Sisk, <sisk@cert.org>
COPYRIGHT & LICENSE
Copyright (C) 2010-2015 by Carnegie Mellon University
Use of the Net-Silk library and related source code is subject to the terms of the following licenses:
GNU Public License (GPL) Rights pursuant to Version 2, June 1991 Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013
NO WARRANTY
See GPL.txt and LICENSE.txt for more details.