Documentation ¶
Overview ¶
Package ssdp provides SSDP advertiser or so.
Index ¶
- Constants
- Variables
- func AnnounceAlive(nt, usn string, location interface{}, server string, maxAge int, ...) error
- func AnnounceBye(nt, usn, localAddr string) error
- func SetMulticastRecvAddrIPv4(addr string) error
- func SetMulticastSendAddrIPv4(addr string) error
- type Advertiser
- type AliveHandler
- type AliveMessage
- type ByeHandler
- type ByeMessage
- type LocationProvider
- type LocationProviderFunc
- type Monitor
- type SearchHandler
- type SearchMessage
- type Service
Constants ¶
const ( // All is a search type to search all services and devices. All = "ssdp:all" // RootDevice is a search type to search UPnP root devices. RootDevice = "upnp:rootdevice" )
Variables ¶
var Interfaces []net.Interface
Interfaces specify target interfaces to multicast. If no interfaces are specified, all interfaces will be used.
var Logger *log.Logger
Logger is default logger for SSDP module.
Functions ¶
func AnnounceAlive ¶
func AnnounceAlive(nt, usn string, location interface{}, server string, maxAge int, localAddr string) error
AnnounceAlive sends ssdp:alive message. location should be a string or a ssdp.LocationProvider.
func AnnounceBye ¶
AnnounceBye sends ssdp:byebye message.
func SetMulticastRecvAddrIPv4 ¶
SetMulticastRecvAddrIPv4 updates multicast address where to receive packets. This never fail now.
func SetMulticastSendAddrIPv4 ¶
SetMulticastSendAddrIPv4 updates a UDP address to send multicast packets. This never fail now.
Types ¶
type Advertiser ¶
type Advertiser struct {
// contains filtered or unexported fields
}
Advertiser is a server to advertise a service.
type AliveMessage ¶
type AliveMessage struct { // From is a sender of this message From net.Addr // Type is a property of "NT" Type string // USN is a property of "USN" USN string // Location is a property of "LOCATION" Location string // Server is a property of "SERVER" Server string // contains filtered or unexported fields }
AliveMessage represents SSDP's ssdp:alive message.
func (*AliveMessage) Header ¶
func (m *AliveMessage) Header() http.Header
Header returns all properties in alive message.
func (*AliveMessage) MaxAge ¶
func (m *AliveMessage) MaxAge() int
MaxAge extracts "max-age" value from "CACHE-CONTROL" property.
type ByeMessage ¶
type ByeMessage struct { // From is a sender of this message From net.Addr // Type is a property of "NT" Type string // USN is a property of "USN" USN string // contains filtered or unexported fields }
ByeMessage represents SSDP's ssdp:byebye message.
func (*ByeMessage) Header ¶
func (m *ByeMessage) Header() http.Header
Header returns all properties in bye message.
type LocationProvider ¶
type LocationProvider interface { // Location provides an address be reachable from the network located // by "from" address or "ifi" interface. // One of "from" or "ifi" must not be nil. Location(from net.Addr, ifi *net.Interface) string }
LocationProvider provides address for Location header which can be reached from "from" address network.
type LocationProviderFunc ¶
LocationProviderFunc type is an adapter to allow the use of ordinary functions are location providers.
type Monitor ¶
type Monitor struct { Alive AliveHandler Bye ByeHandler Search SearchHandler // contains filtered or unexported fields }
Monitor monitors SSDP's alive and byebye messages.
type SearchHandler ¶
type SearchHandler func(*SearchMessage)
SearchHandler is handler of Search message.
type SearchMessage ¶
SearchMessage represents SSDP's ssdp:discover message.
func (*SearchMessage) Header ¶
func (s *SearchMessage) Header() http.Header
Header returns all properties in search message.
type Service ¶
type Service struct { // Type is a property of "ST" Type string // USN is a property of "USN" USN string // Location is a property of "LOCATION" Location string // Server is a property of "SERVER" Server string // contains filtered or unexported fields }
Service is discovered service.