SLP Service Browser

Introduction

The SLP Service Browser (SSB) provides a graphical front-end to the SLP-aware services on the local network. It allows the user to perform parameterized searches, browse, and modify the configuration of the local machine.

This document is divided into a number of sections:

Use
Information on starting and basic use of the SSB.
Configuration
Modifying SSB's configuration.
Extending
The internal architecture of the SSB, and changing it.
Further Resources
Information on SLP.

Use

Starting

SSB is currently launched with:
$ ./browse
in its home directory.

A number of command-line parameters are available:
None of these are implemented.

-s[how] or --select[how]
Allows single selection of service. When a service is selected in the All or Type pages, it is printed to the process's STDOUT and SSB immediately exits.

The optional how specifies how the URL should be displayed. See URL Display for parameters.

For example:

$ ping 'SSB -s%h'

would ping the host of the selected service.

-t {type} or --type {type}
Start immediately with a search given by type.
--scope {scope_list}
Use scope_list as the scope for searches.
-p{pred_string} or --query{pred_string}
Use pred_string as the query parameters for the starting query.
-[number]
Prevents the GUI from being launched, and causes the browser to immediately exit on the receipt of number of responses. Each response is printed to STDOUT.

If no response is received, 1 is returned, otherwise 0 is returned.

-n or --nogui
Prevents the GUI from being launched. If no query is given, a list of all services is printed to STDOUT and SSB quits. If a query is given, SSB performs that query and then quits.
-w{integer} or --wait {integer}
The "maximum" time to wait while doing a search. integer is the wait time in seconds.
-v or --version
Display the version and immediately exit. GUI is not launched.

Using the GUI

Running in GUI mode is straight-forward. On startup, you are presented with three pages in a dialog: "Type", "Attr", and "All".

The Type Page

The contents of the Type page allow you to search for a service you already know the name of. Select the service type in the combo-box and fire Request away. The other two fields are not yet supported.

When (if) results return, they will appear in the table below. To run a command, right-click on the listed service and select the available command.

The Attr Page

Select a service from the list of known services and click on it (or hit space/return). The attributes (if there are any) will appear in the window below.

The Refresh button doesn't do anything.

The All Page

Right now, it falls in the "useless" category.

Configuration

Configuration in SSB is (currently) done in only one file: the data file in the directory it is run in.

Basic Syntax

The data file contains records of the form:

[service:type]
name=
icon=
command=

The type is declared in the leading open square brackets (retro Windows .INI style =). The following "name" field defines the name to be used for that type (ie, the human readable type). The "icon" field is a path to a .xpm to use as the type's mini-icon. The "command" field declares one or more commands that are to be made available when the user right-clicks on a service of this type.

A field ends at the first new-line encountered.

There are three additional constructs that enable snazzy stuff to be done:

Comments
Comments are delimited by a '#' at the start of a line. If any non-whitespace character precedes the #, the line is not a comment.

# This is a comment

name=Bob # This is NOT a comment

Quotes
Certain kinds of lines (currently only command lines) are broken into subfields. Fields break either on white space or on quotations ('"'s).

Quotes cannot be escaped.

@-Lines
@-lines (pronounced "at-lines") allow a field to continue on after a newline. To use an @-line, stick a '@' at the start of a line. An @-line must be preceded by a field.


			[service:printer:ipp]
			command=command text
				@ more text
				@ and some more!
			
Is the same as:

			[service:printer:ipp]
			command=command text  more text  and some more!
			

If you put an @-line in a bad place, SSB will complain. It will tell you the location of the offending @-line.

Declaring Commands

Commands allow scripted functionality to be attached to a type. Commands can be activated by right-clicking on a service in the SSB. (Currently only in the "Type" page).

In the configuration file, the command field is broken into a number of subfields (see Quote above to see where the breaks occur). A set of subfields starts with a Command-Type (which is a word followed by a colon). Depending on the Command-Type, a certain number of subfields must follow. At the end of those fields there must be another Command-Type or the command must end.

The script Command Type

Currently, the only supported Command-Type is the script. A script tells the SSB to run an executable. The script requires three following subfields:
  1. The first is the text to be shown in the right-click menu.
  2. The second is blank, as it is currently unsupported. It will be a reference to a script to run before the menu item is displayed, to determine if the command can be executed (due to file permissions or other problems).
  3. The third is a command-line to execute when this command is selected in the menu. It may contain Variable References.

For example:


[service:printer:ipp]
name=Printer
icon=./img/printer.xpm
command= 
        @script: "Install Printer" "" "./scripts/add_cups_printer ${attr:printer-name} ${url:url_minus_service} ${attr:printer-location} ${attr:printer-info}"
        @script: "Remove Printer" "" "./scripts/remove_cups_printer ${attr:printer-name}"

The above has two commands (prefixed by script, and a colon). Notice that attributes and URL-fields are referenced.

Variable References

It is possible to reference attributes and url-fields in certain parts of the configuration files. This is done with a reference syntax, namely:

${(url|attr):reference}

URL References

URL references are of the form:

${url:reference}

The available variables are:

${url:all}
The entire service URL, as returned from SA/DA.
${url:url_minus_service}
The entire service URL, minus the leading "service" (if there is one).
There should really be others, but they have yet to be implemented.

Attribute References

Attribute references reference an attribute the service is advertising. Attribute references are of the form:

${attr:reference}

The text that follows the ':' depends entirely on the type. Look in the service's template for examples.

Extending

Umm... This will be written later. If anyone has an overwhelming need to work on this, mail me.

Further Resources

The following is a list of resources that were useful when I was writing SSB. For those who wish to modify/extend SSB, the following will probably be useful.

SLP

The SLPv2 protocol is described in RFC 2608. The standard API is described in RFC 2614. Budding template authors will want to consult RFC 2609 for the skinny on that valiant task.

A number of SLP implementations exist: OpenSLP (which SSB uses), the Sun SLP implementation can be found at http://www.sun.com/research/slp. The SLP working group can be found at srvloc.org.

A less out of date list can be found at the SSB home page.

Gtk

The Gtk docs can be found at Gtk.