-
Notifications
You must be signed in to change notification settings - Fork 39
/
NAS_TMSI5GS.go
117 lines (99 loc) · 2.85 KB
/
NAS_TMSI5GS.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
package nasType
import (
"encoding/hex"
)
// TMSI5GS 9.11.3.4
// Spare Row, sBit, len = [0, 0], 4 , 1
// TypeOfIdentity Row, sBit, len = [0, 0], 3 , 3
// AMFSetID Row, sBit, len = [1, 1], 8 , 8
// AMFSetID Row, sBit, len = [1, 2], 8 , 10
// AMFPointer Row, sBit, len = [2, 2], 6 , 6
// TMSI5G Row, sBit, len = [3, 6], 8 , 32
type TMSI5GS struct {
Iei uint8
Len uint16
Octet [7]uint8
}
func NewTMSI5GS(iei uint8) (tMSI5GS *TMSI5GS) {
tMSI5GS = &TMSI5GS{}
tMSI5GS.SetIei(iei)
return tMSI5GS
}
// TMSI5GS 9.11.3.4
// Iei Row, sBit, len = [], 8, 8
func (a *TMSI5GS) GetIei() (iei uint8) {
return a.Iei
}
// TMSI5GS 9.11.3.4
// Iei Row, sBit, len = [], 8, 8
func (a *TMSI5GS) SetIei(iei uint8) {
a.Iei = iei
}
// TMSI5GS 9.11.3.4
// Len Row, sBit, len = [], 8, 16
func (a *TMSI5GS) GetLen() (len uint16) {
return a.Len
}
// TMSI5GS 9.11.3.4
// Len Row, sBit, len = [], 8, 16
func (a *TMSI5GS) SetLen(len uint16) {
a.Len = len
}
// TMSI5GS 9.11.3.4
// Spare Row, sBit, len = [0, 0], 4 , 1
func (a *TMSI5GS) GetSpare() (spare uint8) {
return a.Octet[0] & GetBitMask(4, 3) >> (3)
}
// TMSI5GS 9.11.3.4
// Spare Row, sBit, len = [0, 0], 4 , 1
func (a *TMSI5GS) SetSpare(spare uint8) {
a.Octet[0] = (a.Octet[0] & 247) + ((spare & 1) << 3)
}
// TMSI5GS 9.11.3.4
// TypeOfIdentity Row, sBit, len = [0, 0], 3 , 3
func (a *TMSI5GS) GetTypeOfIdentity() (typeOfIdentity uint8) {
return a.Octet[0] & GetBitMask(3, 0)
}
// TMSI5GS 9.11.3.4
// TypeOfIdentity Row, sBit, len = [0, 0], 3 , 3
func (a *TMSI5GS) SetTypeOfIdentity(typeOfIdentity uint8) {
a.Octet[0] = (a.Octet[0] & 248) + (typeOfIdentity & 7)
}
// TMSI5GS 9.11.3.4
// AMFSetID Row, sBit, len = [1, 2], 8 , 10
func (a *TMSI5GS) GetAMFSetID() (aMFSetID uint16) {
return (uint16(a.Octet[1])<<2 + uint16((a.Octet[2])&GetBitMask(8, 2))>>6)
}
// TMSI5GS 9.11.3.4
// AMFSetID Row, sBit, len = [1, 2], 8 , 10
func (a *TMSI5GS) SetAMFSetID(aMFSetID uint16) {
a.Octet[1] = uint8((aMFSetID)>>2) & 255
a.Octet[2] = a.Octet[2]&GetBitMask(6, 6) + uint8(aMFSetID&3)<<6
}
// TMSI5GS 9.11.3.4
// AMFPointer Row, sBit, len = [2, 2], 6 , 6
func (a *TMSI5GS) GetAMFPointer() (aMFPointer uint8) {
return a.Octet[2] & GetBitMask(6, 0)
}
// TMSI5GS 9.11.3.4
// AMFPointer Row, sBit, len = [2, 2], 6 , 6
func (a *TMSI5GS) SetAMFPointer(aMFPointer uint8) {
a.Octet[2] = (a.Octet[2] & 192) + (aMFPointer & 63)
}
// TMSI5GS 9.11.3.4
// TMSI5G Row, sBit, len = [3, 6], 8 , 32
func (a *TMSI5GS) GetTMSI5G() (tMSI5G [4]uint8) {
copy(tMSI5G[:], a.Octet[3:7])
return tMSI5G
}
// TMSI5GS 9.11.3.4
// TMSI5G Row, sBit, len = [3, 6], 8 , 32
func (a *TMSI5GS) SetTMSI5G(tMSI5G [4]uint8) {
copy(a.Octet[3:7], tMSI5G[:])
}
func (a *TMSI5GS) Get5GSTMSI() (tMSI5GS string, mobileIdType string, err error) {
partOfAmfId := hex.EncodeToString(a.Octet[1:3])
tmsi5g := hex.EncodeToString(a.Octet[3:7])
tMSI5GS = partOfAmfId + tmsi5g
return tMSI5GS, "5G-S-TMSI", nil
}