aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-08 20:15:17 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-08 20:15:17 +0200
commit044255e7d40bdbadd442ff60b66b096518610af8 (patch)
tree1b323603d5028eab41585321ba580593f0f592e4
parentcd42ef6603dc8b6703ff261e628b31ee07ef0165 (diff)
Work in progress
-rw-r--r--acse/acse.go61
-rw-r--r--parse/parse.go64
-rw-r--r--rose/rose.go6
3 files changed, 75 insertions, 56 deletions
diff --git a/acse/acse.go b/acse/acse.go
index adbb17a..2552710 100644
--- a/acse/acse.go
+++ b/acse/acse.go
@@ -8,9 +8,13 @@ import "github.com/dim13/asn1"
// Application Constructed implicit 0
type AARQ struct {
asn1.Tag `asn1:"application,tag:0"`
- ProtocolVersion asn1.BitString `asn1:"tag:0"` // 0 implicit BitString
- ApplicationContextName asn1.ObjectIdentifier `asn1:"tag:1,explicit"` // 1
- UserInformation struct{ asn1.RawContent } `asn1:"tag:30,optional"` // 30 implicit
+ ProtocolVersion asn1.BitString `asn1:"tag:0"` // 0 implicit BitString
+ ApplicationContextName asn1.ObjectIdentifier `asn1:"tag:1,explicit"` // 1
+ UserInformation UserInformation `asn1:"tag:30,optional"` // 30 implicit
+}
+
+type UserInformation struct {
+ External `asn1:"instance"`
}
// A-ASSOCIATE Result (Result == 0)
@@ -18,16 +22,16 @@ type AARQ struct {
// Application Constructed implicit 1
type AARE struct {
asn1.Tag `asn1:"application,tag:1"`
- ProtocolVersion asn1.BitString `asn1:"tag:0"` // 0 implicit BitString
- ApplicationContextName asn1.ObjectIdentifier `asn1:"tag:1,explicit"` // 1
- Result int `asn1:"tag:2,explicit"` // 2
- ResultSourceDiagnostic AcseServiceUser `asn1:"tag:3"` // 3
- UserInformation struct{ asn1.RawContent } `asn1:"tag:30,optional"` // 30 implicit
+ ProtocolVersion asn1.BitString `asn1:"tag:0"` // 0 implicit BitString
+ ApplicationContextName asn1.ObjectIdentifier `asn1:"tag:1,explicit"` // 1
+ Result int `asn1:"tag:2,explicit"` // 2
+ ResultSourceDiagnostic AcseServiceUser `asn1:"tag:3,explicit"` // 3
+ UserInformation UserInformation `asn1:"tag:30,optional"` // 30 implicit
}
type AcseServiceUser struct {
- User int `asn1:"tag:0,optional"`
- Provider int `asn1:"tag:0,optional"`
+ asn1.Tag `asn1:"tag:1"`
+ Reason int
}
// A-RELEASE Request
@@ -48,3 +52,40 @@ type ABRT struct {
asn1.Tag `asn1:"application,tag:4"`
AbortSource int `asn1:"tag:0"` // 0 implicit
}
+
+type External struct {
+ DirectReference asn1.ObjectIdentifier `asn1:"optional"`
+ Encoding ACSEUserInformationForCSTA `asn1:"tag:0,optional"`
+}
+
+type ACSEUserInformationForCSTA struct {
+ NewDefinition `asn1:"tag:0"`
+}
+
+type NewDefinition struct {
+ CSTAVersion asn1.BitString
+}
+
+func Associate() ([]byte, error) {
+ aarq := AARQ{
+ ProtocolVersion: asn1.BitString{
+ Bytes: []byte{0x80},
+ BitLength: 1,
+ },
+ ApplicationContextName: asn1.ObjectIdentifier([]int{1, 3, 12, 0, 218}),
+ UserInformation: UserInformation{
+ External{
+ DirectReference: asn1.ObjectIdentifier([]int{1, 3, 12, 0, 285, 200}),
+ Encoding: ACSEUserInformationForCSTA{
+ NewDefinition{
+ CSTAVersion: asn1.BitString{
+ Bytes: []byte{0x08, 0x00},
+ BitLength: 16,
+ },
+ },
+ },
+ },
+ },
+ }
+ return asn1.Marshal(aarq)
+}
diff --git a/parse/parse.go b/parse/parse.go
index 8f53c06..60c59b6 100644
--- a/parse/parse.go
+++ b/parse/parse.go
@@ -2,13 +2,15 @@ package main
import (
"fmt"
+ "log"
//"dim13.org/asn1/ber"
"dim13.org/asn1/acse"
- "dim13.org/asn1/csta"
+ //"dim13.org/asn1/csta"
"dim13.org/asn1/rose"
"github.com/dim13/asn1"
+ "github.com/kr/pretty"
)
var t = map[byte]string{
@@ -21,61 +23,37 @@ var t = map[byte]string{
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:
- v := rose.Invoke{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v, csta.Modules[v.Opcode])
+ unmarshal(s, &rose.Invoke{})
case 0xa2:
- v := rose.ReturnResult{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v, csta.Modules[v.Result.Opcode])
+ unmarshal(s, &rose.ReturnResult{})
case 0x60:
- v := acse.AARQ{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v)
+ unmarshal(s, &acse.AARQ{})
case 0x61:
- v := acse.AARE{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v)
+ unmarshal(s, &acse.AARE{})
case 0x62:
- v := acse.RLRQ{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v)
+ unmarshal(s, &acse.RLRQ{})
case 0x63:
- v := acse.RLRE{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v)
+ unmarshal(s, &acse.RLRE{})
case 0x64:
- v := acse.ABRT{}
- _, err := asn1.Unmarshal(s, &v)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(v)
+ unmarshal(s, &acse.ABRT{})
}
}
+ fmt.Printf("%x\n", session[0])
+ a, _ := acse.Associate()
+ fmt.Printf("%x\n", a)
}
diff --git a/rose/rose.go b/rose/rose.go
index 4500f01..7e9739f 100644
--- a/rose/rose.go
+++ b/rose/rose.go
@@ -19,7 +19,7 @@ type ReturnResult struct {
asn1.Tag `asn1:"tag:2"`
InvokeId int
Result struct {
- asn1.RawContent `asn1:"optional"`
- Opcode int `asn1:"optional"`
- }
+ asn1.RawContent
+ Opcode int
+ } `asn1:"optional"`
}