summaryrefslogtreecommitdiff
path: root/acse.erl
blob: 82ba4b1123b943d5c60a8e8c1833201e432be473 (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
-module(acse).

-include("ACSE-1.hrl").
-include("CSTA-application-context-information-csta3.hrl").

-export([user_information/0, associate_request/0, release_request/0]).
-export([decode/1, accepted/1]).

user_information() ->
	{ok, UI} = 'CSTA-application-context-information-csta3':encode(
		'ACSEUserInformationForCSTA', {newDefinition,
		#'NewACSEUserInformationForCSTA'{cSTAVersion = [versionFive]}}),
	{'single-ASN1-type', UI}.

associate_request() ->
	'ACSE-1':encode('ACSE-apdu', {aarq, #'AARQ-apdu'{
		'protocol-version' = [version1],
		'application-context-name' = {1, 3, 12, 0, 218},
		'user-information' = [#'EXTERNAL'{
			'direct-reference' = {1, 3, 12, 0, 285, 200},
			encoding = user_information()}]}}).

release_request() -> 'ACSE-1':encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}}).

decode(Msg) -> 'ACSE-1':decode('ACSE-apdu', Msg).

accepted({aarq, _}) -> error;
accepted({aare, Apdu}) ->
	case Apdu#'AARE-apdu'.result of
		accepted -> ok;
		'rejected-permanent' -> error;
		'rejected-transient' -> error
	end;
accepted({rlrq, _}) -> error;
accepted({rlre, _}) -> error;
accepted({abrt, _}) -> error.