tr064

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

README

Go module for TR-064 service access

GoDoc Build Coverage Go Report Card

License

This project is subject to the the Apache License, Version 2.0. See LICENSE information for details.

Documentation

Index

Constants

View Source
const XMLEncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"

XMLEncodingStyle defines the XML encoding to use for SOAP calls.

View Source
const XMLNameSpace = "http://schemas.xmlsoap.org/soap/envelope/"

XMLNameSpace defines the XML namespace to use for SOAP calls.

Variables

View Source
var ErrDocNotFound = errors.New("document not found")

ErrDocNotFound indicates a specification document was not found.

Functions

func Generate

func Generate(baseUrl *url.URL, spec ServiceSpec, dir string)

Generate generates Go code suitable for invoking the services defined in the given specification.

The base URL points towards the device providing the service. The spec argument defines the specification use for code generation. The code is generated within the given directory. Already existing files are overwritten without notice.

Types

type Client

type Client struct {
	// Url defines the URL to access the TR-064 server.
	DeviceUrl *url.URL
	// Username is set to the login to use for accessing restricted services.
	Username string
	// Password is set to the password to use for accessing restricted services.
	Password string
	// Timeout sets the timeout for HTTP(S) communication.
	Timeout time.Duration
	// TlsConfig defines the TLS options to use for HTTPS communication. May be nil.
	TlsConfig *tls.Config
	// Debug enables debug logging while accessing the TR-064 server.
	Debug bool
	// contains filtered or unexported fields
}

Client provides the necessary parameters to access a TR-064 capable server and perform service discovery.

To access an actual service, this client as well as the desired service descriptor is combined into a service specific service client:

client := tr064.NewClient(deviceUrl)
services, _ := client.ServicesByName(tr064.DefaultServiceSpec, deviceinfo.ServiceName)
serviceClient := deviceinfo.ServiceClient {
	TR064Client: client,
	Service:     services[0],
}
info := &deviceinfo.GetInfoResponse{}
_ = serviceClient.GetInfo(info)

The service client is then used to access the individual service functions.

func NewClient

func NewClient(deviceUrl *url.URL) *Client

NewClient instantiates a new TR-064 client for accessing the given URL.

If the given URL contains a user info, the contained username and password are automatically used for authentication.

func (*Client) Get added in v0.1.6

func (client *Client) Get(ref string) (*http.Response, error)

Get performs a simple GET request towards the TR-064 server using the given path reference.

func (*Client) InvokeService

func (client *Client) InvokeService(service ServiceDescriptor, actionName, in any, out any) error

InvokeService invokes the SOAP service identifed via the given service descriptor using the given input and output objects.

If needed, the function performs the required authentication using the client's username and password attributes.

func (*Client) Services

func (client *Client) Services(spec ServiceSpec) ([]ServiceDescriptor, error)

Services fetches and parses the given specification and returns the defined services.

func (*Client) ServicesByType added in v0.1.4

func (client *Client) ServicesByType(spec ServiceSpec, serviceType string) ([]ServiceDescriptor, error)

ServicesByType fetches and parses the TR-064 server's service specifications like [Services], but returns only the services matching service type.

type SOAPRequest

type SOAPRequest[T any] struct {
	XMLName          xml.Name `xml:"s:Envelope"`
	XMLNameSpace     string   `xml:"xmlns:s,attr"`
	XMLEncodingStyle string   `xml:"s:encodingStyle,attr"`
	Body             *SOAPRequestBody[T]
}

SOAPRequest defines XML based SOAP request object.

func NewSOAPRequest added in v0.1.3

func NewSOAPRequest[T any](in *T) *SOAPRequest[T]

NewSOAPRequest constructs a new SOAP request object wrapping the given input argument. The constructed SOAP request is suitable for invoking Client.InvokeService

type SOAPRequestBody

type SOAPRequestBody[T any] struct {
	XMLName xml.Name `xml:"s:Body"`
	In      *T
}

SOAPRequestBody defines the Body element for a SOAP request.

type SOAPResponse

type SOAPResponse[T any] struct {
	XMLName xml.Name `xml:"Envelope"`
	Body    *SOAPResponseBody[T]
}

SOAPResponse defines XML based SOAP response object.

func NewSOAPResponse added in v0.1.3

func NewSOAPResponse[T any](out *T) *SOAPResponse[T]

NewSOAPResponse constructs a new SOAP response object wrapping the given output argument. The constructed SOAP response is suitable for invoking Client.InvokeService

type SOAPResponseBody

type SOAPResponseBody[T any] struct {
	XMLName xml.Name `xml:"Body"`
	Out     *T
}

SOAPResponseBody defines the Body element for a SOAP response.

type ServiceDescriptor

type ServiceDescriptor interface {
	// Spec returns the TR-064 specification describing this service.
	Spec() ServiceSpec
	// Type returns the full service type as defined in the specification document.
	Type() string
	// ShortType returns the short type name of this service.
	ShortType() string
	// Id returns the full service id as defined in the specification document.
	Id() string
	// ShortId returns the short id of this service.
	ShortId() string
	// ControlUrl returns the control URL to use for accessing this service.
	ControlUrl() string
}

ServiceDescriptor represents a concrete service provided by a TR-064 server.

The available services of a TR-064 server are determined by calling Client.Services. Via Client.InvokeService a identified service can be invoked. The latter is normally not used directly. Instead the generated ServiceClient for the service is instantiated and invoked. See Client for further details.

type ServiceSpec added in v0.1.4

type ServiceSpec string

