-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoder.go
65 lines (42 loc) · 1.11 KB
/
encoder.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
package main
import (
"bytes"
"fmt"
"github.com/HewlettPackard/structex"
)
type Nas5GSUpdateType struct {
IEI uint8 // Octet 1
Length uint8 // Octet 2
SMS_requested uint8 `bitfield:"1"`// Octet 3
NG_RAN_RCU uint8 `bitfield:"1"`
F5GS_PNB_CIoT uint8 `bitfield:"2"`
EPS_PNB_CIoT uint8 `bitfield:"2"`
spare0 uint8 `bitfield:"1",reserved`
spare1 uint8 `bitfield:"1",reserved`
}
func (ie Nas5GSUpdateType) Encode(buffer *bytes.Buffer) {
fmt.Println("Enter Encode")
buff, err := structex.EncodeByteBuffer(ie)
if err != nil {
panic("a problem")
}
fmt.Println("Encoded array",buff)
n,_:=buffer.Write(buff)
fmt.Println("Number of Bytes :", n)
fmt.Printf("Bytestrom=")
for i := 0; i < n; i++ {
fmt.Printf("0x%02X", buff[i])
if i != n-1 {
fmt.Printf(",")
}
}
fmt.Println()
fmt.Println("Exit Encode")
}
func main() {
fmt.Println("Enter Main")
ie := Nas5GSUpdateType{ IEI:1, Length:2, SMS_requested:1, NG_RAN_RCU:1, F5GS_PNB_CIoT:0, EPS_PNB_CIoT:0, spare0: 0, spare1:0}
buf := new(bytes.Buffer)
ie.Encode(buf)
fmt.Println("Exit Main")
}