summaryrefslogtreecommitdiff
path: root/src/pbx_acse.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/pbx_acse.erl')
-rw-r--r--src/pbx_acse.erl38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/pbx_acse.erl b/src/pbx_acse.erl
index c3ef94e..f225eda 100644
--- a/src/pbx_acse.erl
+++ b/src/pbx_acse.erl
@@ -8,24 +8,8 @@
terminate/2, code_change/3]).
-export([encode/1]).
-encode(associate) ->
- UIforCSTA = #'NewACSEUserInformationForCSTA'{
- cSTAVersion = [versionFive]},
- {ok, UI} = 'CSTA-application-context-information-csta3':encode(
- 'ACSEUserInformationForCSTA', {newDefinition, UIforCSTA}),
- Ext = #'EXTERNAL'{'direct-reference' = {1, 3, 12, 0, 285, 200},
- encoding = {'single-ASN1-type', UI}},
- AARQ = #'AARQ-apdu'{
- 'protocol-version' = [version1], % required
- 'application-context-name' = {1, 3, 12, 0, 218},
- 'user-information' = [Ext]},
- 'ACSE-1':encode('ACSE-apdu', {aarq, AARQ});
-encode(release) ->
- 'ACSE-1':encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}}).
-
-%%%
-
init(_Args) ->
+ pbx_conn:send(encode(associate)),
{ok, undefined}.
handle_event({aare, #'AARE-apdu'{result = Result}}, _State) ->
@@ -48,8 +32,28 @@ handle_call(_Request, State) ->
handle_info(_Info, State) ->
{ok, State}.
+terminate(_Reason, accepted) ->
+ pbx_conn:send(encode(release)),
+ ok;
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+
+%%%
+
+encode(associate) ->
+ UIforCSTA = #'NewACSEUserInformationForCSTA'{
+ cSTAVersion = [versionFive]},
+ {ok, UI} = 'CSTA-application-context-information-csta3':encode(
+ 'ACSEUserInformationForCSTA', {newDefinition, UIforCSTA}),
+ Ext = #'EXTERNAL'{'direct-reference' = {1, 3, 12, 0, 285, 200},
+ encoding = {'single-ASN1-type', UI}},
+ AARQ = #'AARQ-apdu'{
+ 'protocol-version' = [version1], % required
+ 'application-context-name' = {1, 3, 12, 0, 218},
+ 'user-information' = [Ext]},
+ 'ACSE-1':encode('ACSE-apdu', {aarq, AARQ});
+encode(release) ->
+ 'ACSE-1':encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}}).