Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2016-07-30 13:30:29 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2016-07-30 13:30:29 +0300
commitd2d3b961eb5738c03216ef436a8575da80a5a2e4 (patch)
tree23a7d3727eb9af22dd42397647e9c5530f864378 /tools
parentf19d2fdcffb3474aeea1050746ac30a778607954 (diff)
Rewrite mod_sic to use XML generator
Diffstat (limited to 'tools')
-rw-r--r--tools/xmpp_codec.spec34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/xmpp_codec.spec b/tools/xmpp_codec.spec
index f72e250f2..9cb14282c 100644
--- a/tools/xmpp_codec.spec
+++ b/tools/xmpp_codec.spec
@@ -2997,6 +2997,30 @@
#ref{name = oob_desc, default = <<"">>,
min = 0, max = 1, label = '$desc'}]}).
+-xml(sic_ip,
+ #elem{name = <<"ip">>,
+ xmlns = [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>],
+ result = '$cdata',
+ cdata = #cdata{required = true,
+ dec = {dec_ip, []},
+ enc = {enc_ip, []}}}).
+
+-xml(sip_port,
+ #elem{name = <<"port">>,
+ xmlns = <<"urn:xmpp:sic:1">>,
+ result = '$cdata',
+ cdata = #cdata{required = true,
+ dec = {dec_int, [0, 65535]},
+ enc = {enc_int, []}}}).
+
+-xml(sic,
+ #elem{name = <<"address">>,
+ xmlns = [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>],
+ result = {sic, '$ip', '$port', '$xmlns'},
+ attrs = [#attr{name = <<"xmlns">>}],
+ refs = [#ref{name = sic_ip, min = 0, max = 1, label = '$ip'},
+ #ref{name = sip_port, min = 0, max = 1, label = '$port'}]}).
+
dec_tzo(Val) ->
[H1, M1] = str:tokens(Val, <<":">>),
H = jlib:binary_to_integer(H1),
@@ -3050,6 +3074,16 @@ join([], _Sep) -> <<>>;
join([H | T], Sep) ->
<<H/binary, (<< <<Sep, X/binary>> || X <- T >>)/binary>>.
+dec_ip(S) ->
+ {ok, Addr} = inet_parse:address(binary_to_list(S)),
+ Addr.
+
+enc_ip({0,0,0,0,0,16#ffff,A,B}) ->
+ enc_ip({(A bsr 8) band 16#ff, A band 16#ff,
+ (B bsr 8) band 16#ff, B band 16#ff});
+enc_ip(Addr) ->
+ list_to_binary(inet_parse:ntoa(Addr)).
+
%% Local Variables:
%% mode: erlang
%% End: