Version 0 of Netinfo

Updated 2007-01-21 19:31:55

Netinfo - Protocol, service and host info

Directions to find it at Stu

Man page:

 NAME
        netinfo - Protocol, service and host info

 SYNOPSIS
        package require Tcl

        package require netinfo 0.3
        namespace import ::netinfo::*

        protocolDataFilename ?fileName?
        serviceDataFilename  ?fileName?
        hostDataFilename     ?fileName?

        loadProtocolData
        loadServiceData
        loadHostData

        protocolFields
        serviceFields
        hostFields

        protocol field value ?field value ...?
        service  field value ?field value ...?
        host     field value ?field value ...?

        protocolData protocolInfo field ?field ...?
        serviceData  serviceInfo  field ?field ...?
        hostData     hostInfo     field ?field ...?

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

 COMMANDS
        protocolDataFilename  ?fileName?, serviceDataFilename
        ?fileName?, hostDataFilename ?fileName?
               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
host
/etc/hosts
        loadProtocolData, loadServiceData, loadHostData
               These  commands  import  data   from   the   system
               databases.   No  files  are loaded when the netinfo
               extension is loaded.  One of these must  be  called
               (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.

        protocolFields, serviceFields, hostFields
               These commands return a list  of  field  names  for
               their respective data sets. 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  excep-
               tion  of  host which has an additional -domain ele-
               ment which can be either inet or inet6.  The  -type
               element  for  service  data  is usually tcp or udp.
               The -alias element really means 'aliases'.

               The fields are:

               protocol: -name -address -alias -comment -domain
               service:  -name -number  -alias -comment
host
-name -port -alias -comment -type
        protocol field value  ?field  value  ...?,  service  field
        value     ?field value ...?, host field value ?field value
        ...?
               These commands query their respective data sets 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  'xxxFields'  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 a single list result and only the first  match
               is returned. If no matches occur then an empty list
               '{}' is returned.  For host queries without a  sup-
               plied  -domain  argument,  inet  domains will match
               first. For service queries without a supplied -type
               argument, tcp types will match first.

        protocolData protocolInfo field ?field ...?, serviceData
        service-   Info field ?field ...?, hostData hostInfo field
        ?field ...?
               These commands extract  data  from  query  results.
               The  'xxxInfo' parameter is a single list result 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  'xxxFields'  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 parameter is 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::*
        loadProtocolData; loadServiceData; loadHostData

        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 -type udp
        #=> discard 9 {sink null} {} udp
        service -port 9 -type *
        #=> {discard 9 {sink null} {} tcp} {discard 9 {sink null} {} udp}
        serviceData [lindex [service -port 9 -type *] 1] -type
        #=> udp

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

        # To obtain a list of all services (same for protocols and hosts):
        service -name *

 CAVEATS
        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
        network protocol service host