cl-slp

https://github.com/fjames86/cl-slp.git

git clone 'https://github.com/fjames86/cl-slp.git'

(ql:quickload :cl-slp)
3

CL-SLP

Common Lisp CFFI bindings to the OpenSLP library. Used for discovering and advertising services over the Service Location Protocol (SLP).

CL-SLP uses the package nickname SLP.

Usage

CL-SLP just wraps the OpenSLP functions, see http://www.openslp.org/doc/html/ProgrammersGuide/index.html for the official API reference.

Before loading the library, ensure your libslp.so (unix) or slp.dll (windows) library is available to be loaded on your system. CL-SLP automatically pushes “C:/program files (x86)/OpenSLP/” onto foreign-library-directories which should enable it to be loaded on Windows.

Note that since SLP attributes map names to a list of values, this function accepts as input an assoc list that maps names to either atoms or lists, e.g. (slp-format-attributes '((:a . 123) (:b 321) (:c 123 456)) → “(A=123),(B=321),(C=123,456)”

Notes

The OpenSLP library makes extensive use of callbacks in its API. CL-SLP defines a default callback for each of the library calls, which it uses to collect return data. Users of CL-SLP may if they wish define their own callbacks using the macros DEFINE-SERVER-TYPE-CALLBACK, DEFINE-SERVER-URL-CALLBACK, DEFINE-ATTR-CALLBACK and DEFINE-REGISTER-CALLBACK.

They can be called by passing the name of the new callback with the :callback-name keyword parameter to the functions that take it.

The default callbacks should be sufficient for most needs because they just collect all the data available and return it to Lisp.

Note also that you MUST use a Lisp that supports callbacks; CL-SLP was developed and tested using SBCL on Ubuntu Linux and Windows 7.

All the callbacks take an optional argument, COOKIE, that is a pointer to an area of memory for use in return values. This doesn't make much sense in Common Lisp, since we have other ways of returning data from callbacks so it probably should be either ignored or removed from the Lisp calls.

API changes

In earlier versions of CL-SLP the functions FIND-SERVICES, FIND-ALL-SERVICES and FIND-SERVICE-TYPES were slightly misnamed as FIND-SERVERS, FIND-ALL-SERVERS and FIND-SERVER-TYPES. These functions remain but are now deprecated.

Example

;; Find service types
(slp:find-service-types)
-> ("service:wbem:https")

;; Find all servers
(slp:find-all-services)
-> ("service:wbem:https://localhost:5989")

;; Register a service 
(slp:register "service:myservice.x://localhost:8000" :attributes '((:num1 123) (:num2 321)))
-> T

;; Find services on the new service type
(slp:find-services "myservice.x")
-> ("service:myservice.x://localhost:8000")

;; Get attributes (try on a remote machine)
(slp:find-attributes "service:myservice.x://localhost:8000")
-> ((:NUM1 123) (:NUM2 321))

;; On a remote machine using slptool
;; $ slptool findattrs service:myservice.x://localhost:8000
;; (NUM1=123),(NUM2=321)

;; Deregister service
(slp:deregister "service:myservice.x://localhost:8000")
-> T

;; Check it has now gone
(slp:find-services "myservice.x")
-> NIL

Note that the OpenSLP daemon (slpd) must be running for register/deregister functions to work.

Frank James March 2014