Documentation
¶
Overview ¶
nolint:revive
Package rpc implements the TR-069 RPC (Remote Procedure Call) protocol, which is used for communication between Customer Premises Equipment (CPE) and Auto Configuration Servers (ACS). This package provides encoding and decoding functionalities for various TR-069 RPC messages, including Inform, GetRPCMethodsResponse, SetParameterValuesResponse, and more. It ensures proper XML formatting and namespace handling as per the TR-069 specifications. The package also includes support for generating fault responses and encoding messages with optional pretty-printing.
nolint:revive
nolint:revive
nolint:revive
Index ¶
- Constants
- func ArrayType(typ string, size int) string
- func SupportedMethods() []string
- func XSD(typ string) string
- type AccessListEncoder
- type AddObjectRequest
- type AddObjectResponseEncoder
- type AttributeNotification
- type AutonomousTransferCompleteRequestEncoder
- type BodyDecoder
- type BodyEncoder
- type DeleteObjectRequest
- type DeleteObjectResponseEncoder
- type DeviceID
- type DownloadRequest
- type DownloadResponseEncoder
- type EmptyPayload
- type EnvelopeDecoder
- type EnvelopeEncoder
- func (ee EnvelopeEncoder) Encode() ([]byte, error)
- func (ee EnvelopeEncoder) EncodePretty() ([]byte, error)
- func (ee *EnvelopeEncoder) Method() string
- func (ee *EnvelopeEncoder) WithFault(fault FaultCode) *EnvelopeEncoder
- func (ee *EnvelopeEncoder) WithFaultMsg(fault FaultCode, msg string) *EnvelopeEncoder
- type EventEncoder
- type EventStruct
- type FactoryResetResponseEncoder
- type FaultCode
- type FaultDetailEncoder
- type FaultDetailPayload
- type FaultEncoder
- type FaultPayload
- type FaultStruct
- type GetOptionsRequest
- type GetParameterAttributesRequest
- type GetParameterAttributesResponseEncoder
- type GetParameterNamesRequest
- type GetParameterNamesResponseEncoder
- type GetParameterValuesRequest
- type GetParameterValuesResponseEncoder
- type GetRPCMethodsResponseEncoder
- type HeaderDecoder
- type HeaderEncoder
- type IDDecoder
- type IDEncoder
- type InformRequestEncoder
- type InformResponse
- type MethodListEncoder
- type NoFaultStruct
- type ParameterAttribute
- type ParameterAttributeStruct
- type ParameterAttributeStructEncoder
- type ParameterInfoEncoder
- type ParameterInfoStruct
- type ParameterListEncoder
- type ParameterNames
- type ParameterValueDecoder
- type ParameterValueEncoder
- type RebootRequest
- type RebootResponseEncoder
- type ScheduleInformRequest
- type SetParameterAttributesRequest
- type SetParameterAttributesResponseEncoder
- type SetParameterAttributesStruct
- type SetParameterValuesFault
- type SetParameterValuesRequest
- type SetParameterValuesResponseEncoder
- type SetVouchersRequest
- type TransferCompleteRequestEncoder
- type UploadRequest
- type ValueEncoder
Constants ¶
const ( NSEnc = "http://schemas.xmlsoap.org/soap/encoding/" NSEnv = "http://schemas.xmlsoap.org/soap/envelope/" NSXSD = "http://www.w3.org/2001/XMLSchema" NSXSI = "http://www.w3.org/2001/XMLSchema-instance" NSCWMP = "urn:dslforum-org:cwmp-1-0" EventBootstrap = "0 BOOTSTRAP" EventBoot = "1 BOOT" EventPeriodic = "2 PERIODIC" EventScheduled = "3 SCHEDULED" EventValueChange = "4 VALUE CHANGE" EventKicked = "5 KICKED" EventConnectionRequest = "6 CONNECTION REQUEST" EventTransferComplete = "7 TRANSFER COMPLETE" EventDiagnosticsComplete = "8 DIAGNOSTICS COMPLETE" EventRequestDownload = "9 REQUEST DOWNLOAD" EventAutonomousTransferComplete = "10 AUTONOMOUS TRANSFER COMPLETE" EventReboot = "M Reboot" EventScheduleInform = "M ScheduleInform" EventDownload = "M Download" EventUpload = "M Upload" FileTypeFirmwareUpgradeImage = "1 Firmware Upgrade Image" FileTypeWebContent = "2 Web Content" FileTypeVendorConfigurationFile = "3 Vendor Configuration File" // AttributeNotificationOff indicates that the CPE need not inform the ACS // of a change to the specified parameter(s). AttributeNotificationOff AttributeNotification = 0 // AttributeNotificationPassive indicates that whenever the specified // parameter value changes, the CPE MUST include the new value in the // ParameterList in the Inform message that is sent the next time a session // is established to the ACS. If the CPE has rebooted, or the URL of the ACS // has changed since the last session, the CPE MAY choose not to include the // list of changed parameters in the first session established with the new // ACS. AttributeNotificationPassive AttributeNotification = 1 // AttributeNotificationActive indicates that whenever the specified // parameter value changes, the CPE MUST initiate a session to the ACS, and // include the new value in the ParameterList in the associated Inform // message. AttributeNotificationActive AttributeNotification = 2 // MaxEnvelopes MUST be set to a value of 1 because this version of the // protocol supports only a single envelope per message, and on reception // its value MUST be ignored. MaxEnvelopes = 1 // Download has completed and been applied. DownloadCompleted = 0 // Download has not yet been completed and applied (for example, if the CPE // needs to reboot itself before it can perform the file download, or if the // CPE needs to reboot itself before it can apply the downloaded file). DownloadNotCompleted = 1 )
const ( TypeObject = "object" TypeBase64 = "base64" TypeBase64Binary = "base64Binary" TypeBoolean = "boolean" TypeDateTime = "dateTime" TypeHEXBinary = "hexBinary" TypeInt = "int" TypeLong = "long" TypeString = "string" TypeUnsignedInt = "unsignedInt" TypeUnsignedLong = "unsignedLong" TypeIPAddress = "IPAddress" TypeIPPrefix = "IPPrefix" TypeIPv4Address = "IPv4Address" TypeIPv6Address = "IPv6Address" TypeIPv6Prefix = "IPv6Prefix" TypeMACAddress = "MACAddress" // TypeGenerator is a special type used to define a generator function. TypeGenerator = "sim:generator" )
List of supported types.
Variables ¶
This section is empty.
Functions ¶
func SupportedMethods ¶
func SupportedMethods() []string
Types ¶
type AccessListEncoder ¶
type AddObjectRequest ¶
func (AddObjectRequest) Debug ¶
func (r AddObjectRequest) Debug(logger zerolog.Logger)
type AttributeNotification ¶
type AttributeNotification int
type BodyDecoder ¶
type BodyDecoder struct {
GetRPCMethods *EmptyPayload
SetParameterValues *SetParameterValuesRequest
GetParameterValues *GetParameterValuesRequest
GetParameterNames *GetParameterNamesRequest
SetParameterAttributes *SetParameterAttributesRequest
GetParameterAttributes *GetParameterAttributesRequest
AddObject *AddObjectRequest
DeleteObject *DeleteObjectRequest
Reboot *RebootRequest
Download *DownloadRequest
Upload *UploadRequest
FactoryReset *EmptyPayload
GetQueuedTransfers *EmptyPayload
GetAllQueuedTransfers *EmptyPayload
ScheduleInform *ScheduleInformRequest
SetVouchers *SetVouchersRequest
GetOptions *GetOptionsRequest
InformResponse *InformResponse
TransferCompleteResponse *EmptyPayload
AutonomousTransferCompleteResponse *EmptyPayload
Fault *FaultPayload
}
type BodyEncoder ¶
type BodyEncoder struct {
Inform *InformRequestEncoder `xml:"cwmp:Inform,omitempty"`
GetRPCMethodsResponse *GetRPCMethodsResponseEncoder `xml:"cwmp:GetRPCMethodsResponse,omitempty"`
SetParameterValuesResponse *SetParameterValuesResponseEncoder `xml:"cwmp:SetParameterValuesResponse,omitempty"`
GetParameterValuesResponse *GetParameterValuesResponseEncoder `xml:"cwmp:GetParameterValuesResponse,omitempty"`
GetParameterNamesResponse *GetParameterNamesResponseEncoder `xml:"cwmp:GetParameterNamesResponse,omitempty"`
SetParameterAttributesResponse *SetParameterAttributesResponseEncoder `xml:"cwmp:SetParameterAttributesResponse,omitempty"`
GetParameterAttributesResponse *GetParameterAttributesResponseEncoder `xml:"cwmp:GetParameterAttributesResponse,omitempty"`
AddObjectResponse *AddObjectResponseEncoder `xml:"cwmp:AddObjectResponse,omitempty"`
DeleteObjectResponse *DeleteObjectResponseEncoder `xml:"cwmp:DeleteObjectResponse,omitempty"`
RebootResponse *RebootResponseEncoder `xml:"cwmp:RebootResponse,omitempty"`
DownloadResponse *DownloadResponseEncoder `xml:"cwmp:DownloadResponse,omitempty"`
FactoryResetResponse *FactoryResetResponseEncoder `xml:"cwmp:FactoryResetResponse,omitempty"`
TransferCompleteRequest *TransferCompleteRequestEncoder `xml:"cwmp:TransferComplete,omitempty"`
AutonomousTransferCompleteRequest *AutonomousTransferCompleteRequestEncoder `xml:"cwmp:AutonomousTransferComplete,omitempty"`
Fault *FaultEncoder `xml:"soapenv:Fault,omitempty"`
}
type DeleteObjectRequest ¶
func (DeleteObjectRequest) Debug ¶
func (r DeleteObjectRequest) Debug(logger zerolog.Logger)
type DeleteObjectResponseEncoder ¶
type DeleteObjectResponseEncoder struct {
Status int
}
type DownloadRequest ¶
type DownloadRequest struct {
CommandKey string
FileType string
URL string
Username string
Password string
FileSize int
TargetFileName string
DelaySeconds int
SuccessURL string
FailureURL string
}
func (DownloadRequest) Debug ¶
func (r DownloadRequest) Debug(logger zerolog.Logger)
type DownloadResponseEncoder ¶
type EmptyPayload ¶
type EmptyPayload struct{}
type EnvelopeDecoder ¶
type EnvelopeDecoder struct {
XMLName xml.Name `xml:"Envelope"`
Header HeaderDecoder
Body BodyDecoder
}
func Decode ¶
func Decode(b []byte) (*EnvelopeDecoder, error)
Decode attempts to decode given payload into a SOAP envelope.
func (EnvelopeDecoder) Method ¶ added in v0.2.12
func (env EnvelopeDecoder) Method() string
nolint:gocyclo
type EnvelopeEncoder ¶
type EnvelopeEncoder struct {
XMLName xml.Name `xml:"soapenv:Envelope"`
XMLSpaceEnv string `xml:"xmlns:soapenv,attr"`
XMLSpaceEnc string `xml:"xmlns:soapenc,attr"`
XMLSpaceXSD string `xml:"xmlns:xsd,attr"`
XMLSpaceXSI string `xml:"xmlns:xsi,attr"`
XMLSpaceCWMP string `xml:"xmlns:cwmp,attr"`
Header HeaderEncoder `xml:"soapenv:Header"`
Body BodyEncoder `xml:"soapenv:Body"`
}
func NewEnvelope ¶
func NewEnvelope(id string) *EnvelopeEncoder
func (EnvelopeEncoder) Encode ¶
func (ee EnvelopeEncoder) Encode() ([]byte, error)
func (EnvelopeEncoder) EncodePretty ¶
func (ee EnvelopeEncoder) EncodePretty() ([]byte, error)
func (*EnvelopeEncoder) WithFault ¶
func (ee *EnvelopeEncoder) WithFault(fault FaultCode) *EnvelopeEncoder
func (*EnvelopeEncoder) WithFaultMsg ¶ added in v0.1.3
func (ee *EnvelopeEncoder) WithFaultMsg(fault FaultCode, msg string) *EnvelopeEncoder
type EventEncoder ¶
type EventEncoder struct {
ArrayType string `xml:"soapenc:arrayType,attr"`
Events []EventStruct `xml:"EventStruct"`
}
type EventStruct ¶
type FactoryResetResponseEncoder ¶
type FactoryResetResponseEncoder struct{}
type FaultCode ¶
type FaultCode int
const ( FaultMethodNotSupported FaultCode = 9000 FaultRequestDenied FaultCode = 9001 FaultInternalError FaultCode = 9002 FaultInvalidArguments FaultCode = 9003 // When used in association with SetParameterValues, this must not be used // to indicate parameters in error. FaultResourcesExceeded FaultCode = 9004 // Associated with SetParameterValues, GetParameterValues, // GetParameterNames, SetParameterAttributes, GetParameterAttributes, // AddObject, and DeleteObject. FaultInvalidParameterName FaultCode = 9005 // Associated with SetParameterValues. FaultInvalidParameterType FaultCode = 9006 // Associated with SetParameterValues. FaultInvalidParameterValue FaultCode = 9007 // Attempt to set a non-writable parameter. Associated with // SetParameterValues. FaultNonWritableParameter FaultCode = 9008 // Associated with SetParameterAttributes method. FaultNotificationRequestRejected FaultCode = 9009 // Associated with Download, TransferComplete, or AutonomousTransferComplete // methods. FaultDownloadFailure FaultCode = 9010 // Associated with Upload, TransferComplete, or AutonomousTransferComplete // methods. FaultUploadFailure FaultCode = 9011 // File transfer server authentication failure. Associated with Upload, // Download, TransferComplete, or AutonomousTransferComplete methods. FaultFileTransferAuthenticationFailure FaultCode = 9012 // Unsupported protocol for file transfer. Associated with Upload and // Download methods. FaultFileTransferUnsupportedProtocol FaultCode = 9013 // Unable to join multicast group. Associated with Download, // TransferComplete, or AutonomousTransferComplete methods. FaultDownloadFailureJoinMulticastGroup FaultCode = 9014 // Unable to contact file server. Associated with Download, // TransferComplete, or AutonomousTransferComplete methods. FaultDownloadFailureContactFileServer FaultCode = 9015 // Unable to access file. Associated with Download, TransferComplete, or // AutonomousTransferComplete methods. FaultDownloadFailureAccessFile FaultCode = 9016 // Unable to complete download. Associated with Download, TransferComplete, // or AutonomousTransferComplete methods. FaultDownloadFailureCompleteDownload FaultCode = 9017 // Associated with Download, TransferComplete, or // AutonomousTransferComplete methods. FaultDownloadFailureFileCorrupted FaultCode = 9018 // file authentication failure. Associated with Download, TransferComplete, // or AutonomousTransferComplete methods. FaultDownloadFailureAuthenticationFailure FaultCode = 9019 FaultACSMethodNotSupported FaultCode = 8000 FaultACSRequestDenied FaultCode = 8001 FaultACSInternalError FaultCode = 8002 FaultACSInvalidArguments FaultCode = 8003 FaultACSResoucesExceeded FaultCode = 8004 FaultACSRetryRequest FaultCode = 8005 )
type FaultDetailEncoder ¶
type FaultDetailEncoder struct {
Fault FaultStruct `xml:"cwmp:Fault"`
}
type FaultDetailPayload ¶ added in v0.2.0
type FaultDetailPayload struct {
Fault FaultStruct
}
type FaultEncoder ¶
type FaultEncoder struct {
FaultCode string `xml:"faultcode"`
FaultString string `xml:"faultstring"`
Detail FaultDetailEncoder `xml:"detail"`
}
func NewFaultResponse ¶
func NewFaultResponse(code FaultCode, str string) *FaultEncoder
type FaultPayload ¶ added in v0.2.0
type FaultPayload struct {
FaultCode string `xml:"faultcode"`
FaultString string `xml:"faultstring"`
Detail FaultDetailPayload `xml:"detail"`
}
type FaultStruct ¶
type FaultStruct struct {
FaultCode FaultCode
FaultString string
SetParameterValuesFault []SetParameterValuesFault
}
type GetOptionsRequest ¶
type GetOptionsRequest struct {
OptionName string
}
type GetParameterAttributesRequest ¶
type GetParameterAttributesRequest struct {
ParameterNames ParameterNames
}
func (GetParameterAttributesRequest) Debug ¶
func (r GetParameterAttributesRequest) Debug(logger zerolog.Logger)
type GetParameterAttributesResponseEncoder ¶
type GetParameterAttributesResponseEncoder struct {
ParameterList ParameterAttributeStructEncoder
}
type GetParameterNamesRequest ¶
func (GetParameterNamesRequest) Debug ¶
func (r GetParameterNamesRequest) Debug(logger zerolog.Logger)
type GetParameterNamesResponseEncoder ¶
type GetParameterNamesResponseEncoder struct {
ParameterList ParameterInfoEncoder
}
type GetParameterValuesRequest ¶
type GetParameterValuesRequest struct {
ParameterNames ParameterNames
}
func (GetParameterValuesRequest) Debug ¶
func (r GetParameterValuesRequest) Debug(logger zerolog.Logger)
type GetParameterValuesResponseEncoder ¶
type GetParameterValuesResponseEncoder struct {
ParameterList ParameterListEncoder
}
type GetRPCMethodsResponseEncoder ¶
type GetRPCMethodsResponseEncoder struct {
MethodList MethodListEncoder
}
type HeaderDecoder ¶
type HeaderDecoder struct {
ID IDDecoder
}
type HeaderEncoder ¶
type HeaderEncoder struct {
ID IDEncoder `xml:"cwmp:ID"`
}
type InformRequestEncoder ¶
type InformRequestEncoder struct {
DeviceId DeviceID
Event EventEncoder
MaxEnvelopes int
CurrentTime string
RetryCount int
ParameterList ParameterListEncoder
}
nolint:stylecheck
type InformResponse ¶
type InformResponse struct {
MaxEnvelopes int
}
type MethodListEncoder ¶
type NoFaultStruct ¶
type NoFaultStruct struct {
Status int `xml:",chardata"`
}
type ParameterAttribute ¶
type ParameterAttributeStruct ¶
type ParameterAttributeStruct struct {
Name string
Notification AttributeNotification
AccessList AccessListEncoder
}
type ParameterAttributeStructEncoder ¶
type ParameterAttributeStructEncoder struct {
ArrayType string `xml:"soapenc:arrayType,attr"`
ParameterAttributes []ParameterAttributeStruct `xml:"ParameterAttributeStruct"`
}
type ParameterInfoEncoder ¶
type ParameterInfoEncoder struct {
ArrayType string `xml:"soapenc:arrayType,attr"`
Parameters []ParameterInfoStruct `xml:"ParameterInfoStruct"`
}
type ParameterInfoStruct ¶
type ParameterListEncoder ¶
type ParameterListEncoder struct {
ArrayType string `xml:"soapenc:arrayType,attr"`
ParameterValues []ParameterValueEncoder `xml:"ParameterValueStruct"`
}
type ParameterNames ¶
type ParameterValueDecoder ¶
type ParameterValueEncoder ¶
type ParameterValueEncoder struct {
Name string
Value ValueEncoder
}
type RebootRequest ¶
type RebootRequest struct {
CommandKey string
}
type RebootResponseEncoder ¶
type RebootResponseEncoder struct{}
type ScheduleInformRequest ¶
type SetParameterAttributesRequest ¶
type SetParameterAttributesRequest struct {
ParameterList struct {
ArrayType string `xml:"arrayType,attr"`
ParameterAttributes []SetParameterAttributesStruct `xml:"SetParameterAttributesStruct"`
}
}
func (SetParameterAttributesRequest) Debug ¶
func (r SetParameterAttributesRequest) Debug(logger zerolog.Logger)
type SetParameterAttributesResponseEncoder ¶
type SetParameterAttributesResponseEncoder struct{}
type SetParameterValuesFault ¶
type SetParameterValuesRequest ¶
type SetParameterValuesRequest struct {
ParameterList struct {
ArrayType string `xml:"arrayType,attr"`
ParameterValues []ParameterValueDecoder `xml:"ParameterValueStruct"`
}
ParameterKey string
}
func (SetParameterValuesRequest) Debug ¶
func (r SetParameterValuesRequest) Debug(logger zerolog.Logger)
type SetParameterValuesResponseEncoder ¶
type SetParameterValuesResponseEncoder struct {
Status int
}
type SetVouchersRequest ¶
type UploadRequest ¶
type UploadRequest struct {
CommandKey string
}
func (UploadRequest) Debug ¶
func (r UploadRequest) Debug(logger zerolog.Logger)