/
UPFunctionFeatures.go
49 lines (41 loc) · 1.19 KB
/
UPFunctionFeatures.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
package pfcpType
import (
"encoding/binary"
"fmt"
)
const (
UpFunctionFeaturesBucp uint16 = 1
UpFunctionFeaturesDdnd uint16 = 1 << 1
UpFunctionFeaturesDlbd uint16 = 1 << 2
UpFunctionFeaturesTrst uint16 = 1 << 3
UpFunctionFeaturesFtup uint16 = 1 << 4
UpFunctionFeaturesPfdm uint16 = 1 << 5
UpFunctionFeaturesHeeu uint16 = 1 << 6
UpFunctionFeaturesTreu uint16 = 1 << 7
UpFunctionFeaturesEmpu uint16 = 1 << 8
UpFunctionFeaturesPdiu uint16 = 1 << 9
UpFunctionFeaturesUdbc uint16 = 1 << 10
UpFunctionFeaturesQuoac uint16 = 1 << 11
UpFunctionFeaturesTrace uint16 = 1 << 12
UpFunctionFeaturesFrrt uint16 = 1 << 13
)
type UPFunctionFeatures struct {
SupportedFeatures uint16
}
func (u *UPFunctionFeatures) MarshalBinary() (data []byte, err error) {
var idx uint16 = 0
// Octet 5 to 6
data = make([]byte, 2)
binary.LittleEndian.PutUint16(data[idx:], u.SupportedFeatures)
return data, nil
}
func (u *UPFunctionFeatures) UnmarshalBinary(data []byte) error {
length := uint16(len(data))
var idx uint16 = 0
// Octet 5 to 6
if length < idx+2 {
return fmt.Errorf("Inadequate TLV length: %d", length)
}
u.SupportedFeatures = binary.LittleEndian.Uint16(data[idx : idx+2])
return nil
}