On Tue, 2005-09-13 at 12:22 -0400, Robert Story wrote:
> On Tue, 13 Sep 2005 13:32:39 +0100 Dave wrote:
> DS> Robert and I have been suggesting different forms of how to represent
> DS> the requested service - either a string-based token ("snmpd:receive")
> DS> or an integer ID (which happens to be the same as the default UDP
> DS> port number).
> 
> I like the strings because it's easier to extend,
> and users can define their own.

I've been thinking about this all morning (in between
dealing with a dead disk in the main staff fileserver!).
And I really can't see how you come to that conclusion.

AFAICS, the necessary code is almost identical, regardless
of the syntax of the identifying token.  Setting the library
up to support a new service would involve code such as
the following:

   netsnmp_register_service( MY_SERVICE, "udp:",  "12345" );
   netsnmp_register_service( MY_SERVICE, "unix:", "/var/my/service" );
   netsnmp_register_service( MY_SERVICE, "osi:",  "myserv-l" );
   netsnmp_register_service( MY_SERVICE, "nbp:",  "My Service" );

and opening a connection to this service would be
either
       netsnmp_open_session( "localhost", MY_SERVICE );
or
       netsnmp_open_session( MY_SERVICE, 0, "localhost", 0, 0 );

(depending on the style of the open_session call).


This code is essentially identical, regardless of whether
the service identifier was defined using:

        #define MY_SERVICE    "my:service"
or
        #define MY_SERVICE    6789

(with corresponding implications for the API prototypes).


In what way does using a string tag make this "easier to extend"
than with a numeric one?   What prevents a user from "defining
their own" new numeric tokens?

OK - a given application would probably be limited to 2^32
different services (including the default ones hard-wired
into the library).  While a string-based approach would
allow a practically unlimited number.  But I'm not convinced
this is a particularly significant limitation :-)



There's not really much to choose between the two approaches.
IMO, the numeric style has two (relatively minor) advantages:

  a)  Numeric comparisons are more efficient than
      string-based ones (so there'd be slightly less
      overhead involved in looking up which port to use)

  b)  If the numeric MY_SERVICE identifier were defined as

        #define MY_SERVICE    12345

      (i.e. using the same numeric value as the default UDP
      port) then the first ("udp:") registration call would
      not be necessary.  But that's a useful optimisation,
      rather than a core part of using a numeric identifier.


Can you give me an example of some scenario where using a
string-based tag provides functionality which a numeric
identifier could not?


Dave


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to