aboutsummaryrefslogtreecommitdiff
path: root/acse/acse.go
blob: 25527105770f4070f8fd1c52fe55320e8d4fd603 (plain)
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
package acse

import "github.com/dim13/asn1"

// 2.2.0.0.1

// A-ASSOCIATE Request
// 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        UserInformation       `asn1:"tag:30,optional"` // 30 implicit
}

type UserInformation struct {
	External `asn1:"instance"`
}

// A-ASSOCIATE Result (Result == 0)
// A-REJECT (Result == 1)
// 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,explicit"`  // 3
	UserInformation        UserInformation       `asn1:"tag:30,optional"` // 30 implicit
}

type AcseServiceUser struct {
	asn1.Tag `asn1:"tag:1"`
	Reason   int
}

// A-RELEASE Request
// Application Constructed implicit 2
type RLRQ struct {
	asn1.Tag `asn1:"application,tag:2"`
}

// A-RELEASE Result
// Application Constructed implicit 3
type RLRE struct {
	asn1.Tag `asn1:"application,tag:3"`
}

// A-ABORT
// Application Constructed implicit 4
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)
}