From cd42ef6603dc8b6703ff261e628b31ee07ef0165 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 8 Oct 2015 18:49:29 +0200 Subject: work in progress --- acse/acse.go | 63 ++++++++++++++++++++++------------------------------------ ber/common.go | 2 ++ csta/csta.go | 2 +- parse/parse.go | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- rose/rose.go | 8 ++++---- 5 files changed, 90 insertions(+), 46 deletions(-) diff --git a/acse/acse.go b/acse/acse.go index 8429b83..adbb17a 100644 --- a/acse/acse.go +++ b/acse/acse.go @@ -1,65 +1,50 @@ package acse -// 2.2.0.0.1 +import "github.com/dim13/asn1" -type ObjectIdentifier []int // asn1.ObjectIdentifier +// 2.2.0.0.1 // A-ASSOCIATE Request // Application Constructed implicit 0 type AARQ struct { - ProtocolVersion Version // 0 implicit BitString - ApplicationContextName ObjectIdentifier // 1 - UserInformation interface{} // 30 implicit + 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 } -type Version byte - -const ( - Version1 Version = iota -) - // A-ASSOCIATE Result (Result == 0) // A-REJECT (Result == 1) // Application Constructed implicit 1 type AARE struct { - ProtocolVersion Version // 0 implicit BitString - ApplicationContextName ObjectIdentifier // 1 - Result Result // 2 - ResultSourceDiagnostic AcseServiceUser // 3 - UserInformation interface{} // 30 implicit + 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 } -type Result int - -const ( - Accepted Result = iota - RejectedPermanent -) - -type AcseServiceUser int - -const ( - Null AcseServiceUser = iota - NoReasonGiven -) +type AcseServiceUser struct { + User int `asn1:"tag:0,optional"` + Provider int `asn1:"tag:0,optional"` +} // A-RELEASE Request // Application Constructed implicit 2 -type RLRQ struct{} +type RLRQ struct { + asn1.Tag `asn1:"application,tag:2"` +} // A-RELEASE Result // Application Constructed implicit 3 -type RLRE struct{} +type RLRE struct { + asn1.Tag `asn1:"application,tag:3"` +} // A-ABORT // Application Constructed implicit 4 type ABRT struct { - AbortSource AbortSource // 0 implicit + asn1.Tag `asn1:"application,tag:4"` + AbortSource int `asn1:"tag:0"` // 0 implicit } - -type AbortSource int - -const ( - ServiceUser AbortSource = iota - ServiceProvider -) diff --git a/ber/common.go b/ber/common.go index aded3ef..4266848 100644 --- a/ber/common.go +++ b/ber/common.go @@ -78,3 +78,5 @@ func (o BitString) String() string { } type Raw []byte + +type Tag int diff --git a/csta/csta.go b/csta/csta.go index 4ee7f99..8d806bc 100644 --- a/csta/csta.go +++ b/csta/csta.go @@ -2,7 +2,7 @@ package csta var baseOID = []int{1, 3, 12, 0, 285} -var modules = map[int]string{ +var Modules = map[int]string{ //1: "error-definition", 1: "alternate-call", 2: "answer-call", diff --git a/parse/parse.go b/parse/parse.go index a5ca546..8f53c06 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -3,7 +3,12 @@ package main import ( "fmt" - "dim13.org/asn1/ber" + //"dim13.org/asn1/ber" + "dim13.org/asn1/acse" + "dim13.org/asn1/csta" + "dim13.org/asn1/rose" + + "github.com/dim13/asn1" ) var t = map[byte]string{ @@ -19,6 +24,58 @@ var t = map[byte]string{ func main() { for n, s := range session { fmt.Println(">>> packet", n, t[s[0]]) - fmt.Println(ber.Dump(s)) + //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]) + case 0xa2: + v := rose.ReturnResult{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v, csta.Modules[v.Result.Opcode]) + case 0x60: + v := acse.AARQ{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v) + case 0x61: + v := acse.AARE{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v) + case 0x62: + v := acse.RLRQ{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v) + case 0x63: + v := acse.RLRE{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v) + case 0x64: + v := acse.ABRT{} + _, err := asn1.Unmarshal(s, &v) + if err != nil { + fmt.Println(err) + } + fmt.Println(v) + + } } } diff --git a/rose/rose.go b/rose/rose.go index f5cafbb..4500f01 100644 --- a/rose/rose.go +++ b/rose/rose.go @@ -8,10 +8,10 @@ import "github.com/dim13/asn1" type Invoke struct { asn1.Tag `asn1:"tag:1"` InvokeId int - Opcode int + Opcode int `asn1:"optional"` Payload struct { asn1.RawContent - } + } `asn1:"optional"` } // ReturnResult it Context-specific Constructed 2 @@ -19,7 +19,7 @@ type ReturnResult struct { asn1.Tag `asn1:"tag:2"` InvokeId int Result struct { - asn1.RawContent - Opcode int + asn1.RawContent `asn1:"optional"` + Opcode int `asn1:"optional"` } } -- cgit v1.2.3