Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
76 lines (55 sloc) 2.17 KB
#lang at-exp racket/base
;; For legal info, see file "info.rkt".
(require (planet neil/mcfly)
(doc (section "Introduction")
This is a Racket library for discovering, accessing and invoking
UPnP services.
This UPnP library currently only implements the client side, that
is the service consumer.
(doc (section "How it works")
First you must initiate a search with @racket[upnp-discovery] which will begin
to collect service advertisements via UDP, when you are ready you can
search for a UPnP service by service ID or type. Finally you create a
"service wrapper" from a UPnP service.
(define d (upnp-discovery))
(define s (upnp-search-service-srvid d "urn:upnp-org:serviceId:WANIPConn1"))
(define c (upnp-make-service-wrapper s))
With the service wrapper, you can create functions that wrap SOAP
request calls to the UPnP service:
(define get-external-ip
(c "GetExternalIPAddress" '("NewExternalIPAddress")))
(define add-port-mapping
(c "AddPortMapping" '()
"NewRemoteHost" "NewExternalPort" "NewProtocol"
"NewInternalPort" "NewInternalClient" "NewEnabled"
"NewPortMappingDescription" "NewLeaseDuration"))
And then use @racket[(get-external-ip)] to get the external ip, or use
@racket[(add-port-mapping ...)] with the parameters.
(doc (section "Known Issues")
At this moment, this library seems to work fine to grab an IP address on my
personal router :). This library is relatively new, so certain things might
not work quite right or might not work at all with different brands of
routers, other networking equipment and anything else that might provide UPnP
(doc history
(#:planet 1:0 #:date "2012-11-16"
"Initial release."))