Documentation ¶
Overview ¶
Package ssdp implements the Simple Service Discovery Protocol (SSDP) as described in http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf.
Index ¶
- Constants
- type AdvertRedirector
- type ControlPoint
- func (cp *ControlPoint) Close() error
- func (cp *ControlPoint) GroupAddr() *net.UDPAddr
- func (cp *ControlPoint) Interfaces() []net.Interface
- func (cp *ControlPoint) MSearch(hdr http.Header, mifs []net.Interface, tmo time.Duration) ([]*http.Response, error)
- func (cp *ControlPoint) Serve(hdlr http.Handler) error
- type Device
- type Listener
- type RedirectHandler
- type Redirector
- type ResponseRedirector
Constants ¶
const ( DefaultIPv4Group = "239.255.255.250" DefaultIPv6LinkLocalGroup = "ff02::c" DefaultIPv6SiteLocalGroup = "ff05::c" // for unique local address, global unicast address DefaultPort = "1900" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvertRedirector ¶
type AdvertRedirector struct {
// contains filtered or unexported fields
}
An AdvertRedirector represents a SSDP advertisement message redirector.
func (*AdvertRedirector) ForwardPath ¶
func (rdr *AdvertRedirector) ForwardPath() *net.UDPAddr
ForwardPath returns the destination address of the SSDP advertisement message.
func (*AdvertRedirector) Header ¶
func (rdr *AdvertRedirector) Header() http.Header
Header returns the HTTP header map that will be sent by WriteTo method.
func (*AdvertRedirector) ReversePath ¶
func (rdr *AdvertRedirector) ReversePath() (*net.UDPAddr, *net.Interface)
ReversePath returns the source address and inbound interface of the SSDP advertisement message.
type ControlPoint ¶
type ControlPoint struct { // ErrorLog specified an optional logger for errors. If it is // nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // contains filtered or unexported fields }
A ControlPoint represents a SSDP control point.
func (*ControlPoint) GroupAddr ¶
func (cp *ControlPoint) GroupAddr() *net.UDPAddr
GroupAddr returns the joined group network address.
func (*ControlPoint) Interfaces ¶
func (cp *ControlPoint) Interfaces() []net.Interface
Interfaces returns a list of the joined multicast network interfaces.
func (*ControlPoint) MSearch ¶
func (cp *ControlPoint) MSearch(hdr http.Header, mifs []net.Interface, tmo time.Duration) ([]*http.Response, error)
MSearch issues a M-SEARCH SSDP message, takes a timeout and returns a list of responses. Callers should close each http.Response.Body when done reading from it. If mifs is nil, it tries to use all available multicast network interfaces.
type Device ¶
type Device struct { // ErrorLog specified an optional logger for errors. If it is // nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // contains filtered or unexported fields }
A Device represents a SSDP device.
func (*Device) Interfaces ¶
Interfaces returns a list of the joined multicast network interfaces.
type Listener ¶
type Listener struct { // Group specifies a group IP address of the multicast UDP // HTTP message exchange. if it is empty, DefaultIPv4Group // will be used. Group string // Port specifies a service port of the unicast and multicast // UDP HTTP message exchanges. If it is empty, DefaultPort // will be used. Port string // Port specifies a local listening port of the unicast and // multicast UDP HTTP message exchanges. If it is not empty, // the listener prefers LocalPort than Port. LocalPort string // Loopback sets whether transmitted multicast packets should // be copied and send back to the originator. MulticastLoopback bool }
A Listener represents a UDP multicast listener.
func (*Listener) ListenControlPoint ¶
func (ln *Listener) ListenControlPoint(mifs []net.Interface) (*ControlPoint, error)
ListenControlPoint listens on the UDP network Listener.Group and Listener.Port, and returns a control point. If mifs is nil, it tries to listen on all available multicast network interfaces.
func (*Listener) ListenDevice ¶
ListenDevice listens on the UDP network Listener.Group and Listener.Port, and returns a device. If mifs is nil, it tries to listen on all available multicast network interfaces.
func (*Listener) ListenRedirector ¶
func (ln *Listener) ListenRedirector(mifs []net.Interface) (*Redirector, error)
ListenRedirector listens on the UDP network Listener.Group and Listener.Port, and returns a redirector. If mifs is nil, it tries to listen on all available multicast network interfaces.
type RedirectHandler ¶
type RedirectHandler interface { // RedirectAdvert handles an inbound SSDP advertisement // message. RedirectAdvert(*AdvertRedirector) // RedirectResponse handles an inbound SSDP response message. RedirectResponse(*ResponseRedirector) }
A RedirectHandler represens a generic redirect handler.
type Redirector ¶
type Redirector struct { // ErrorLog specified an optional logger for errors. If it is // nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // contains filtered or unexported fields }
A Redirector represents a back-to-back SSDP entity.
func (*Redirector) GroupAddr ¶
func (rdr *Redirector) GroupAddr() *net.UDPAddr
GroupAddr returns the joined group network address.
func (*Redirector) Interfaces ¶
func (rdr *Redirector) Interfaces() []net.Interface
Interfaces returns a list of the joined multicast network interfaces.
func (*Redirector) Serve ¶
func (rdr *Redirector) Serve(hdlr RedirectHandler) error
Serve starts to handle incoming SSDP messages from either SSDP control points or SSDP devices. The handler must not be nil.
type ResponseRedirector ¶
type ResponseRedirector struct {
// contains filtered or unexported fields
}
A ResponseRedirector represents a SSDP response message redirector.
func (*ResponseRedirector) ForwardPath ¶
func (rdr *ResponseRedirector) ForwardPath() *net.UDPAddr
ForwardPath returns the destination address of the SSDP response message.
func (*ResponseRedirector) Header ¶
func (rdr *ResponseRedirector) Header() http.Header
Header returns the HTTP header map that will be sent by WriteTo method.
func (*ResponseRedirector) ReversePath ¶
func (rdr *ResponseRedirector) ReversePath() (*net.UDPAddr, *net.Interface)
ReversePath returns the source address and inbound interface of the SSDP response message.