home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_ietf_q_t / draft-ietf-svrloc-api-00.txt < prev    next >
Text File  |  1996-11-26  |  61KB  |  1,712 lines

  1.  
  2.  
  3.  Service Location Working Group                            Erik Guttman
  4.  Internet Draft                                  Sun Microsystems, Inc.
  5.  Expires in six months
  6.  
  7.  
  8.  
  9.                        An API for Service Location
  10.                       <draft-ietf-svrloc-api-00.txt>
  11.  
  12.  
  13.  
  14.       This document is an Internet-Draft.  Internet-Drafts are working
  15.       documents of the Internet Engineering Task Force (IETF), its
  16.       areas, and its working groups.  Note that other groups may also
  17.       distribute working documents as Internet-Drafts.
  18.  
  19.       Internet-Drafts are draft documents valid for a maximum of six
  20.       months and may be updated, replaced, or obsoleted by other
  21.       documents at any time.  It is inappropriate to use Internet-
  22.       Drafts as reference material or to cite them other than as
  23.       ``work in progress.''
  24.  
  25.       To learn the current status of any Internet-Draft, please check
  26.       the ``1id-abstracts.txt'' listing contained in the Internet-
  27.       Drafts Shadow Directories on ftp.is.co.za (Africa),
  28.       nic.nordu.net (Europe), munnari.oz.au (Pacific Rim),
  29.       ds.internic.net (US East Coast), or ftp.isi.edu (US West Coast).
  30.  
  31.  
  32. Abstract
  33.  
  34.    The Service Location Protocol coupled with the Service Location API
  35.    provide a new way for clients to dynamically discovery network
  36.    services.  It is simple to offer highly available services which
  37.    require no user configuration or communication with network
  38.    administrators prior to use.  The document includes examples and
  39.    applications.
  40.  
  41.    Client software modified to use Service Location can make very simple
  42.    requests to find service by type or by characteristic. The latter
  43.    capability allows the client to choose intelligently between services
  44.    of the same type.  Service software modified to use Service Location
  45.    may dynamically advertise its characteristics and existence.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. Guttman                                                         [Page 1]
  58.  
  59. Internet Draft        An API for Service Location       25 November 1996
  60.  
  61.  
  62. Table of Contents
  63.  
  64.       1. Introduction
  65.       2. Glossary
  66.       3. Interfaces
  67.          3.1. SL_Open
  68.          3.2. SL_Close
  69.          3.3. SL_Register
  70.          3.4. SL_DeRegister
  71.          3.5. SL_GetScopes
  72.          3.6. SL_GetServiceTypes
  73.          3.7. SL_GetService
  74.          3.8. SL_GetAttrs
  75.          3.9. SL_Free
  76.       4. API programming notes
  77.          4.1. Multithreading Issues
  78.          4.2. Nonstandard Service Types are easy
  79.          4.3. Typical Client Scenarios
  80.          4.4. Top level information
  81.          4.5. Example applications of SLP
  82.               4.5.1. Coarse dynamic load balancing
  83.               4.5.2. Mobile user finds the nearest printer
  84.               4.5.3. Providing highly available services
  85.       5. API implementation issues
  86.       6. Language specific API specification and examples
  87.          6.1. SLP API C bindings
  88.               6.1.1. Header file definitions
  89.               6.1.2. Interface clarification
  90.               6.1.3. Examples
  91.          6.2. SLP API Java bindings
  92.               6.2.1. Class definitions
  93.               6.2.2. Examples
  94.          6.3. Syntax for string parameters
  95.               6.3.1. Query Syntax
  96.                      6.3.1.1. List Query Syntax
  97.                      6.3.1.2. General Query Syntax
  98.               6.3.2. Attribute Registration List
  99.               6.3.3. Attribute Deregistration List
  100.               6.3.4. Attribute Selection List Syntax
  101.          6.4. Interpretation of SLP error values
  102.       7. Security Considerations
  103.       8. Internationalization Considerations
  104.          8.1. Character Set identification and use
  105.          8.2. Language identification and translation
  106.       9. Bibliography
  107.      10. Author's Address
  108.  
  109. 1. Introduction
  110.  
  111.    The Service Location API allows client and service programs to
  112.    be modified in a very simple manner to provide dynamic service
  113.  
  114.  
  115.  
  116. Guttman                                                         [Page 2]
  117.  
  118. Internet Draft        An API for Service Location       25 November 1996
  119.  
  120.  
  121.    discovery and selection.
  122.  
  123.    The underlying protocol makes use of strings extensively, as
  124.    does the interface.  String syntax for the List Query, General
  125.    Query, Attribute Deregistration List and Attribute Registration
  126.    List and Attribute Filter List are defined below, in the
  127.    appropriate sections.
  128.  
  129.    The API bindings are given in C and Java.  The semantics are
  130.    discussed in a language and implementation neutral way, with
  131.    these details left to later sections.
  132.  
  133.    Applications which are modified to use this API will be
  134.    source compatible with different SLP framework implementations.
  135.  
  136. 2. Glossary
  137.  
  138.    Service Location Protocol (SLP)
  139.  
  140.       The underlying protocol allowing dynamic and scalable
  141.       service discovery.  This protocol is specified in the Service
  142.       Location Protocol [SLP].
  143.  
  144.    SLP framework
  145.  
  146.       When a 'Service Location framework' is mentioned, it refers
  147.       to both the SLP implementation and interface implementation;
  148.       ie. whatever provides the SLP functionality to user level
  149.       programs.
  150.  
  151.    Directory Agent (DA)
  152.  
  153.       A service which automatically gathers service advertisements
  154.       from SAs in order to provide them to UAs.
  155.  
  156.    User Agent (UA)
  157.  
  158.       This is the Service Location process or library which allows
  159.       SLP requests to be made on behalf of a client process.  UAs
  160.       direct requests to DAs when they exist automatically when
  161.       they exist.  In their absense, UAs make requests directly
  162.       from SAs.
  163.  
  164.    Service Agent (SA)
  165.  
  166.       This is the Service Location process or library which allows
  167.       service software to register and deregister itself with the
  168.       SLP framework.  The SA SHOULD also respond to UA requests
  169.       directly in the absense of DAs.
  170.  
  171.    Service advertisement
  172.  
  173.  
  174.  
  175. Guttman                                                         [Page 3]
  176.  
  177. Internet Draft        An API for Service Location       25 November 1996
  178.  
  179.  
  180.       A service: URL possibly combined with service attributes.
  181.       When a service 'makes' a service advertisement, it uses the
  182.       SL_Register API.  This distributes the service advertisements
  183.       to Directory Agents and in the SLP framework.
  184.  
  185.    The service: URL
  186.  
  187.       A service of a particular type announces its availability
  188.       with a service: URL which includes its service access point
  189.       (domain name and possibly its port number) and optionally
  190.       basic configuration parameters.
  191.  
  192.    Service Attributes
  193.  
  194.       The attributes associated with a given service.  The values
  195.       that can be assigned to service attributes are defined by the
  196.       Service Type template.
  197.  
  198.    Service Type template
  199.  
  200.       A document which describes the syntax of the service: URL for
  201.       a given Service Type, the protocol the client will use to make
  202.       use of the service and a definition of all service attributes:
  203.       the meaning, defaults, constraints of each value the attributes
  204.       can take on.  Each Service Type is identified by a string
  205.       (usually the same name as the protocol used to deliver the
  206.       service.)  See "The service: URL Scheme" [SRV].
  207.  
  208.    Scope
  209.  
  210.       A string used to control the availability of service
  211.       advertisements.  Scopes are assigned by site administrators to
  212.       group services for many purposes, but chiefly as a means of
  213.       scalability.  DAs assigned a scope will store only services
  214.       advertised with the same scope value.  UAs SHOULD use a scope
  215.       string in requests whenever possible.
  216.  
  217.    Closure
  218.  
  219.       The set of attributes supported by all the services in a
  220.       network of a particular type.  For instance, the collected
  221.       attributes of all printers may be obtained.  Closures are
  222.       used to discover the range of possible values for services.
  223.       Service queries are constructed by selecting combinations
  224.       of desirable characteristics from this range.
  225.  
  226.    Naming Authority (NA)
  227.  
  228.       This is a 'suffix' to the service type string.  It completely
  229.       changes the meaning of the service type.   NAs are used for
  230.       private definitions of well known Service Types and
  231.  
  232.  
  233.  
  234. Guttman                                                         [Page 4]
  235.  
  236. Internet Draft        An API for Service Location       25 November 1996
  237.  
  238.  
  239.       experimental Service Type extensions.  The default NA is
  240.       "IANA", which may be omitted.
  241.  
  242. 3. Interfaces
  243.  
  244.    Of the interfaces listed below, three are for use only in a C API:
  245.    SL_Open, SL_Close and SL_Free.  The first two interfaces are
  246.    unnecessary in an object oriented interface, as the object
  247.    initialization and finalization code will perform all the needed
  248.    resource allocation and freeing.  Further, the object providing SLP
  249.    interfaces will encapsulate preference variables.  SL_Free is
  250.    included solely as a convenience, for freeing Result data structures.
  251.    In an object-oriented language, resource freeing will be handled by
  252.    the result objects themselves.
  253.  
  254.    The C API requires the use of a SL_SrvHandle, which is created by
  255.    SL_Open and passed into each interface.  The analagous entity for the
  256.    Java API is the ServiceLocator object which encapsulates all the
  257.    information and functionality that the SL_SrvHandle provides.  For
  258.    Java interface implementors:  The semantics of SL_Open and SL_Close
  259.    must be followed even if SL_SrvHandles are not required.
  260.  
  261. 3.1. SL_Open
  262.  
  263.    This interface is used to create a "SL_SrvHandle", which encapsulates
  264.    the program's default settings set by this call.
  265.  
  266.    SL_Open may also be used to modify the settings associated with an
  267.    existing SL_SrvHandle.  SL_Open must be used to generate a
  268.    SL_SrvHandle before any other API functions are used:  The library
  269.    should be initialized at this point.
  270.  
  271.    The settings which are configurable by SL_Open determine how service
  272.    requests will be issued.  They include the Language tag, character
  273.    set, the maximum time to wait for a response, and whether to "get all
  274.    services" or just "return the first one found."
  275.  
  276.    The SL_SrvHandle is entirely implementation dependent.  It is a
  277.    simple mechanism which allows instrumentation, resource tracking and
  278.    avoidance of global state.  The SL_SrvHandle will also allow the API
  279.    implementation to refer to some synchronization state, to provide the
  280.    synchronous and sequential access semantics described in Section 4.1.
  281.  
  282. 3.2. SL_Close
  283.  
  284.    This interface closes and frees all resources associated with the
  285.    SL_SrvHandle.  It sets the SL_SrvHandle to NULL.   When the last
  286.    SL_SrvHandle is closed, the library frees all its resources.
  287.  
  288. 3.3. SL_Register
  289.  
  290.  
  291.  
  292.  
  293. Guttman                                                         [Page 5]
  294.  
  295. Internet Draft        An API for Service Location       25 November 1996
  296.  
  297.  
  298.    The service supplies a service: URL, and possibly service attributes.
  299.    The attributes to use, their defaults and interpretation, are all
  300.    given in the Service Type template. The service also specifies the
  301.    Lifetime of the service (how long it should remain registered), as
  302.    well as the Language tag and character set used.
  303.  
  304.    A call to SL_Register with a URL which has already been registered
  305.    will be an 'update'.  It will replace the attributes previously
  306.    registered, if the update contains attributes of the same name,
  307.    language and character set. For example:  If the first registration
  308.    has attributes
  309.  
  310.       "(A=1),(B=2),(C=3)"
  311.  
  312.    and the subsequent registration has attributes
  313.  
  314.       "(C=30),(D=40)"
  315.  
  316.    the registration will end up with
  317.  
  318.       "(A=1),(B=2),(C=30),(D=40)".
  319.  
  320.    An Attribute Registration list string is used for registration. The
  321.    above are examples of such strings.
  322.  
  323.    Service advertisements may be made multiple times for the same URL,
  324.    in different languages and different character set encodings. A
  325.    service program may provide different translations of the services
  326.    offered in this way.  For example, the service could be registered
  327.    with service attributes translated to English, Russian and Arabic,
  328.    with the appropriate character sets.  The same service: URL may now
  329.    be obtained by client programs with different user language skills.
  330.  
  331.    A service registered without a scope may only be available from DAs
  332.    which have not been configured with any scopes.  UAs must explicitely
  333.    request services which are unscoped.   For these reasons, it is
  334.    highly recommended that scopes be used if they have been defined for
  335.    a given site.
  336.  
  337.    If a SA crashes, or the program which used the SL_Register function
  338.    to make a service advertisement exits without calling SL_Deregister,
  339.    the longest that the stale service advertisement can remain available
  340.    in the SLP framework is 18 hours.
  341.  
  342.    The iLifetime parameter determines how long the registration is valid
  343.    for.  It can take any value from 1-65535 (seconds). If the value is
  344.    -1, the SLP API implementation will make sure to schedule updates so
  345.    the service advertisement is continually available.
  346.  
  347.    The final parameter, iRefreshHint, may be set to 0 for the 'default'
  348.    refresh interval.  It may also be set at a number (less than the
  349.  
  350.  
  351.  
  352. Guttman                                                         [Page 6]
  353.  
  354. Internet Draft        An API for Service Location       25 November 1996
  355.  
  356.  
  357.    value for iLifetime).  This is a request that the API implementation
  358.    refresh the service advertisement at a particular interval.  For
  359.    example, if iRefreshHint is 60, the service will be refreshed every
  360.    60 seconds.  The iLifetime could be -1 (continual).  The service will
  361.    be available continuously:  The API will choose some Lifetime on the
  362.    order of 120 or 180 to ensure this, and refresh it every 60 seconds
  363.    or so.  If the service goes down, the longest the service will be
  364.    "falsely advertised" is a minute or two.
  365.  
  366.    The shorter the iRefreshHint, the less chance the SLP framework will
  367.    have stale data in the event of a service failure.  The shorter the
  368.    interval between refresh though, the greater the amount of protocol
  369.    work that needs to be done.
  370.  
  371. 3.4. SL_DeRegister
  372.  
  373.    The service: URL of the service to deregister must be provided. If
  374.    this is the only information provided, the service advertisment will
  375.    be deregistered in every language and character set it has been
  376.    registered in .
  377.  
  378.    If a Language tag, character set and Attribute Deregistration List
  379.    are provided the attributes in the Deregistration list will be
  380.    removed from the service advertisement.
  381.  
  382. 3.5. SL_GetScopes
  383.  
  384.    This returns an array of strings with all available scope values.
  385.  
  386. 3.6. SL_GetServiceTypes
  387.  
  388.    This returns an array of strings with all available service types.
  389.    Service Types with NAs will be returned as distinct Service Types,
  390.    ie.  "blah" and "blah.xyz" are not the same.
  391.  
  392.    This request may include a Scope.  If it does not, it will only
  393.    return the Service Types of service advertisements made without a
  394.    Scope.
  395.  
  396. 3.7. SL_GetService
  397.  
  398.    This interface takes a Query String.   This string includes three
  399.    parts:
  400.  
  401.       Service Type - (can be discovered using SL_GetServiceTypes)
  402.       Scope            - (can be discovered using SL_GetScopes)
  403.       Query            - (can be either a list or general query.
  404.                           The attributes used in the query can be
  405.                           discovered using SL_GetAttrs).
  406.  
  407.    The Query portion of the parameter allows the caller to specify
  408.  
  409.  
  410.  
  411. Guttman                                                         [Page 7]
  412.  
  413. Internet Draft        An API for Service Location       25 November 1996
  414.  
  415.  
  416.    exactly what service advertisement or advertisements are desired.
  417.  
  418.    This returns one or more service: URLs, their Lifetime in seconds and
  419.    address information ready to be used in networking calls.
  420.  
  421. 3.8. SL_GetAttrs
  422.  
  423.    If the URL supplied is a complete service: URL, the attribute
  424.    information returned will be for that particular service.
  425.  
  426.    The service type string may include a NA suffix.  The syntax for
  427.    including this is:
  428.  
  429.       service-type-with-NA = srvtype-string "." NA-string
  430.       restricted-string    = ALPHA / "+" / "-"
  431.       srvtype-string       = restricted-string
  432.       NA-string            = restricted-string
  433.  
  434.    Attributes will only be returned for the service registered with the
  435.    Scope provided in the SL_GetAttrs call.
  436.  
  437.    Finally, the result may be filtered with a Attribute Request Filter
  438.    string parameter.  If this is not supplied, ALL attributes are
  439.    returned.  If it is supplied, only those attributes on the list are.
  440.    An attribute tag ending in '*' matches all attributes starting with
  441.    this substring.
  442.  
  443.    A Service Type string may be passed in as the URL parameter instead
  444.    of providing a complete service: URL.  In this case, the results
  445.    which are returned are the attributes for ALL services of the
  446.    specified Service Type.
  447.  
  448. 3.9. SL_Free
  449.  
  450.    This API is only available for a C language interface.  This function
  451.    frees all resources associated with the data passed in.  The Result
  452.    pointer passed in will be modified to be NULL.
  453.  
  454. 4. API programming notes
  455.  
  456. 4.1. Multithreading issues
  457.  
  458.    Each SL_SrvHandle (C) or ServiceLocator Object (Java) will only allow
  459.    one concurrent access at a time.  Interfaces are synchronous and will
  460.    block until they are complete.  If a second thread attempts to use
  461.    the same SL_SrvHandle or ServiceLocator Object to perform a SLP API
  462.    function which has been labeled as 'synchronous', it will block until
  463.    the first thread completes its synchronous operation.
  464.  
  465.    A multithreaded program may create multiple SL_SrvHandles or
  466.    ServiceLocator objects to make concurrent use of SLP interfaces.
  467.  
  468.  
  469.  
  470. Guttman                                                         [Page 8]
  471.  
  472. Internet Draft        An API for Service Location       25 November 1996
  473.  
  474.  
  475. 4.2. Nonstandard Services Types are easy
  476.  
  477.    It is trivial to register and discover services of nonstandard types.
  478.    Simply make up a Service Type string (by convention, nonstandard
  479.    service types begin with the string "x-").
  480.  
  481. 4.3. Typical Client Scenarios
  482.  
  483.    There are two typical use scenarios:
  484.  
  485.      - canned query:  Issue a SL_GetService.  Try each service in turn
  486.        in the reply until one works.
  487.  
  488.      - browse for a service:  Issue SL_GetScopes.  Issue SL_GetAttrs for
  489.        the desired Service Type using the selected Scope.  Construct a
  490.        query string, then use SL_GetService.  If the user wishes, call
  491.        SL_GetAttrs to get all (or some more) attributes for the service
  492.        returened by the SL_GetService.
  493.  
  494. 4.4. Top level information
  495.  
  496.    The SL_GetServiceTypes is used to implement network service browsers
  497.    and administrative tools.  Normally a client application knows what
  498.    Service Type it will need.
  499.  
  500.    Use the Service Template as a guide to designing client query and
  501.    service profile user interfaces.  It can also be used for designing a
  502.    user interface for system administrators who will define the
  503.    attributes of a service.  Service Templates are themselves a service
  504.    which can be discovered.  See "The service: URL Scheme" [SRV].
  505.  
  506. 4.5. Example applications of SLP
  507.  
  508.    The most common use of SLP will simply be for clients to locate their
  509.    server by type and attribute.  Many distributed applications require
  510.    discovery at configuration time.  The SLP framework provides a
  511.    lightweight standard mechanism for doing this.  Example domains which
  512.    might benefit are:  Client-Server Database systems, network based
  513.    games, and distributed object systems.
  514.  
  515.    Some more sophisticated examples are described below:
  516.  
  517. 4.5.1. Coarse dynamic load balancing
  518.  
  519.    One approach to load balancing simply distributes work on a rotating
  520.    basis among a set of servers.  This rotation may be achieved using
  521.    redirection at various levels.  This is a static approach:  It has an
  522.    distribution algorithm which does not change depending on the actual
  523.    state of the servers.
  524.  
  525.    A better approach could be to have the services provide feedback, so
  526.  
  527.  
  528.  
  529. Guttman                                                         [Page 9]
  530.  
  531. Internet Draft        An API for Service Location       25 November 1996
  532.  
  533.  
  534.    as to allow dynamic load balancing.  In this approach, the state of
  535.    the load of the services themselves determines the amount of work to
  536.    shift away or to the server.
  537.  
  538.    To achive this, services would have to be instrumented so as to
  539.    provide a "load metric."  This attribute could be advertised using
  540.    SL_Register, updating the current service advertisement.  The finest
  541.    granularity achievable given the timing of SLP would be on the order
  542.    of seconds.  This is why I call the dynamic load balancing "coarse."
  543.  
  544.    Clients seeking to dynamically discover a server with the lowest
  545.    "load metric" would first issue a SL_GetAttrs to obtain the range of
  546.    the attribute.  Then, the SL_GetService function would be used, with
  547.    the query selecting the lowest load metric value.  This would return
  548.    the service: URL to bind to.
  549.  
  550. 4.5.2.  Mobile user finds the nearest printer
  551.  
  552.    A mobile user could use SL_GetAttrs to on the lpr service type,
  553.    requesting all "Location Description" and "Location Address"
  554.    attribute values be returned.  The user is presented with this list
  555.    and selects the closest location.  SL_GetServices is used to obtain
  556.    the service: URL which has this location attribute.  The user may now
  557.    print and know where to find the result.
  558.  
  559. 4.5.3.  Providing highly available services
  560.  
  561.    When a vital service needs to be brought down, users often suffer
  562.    down time.  This requires network administrators to communicate with
  563.    their user community, defer nonessential maintainance and upgrades
  564.    and to schedule them at off hours.
  565.  
  566.    Using Service Location, system administrators would need only start a
  567.    back up service and bring down the primary server. Client software
  568.    could simply rediscover the necessary service by type and
  569.    characteristic, reconnect and proceed.
  570.  
  571.    This sounds harder than it would be in practice:  The client software
  572.    would only need to be changed in one respect.  The error path which
  573.    announced the client "lost contact with the server" would be changed.
  574.    The same code the client used for dynamically discovering the service
  575.    in the first place would be used again.  Only if this rediscovery
  576.    fails need the software decry its sad disconnection.
  577.  
  578. 5. API implementation issues
  579.  
  580.    Results of requests should always be coallated to remove duplicates.
  581.    This is especially important for the results of SL_GetAttrs and
  582.    SL_GetTypes when there are no DAs:  The request will be multicast to
  583.    all SAs, and the results will no doubt include duplicate values.
  584.  
  585.  
  586.  
  587.  
  588. Guttman                                                        [Page 10]
  589.  
  590. Internet Draft        An API for Service Location       25 November 1996
  591.  
  592.  
  593.    An SA implementation requires as a minimum that service
  594.    advertisements be registered with a DA.  They SHOULD be able to
  595.    respond to UA queries directly in the absense of a DA.
  596.  
  597.    If the latter feature is implemented, the SA will run on the same
  598.    host, and need some way to service UA requests on behalf of all the
  599.    hosts services.  This SA must listen for TCP requests. Since only one
  600.    process per host may be bound to a particular TCP port, the SA
  601.    process will have to be a shared resource and communicate with the
  602.    different service processes using some form of interprocess
  603.    communication.
  604.  
  605.    There is a subtle bending of the semantics of Service Location if a
  606.    SA and DA are collocated on the same host.  On some socket based
  607.    implementations of IP multicast, the following occurs: Two sockets
  608.    are bound to the same UDP port.  One of the sockets has joined a
  609.    multicast group, the other hasn't.  A multicast datagram arriving for
  610.    that multicast group, for the port in question, is delivered to BOTH
  611.    sockets.  Suppose a DA is listening for unicast datagrams on the SLP
  612.    port, while the SA is listening for multicast packets on the same
  613.    port. A multicast datagram arrives for the SA, but is delivered to
  614.    the DA as well.  In the worst case, BOTH respond. This will possibly
  615.    supply redundent information (if the SA services are registered with
  616.    the DA.)  Worse, the DA may reply with information which it
  617.    'shouldn't.'  None of this is very serious, because the worst that
  618.    can happen is the UA will receive more information than it would have
  619.    otherwise.  The UA will only receive correct information in any case;
  620.    it MUST satisfy the UAs request or it won't be returned.
  621.  
  622.  
  623. 6. Language specific API specification and examples
  624.  
  625.    The interfaces presented below are not equivalent, though they both
  626.    have the semantics described in sections 3, 4 and 5 above.
  627.  
  628. 6.1 SLP API C bindings
  629.  
  630. 6.1.1. Header file definitions
  631.  
  632.    /*
  633.     * The SLP API definition.
  634.     *
  635.     */
  636.  
  637.      /*-------------------------------------------------------------
  638.       * type declarations for service location
  639.       */
  640.  
  641.    #ifndef SLP_H
  642.    #define SLP_H
  643.  
  644.  
  645.  
  646.  
  647. Guttman                                                        [Page 11]
  648.  
  649. Internet Draft        An API for Service Location       25 November 1996
  650.  
  651.  
  652.      typedef enum {
  653.        SL_CHAR_ASCII = 3, SL_CHAR_LATIN1 = 4, SL_CHAR_UTF8 = 6
  654.      } SL_CharType;
  655.  
  656.      typedef enum {
  657.        SL_TYPE_RESULT = 1, SL_ATTR_RESULT = 2, SL_SRV_RESULT = 3,
  658.        SL_SCOPE_RESULT = 4
  659.      } SL_ResType;
  660.  
  661.      typedef enum {
  662.        SL_STR_VAL = 1, SL_INT_VAL = 2,  SL_OPAQUE_VAL = 3,
  663.        SL_BOOL_VAL = 4
  664.      } SL_ValType;
  665.  
  666.      typedef struct servicetag {
  667.        char               *s_pcURL;
  668.        struct sockaddr_in  s_sin;
  669.        int                 s_iLifetime;
  670.      } SL_Service;
  671.  
  672.      typedef struct opaquetag {
  673.        int      op_iLen;
  674.        char    *op_pcVal;
  675.      } SL_Opaque;
  676.  
  677.      typedef union {
  678.        int      intval;
  679.        u_char   boolval;
  680.        Opaque   opaqueval;
  681.        char    *pcStrVal;
  682.      } SL_Value;
  683.  
  684.      typedef struct attrtag {
  685.        int         a_iNumVals;
  686.        char       *a_pcAttrTag;
  687.        SL_ValType  a_slvaltype;
  688.        SL_Value   *a_pslValue;
  689.      } SL_Attribute;
  690.  
  691.      typedef union {
  692.        SL_Service    i_sl_service;
  693.        SL_Attribute  i_sl_attribute;
  694.        char         *i_pcSrvtype;
  695.        char         *i_pcScope;
  696.      } SL_ResInfo;
  697.  
  698.      typedef struct resulttag {
  699.        int         r_iErrorCode;
  700.        int         r_iAsyncId;
  701.        int         r_iNumValues;
  702.        int         r_iCharEncoding;
  703.  
  704.  
  705.  
  706. Guttman                                                        [Page 12]
  707.  
  708. Internet Draft        An API for Service Location       25 November 1996
  709.  
  710.  
  711.        char       *r_pcLang;
  712.        SL_ResType  r_sl_restype;
  713.        SL_ResInfo *r_psl_Info;
  714.      } SL_Result;
  715.  
  716.      typedef void* SL_SrvHandle;
  717.  
  718.      /*------------------------------------------------------------
  719.       * Ease-of-use macros, to enable dereferencing of structures.
  720.       *
  721.       *    res_srv_url        returns the URL of the i'th service
  722.       *                          in the service result
  723.       *    res_srv_sin        returns the struct sockaddr_in of the
  724.       *                          i'th service in the service result
  725.       *    res_srv_life       returns the lifetime in seconds of the
  726.       *                          i'th service in the service result
  727.       *    res_srvtype        returns the string of the i'th service
  728.       *                          type in the service type result
  729.       *    res_scope          returns the scope string of the i'th
  730.       *                          scope result
  731.       *    res_attr_numval    returns the number of attr values for
  732.       *                          the i'th attr in the attr result.
  733.       *    res_attr_tag       returns the tag string for the i'th
  734.       *                          attr in the attr result
  735.       *    res_attr_type      returns the type for the i'th attr
  736.       *                          in the attr result
  737.       *    res_attr_str       returns the j'th string value of the
  738.       *                          i'th attr in the attr result
  739.       *    res_attr_int       returns the j'th int value of the i'th
  740.       *                          attr in the attr_result
  741.       *    res_attr_bool      returns the j'th boolean value of the
  742.       *                          i'th attr in the attr result
  743.       *    res_attr_opaque    returns the j'th opaque value of the
  744.       *                          i'th attr in the attr result
  745.       */
  746.  
  747.    #define res_srv_url(i)     r_psl_Info[(i)].i_sl_service.s_pcURL
  748.    #define res_srv_sin(i)     r_psl_Info[(i)].i_sl_service.s_sin
  749.    #define res_srv_life(i)    r_psl_Info[(i)].i_sl_service.s_iLifetime
  750.    #define res_srvtype(i)     r_psl_Info[(i)].i_pcSrvtype
  751.    #define res_scope(i)       r_psl_Info[(i)].i_pcScope
  752.    #define res_attr_numval(i) r_psl_Info[(i)].i_sl_attribute.a_iNumVals
  753.    #define res_attr_tag(i)    r_psl_Info[(i)].i_sl_attribute.a_pcAttrTag
  754.    #define res_attr_type(i)   r_psl_Info[(i)].i_sl_attribute.a_slvaltype
  755.    #define res_attr_str(i,j)     /
  756.       r_pls_Info[(i)].i_sl_attribute.a_pslValue[(j)].pcStrVal
  757.    #define res_attr_int(i,j)     /
  758.       r_pls_Info[(i)].i_sl_attribute.a_pslValue[(j)].intval
  759.    #define res_attr_bool(i,j)    /
  760.       r_pls_Info[(i)].i_sl_attribute.a_pslValue[(j)].boolval
  761.    #define res_attr_opaque(i,j)  /
  762.  
  763.  
  764.  
  765. Guttman                                                        [Page 13]
  766.  
  767. Internet Draft        An API for Service Location       25 November 1996
  768.  
  769.  
  770.       r_pls_Info[(i)].i_sl_attribute.a_pslValue[(j)].opaqueval
  771.  
  772.      /*-----------------------------------------------------------------
  773.       * SLP errors, can be received from a DA or SA.
  774.       */
  775.  
  776.    #define     SLP_OK                            0
  777.    #define     SLP_LANG_NOT_SUPPORTED            0x01
  778.    #define     SLP_PROTOCOL_PARSE_ERR            0x02
  779.    #define     SLP_INVALID_REGISTRATION          0x03
  780.    #define     SLP_SCOPE_NOT_SUPPORTED           0x04
  781.    #define     SLP_CHARSET_NOT_UNDERSTOOD        0x05
  782.    #define     SLP_AUTHENTICATION_INVALID        0x06
  783.  
  784.      /*-----------------------------------------------------------------
  785.       * Interface errors.
  786.       */
  787.  
  788.    #define     SLP_NOT_SUPPORTED_YET             0x10
  789.    #define     SLP_REQUEST_TIMED_OUT             0x11
  790.    #define     SLP_COULD_NOT_INIT_NET_RESOURCES  0x12
  791.    #define     SLP_COULD_NOT_ALLOCATE_MEMORY     0x13
  792.    #define     SLP_PARAMETER_BAD                 0x14
  793.    #define     SLP_INTERNAL_NET_ERROR            0x15
  794.    #define     SLP_INTERNAL_SYSTEM_ERROR         0x16
  795.  
  796.  
  797.    #ifdef __cplusplus
  798.    extern "C" {
  799.    #endif /* for C++ use of C interface */
  800.  
  801.    /*-------------------------------------------------------------------
  802.     * General interfaces for all clients
  803.     *
  804.     * The term "EXPORT" is included so as to make the interface portable
  805.     * to Win32.  For Unix environments, etc. EXPORT is defined as nothing.
  806.     * For Win32, EXPORT is __declspec(dllimport) for the client library
  807.     * and __declspec(dllexport) for the library implementation.
  808.     */
  809.  
  810.    /*------------------------------------------------------------------*/
  811.      EXPORT SL_SrvHandle SL_Open(
  812.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open   */
  813.         const char  *pcLangPref,       /* Set to the ISO 639 code    */
  814.         int          iDialect,         /* Set to 0, reserved         */
  815.         int          iMonoling,        /* 1 = Monolingual, 0 = not   */
  816.         int          iMaxWait,         /* # seconds max, 0 = default */
  817.         int          iMultiple,        /* 0 = return first result,   */
  818.                                        /* 1 = return all results     */
  819.         SL_CharType  slchartype,       /* Type for characters used.  */
  820.         int         *piErrValue);      /* 0 unless an error occurred */
  821.  
  822.  
  823.  
  824. Guttman                                                        [Page 14]
  825.  
  826. Internet Draft        An API for Service Location       25 November 1996
  827.  
  828.  
  829.  
  830.    /*------------------------------------------------------------------*/
  831.      EXPORT void       SL_Close(
  832.         SL_SrvHandle *pSL_SrvHandle);  /* pSrvState from SL_Open  */
  833.  
  834.    /*------------------------------------------------------------------
  835.     * SA interfaces
  836.     */
  837.  
  838.    /*------------------------------------------------------------------*/
  839.      EXPORT int     SrvRegister(
  840.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  841.         const char  *pcURL,            /* Unique URL (of reg.)      */
  842.         const char  *pcLang,           /* Language code of reg.     */
  843.         int          iDialect,         /* Set to 0, reserved.       */
  844.         SL_CharType  slchartype,       /* Character type of reg.    */
  845.         const char  *pcAttributes,     /* Service Attribute list    */
  846.         int          iLifetime,        /* 1..65535 = # of seconds   */
  847.                                        /* -1 = CONTINUAL registra-  */
  848.                                        /*   tion of service         */
  849.         int          iRefreshHint);    /* # seconds till refresh    */
  850.  
  851.    /*------------------------------------------------------------------*/
  852.      EXPORT int     SrvDeRegister(
  853.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  854.         const char  *pcURL,            /* URL (of service todereg.) */
  855.         const char  *pcLang,           /* Language code of dereg.   */
  856.         int          iDialect,         /* Set to 0, reserved.       */
  857.         SL_CharType  slchartype,       /* Character type of dereg.  */
  858.         const char  *pcAttrTags);      /* Tags of attrs to dereg.   */
  859.  
  860.    /*------------------------------------------------------------------
  861.     *  UA interfaces
  862.     */
  863.  
  864.    /*------------------------------------------------------------------*/
  865.      EXPORT Result * SL_GetScopes(
  866.         SL_SrvHandle hSL_SrvHandle);   /* State created by SL_Open  */
  867.  
  868.    /*------------------------------------------------------------------*/
  869.      EXPORT Result * SL_GetSrvTypes(
  870.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  871.         const char  *pcNamingAuth,     /* NULL = default            */
  872.         const char  *pcScope);         /* NULL = none               */
  873.  
  874.    /*------------------------------------------------------------------*/
  875.      EXPORT Result * SL_GetAttrs(
  876.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  877.         const char  *pcURL,            /* Either full or partial    */
  878.         const char  *pcScope,          /* Scope of attrs to get     */
  879.         const char  *pcAttrTags);      /* Tags for 'selected' attrs */
  880.  
  881.  
  882.  
  883. Guttman                                                        [Page 15]
  884.  
  885. Internet Draft        An API for Service Location       25 November 1996
  886.  
  887.  
  888.    /*------------------------------------------------------------------*/
  889.      EXPORT Result * SL_GetService(
  890.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  891.         const char  *pcRequest);       /* Request string to supply  */
  892.  
  893.    /*------------------------------------------------------------------*/
  894.      EXPORT void    SrvFreeResult(
  895.         SL_SrvHandle hSL_SrvHandle,    /* State created by SL_Open  */
  896.         SL_Result  **ppResult);        /* SL_Result to be freed     */
  897.  
  898.    #ifdef __cplusplus
  899.    }
  900.    #endif /* for C++ use of C interface */
  901.  
  902.    #endif /* End of the SLP API definition */
  903.    /*------------------------------------------------------------------*/
  904.  
  905. 6.1.2. Interface clarification
  906.  
  907.    The values #defined with SLP_ as their prefixes are the return values
  908.    of the interfaces.  In the case of SL_Open, the return value is set
  909.    via an integer parameter supplied by the caller.  In SL_Register and
  910.    SL_DeRegister the int is returned directly. In the case of all the
  911.    queries beginning with "SL_Get", the result code is in the Result
  912.    value returned, in the r_iErrorCode field of the structure.  In the
  913.    case of an error, results MAY be returned on a best effort basis.
  914.  
  915.    SL_Open
  916.  
  917.       Pass NULL in as the SrvHandle parameter to create a new SrvHandle.
  918.       Pass an existing SrvHandle parameter to modify the default values
  919.       associated with it.
  920.  
  921.    SL_Register
  922.  
  923.       The pcLang and slchartype parameter must be set.  See [SLP] for
  924.       a table of legitimate values for pcLang.  iDialect SHOULD be set
  925.       to 0.  See Section 6.3.2. for the syntax of pcAttributes.
  926.  
  927.    SL_DeRegister
  928.  
  929.       The pcURL paramter must be set.  Instead of deregistering the
  930.       service, one can deregister attributes.  In this case the pcLang
  931.       and slchartype parameter must be set.  iDialect SHOULD be set
  932.       to 0.  See Section 6.3.3. for the syntax of pcAttrTags.
  933.  
  934.    SL_GetSrvTypes
  935.  
  936.       The parameters may be NULL.
  937.  
  938.    SL_GetAttrs
  939.  
  940.  
  941.  
  942. Guttman                                                        [Page 16]
  943.  
  944. Internet Draft        An API for Service Location       25 November 1996
  945.  
  946.  
  947.       The pcURL parameter must be supplied.  It can either be a
  948.       complete service: URL or merely a Service Type string.  The
  949.       semantics of the call vary in this case.
  950.  
  951.       The psScope parameter may be NULL.
  952.  
  953.       The pcAttrTags parameter may be NULL.  If it is not, it follows
  954.       the grammar in Section 6.3.4.
  955.  
  956.    SL_GetService
  957.  
  958.       The pcQuery must be supplied.  It follows the grammar in Section
  959.       6.3.1.
  960.  
  961. 6.1.3. Examples
  962.  
  963.    Suppose web servers register themselves with Service Location.
  964.    The attributes they register are their Scope as well as an
  965.    index of all the 'home pages' available on the server.  The
  966.    homepages are listed as
  967.  
  968.       <relative URL> "::" <title> "::" <description>
  969.  
  970.       The web server could do the following:
  971.  
  972.          int err = SLP_OK;
  973.          SrvHandle sh = SL_Open(
  974.             NULL,       /* NULL indicates: Create the SrvHandle */
  975.             "en", 0,    /* Select English as default language   */
  976.             1,          /* Monolingual results for replies      */
  977.             10,         /* 10 seconds max blocking on calls     */
  978.             1,          /* Return all results                   */
  979.             CHAR_UTF8,  /* All requests and replies in UTF8     */
  980.             &err);      /* error value will be returned in err. */
  981.          if (err != SLP_OK) ; /* do something better here       */
  982.          err = SL_Register(
  983.             sh,                              /* supply the SrvHandle   */
  984.             "service:http://myhost.sun.com", /* supply the URL         */
  985.             "en", 0,                         /* reg in English         */
  986.             CHAR_ASCII,                      /* reg in UTF8            */
  987.             "(SCOPE=ENGINEERING),"           /* declare attributes     */
  988.             "(HOME PAGES="
  989.               "schedule/index.html::Schedule::"
  990.                  "This site contains updated timelines for all the work in"
  991.                  "the F.L.O.R.B. project,"
  992.               "snort/releases.html::Bob Snort's Home::"
  993.                  "Release engineer Bob posts results of all the builds here,"
  994.               "specs/index.html::Specs galore::"
  995.                  "Technical specifications for the F.L.O.R.B. and X872"
  996.                  "projects.)",
  997.               -1,                            /* continual registration */
  998.  
  999.  
  1000.  
  1001. Guttman                                                        [Page 17]
  1002.  
  1003. Internet Draft        An API for Service Location       25 November 1996
  1004.  
  1005.  
  1006.                0);                           /* use default refresh    */
  1007.  
  1008.          if (err != SLP_OK) ; // do something better here
  1009.  
  1010.       A web browser could use Service Location to find a particular web site
  1011.       this way.  Unlike web indexing search engines, SLP will keep information
  1012.       up to date and it will be available within a few seconds after a web
  1013.       server registers itself.
  1014.  
  1015.          /*
  1016.           * The client calls SL_Open, exactly as above.
  1017.           */
  1018.          char *pcPageDescr = NULL;
  1019.          Result *pr = SL_GetAttrs(
  1020.             sh,                /* The SrvHandle from SL_Open  */
  1021.             "http",            /* The service type desired    */
  1022.             "ENGINEERING",     /* The request's scope         */
  1023.             "HOME PAGES");     /* The attribute to return.    */
  1024.          if (pr->r_iErrorCode != SLP_OK) ; // do something better here
  1025.  
  1026.          /*
  1027.           * The client will examine the AttrResult and choose a HOME PAGE
  1028.           */
  1029.          SL_Free(&pr); /* free previous result */
  1030.          pr = SL_GetService(sh, "http/engineering/HOME PAGE ="
  1031.               "specs/index.html::Specs galore::"
  1032.                  "Technical specifications for the F.L.O.R.B. and X872"
  1033.                  "projects./");
  1034.  
  1035.          This will return a SL_Service with the URL:
  1036.  
  1037.             "service:http://myhost.sun.com"
  1038.  
  1039.          The application can append on the "specs/index.html" from the
  1040.          attribute to obtain a URL for the browser to use:
  1041.  
  1042.             "http://myhost.sun.com/specs/index.html"
  1043.  
  1044. 6.2. SLP API Java bindings
  1045.  
  1046.    The ServiceLocator is created using a 'singleton' interface.  This
  1047.    allows the implementation to keep track of state pertains to all
  1048.    instances of the class.  The AttributeResult provides the same
  1049.    information as the C interface, though in a different form.  The
  1050.    ServiceResult allows the creation of a Socket for immediate use of
  1051.    the application protocol.
  1052.  
  1053. 6.2.1. Class definitions
  1054.  
  1055.    public class AttributeResult {
  1056.      public static final int TYPE_STRING = 1;
  1057.  
  1058.  
  1059.  
  1060. Guttman                                                        [Page 18]
  1061.  
  1062. Internet Draft        An API for Service Location       25 November 1996
  1063.  
  1064.  
  1065.      public static final int TYPE_INT    = 2;
  1066.      public static final int TYPE_OPAQUE = 3;
  1067.      public static final int TYPE_BOOL   = 4;
  1068.  
  1069.      public int getType();
  1070.      public int getCharSet();
  1071.      public String getLanguage();
  1072.      public int getDialect();
  1073.  
  1074.      public Vector vAttributes;  // may have String, int, boolean or byte[]
  1075.    };
  1076.  
  1077.    public class ServiceResult {
  1078.      public String      sURL;
  1079.      public int         iLifetime;
  1080.      public InetAddress iaServiceAddress;
  1081.      public int         iPort;
  1082.    };
  1083.  
  1084.    public class ServiceLocator {
  1085.      // No Constructor
  1086.  
  1087.      // Constants
  1088.      public static final int CHAR_ASCII   = 3;
  1089.      public static final int CHAR_LATIN1  = 4;
  1090.      public static final int CHAR_UTF8    = 6;
  1091.  
  1092.      // Class Methods
  1093.      public static ServiceLocator getServiceLocator();
  1094.  
  1095.      // Instance Methods
  1096.      public String  getLanguage();    // default to "en" (English)
  1097.      public int     getsDialect();    // default to 0
  1098.      public boolean getMonolingual(); // default to true
  1099.      public int     getMaxWait();     // default to 10 (seconds)
  1100.      public boolean getMultiple();    // default to true
  1101.  
  1102.      public void    setLanguage(String sLanguage);
  1103.      public void    setDialect(int iDialect);
  1104.      public void    setMonolingual(boolean bMonolingual);
  1105.      public void    setMaxWait(int iMaxWait);
  1106.      public void    setMultiple(boolean iGetMultipleResults);
  1107.  
  1108.      public synchronized void SL_Register(
  1109.         String sURL,
  1110.         String sLanguage,
  1111.         int    iDialect,
  1112.         int    iCharType,
  1113.         String sAttributes[],
  1114.         int    iLifetime,
  1115.         int    iRefreshHint)
  1116.  
  1117.  
  1118.  
  1119. Guttman                                                        [Page 19]
  1120.  
  1121. Internet Draft        An API for Service Location       25 November 1996
  1122.  
  1123.  
  1124.         throws SLPException;
  1125.  
  1126.      public synchronized void SL_DeRegister(
  1127.         String sURL,
  1128.         String sLanguage,
  1129.         int    iDialect,
  1130.         int    iCharType,
  1131.         String sAttributes)
  1132.         throws SLPException;
  1133.  
  1134.      public synchronized String[] SL_GetScopes();
  1135.  
  1136.      public synchronized String[] SL_GetServiceTypes(
  1137.         String sNamingAuthority,
  1138.         String sScope)
  1139.         throws SLPException;
  1140.  
  1141.      public synchronized SL_ServiceResult SL_GetService(
  1142.         String sQuery)
  1143.         throws SLPException;
  1144.  
  1145.      public synchronized AttributeResult SL_GetAttrs(
  1146.         String sURL,
  1147.         String sScope,
  1148.         String sAttributeTags)
  1149.         throws SLPException;
  1150.  
  1151.      public synchronized AttributeResult SL_GetAttrs(
  1152.         String sServiceType,
  1153.         String sScope,
  1154.         String sAttributeTags)
  1155.         throws SLPException;
  1156.    };
  1157.  
  1158.    public class SLPException extends Exception {
  1159.      public SLPException();
  1160.      public SLPException(String s);
  1161.    };
  1162.  
  1163.    // Exceptions caused by error conditions detected due to
  1164.    //    interaction with remote SLP entities (SAs and DAs)
  1165.  
  1166.    public class SLPLanguageNotSupportedException extends SLPException {
  1167.      public SLPLanguageNotSupportedException();
  1168.      public SLPLanguageNotSupportedException(String s);
  1169.    };
  1170.  
  1171.    // Note:  This error should never occur.  It indicates a flawed
  1172.    //        underlying SLP implementation.  Hence, it is an error
  1173.    //        not an exception.
  1174.    public class SLPParseError extends Error {
  1175.  
  1176.  
  1177.  
  1178. Guttman                                                        [Page 20]
  1179.  
  1180. Internet Draft        An API for Service Location       25 November 1996
  1181.  
  1182.  
  1183.      public SLPParseException();
  1184.      public SLPParseException(String s);
  1185.    };
  1186.  
  1187.    public class SLPInvalidRegistrationException extends SLPExcpetion {
  1188.      public SLPInvalidRegistrationException();
  1189.      public SLPInvalidRegistrationException(String s);
  1190.    };
  1191.  
  1192.    public class SLPScopeNotSupportedException extends SLPException {
  1193.      public SLPScopeNotSupportedException();
  1194.      public SLPScopeNotSupportedException(String s);
  1195.    };
  1196.  
  1197.    public class SLPCharsetNotUnderstoodException {
  1198.      public SLPCharsetNotUnderstoodException();
  1199.      public SLPCharsetNotUnderstoodException(String s);
  1200.    };
  1201.  
  1202.    public class SLPAuthenticationException {
  1203.      public SLPAuthenticationException();
  1204.      public SLPAuthenticationException(String s);
  1205.    };
  1206.  
  1207.    // Exceptions caused by error conditions arising through
  1208.    //    the program's use of the API or failure of the SLP
  1209.    //    implementation.
  1210.  
  1211.    public class SLPNotSupportedYet extends SLPException {
  1212.      public SLPNotSupportedYet();
  1213.      public SLPNotSupportedYet(String s);
  1214.    };
  1215.  
  1216.    public class SLPTimeOutException extends SLPException {
  1217.      public SLPTimeOutException();
  1218.      public SLPTimeOutException(String s);
  1219.    };
  1220.  
  1221.    public class SLPInitNetException extends SLPException {
  1222.      public SLPInitNetException();
  1223.      public SLPInitNetException(String s);
  1224.    };
  1225.  
  1226.    // The 'message' SHOULD indicate which parameter was bad.
  1227.    public class SLPParameterBadException extends SLPException {
  1228.      public SLPParameterBadException();
  1229.      public SLPParameterBadException(String s);
  1230.    };
  1231.  
  1232.    public class SLPInternalNetError extends SLPException {
  1233.      public SLPInternalNetError();
  1234.  
  1235.  
  1236.  
  1237. Guttman                                                        [Page 21]
  1238.  
  1239. Internet Draft        An API for Service Location       25 November 1996
  1240.  
  1241.  
  1242.      public SLPInternalNetError(String s);
  1243.    };
  1244.  
  1245.    public class SLPInternalSystemError extends SLPException {
  1246.      public SLPInternalSystemError();
  1247.      public SLPInternalSystemError(String s);
  1248.    };
  1249.  
  1250. 6.2.2. Examples
  1251.  
  1252.    A simplest application is: A server of type blah makes a service
  1253.    advertisement:
  1254.  
  1255.       ServiceLocator sl = ServiceLocator.getServiceLocator();
  1256.       sl.SL_Register("service:blah://myhost.sun.com", // service URL.
  1257.                      "en", 0,         // Attributes is in English.
  1258.                      "(SCOPE=ADMIN)", // The attribute.
  1259.                      CHAR_ASCII,      // Attribute uses ASCII.
  1260.                      -1);             // Continual registration.
  1261.  
  1262.    A blah client system can discover this with the following:
  1263.  
  1264.       try {
  1265.         ServiceLocator sl = ServiceLocator.getServiceLocator();
  1266.         ServiceResult  sr = sl.SL_GetService("blah/admin//");
  1267.       catch (SLPException) ; // do something better here
  1268.       try Socket         s  = new Socket(sr.iaServiceAddress, sr.iPort);
  1269.       catch (IOException)  ; // do something better here
  1270.  
  1271.       // ... now use s to do blah client-server stuff ...
  1272.  
  1273.    Note that the scope matching is case insensitive.  The query string
  1274.    is omitted, so the request will return all blah services.  The client
  1275.    may then proceed to use the blah service, simply by creating a socket
  1276.    from the information in the ServiceResult.
  1277.  
  1278. 6.3. Syntax for string parameters
  1279.  
  1280.    The definitions which follow are cumulative.   The syntax is
  1281.    specified using Augmented BNF [ABNF].  There are some rules which
  1282.    specify explicitely what characters are NOT permitted.
  1283.  
  1284.    For the syntax of the service: URL, see [SRV].
  1285.  
  1286. 6.3.1. Query Syntax
  1287.  
  1288.    This is used in SL_GetService (See Section 3.7.)
  1289.  
  1290.    A Query may take two forms.
  1291.  
  1292.       white = SPACE / TAB / CR / LF
  1293.  
  1294.  
  1295.  
  1296. Guttman                                                        [Page 22]
  1297.  
  1298. Internet Draft        An API for Service Location       25 November 1996
  1299.  
  1300.  
  1301.       query = listquery /         ; conjunction query
  1302.               generalquery /      ; complex query
  1303.               *white              ; ie. the query matches everything
  1304.  
  1305.    These are defined in the next sections.  The list-query is a very
  1306.    simple form.  The general-query allows arbitrarily complex logical
  1307.    combinations of conditions.
  1308.  
  1309.    Common syntax to both kinds of queries follows:
  1310.  
  1311.       predicate   = srvtype [ "." na ] "/" scope "/" query "/"
  1312.  
  1313.       schemechar  = ALPHA / "+" / "-"
  1314.       srvtype     = schemechar
  1315.       na          = schemechar
  1316.                       ; omit na when it is "IANA", the default
  1317.  
  1318.       scope       = ; Any string with the following restrictions:
  1319.                     ; "/", ",", and ":" are not allowed in this
  1320.                     ; string. "LOCAL" and "REMOTE" scope strings are
  1321.                     ; reserved.
  1322.  
  1323.       safe-char   = ; Any character with the following restrictions:
  1324.                     ; "(", ")", ",", "=", "!", ">", "<", "/", "*"
  1325.                     ; are not allowed.
  1326.       attr-tag    = 1*safe-char
  1327.  
  1328.       safer-char  = ; As safe-char but SPACE is also not allowed.
  1329.       keyword     = 1*safer-char
  1330.  
  1331.       query-item  =  keyword / attr-tag comp-op value
  1332.  
  1333.       comp-op     = "!=" / "==" / "<" / "<=" / ">" / ">="
  1334.  
  1335.       value      =  string / integer / boolean / opaque
  1336.  
  1337.       string     =  1*safe-char
  1338.  
  1339.       integer    =  [-] 1*DIGIT
  1340.                       ; The integer MUST fall within the range of
  1341.                       ; values a 32 bit integer may take, ie.
  1342.                       ; "-2147483648" to "2147483647".
  1343.  
  1344.       boolean    =  "TRUE" / "FALSE"
  1345.                       ; These values are the only exception to the
  1346.                       ; Internationalization rules in Section 8.0.
  1347.                       ; Independent of the translation of the
  1348.                       ; attributes, the boolean values remain the
  1349.                       ; indicated strings.
  1350.  
  1351.       rad64-char =  ALPHA / DIGIT / "+" / "-" / white-sp
  1352.  
  1353.  
  1354.  
  1355. Guttman                                                        [Page 23]
  1356.  
  1357. Internet Draft        An API for Service Location       25 November 1996
  1358.  
  1359.  
  1360.       opaque     =  1*DIGIT ":" 4*rad64-char
  1361.                       ; The digits define the original length of the
  1362.                       ; opaque value. The restricted character string
  1363.                       ; is the radix-64 encoding of the opaque value.
  1364.                       ; See [RFC 1521], Section 5.2.
  1365.  
  1366.                       ; NOTE:  White space is ignored in decoding
  1367.                       ; radix-64 values.
  1368.  
  1369.    Note on the use of white space:
  1370.  
  1371.    A string is considered to be a token in the case of a tag or <string>
  1372.    value.  In this case, the string is 'trimmed'.  White space interior
  1373.    to a string token is left alone, while white space between the tokens
  1374.    is removed.  For example:
  1375.  
  1376.          "  some  name  =  some  value , another  example "
  1377.  
  1378.       would be trimmed to
  1379.  
  1380.          "some  name" "=" "some  value" and "another  example".
  1381.  
  1382.    Note on string matching:
  1383.  
  1384.    Attribute tags and values may be used by some protocols for directory
  1385.    look-up.  In this case, the following rules should be applied for
  1386.    string matching of attribute strings.
  1387.  
  1388.    String matching MUST be done after character escape encoding has been
  1389.    removed, white space has been trimmed.  In addition, string matching
  1390.    SHOULD be case insensitive.
  1391.  
  1392. 6.3.1.1. List Query Syntax
  1393.  
  1394.       list-query = 1#query-item
  1395.  
  1396. 6.3.1.2. General Query Syntax
  1397.  
  1398.       general-query   = "(" "&" general-query query-item-list ")" /
  1399.                         "(" "|" general-query query-item-list ")" /
  1400.                         "(" query-item ")"
  1401.  
  1402.       query-item-list = general-query /
  1403.                         general-query query-item-list
  1404.  
  1405.  
  1406. 6.3.2. Attribute Registration List
  1407.  
  1408.    This is used in SL_Register (See Section 3.3.)
  1409.  
  1410.       attr-reg-list = 1#attr-reg
  1411.  
  1412.  
  1413.  
  1414. Guttman                                                        [Page 24]
  1415.  
  1416. Internet Draft        An API for Service Location       25 November 1996
  1417.  
  1418.  
  1419.       attr-reg      = keyword / "(" attr-tag = 1#value ")
  1420.  
  1421. 6.3.3. Attribute Deregistration List
  1422.  
  1423.    This is used in SL_DeRegister (See Section 3.4.)
  1424.  
  1425.       attr-dereg-list = 1#attr-dereg
  1426.       attr-dereg      = keyword / attr-tag
  1427.  
  1428. 6.3.4. Attribute Selection List Syntax
  1429.  
  1430.    This is used in SL_GetAttrs (See Section 3.8.)
  1431.  
  1432.       attr_select_list = 1#attr-select
  1433.       attr_select      = keyword / attr-tag / partial-tag
  1434.       partial_tag      = 1*safe-char "*"
  1435.  
  1436. 6.4. Interpretation of SLP error values
  1437.  
  1438.    The following errors occur as a result of interaction between SLP
  1439.    entities:
  1440.  
  1441.    SLP_LANG_NOT_SUPPORTED
  1442.  
  1443.     A request was made in a language not supported by a DA.  If the
  1444.     request could be handled by the DA in a language other than the
  1445.     requested one, it will do so.  The UA may explicitely declare itself
  1446.     to be monolingual, in which case the absense of service
  1447.     advertisement information in the requested language will elicit this
  1448.     error.
  1449.  
  1450.    SLP_PROTOCOL_PARSE_ERR
  1451.  
  1452.     The internal implementation of SLP created a SLP message which was
  1453.     rejected by a remote SLP entity.
  1454.  
  1455.    SLP_INVALID_REGISTRATION
  1456.  
  1457.     The service advertisement created with SL_Register was rejected by a
  1458.     DA.  This is due to a malformed URL or attributes.
  1459.  
  1460.    SLP_SCOPE_NOT_SUPPORTED
  1461.  
  1462.     A DA will return this error code if a UA or SA sends a request or
  1463.     registration lacking its configured scope.  Note that DAs without a
  1464.     Scope never issue this error.
  1465.  
  1466.    SLP_CHARSET_NOT_UNDERSTOOD
  1467.  
  1468.     DAs and SAs have string storage, comparison, copying and other
  1469.     capabilities in only a narrow range of character sets.  Thus
  1470.  
  1471.  
  1472.  
  1473. Guttman                                                        [Page 25]
  1474.  
  1475. Internet Draft        An API for Service Location       25 November 1996
  1476.  
  1477.  
  1478.     requests or registrations in unsupported character sets will illicit
  1479.     this error.  SLP messages using US-ASCII will always be supported.
  1480.  
  1481.    SLP_AUTHENTICATION_INVALID
  1482.  
  1483.     If the SLP framework supports authentication, this error will arise
  1484.     when a remote DA fails to accept a registration.  This error will
  1485.     not occur if a UA rejects a reply to a request:  The UA will simply
  1486.     silently discard (and possibly log) the rejected reply.
  1487.  
  1488.    The following errors are generated through a program interacting with
  1489.    the API and SLP implementation.  They also indicated internal
  1490.    failures which are not fatal.
  1491.  
  1492.    SLP_NOT_SUPPORTED_YET
  1493.  
  1494.     When a particular feature is used which is not implemented in the
  1495.     API, this error is returned.  This error SHOULD not occur.
  1496.  
  1497.    SLP_REQUEST_TIMED_OUT
  1498.  
  1499.     When no reply can be obtained in the time specified by the
  1500.     configured timeout interval, this error is returned instead.
  1501.  
  1502.    SLP_COULD_NOT_INIT_NET_RESOURCES
  1503.  
  1504.     If the SLP framework cannot initialize properly, this error will be
  1505.     returned.
  1506.  
  1507.    SLP_COULD_NOT_ALLOCATE_MEMORY
  1508.  
  1509.     If the API or SLP implementation fails to allocate memory, the
  1510.     operation is aborted and returns this.
  1511.  
  1512.    SLP_PARAMETER_BAD
  1513.  
  1514.     If a parameter passed into an interface is bad, this error is
  1515.     returned.
  1516.  
  1517.    SLP_INTERNAL_NET_ERROR
  1518.  
  1519.     The failure of networking during normal operations causes this error
  1520.     to be returned.
  1521.  
  1522.    SLP_INTERNAL_SYSTEM_ERROR
  1523.  
  1524.     A basic failure of the SLP implementation causes this error to be
  1525.     returned.  This occurs when a system call or library fails.  The
  1526.     operation could not recover.
  1527.  
  1528. 7. Security Considerations
  1529.  
  1530.  
  1531.  
  1532. Guttman                                                        [Page 26]
  1533.  
  1534. Internet Draft        An API for Service Location       25 November 1996
  1535.  
  1536.  
  1537.     SLP will make use of an existing host based authentication framework
  1538.     once it becomes available as an Internet Standard.  [RFC1825]
  1539.  
  1540.     In the absense of this, it is extremely easy for anyone to register
  1541.     any service with Service Location.  SLP does not authenticate the
  1542.     source of service advertisements, either at the DA or when the UA
  1543.     receives it.
  1544.  
  1545.     For this reason, use of SLP on open networks, such as the internet,
  1546.     should be avoided.  A DA may be provided on an open network with
  1547.     registration capabilities disabled; but this is of limited utility
  1548.     since a UA would not  be able to distinguish it from a DA full of
  1549.     impersonations.
  1550.  
  1551.     For this reason, SLP should only be used in 'private' networks, as
  1552.     those behind firewalls where  users are expected to perform in a
  1553.     responsible manner.
  1554.  
  1555.     SLP is neutral to the protocols clients and servers use between
  1556.     themselves.  Strong bidirectional authentication at higher levels
  1557.     (ie. transport level: "The SSL Protocol, Version 3" [SSH] or
  1558.     application level: "Generic Security Service Application Program
  1559.     Interface" [GSSAPI],) would obviate the risk of masquerading by an
  1560.     adversary using SLP.
  1561.  
  1562.     An adversary could delete valid service advertisements and deny UAs
  1563.     knowledge of existing services.
  1564.  
  1565. 8. Internationalization Considerations
  1566.  
  1567.     The service: URL itself must be encoded using the rules set forth in
  1568.     [RFC1738].  The character set encoding is limited to specific ranges
  1569.     within the US-ASCII character set [ASCII].
  1570.  
  1571.     The attribute information associated with the service: URL may be
  1572.     expressed in any character set, and in any language.
  1573.  
  1574. 8.1. Character Set identification and use
  1575.  
  1576.     The way of identifying the character set used is the IANA Character
  1577.     Set registry MIB Enum value. [CHAR-REG]
  1578.  
  1579.     It can be assumed that US-ASCII [ASCII] will be supported.  Programs
  1580.     which register or request information using other character sets
  1581.     must be prepared for the possibility that the SLP framework is not
  1582.     capable of supporting it.  In this case, they should fall back to
  1583.     US-ASCII if possible.
  1584.  
  1585. 8.2. Language identification and translation
  1586.  
  1587.     The language used in attribute string should be identified using a
  1588.  
  1589.  
  1590.  
  1591. Guttman                                                        [Page 27]
  1592.  
  1593. Internet Draft        An API for Service Location       25 November 1996
  1594.  
  1595.  
  1596.     Language tag as defined by [ISO-639].
  1597.  
  1598.     A program registering a service should use the strings provided in
  1599.     the Service Type template which defines the range of standard
  1600.     values.  If this document provides translations to other languages,
  1601.     the service advertisement should be made in each.
  1602.  
  1603.     If however no translation exists, or there is no standardized
  1604.     Service Type template, translation may still be provided on a "best
  1605.     effort" basis.
  1606.  
  1607.     A service advertisement is made in multiple languages, one after the
  1608.     other.  The same information is registered using SL_Register, though
  1609.     the Language tag differs and the strings are translated.  Many
  1610.     attribute strings are 'literal' and will not be translated.  See
  1611.     [SRV] for details.
  1612.  
  1613. 9. Bibliography
  1614.  
  1615.     [ABNF]      D. Crocker, "Augmented BNF for Syntax Specifications:
  1616.                 ABNF", Work in progress, November 1996.
  1617.  
  1618.     [ASCII]     "Coded Character Set -- 7-bit American Standard code
  1619.                 for Information Interchange", ANSI X3.4-1986.
  1620.  
  1621.     [CHAR-REG]  IANA Character Set registry, <URL:http://www.isi.edu
  1622.                 /in-notes/iana/assignments/character-sets>.
  1623.  
  1624.     [GSSAPI]    J. Linn, "Generic Security Service Application Program
  1625.                 Interface", RFC 1508, September 1993.  Also:
  1626.                 J. Linn, "Generic Security Service Application Program
  1627.                 Interface, Version 2", A work in progress,
  1628.                 November 1996.
  1629.  
  1630.     [RFC1825]   R. Atkinson, "Security Architecture for the Internet
  1631.                 Protocol", RFC 1825,  July 1995.
  1632.  
  1633.     [SSH]       A. Freier, P. Karlton, P. Kocher, "The SSL Protocol,
  1634.                 Version 3.0", A work in progress, November 1996.
  1635.  
  1636.     [SLP]       J. Veizades, E. Guttman, C. Perkins & S. Kaplan,
  1637.                 Service Location Protocol", Work in progress,
  1638.                 November 1996.
  1639.  
  1640.     [SRV]       E. Guttman, "The service: URL Scheme", Work in
  1641.                 progress, November 1996.
  1642.  
  1643.     [ISO-639]   This standard is provided as Appendix A of [SLP].
  1644.  
  1645.  
  1646. 10. Author's Address
  1647.  
  1648.  
  1649.  
  1650. Guttman                                                        [Page 28]
  1651.  
  1652. Internet Draft        An API for Service Location       25 November 1996
  1653.  
  1654.  
  1655.           Erik Guttman
  1656.  
  1657.           Sun Microsystems, Inc.
  1658.           Gaisbergstr. 6
  1659.           D-69115 Heidelberg
  1660.           Germany
  1661.  
  1662.           Phone: +1 415 336 6697
  1663.           email: Erik.Guttman@eng.sun.com
  1664.  
  1665.  
  1666.        This memo expires on May 25, 1997
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709. Guttman                                                        [Page 29]
  1710.  
  1711.  
  1712.