summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-09 01:44:10 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-09 01:44:10 +0100
commit55bedf3292656dccfea59bde7cc9af9ba2a616cc (patch)
tree5431a35a49a14784cf0d16c999fbe748c223c6ca
parent446d0ef9d7fefd3ba0d3ce2640bf53b4a102de7f (diff)
Add error, acse:encode
-rw-r--r--src/pbx_acse.erl14
-rw-r--r--src/pbx_conn.erl8
2 files changed, 12 insertions, 10 deletions
diff --git a/src/pbx_acse.erl b/src/pbx_acse.erl
index 5b37964..d7d1114 100644
--- a/src/pbx_acse.erl
+++ b/src/pbx_acse.erl
@@ -3,10 +3,9 @@
-include("ACSE-1.hrl").
-include("CSTA-application-context-information-csta3.hrl").
--export([associate/0, release/0]).
--export([decode/1, dispatch/1]).
+-export([encode/1, decode/1, dispatch/1]).
-associate() ->
+encode(associate) ->
{ok, UI} = 'CSTA-application-context-information-csta3':encode(
'ACSEUserInformationForCSTA', {newDefinition,
#'NewACSEUserInformationForCSTA'{cSTAVersion = [versionFive]}}),
@@ -15,10 +14,11 @@ associate() ->
'application-context-name' = {1, 3, 12, 0, 218},
'user-information' = [#'EXTERNAL'{
'direct-reference' = {1, 3, 12, 0, 285, 200},
- encoding = {'single-ASN1-type', UI}}]}}).
-
-release() ->
- 'ACSE-1':encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}}).
+ encoding = {'single-ASN1-type', UI}}]}});
+encode(release) ->
+ 'ACSE-1':encode('ACSE-apdu', {rlrq, #'RLRQ-apdu'{}});
+encode(Data) ->
+ 'ACSE-1':encode('ACSE-apdu', Data).
decode(Data) ->
'ACSE-1':decode('ACSE-apdu', Data).
diff --git a/src/pbx_conn.erl b/src/pbx_conn.erl
index af3dbc0..3b7465a 100644
--- a/src/pbx_conn.erl
+++ b/src/pbx_conn.erl
@@ -13,7 +13,7 @@ start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [?HOST, ?PORT], []).
init(Args) ->
- send(pbx_acse:associate()),
+ send(pbx_acse:encode(associate)),
[Host, Port] = Args,
gen_tcp:connect(Host, Port, [binary, {packet, 2}]).
@@ -22,7 +22,9 @@ handle_call(_Request, _From, Socket) ->
handle_cast({ok, Reply}, Socket) ->
gen_tcp:send(Socket, Reply),
- {noreply, Socket}.
+ {noreply, Socket};
+handle_cast({error, Reason}, Socket) ->
+ {stop, Reason, Socket}.
handle_info({tcp, _, Data}, Socket) ->
case pbx_acse:decode(Data) of
@@ -38,7 +40,7 @@ handle_info({tcp_closed, _}, Socket) ->
{stop, normal, Socket}.
terminate(_Reason, Socket) ->
- send(pbx_acse:release()),
+ send(pbx_acse:encode(release)),
gen_tcp:close(Socket).
code_change(_OldVsn, Socket, _Extra) ->