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
|
package main
import (
"fmt"
"log"
//"dim13.org/asn1/ber"
"dim13.org/asn1/acse"
"dim13.org/asn1/csta"
"dim13.org/asn1/rose"
"github.com/dim13/asn1"
"github.com/kr/pretty"
)
var t = map[byte]string{
0x60: "ACSE Associate Request",
0x61: "ACSE Associate Result",
0x62: "ACSE Release Request",
0x63: "ACSE Release Result",
0x64: "ACSE Abort",
0xa1: "ROSE Invoke",
0xa2: "ROSE Response",
}
func unmarshal(b []byte, v interface{}) {
_, err := asn1.Unmarshal(b, v)
if err != nil {
log.Fatal(err)
}
pretty.Println(v)
}
func main() {
for n, s := range session {
fmt.Println(">>> packet", n, t[s[0]])
//fmt.Println(ber.Dump(s))
switch s[0] {
case 0xa1:
id, opcode, buf, err := rose.Unmarshal(s)
if err != nil {
fmt.Println(err)
}
if m, ok := csta.Modules[opcode]; ok {
fmt.Println("Opcode:", m)
}
switch opcode {
case csta.SystemStatusOpcode:
ss := &csta.SystemStatusArg{}
asn1.Unmarshal(buf, ss)
fmt.Println("Status", ss.SystemStatus)
null, _ := asn1.Marshal(asn1.Null{})
res, err := rose.Marshal(id, opcode, null)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%x\n", s)
fmt.Printf("%x\n", res)
case csta.MonitorStartOpcode:
ms := &csta.MonitorStartArg{}
asn1.Unmarshal(buf, ms)
pretty.Println(ms)
res, _ := asn1.Marshal(*ms)
fmt.Printf("%x\n", buf)
fmt.Printf("%x\n", res)
default:
unmarshal(s, &rose.Invoke{})
}
case 0xa2:
unmarshal(s, &rose.ReturnResult{})
case 0x60:
unmarshal(s, &acse.AARQ{})
a, _ := acse.Associate()
fmt.Printf("%x\n", s)
fmt.Printf("%x\n", a)
case 0x61:
unmarshal(s, &acse.AARE{})
reason, _ := acse.AssociateResult(s)
fmt.Println("Reason", reason)
fmt.Println(s)
case 0x62:
unmarshal(s, &acse.RLRQ{})
case 0x63:
unmarshal(s, &acse.RLRE{})
case 0x64:
a := &acse.ABRT{}
unmarshal(s, a)
fmt.Println(a)
}
}
fmt.Printf("%x\n", session[0])
a, _ := acse.Associate()
fmt.Printf("%x\n", a)
}
|