diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-04-14 21:55:13 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-04-14 21:55:13 +0200 |
commit | 5a1cf3c8513c7eecdfd2234d971cc52c821ede75 (patch) | |
tree | ccdc57a7a4d312a42cef355955c31ac34a832006 /src/sccp_codec.erl | |
parent | 30b6eb2036ae386963cedfb4c27f1a6419422c4e (diff) |
SCCP Codec: Add some defaults for undefined fields in encoding
Diffstat (limited to 'src/sccp_codec.erl')
-rw-r--r-- | src/sccp_codec.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/sccp_codec.erl b/src/sccp_codec.erl index c1918a3..6293fac 100644 --- a/src/sccp_codec.erl +++ b/src/sccp_codec.erl @@ -235,6 +235,8 @@ gt_enc_by_odd(Odd) -> 2 end. +encode_gt(undefined) -> + {?SCCP_GTI_NO_GT, <<>>}; encode_gt(#global_title{gti = GTind, phone_number = PhoneNum, nature_of_addr_ind = Nature, trans_type = TransType, encoding = _EncOrig, @@ -278,6 +280,14 @@ encode_ssn(SSN) -> {1, <<SSN:8>>} end. +undef_or_true(Foo) -> + case Foo of + undefined -> 0; + 0 -> 0; + _ -> 1 + end. + + encode_sccp_addr(#sccp_addr{res_nat_use = ResNatUse, route_on_ssn = RoutInd, point_code = PointCode, @@ -287,7 +297,9 @@ encode_sccp_addr(#sccp_addr{res_nat_use = ResNatUse, {GTind, GTbin} = encode_gt(GT), {SSNind, SSNbin} = encode_ssn(SSN), {PCind, PCbin} = encode_pc(PointCode), - <<ResNatUse:1, RoutInd:1, GTind:4, SSNind:1, PCind:1, PCbin/binary, SSNbin/binary, GTbin/binary>>. + ResNatOut = undef_or_true(ResNatUse), + RoutIndOut = undef_or_true(RoutInd), + <<ResNatOut:1, RoutIndOut:1, GTind:4, SSNind:1, PCind:1, PCbin/binary, SSNbin/binary, GTbin/binary>>. encode_sccp_opt({OptNum, {DataBinLen, DataBin}}) when is_integer(OptNum) -> |