summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-24 17:38:04 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-24 17:38:04 +0200
commit80311e3b4f60bd1c2484ac2d5b77c1f376dfa94d (patch)
tree7f14a8757a324d046aa2351baab36ccdb2b85422
parent815ad55d3a263f91f3a75741eef128e25ddf3230 (diff)
Add dispatch
-rw-r--r--tda.erl25
1 files changed, 16 insertions, 9 deletions
diff --git a/tda.erl b/tda.erl
index 3cc89e8..027efbd 100644
--- a/tda.erl
+++ b/tda.erl
@@ -118,17 +118,14 @@ loop(Sock) ->
end.
decode(Sock, Msg) ->
- case rose:decode('ROS', Msg) of
- {ok, Rose} ->
+ case dispatch(Msg) of
+ rose ->
+ {ok, Rose} = rose:decode('ROS', Msg),
rose_handler(Sock, Rose),
io:format("ROSE> ~p~n", [Rose]);
- {error, _} ->
- case acse:decode('ACSE-apdu', Msg) of
- {ok, Acse} ->
- io:format("ACSE> ~p~n", [Acse]);
- {error, _} ->
- io:format(">>> ~p~n", [Msg])
- end
+ acse ->
+ {ok, Acse} = acse:decode('ACSE-apdu', Msg),
+ io:format("ACSE> ~p~n", [Acse])
end.
rose_handler(Sock, {invoke, Rose}) ->
@@ -146,3 +143,13 @@ invoke_handler(#'Invoke'{invokeId = {present, Id}, opcode = {local, Op}}) ->
end
end.
+dispatch(<<H:8,_/binary>>) ->
+ case H of
+ 96 -> acse;
+ 97 -> acse;
+ 98 -> acse;
+ 99 -> acse;
+ 100 -> acse;
+ 161 -> rose;
+ 162 -> rose
+ end.