summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2013-06-24 07:59:52 +0200
committerHarald Welte <laforge@gnumonks.org>2013-06-24 08:00:24 +0200
commit049ee7350958ec580a8aff02a9c54e6a768396d7 (patch)
tree7ecae0a876e0dfedc92cd2406e0cc4c77e809952
parenta0d2d965665500c2ae912fa06900cf104fd6777c (diff)
isup_codec: add gen_party_number() helper
-rw-r--r--src/isup_codec.erl34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/isup_codec.erl b/src/isup_codec.erl
index ab7285d..dd2149f 100644
--- a/src/isup_codec.erl
+++ b/src/isup_codec.erl
@@ -35,7 +35,8 @@
-author('Harald Welte <laforge@gnumonks.org>').
-include("isup.hrl").
--export([parse_isup_msg/1, encode_isup_msg/1, parse_isup_party/2, encode_isup_party/1]).
+-export([parse_isup_msg/1, encode_isup_msg/1, parse_isup_party/2,
+ encode_isup_party/1, gen_party_number/3]).
-compile(export_all).
@@ -485,3 +486,34 @@ encode_isup_msg(Msg = #isup_msg{msg_type = MsgType}) ->
HdrBin = encode_isup_hdr(Msg),
Remain = encode_isup_msgt(MsgType, Msg),
<<HdrBin/binary, Remain/binary>>.
+
+
+listify(L) when is_list(L) ->
+ L;
+listify(L) when is_integer(L) ->
+ osmo_util:int2digit_list(L).
+
+encode_nature(international) ->
+ ?ISUP_ADDR_NAT_INTERNATIONAL;
+encode_nature(national) ->
+ ?ISUP_ADDR_NAT_NATIONAL;
+encode_nature(subscriber) ->
+ ?ISUP_ADDR_NAT_SUBSCRIBER;
+encode_nature(Int) when is_integer(Int) ->
+ Int.
+
+encode_numplan(isdn) ->
+ 1;
+encode_numplan(telephony) ->
+ 1;
+encode_numplan(data) ->
+ 3;
+encode_numplan(telex) ->
+ 4;
+encode_numplan(Int) when is_integer(Int) ->
+ Int.
+
+gen_party_number(NAI, NumPlan, Number) ->
+ #party_number{nature_of_addr_ind = encode_nature(NAI),
+ numbering_plan = encode_numplan(NumPlan),
+ phone_number = listify(Number)}.