-
Notifications
You must be signed in to change notification settings - Fork 24
/
Message.go
119 lines (102 loc) · 2.89 KB
/
Message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package cwmp
import (
"encoding/xml"
"github.com/ca17/teamsacs/common/xmlx"
)
const (
// XsdString string type
XsdString string = "xsd:string"
// XsdUnsignedint uint type
XsdUnsignedint string = "xsd:unsignedInt"
)
const (
// SoapArray array type
SoapArray string = "soap-enc:Array"
)
const (
// EventBootStrap first connection
EventBootStrap string = "0 BOOTSTRAP"
// EventBoot reset or power on
EventBoot string = "1 BOOT"
// EventPeriodic periodic inform
EventPeriodic string = "2 PERIODIC"
// EventScheduled scheduled infrorm
EventScheduled string = "3 SCHEDULED"
// EventValueChange value change event
EventValueChange string = "4 VALUE CHANGE"
// EventKicked acs notify cpe
EventKicked string = "5 KICKED"
// EventConnectionRequest cpe request connection
EventConnectionRequest string = "6 CONNECTION REQUEST"
// EventTransferComplete download complete
EventTransferComplete string = "7 TRANSFER COMPLETE"
// EventClientChange custom event client online/offline
EventClientChange string = "8 CLIENT CHANGE"
)
// Message tr069 msg interface
type Message interface {
Parse(doc *xmlx.Document)
CreateXML() []byte
GetName() string
GetID() string
}
// Envelope tr069 body
type Envelope struct {
XMLName xml.Name `xml:"soap-env:Envelope"`
XmlnsEnv string `xml:"xmlns:soap-env,attr"`
XmlnsEnc string `xml:"xmlns:soap-enc,attr"`
XmlnsXsd string `xml:"xmlns:xsd,attr"`
XmlnsXsi string `xml:"xmlns:xsi,attr"`
XmlnsCwmp string `xml:"xmlns:cwmp,attr"`
Header interface{} `xml:"soap-env:Header"`
Body interface{} `xml:"soap-env:Body"`
}
// HeaderStruct tr069 header
type HeaderStruct struct {
ID IDStruct `xml:"cwmp:ID"`
NoMore interface{} `xml:"cwmp:NoMoreRequests,ommitempty"`
}
// IDStruct msg id
type IDStruct struct {
Attr string `xml:"soap-env:mustUnderstand,attr,ommitempty"`
Value string `xml:",chardata"`
}
// NodeStruct node
type NodeStruct struct {
Type interface{} `xml:"xsi:type,attr"`
Value string `xml:",chardata"`
}
// EventStruct event
type EventStruct struct {
Type string `xml:"soap-enc:arrayType,attr"`
Events []EventNodeStruct `xml:"EventStruct"`
}
// EventNodeStruct event node
type EventNodeStruct struct {
EventCode NodeStruct `xml:"EventCode"`
CommandKey string `xml:"CommandKey"`
}
// ParameterListStruct param list
type ParameterListStruct struct {
Type string `xml:"soap-enc:arrayType,attr"`
Params []ParameterValueStruct `xml:"ParameterValueStruct"`
}
// ParameterValueStruct param value
type ParameterValueStruct struct {
Name NodeStruct `xml:"Name"`
Value NodeStruct `xml:"Value"`
}
type ParameterInfoStruct struct {
Name string `xml:"Name" json:"name"`
Writable string `xml:"Writable" json:"writable"`
}
// FaultStruct error
type FaultStruct struct {
FaultCode int
FaultString string
}
// ValueStruct value
type ValueStruct struct {
Type string
Value string
}