package rose import "github.com/dim13/asn1" // 2.4.6.0 // Invoke is Context-specific Constructed 1 type Invoke struct { asn1.Tag `asn1:"tag:1"` InvokeID int Opcode int `asn1:"optional"` asn1.RawValue `asn1:"optional"` } type Result struct { Opcode int `asn1:"optional"` asn1.RawValue `asn1:"optional"` } // ReturnResult it Context-specific Constructed 2 type ReturnResult struct { asn1.Tag `asn1:"tag:2"` 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) }