aboutsummaryrefslogtreecommitdiff
path: root/rose
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-09 19:41:46 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-09 19:41:46 +0200
commit3479b3dbacceeb2fdc7591bdb150c10e31299ba4 (patch)
tree8ed0cb7990755c0eda55f4fd07ad189f7ae30dcc /rose
parent5da3820c360e34ef8e7c6b4757783e9514f72f71 (diff)
First real communication
Diffstat (limited to 'rose')
-rw-r--r--rose/rose.go34
1 files changed, 29 insertions, 5 deletions
diff --git a/rose/rose.go b/rose/rose.go
index 27365cd..1e670cc 100644
--- a/rose/rose.go
+++ b/rose/rose.go
@@ -7,7 +7,12 @@ import "github.com/dim13/asn1"
// Invoke is Context-specific Constructed 1
type Invoke struct {
asn1.Tag `asn1:"tag:1"`
- InvokeId int
+ InvokeID int
+ Opcode int `asn1:"optional"`
+ asn1.RawValue `asn1:"optional"`
+}
+
+type Result struct {
Opcode int `asn1:"optional"`
asn1.RawValue `asn1:"optional"`
}
@@ -15,9 +20,28 @@ type Invoke struct {
// ReturnResult it Context-specific Constructed 2
type ReturnResult struct {
asn1.Tag `asn1:"tag:2"`
- InvokeId int
- Result struct {
- Opcode int `asn1:"optional"`
- asn1.RawValue `asn1:"optional"`
+ InvokeID int
+ Result `asn1:"optional,expicit"`
+}
+
+func Unmarshal(b []byte) (int, int, []byte, error) {
+ v := &Invoke{}
+ _, err := asn1.Unmarshal(b, v)
+ if err != nil {
+ return 0, 0, nil, err
+ }
+ return v.InvokeID, v.Opcode, v.RawValue.FullBytes, nil
+}
+
+func Marshal(id, opcode int, b []byte) ([]byte, error) {
+ v := ReturnResult{
+ InvokeID: id,
+ Result: Result{
+ Opcode: opcode,
+ RawValue: asn1.RawValue{
+ FullBytes: b,
+ },
+ },
}
+ return asn1.Marshal(v)
}