ServiceSpec represents a well-known TR-064 specification document.

const (
	// DefaultServiceSpec defines the default TR-064 specification to be assumed available for
	// any TR-064 capabable device.
	DefaultServiceSpec ServiceSpec = "tr64desc"
	// IgdServiceSpec defines the TR-064 specification of Internet-Gateway-Devices (e.g. router).
	IgdServiceSpec ServiceSpec = "igddesc"
)

func (ServiceSpec) Name added in v0.1.4

func (spec ServiceSpec) Name() string

Name gets the specification name.

func (ServiceSpec) Path added in v0.1.4

func (spec ServiceSpec) Path() string

Path gets the specification path relative to the device URL.

type StaticServiceDescriptor

type StaticServiceDescriptor struct {
	// ServiceSpec receives the TR-064 specification this service is normally defined in.
	ServiceSpec ServiceSpec
	// ServiceType receives the full service type of the service.
	ServiceType string
	// ServiceId receives the full service id of the service.
	ServiceId string
	// ServiceControlUrl receives the URL to use for accessing the service.
	ServiceControlUrl string
}

StaticServiceDescriptor represents a statically defined ServiceDescriptor.

Normally a service should be identified dynamically by calling Client.ServicesByType. In case the presence of a service is well-known, this static descriptor can be used.

func (*StaticServiceDescriptor) ControlUrl added in v0.1.10

func (service *StaticServiceDescriptor) ControlUrl() string

ControlUrl returns the control URL to use for accessing this service.

func (*StaticServiceDescriptor) Id

func (service *StaticServiceDescriptor) Id() string

Id returns the full service id as defined in the specification document.

func (*StaticServiceDescriptor) ShortId added in v0.1.10

func (service *StaticServiceDescriptor) ShortId() string

ShortId returns the short id of this service.

func (*StaticServiceDescriptor) ShortType added in v0.1.4

func (service *StaticServiceDescriptor) ShortType() string

ShortType returns the short type name of this service.

func (*StaticServiceDescriptor) Spec added in v0.1.4

func (service *StaticServiceDescriptor) Spec() ServiceSpec

Spec returns the TR-064 specification describing this service.

func (*StaticServiceDescriptor) Type

func (service *StaticServiceDescriptor) Type() string

Type returns the full service type as defined in the specification document.

type WalkServiceFunc

type WalkServiceFunc func(*serviceDoc, *scpdDoc) error

Directories

Path Synopsis
services
igddesc/igd2ipv6fwc
generated from spec version: 1.0
generated from spec version: 1.0
igddesc/igdconn
generated from spec version: 1.0
generated from spec version: 1.0
igddesc/igddsl
generated from spec version: 1.0
generated from spec version: 1.0
igddesc/igdicfg
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/deviceconfig
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/deviceinfo
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/ethifconfig
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/hosts
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/lanconfigsecurity
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/lanhostconfigmgm
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/layer3forwarding
generated from spec version: 1.0
generated from spec version: 1.0
tr64desc/mgmsrv
generated from spec version: 1.0
generated from spec version: 1.0
Time
tr64desc/userif
UserInterface
UserInterface
tr64desc/wancommonifconfig
WANCommonInterfaceConfig
WANCommonInterfaceConfig
tr64desc/wandslifconfig
WANDSLInterfaceConfig
WANDSLInterfaceConfig
tr64desc/wandsllinkconfig
WANDSLLinkConfig
WANDSLLinkConfig
tr64desc/wanethlinkconfig
WANEthernetLinkConfig
WANEthernetLinkConfig
tr64desc/wanipconn
WANIPConnection
WANIPConnection
tr64desc/wanpppconn
WANPPPConnection
WANPPPConnection
tr64desc/wlanconfig
WLANConfiguration
WLANConfiguration
tr64desc/x_appsetup
X_AVM_DE_AppSetup
X_AVM_DE_AppSetup
tr64desc/x_auth
X_AVM_DE_Auth
X_AVM_DE_Auth
tr64desc/x_contact
X_AVM_DE_OnTel
X_AVM_DE_OnTel
tr64desc/x_dect
X_AVM_DE_Dect
X_AVM_DE_Dect
tr64desc/x_filelinks
X_AVM_DE_Filelinks
X_AVM_DE_Filelinks
tr64desc/x_homeauto
X_AVM_DE_Homeauto
X_AVM_DE_Homeauto
tr64desc/x_homeplug
X_AVM_DE_Homeplug
X_AVM_DE_Homeplug
tr64desc/x_hostfilter
X_AVM_DE_HostFilter
X_AVM_DE_HostFilter
tr64desc/x_myfritz
X_AVM_DE_MyFritz
X_AVM_DE_MyFritz
tr64desc/x_remote
X_AVM_DE_RemoteAccess
X_AVM_DE_RemoteAccess
tr64desc/x_speedtest
X_AVM_DE_Speedtest
X_AVM_DE_Speedtest
tr64desc/x_storage
X_AVM_DE_Storage
X_AVM_DE_Storage
tr64desc/x_tam
X_AVM_DE_TAM
X_AVM_DE_TAM
tr64desc/x_upnp
X_AVM_DE_UPnP
X_AVM_DE_UPnP
tr64desc/x_uspcontroller
X_AVM_DE_USPController
X_AVM_DE_USPController
X_VoIP
tr64desc/x_wanmobileconn
X_AVM_DE_WANMobileConnection
X_AVM_DE_WANMobileConnection
tr64desc/x_webdav
X_AVM_DE_WebDAVClient
X_AVM_DE_WebDAVClient

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL