Net::Nmsg::Msg - Perl interface for messages from the NMSG library
use Net::Nmsg::Output; use Net::Nmsg::Input; use Net::Nmsg::Msg; # Each message type (vendor/msgtype) gets its own subclass with # methods specific to the fields for that type. For example: my $o = Net::Nmsg::Output->open('127.0.0.1/9430'); my $m = Net::Nmsg::Msg::ISC::ipconn->new(); for my $i (0 .. 99) { $m->set_srcip("127.0.0.$i"); $m->set_dstip("127.1.0.$i"); $m->set_srcport($i); $m->set_dstport(65535 - $i); $o->write($m); } my $c = 0; my $i = Net::Nmsg::Input->open('input.nmsg'); while (my $m = $i->read) { print "message $c vendor ", $m->vendor, " type ", $m->type, "\n" print $m->as_str, "\n"; ++$c; }
Net::Nmsg::Msg is the base class for NMSG messages. Each vendor/msgtype has a tailored subclass for handling fields particular to that type.
Returns a list of all message module classes installed on the system.
The name of the vendor of this message module.
The message type of this message module.
Return or set the source ID of this nmsg message.
Return or set the operator ID of this nmsg message.
Return or set the group of this nmsg message.
Return or set the timestamp of this nmsg message. Accepts and returns two integer values representing seconds and nanoseconds.
A list of possible fields defined for this message module.
A list of fields actually defined for a message module.
Renders the headers of a message (vendor, type, source, operator, group) as a string.
Renders the entire message, headers plus fields and their values as a string.
Each field of a message has several methods associated with it. Replace 'fieldname' with the actual name of the field:
get_fieldname() get_raw_fieldname() set_fieldname($val) set_raw_fieldname($packed_val)
Fields that are 'repeated' accept multiple values in the setters and return (possibly) multiple values from the getters. Repeated fields have these additional methods associated with them which push values onto the list of existing values:
add_fieldname(@vals) add_raw_fieldname(@packed_vals)
There is no difference between the plain and raw versions of these methods if the field is one of the following data types:
NMSG_FT_BYTES NMSG_FT_STRING NMSG_FT_MLSTRING NMSG_FT_UINT16 NMSG_FT_UINT32 NMSG_FT_INT16 NMSG_FT_INT32 NMSG_FT_DOUBLE NMSG_FT_BOOL
The following field types behave differently since there are no native perl types for them:
field mode type returns/accepts ------------------------------------------------------------- NMSG_FT_IP get IPv4/IPv6 strings NMSG_FT_IP set IPv4/IPv6 strings NMSG_FT_IP get raw IPv4/IPv6 packed network order NMSG_FT_IP set raw IPv4/IPv6 packed network order NMSG_FT_INT64 get Math::Int64 NMSG_FT_INT64 set Math::Int64 or string NMSG_FT_INT64 get raw 64-bit integer packed native NMSG_FT_INT64 set raw 64-bit integer packed native NMSG_FT_UINT64 * * same as above but unsigned NMSG_FT_ENUM get string NMSG_FT_ENUM set string NMSG_FT_ENUM get raw int NMSG_FT_ENUM set raw int
Net::Nmsg::IO, Net::Nmsg::Input, Net::Nmsg::Output, nmsgtool(1)
Matthew Sisk, <sisk@cert.org>
Copyright (C) 2010-2014 by Carnegie Mellon University
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, as published by the Free Software Foundation, under the terms pursuant to Version 2, June 1991.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
To install Net::Nmsg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Nmsg
CPAN shell
perl -MCPAN -e shell install Net::Nmsg
For more information on module installation, please visit the detailed CPAN module installation guide.