From 5374965a510f9ec077e33ecb373b67350182ad92 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 23 Oct 2015 23:32:32 +0200 Subject: Add packet overview --- tda.erl | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tda.erl b/tda.erl index 68ed176..461f352 100644 --- a/tda.erl +++ b/tda.erl @@ -9,15 +9,34 @@ -include("acse.hrl"). -include("rose.hrl"). +% A-ASSOCIATE Request +% 60 23 AARQ-apdu +% 80 02 07 80 protocol-version { version1 } +% A1 07 application-context-name +% 06 05 2B 0C 00 81 5A { 1 3 12 0 218 } +% BE 14 user-information +% 28 12 +% 06 07 2B 0C 00 82 1D 81 48 direct-reference { 1 3 12 0 285 200 } +% A0 07 single-ASN1-type +% (ACSEUserInfomrationForCSTA) +% A0 05 newDefinition +% 03 03 00 08 00 cSTAVersion { versionFive } + associate_request() -> Ver = #'NewACSEUserInformationForCSTA'{cSTAVersion = [versionFive]}, {ok, Enc} = acse:encode('ACSEUserInformationForCSTA', {newDefinition, Ver}), - Pdu = #'AARQ-apdu'{'application-context-name' = {1, 3, 12, 0, 218}, + Pdu = #'AARQ-apdu'{ + 'application-context-name' = {1, 3, 12, 0, 218}, 'user-information' = [#'EXTERNAL'{ 'direct-reference' = {1, 3, 12, 0, 285, 200}, encoding = {'single-ASN1-type', Enc}}]}, + io:format("~p~n", [Pdu]), acse:encode('AARQ-apdu', Pdu). +% Request +% 60,23,80,02,07,80,a1,07,06,05,2b,0c,00,81,5a,be,14,28,12,06,07,2b,0c,00,82,1d,81,48,a0,07,a0,05,03,03,00,08,00 +% <<96,35,128,2,7,128,161,7,6,5,43,12,0,129,90,190,20,40,18,6,7,43,12,0,130,29,129,72,160,7,160,5,3,3,0,8,0>> +% <<96,30,161,7,6,5,43,12,0,129,90,190,19,40,17,6,7,43,12,0, 130,29,129,72,160,6,160,4,3,...>> % Accept % <<97,47,128,2,7,128,161,7,6,5,43,12,0,129,90,162,3,2,1,0,163,5,161,3,2,1,1,190,20,40,18,6,7,43,12,0,130,29,129,72,160,7,160,5,3,3,0,8,0>> % Reject @@ -37,7 +56,7 @@ release_result(Bin) -> % <<100,3,128,1,0>> associate_abort(Bin) -> {ok, Pdu} = acse:decode('ABRT-apdu', Bin), - Pdu#'ABRT-apdu'.'abort-source'. + {ok, Pdu#'ABRT-apdu'.'abort-source'}. % <<161,12,2,1,1,2,2,0,211,48,3,10,1,2>> % <<162,11,2,1,1,48,6,2,2,0,211,5,0>> @@ -75,7 +94,7 @@ client() -> {ok, Sock} -> {ok, Hello} = associate_request(), io:format("Hello: ~p~n", [Hello]), - gen_tcp:send(Sock, [Hello]), + gen_tcp:send(Sock, Hello), loop(Sock); {error, Reason} -> {error, Reason} end. @@ -86,8 +105,8 @@ loop(Sock) -> %inet:setopts(Sock, [{active, once}]), io:format("loop ~p~n", [Sock]), receive - {tcp, Sock, Whatever} -> - io:format(">>> ~p ~p~n", [Sock, Whatever]), + {tcp, Sock, Msg} -> + decode(Msg), loop(Sock); {tcp_closed, Sock} -> io:format(">>> closed", []), @@ -96,3 +115,6 @@ loop(Sock) -> stop(Sock) end, io:format("loop end~n"). + +decode(Msg) -> + io:format(">>> ~p~n", [Msg]). -- cgit v1.2.3