Urrobot
Netinfo
NAME
       netinfo - Protocol, service, network, host and ether info

SYNOPSIS
       package require Tcl

       package require netinfo 0.6
       namespace import ::netinfo::*

       netinfoDatabases

       protocolDataFilename ?fileName?
       serviceDataFilename  ?fileName?
       networkDataFilename  ?fileName?
       hostDataFilename     ?fileName?
       etherDataFilename    ?fileName?

       loadProtocolData
       loadServiceData
       loadNetworkData
       loadHostData
       loadEtherData

       protocolFields
       serviceFields
       networkFields
       hostFields
       etherFields

       protocol field value ?field value ...?
       service  field value ?field value ...?
       network  field value ?field value ...?
       host     field value ?field value ...?
       ether    field value ?field value ...?

       protocolData protocolInfo field ?field ...?
       serviceData  serviceInfo  field ?field ...?
       networkData  networkInfo  field ?field ...?
       hostData     hostInfo     field ?field ...?
       etherData    etherInfo    field ?field ...?

DESCRIPTION
       The netinfo Tcl extension provides access to system protocol, service,
       network, host and ether information which is retrieved from system
       databases and made available for querying.

       This functionality is somewhat analogous to that provided by some of
       the functions referenced in the  C include file usually found
       on unix-like operating systems (gethostbyname, getservbyport, etc).
       Unlike those functions, netinfo does not go beyond referencing the data
       stored in the system databases; netinfo does not access the databases
       per query, rather it loads the data and parses it into an internal
       ready-for-querying format.  If any changes are made to the databases
       after loading then the affected databases would need to be reloaded if
       the changes are to be available to netinfo queries.

       Normal usage involves optionally specifying any database files if the
       defaults do not match your reality, calling as many of the "load"
       commands as are necessary (depending on what data you need to access;
       netinfo does not load anything at startup) and using the querying and
       extraction commands to retrieve info.

       In this man page, the word dbname can replaced by one of: protocol,
       service, network, host or ether.  For example, seeing a description of
       a command named dbnameFields does not mean that a command
       "dbnameFields" exists but rather that the commands protocolFields,
       serviceFields, networkFields, hostFields and etherFields exist.

COMMANDS
       netinfoDatabases
              Returns the list of system databases that netinfo can query:
              {protocol service network host ether}.

       dbnameDataFilename ?fileName?
              Where dbname can be one of: protocol, service, network host or
              ether.  These commands permit the setting and retrieval of the
              file names used to import the system databases. When called
              without a fileName argument they return the current file name.
              When called with a fileName argument they set the file name to
              fileName and return the old file name.

              The defaults are:

              protocol: /etc/protocols
              service:  /etc/services
              network:  /etc/networks
              host:     /etc/hosts
              ether:    /etc/ethers

       loadDbnameData
              Where Dbname can be one of: Protocol, Service, Network, Host or
              Ether.  These commands import data from the system databases.
              No files are loaded when the netinfo extension is loaded.  One
              of these must be called (at least once) to import the system
              data after (optionally) setting the file name. It is necessary
              to load only the data for which querying is desired, i.e. they
              don't all have to be loaded.

       dbnameFields
              Where dbname can be one of: protocol, service, network, host or
              ether.  These commands return a list of field names for their
              respective databases. The order of the fields is the same order
              in which data is returned from the querying commands. The fields
              correspond to the fields in their respective files, with the
              exception of host which has an additional -domain field which
              can be either inet or inet6. The -protocol field for service
              data is usually tcp or udp.

              The fields are:

              protocol: -name -aliases -comment -number
              service:  -name -aliases -comment -port -protocol
              network:  -name -aliases -comment -number
              host:     -name -aliases -comment -address -domain
              ether:    -name -address -comment

       dbname field value ?field value ...?
              Where dbname can be one of: protocol, service, network, host or
              ether.  These commands query their respective databases and
              return lists containing matched data, if any.  The field
              parameter must be one of the available fields for the particular
              data set as returned by one of the dbnameFields commands.  The
              value parameter is matched against the indicated field using the
              rules of [string match]. Additional field value pairs may be
              given for a more precise query. If any of the value parameters
              contain any glob chars ('*', '?' or something enclosed in '[]')
              then the return value will be a list of lists, each element of
              the outer list being one result of the matched query. If no glob
              chars are present in the value parameter then only the first
              match is returned as a single list.  If no matches are found
              then an empty list '{}' is returned.  For host queries without a
              supplied -domain argument, inet domains will match first. For
              service queries without a supplied -protocol argument, tcp
              protocols will match first.

       dbnameData dbnameInfo field ?field ...?
              Where dbname can be one of: protocol, service, network, host or
              ether.  These commands extract data from query results.  The
              dbname parameter is a single database "row" (a list) as returned
              by one of the querying commands.  The field parameter must be
              one of the available fields for the particular data set as
              returned by one of the dbnameFields commands.  If only a single
              field parameter is provided then the result will be the value of
              the specified field. If more than one field parameters are
              provided then the result will be a list containing the values of
              the specified fields in the same order as the specified field
              parameters.


EXAMPLES
       # Results noted with #=>

       package require netinfo
       namespace import ::netinfo::*

       loadServiceData; loadNetworkData; loadHostData; loadEtherData

       protocolData [protocol -number 123] -comment
       #=> Performance Transparency Protocol
       protocolData [protocol -number 123] -comment -name
       #=> {Performance Transparency Protocol} ptp

       service -port 9
       #=> discard 9 {sink null} {} tcp
       service -port 9 -protocol udp
       #=> discard 9 {sink null} {} udp
       service -port 9 -protocol *
       #=> {discard 9 {sink null} {} tcp} {discard 9 {sink null} {} udp}
       serviceData [lindex [service -port 9 -protocol *] 1] -protocol -port
       #=> udp 9

       network -number 127
       #=> loopback loop {} 127
       networkData [network -number 224] -name
       #=> BASE-ADDRESS.MCAST.NET

       hostData [host -aliases localhost] -address
       #=> 127.0.0.1
       hostData [host -aliases localhost -domain inet6] -address
       #=> ::1

       etherData [ether -name toaster] -address
       #=> 00:01:6a:e3:df:0a

       # List all services:
       service -name *

CAVEATS
       Network database files are expected to be RFC? POSIX? compliant (if
       such things exist); the lines/fields are simply parsed with no checks
       for correctness of data (ie: IP addresses); such validation is beyond
       the scope of this extension.  No error checking is done in regards to
       field names or file names or anything else.  This 'crashing as error
       reporting' strategy is motivated by: laziness, a desire for keeping
       things quick and simple and the fact this is an all-around simple
       little extension that I didn't feel like bogging down with all that
       extra stuff.  Besides, you're supposed to know what you're doing. :)

KEYWORDS
       protocol service network host ether