diff options
author | Ulf Wiger <ulf@feuerlabs.com> | 2015-12-15 17:54:29 -0800 |
---|---|---|
committer | Ulf Wiger <ulf@feuerlabs.com> | 2015-12-15 17:54:29 -0800 |
commit | ce9b50c4d6b9710f67300b5a848a10aa77961d36 (patch) | |
tree | e51da386c0cde86af2a3d2511fe4841e3414064a /components | |
parent | d0da97015667246a6e4a7c7cca335e2082ae1166 (diff) | |
download | rvi_core-ce9b50c4d6b9710f67300b5a848a10aa77961d36.tar.gz |
wrong encoding of 'mod' attr in 'rcv' msg
Diffstat (limited to 'components')
-rw-r--r-- | components/dlink_bt/src/dlink_bt_rpc.erl | 4 | ||||
-rw-r--r-- | components/dlink_tcp/src/dlink_tcp_rpc.erl | 4 | ||||
-rw-r--r-- | components/dlink_tls/src/dlink_tls_rpc.erl | 23 | ||||
-rw-r--r-- | components/rvi_common/src/rvi_common.erl | 6 |
4 files changed, 9 insertions, 28 deletions
diff --git a/components/dlink_bt/src/dlink_bt_rpc.erl b/components/dlink_bt/src/dlink_bt_rpc.erl index c675387..75e7926 100644 --- a/components/dlink_bt/src/dlink_bt_rpc.erl +++ b/components/dlink_bt/src/dlink_bt_rpc.erl @@ -303,7 +303,7 @@ announce_local_service_(CompSpec, Service, Availability) -> process_data(_FromPid, RemoteBTAddr, RemoteChannel, ProtocolMod, Data, CompSpec) -> ?debug("dlink_bt:receive_data(): SetupAddress: {~p, ~p}", [ RemoteBTAddr, RemoteChannel ]), ?debug("dlink_bt:receive_data(): ~p:receive_message(~p)", [ ProtocolMod, Data ]), - Proto = list_to_existing_atom(ProtocolMod), + Proto = binary_to_existing_atom(ProtocolMod, latin1), Proto:receive_message(CompSpec, {RemoteBTAddr, RemoteChannel}, Data), ok. @@ -593,7 +593,7 @@ handle_call({rvi, send_data, [ProtoMod, Service, Data, _DataLinkOpts]}, _From, S ConnPid, [ { ?DLINK_ARG_TRANSACTION_ID, 1 }, { ?DLINK_ARG_CMD, ?DLINK_CMD_RECEIVE }, - { ?DLINK_ARG_MODULE, atom_to_list(ProtoMod) }, + { ?DLINK_ARG_MODULE, atom_to_binary(ProtoMod, latin1) }, { ?DLINK_ARG_DATA, Data } ]), { reply, [ Res ], St} diff --git a/components/dlink_tcp/src/dlink_tcp_rpc.erl b/components/dlink_tcp/src/dlink_tcp_rpc.erl index 68d32d7..fc907d6 100644 --- a/components/dlink_tcp/src/dlink_tcp_rpc.erl +++ b/components/dlink_tcp/src/dlink_tcp_rpc.erl @@ -550,7 +550,7 @@ handle_call({rvi, send_data, [ProtoMod, Service, Data, _DataLinkOpts]}, _From, S Res = connection:send(ConnPid, [ { ?DLINK_ARG_TRANSACTION_ID, 1 }, { ?DLINK_ARG_CMD, ?DLINK_CMD_RECEIVE }, - { ?DLINK_ARG_MODULE, atom_to_list(ProtoMod) }, + { ?DLINK_ARG_MODULE, atom_to_binary(ProtoMod, latin1) }, { ?DLINK_ARG_DATA, Data } ]), { reply, [ Res ], St} @@ -727,7 +727,7 @@ connection_authorized(FromPid, {RemoteIP, RemotePort} = Conn, CompSpec) -> process_data(_FromPid, RemoteIP, RemotePort, ProtocolMod, Data, CompSpec) -> ?debug("dlink_tcp:receive_data(): RemoteAddr: {~p, ~p}", [ RemoteIP, RemotePort ]), ?debug("dlink_tcp:receive_data(): ~p:receive_message(~p)", [ ProtocolMod, Data ]), - Proto = list_to_existing_atom(ProtocolMod), + Proto = binary_to_existing_atom(ProtocolMod, latin1), Proto:receive_message(CompSpec, {RemoteIP, RemotePort}, Data). process_announce(Avail, Services, FromPid, IP, Port, CompSpec) -> diff --git a/components/dlink_tls/src/dlink_tls_rpc.erl b/components/dlink_tls/src/dlink_tls_rpc.erl index e4d6adf..137c785 100644 --- a/components/dlink_tls/src/dlink_tls_rpc.erl +++ b/components/dlink_tls/src/dlink_tls_rpc.erl @@ -532,7 +532,7 @@ handle_call({rvi, send_data, [ProtoMod, Service, Data, _DataLinkOpts]}, Res = dlink_tls_conn:send( ConnPid, [{?DLINK_ARG_TRANSACTION_ID, Tid}, {?DLINK_ARG_CMD, ?DLINK_CMD_RECEIVE}, - {?DLINK_ARG_MODULE, atom_to_list(ProtoMod)}, + {?DLINK_ARG_MODULE, atom_to_binary(ProtoMod, latin1)}, {?DLINK_ARG_DATA, Data}]), {reply, [Res], St#st{tid = Tid + 1}} end; @@ -672,15 +672,6 @@ process_authorize(FromPid, PeerIP, PeerPort, RemoteAddress, authorize_rpc:store_creds(CompSpec, Credentials, Conn, PeerCert), connection_authorized(FromPid, Conn, CompSpec). -%% send_creds(Pid, CompSpec) -> -%% ?debug("send_creds (Pid = ~p)", [Pid]), -%% {LocalIP, LocalPort} = rvi_common:node_address_tuple(), -%% dlink_tls_conn:send(Pid, rvi_common:pass_log_id( -%% [{?DLINK_ARG_CMD, ?DLINK_CMD_CRED_EXCHANGE}, -%% {?DLINK_ARG_ADDRESS, LocalIP}, -%% {?DLINK_ARG_PORT, integer_to_list(LocalPort)}, -%% {?DLINK_ARG_CREDENTIALS, [get_credentials(CompSpec)]}], CompSpec)). - send_authorize(Pid, CompSpec) -> ?debug("send_authorize() Pid = ~p; CompSpec = ~p", [Pid, abbrev(CompSpec)]), {LocalIP, LocalPort} = rvi_common:node_address_tuple(), @@ -691,16 +682,6 @@ send_authorize(Pid, CompSpec) -> {?DLINK_ARG_ADDRESS, LocalIP}, {?DLINK_ARG_PORT, LocalPort}, {?DLINK_ARG_CREDENTIALS, Creds}], CompSpec)). - %% dlink_tls_conn:send(Pid, - %% term_to_json( - %% {struct, - %% [ { ?DLINK_ARG_TRANSACTION_ID, 1 }, - %% { ?DLINK_ARG_CMD, ?DLINK_CMD_AUTHORIZE }, - %% { ?DLINK_ARG_ADDRESS, LocalIP }, - %% { ?DLINK_ARG_PORT, integer_to_list(LocalPort) }, - %% { ?DLINK_ARG_VERSION, ?DLINK_TLS_VERSION }, - %% { ?DLINK_ARG_CERTIFICATES, {array, get_certificates(CompSpec)} }, - %% { ?DLINK_ARG_SIGNATURE, get_authorize_jwt(CompSpec) } ]})). connection_authorized(FromPid, {RemoteIP, RemotePort} = Conn, CompSpec) -> %% If FromPid (the genserver managing the socket) is not yet registered @@ -744,7 +725,7 @@ connection_authorized(FromPid, {RemoteIP, RemotePort} = Conn, CompSpec) -> process_data(_FromPid, RemoteIP, RemotePort, ProtocolMod, Data, CompSpec) -> ?debug("dlink_tls:receive_data(): RemoteAddr: {~p, ~p}", [ RemoteIP, RemotePort ]), ?debug("dlink_tls:receive_data(): ~p:receive_message(~p)", [ ProtocolMod, Data ]), - Proto = list_to_existing_atom(ProtocolMod), + Proto = binary_to_existing_atom(ProtocolMod, latin1), Proto:receive_message(CompSpec, {RemoteIP, RemotePort}, Data). process_announce(Avail, Svcs, FromPid, IP, Port, CompSpec) -> diff --git a/components/rvi_common/src/rvi_common.erl b/components/rvi_common/src/rvi_common.erl index 0b54d53..1c4540f 100644 --- a/components/rvi_common/src/rvi_common.erl +++ b/components/rvi_common/src/rvi_common.erl @@ -124,7 +124,7 @@ json_argument([], [], Acc) -> lists:reverse(Acc); json_argument([Arg | AT], [Spec | ST], Acc) when is_atom(Arg)-> - json_argument(AT, ST, [ { Spec, atom_to_list(Arg) } | Acc]); + json_argument(AT, ST, [ { Spec, atom_to_binary(Arg, latin1) } | Acc]); json_argument([Arg | AT], [Spec | ST], Acc) -> json_argument(AT, ST, [ { Spec, Arg } | Acc]). @@ -162,7 +162,7 @@ request(Component, ?debug("Sending ~p:~p(~p) -> ~p.", [Module, Function, InArg, JSONArg]), case get_request_result( - send_json_request(URL, atom_to_list(Function), JSONArg) + send_json_request(URL, atom_to_binary(Function, latin1), JSONArg) ) of { ok, JSONBody} -> @@ -330,7 +330,7 @@ get_json_element_([], JSON) -> %% All proplist keys in JSON are strings. %% Convert atomically provided path elements to strings get_json_element_([Elem | T], JSON ) when is_atom(Elem) -> - get_json_element_([atom_to_list(Elem) | T], JSON); + get_json_element_([atom_to_binary(Elem, latin1) | T], JSON); get_json_element_(Path, {Type, JSON}) when Type==array; Type==struct -> |