Net::Nmsg::Input - Perl interface for nmsg inputs
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->read) {
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);
Net::Nmsg::Input is the base class of a set format-specific input classes which provide perl interfaces for the Net::Nmsg::XS::input extension.
Creates a new input object from the given specification. A reasonable attempt is made to determine whether the specification is a file name (nmsg, pcap), file handle (nmsg), channel alias or socket specification (nmsg), or network device name (pcap), and is opened accordingly. If for some reason this reasonable guess is not so reasonable, use one of the specific open calls detailed below. The class of the returned object depends on the apparent format of the input.
The resulting object can be treated like an IO handle. The following both work:
while (my $msg = <$in>) {
# deal with $msg
}
while (my $msg = $in->read()) {
# deal with $msg
}
Options, where applicable, are valid for the more specific open calls detailed further below. Available options:
Filter incoming messages based on the given vendor/msgtype. Both are required if filtering is desired. Values can either be by name or numeric id.
Filter incoming messages based on the given source (nmsg only).
Filter incoming messages based on the given operator (nmsg only).
Filter incoming messages based on the given group (nmsg only).
Specify whether or not this input is blocking or not.
Set the receive buffer size (socket only)
Specify a Berkley Packet Filter (pcap file/interface only)
Packet capture size (live interface only)
Promiscuous mode (live interface only)
Opens an input in nmsg format, as specified by file name or file handle.
Opens an input in JSON format, as specified by file name or file handle.
Opens an input socket as specified by "host/port" or socket handle. The host and port can also be passed as separate arguments.
Opens an input in nmsg presentation format, as specified by file name. The 'filter_vendor' and 'filter_msgtype' options are required.
Opens an input in pcap format, as specified by file name. The 'filter_vendor' and 'filter_msgtype' options are required.
Opens an input in pcap format, as specified by interface name. The 'filter_vendor' and 'filter_msgtype' options are required.
Returns the next message from this input, if available, as a Net::Nmsg::Msg object.
Initiate processing of this input source, passing messages to the given code reference. Callbacks receive a single Net::Nmsg::Msg reference as an argument. An optional parameter count stops the loop after that many messages have been returned via the callback.
Net::Nmsg, Net::Nmsg::IO, Net::Nmsg::Output, Net::Nmsg::Msg, nmsgtool(1)
Matthew Sisk, <sisk@cert.org>
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 General 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.