summaryrefslogtreecommitdiffstats
path: root/src/mtp3_codec.erl
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-16 20:03:37 +0100
committerHarald Welte <laforge@gnumonks.org>2012-01-16 20:03:37 +0100
commit429456f13f59ed5ecf996caa59e76ee9bdd9bb24 (patch)
treeaa282df99c43e1fdc3961a0e95e7b4b9787691c4 /src/mtp3_codec.erl
parentb668988e25d8edc98a73c4fde0f4a7a7133f5938 (diff)
MTP3: parsing of mgmt messages
Diffstat (limited to 'src/mtp3_codec.erl')
-rw-r--r--src/mtp3_codec.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mtp3_codec.erl b/src/mtp3_codec.erl
index 0fca990..ae86cdd 100644
--- a/src/mtp3_codec.erl
+++ b/src/mtp3_codec.erl
@@ -48,19 +48,24 @@ encode_mtp3_routing_label(#mtp3_routing_label{sig_link_sel = Sls, origin_pc = Op
encode_mtp3_msg(#mtp3_msg{network_ind = NetInd, service_ind = ServiceInd,
routing_label = RoutLbl, payload = Payload}) ->
RoutLblBin = encode_mtp3_routing_label(RoutLbl),
- PayloadBin = payload_to_binary(Payload),
+ PayloadBin = payload_to_binary(ServiceInd, Payload),
<<NetInd:2, 0:2, ServiceInd:4, RoutLblBin/binary, PayloadBin/binary>>.
-decode_payload(?MTP3_SERV_MGMT, Payload) ->
+decode_payload(?MTP3_SERV_MTN, Payload) ->
<<H0:4, H1:4, _:4, Len:4, TP/binary>> = Payload,
- #mtp3mg_msg{h0 = H0, h1 = H1, test_pattern = TP};
+ #mtp3mg_msg{h0 = H0, h1 = H1, payload = TP};
+decode_payload(?MTP3_SERV_MGMT, Payload) ->
+ <<H0:4, H1:4, Remain/binary>> = Payload,
+ #mtp3mg_msg{h0 = H0, h1 = H1, payload = Payload};
decode_payload(_, Payload) ->
Payload.
-payload_to_binary(#mtp3mg_msg{h0=H0, h1=H1, test_pattern=TP}) ->
+payload_to_binary(?MTP3_SERV_MTN, #mtp3mg_msg{h0=H0, h1=H1, payload=TP}) ->
Len = byte_size(TP),
<<H0:4, H1:4, 0:4, Len:4, TP/binary>>;
-payload_to_binary(Whatever) ->
+payload_to_binary(?MTP3_SERV_MGMT, #mtp3mg_msg{h0=H0, h1=H1, payload=Payload}) ->
+ <<H0:4, H1:4, Payload/binary>>;
+payload_to_binary(_, Whatever) ->
Whatever.