forked from fiorix/go-diameter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skel.go
81 lines (68 loc) · 2.45 KB
/
skel.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
// Copyright 2013-2014 go-diameter authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Skeleton of the dictionary file. Part of go-diameter.
package dict
import (
"encoding/xml"
"github.com/fiorix/go-diameter/diam/avp/format"
)
// File is the dictionary root element of a XML file. See diam_base.xml.
type File struct {
XMLName xml.Name `xml:"diameter"`
App []*App `xml:"application"` // Support for multiple applications
}
// App defines a diameter application in XML and its multiple AVPs.
type App struct {
Id uint32 `xml:"id,attr"` // Application Id
Type string `xml:"type,attr"` // Application type
Name string `xml:"name,attr"` // Application name
Vendor []*Vendor `xml:"vendor"` // Support for multiple vendors
Command []*Command `xml:"command"` // Diameter commands
AVP []*AVP `xml:"avp"` // Each application support multiple AVPs
}
// Vendor defines diameter vendors in XML, that can be used to translate
// the VendorId AVP of incoming messages.
type Vendor struct {
Id uint32 `xml:"id,attr"`
Name string `xml:"name,attr"`
}
// Command defines a diameter command (CE, CC, etc)
type Command struct {
Code uint32 `xml:"code,attr"`
Name string `xml:"name,attr"`
Short string `xml:"short,attr"`
Request CommandRule `xml:"request"`
Answer CommandRule `xml:"answer"`
}
type CommandRule struct {
Rule []*Rule `xml:"rule"`
}
// AVP represents a dictionary AVP that is loaded from XML.
type AVP struct {
Name string `xml:"name,attr"`
Code uint32 `xml:"code,attr"`
Must string `xml:"must,attr"`
May string `xml:"may,attr"`
MustNot string `xml:"must-not,attr"`
MayEncrypt string `xml:"may-encrypt,attr"`
Data Data `xml:"data"`
App *App `xml:"none"` // Link back to diameter application
}
// Data of an AVP can be EnumItem or a Parser of multiple AVPs.
type Data struct {
Format format.FormatId `xml:"-"`
FormatName string `xml:"type,attr"`
Enum []*Enum `xml:"item"` // In case of Enumerated AVP data
Rule []*Rule `xml:"rule"` // In case of Grouped AVPs
}
type Enum struct {
Code uint8 `xml:"code,attr"`
Name string `xml:"name,attr"`
}
type Rule struct {
AVP string `xml:"avp,attr"` // AVP Name
Required bool `xml:"required,attr"`
Min int `xml:"min,attr"`
Max int `xml:"max,attr"`
}