diff --git a/include/nksip.hrl b/include/nksip.hrl
index 5c71b4ec..d9ea543f 100644
--- a/include/nksip.hrl
+++ b/include/nksip.hrl
@@ -204,33 +204,6 @@
}).
-%% Meta current uses:
-%% - {nksip_min_se, MinSE}
-
--record(dialog, {
- id :: nksip_dialog_lib:id(),
- app_id :: nksip:app_id(),
- call_id :: nksip:call_id(),
- created :: nksip_lib:timestamp(),
- updated :: nksip_lib:timestamp(),
- local_seq :: 0 | nksip:cseq(),
- remote_seq :: 0 | nksip:cseq(),
- local_uri :: nksip:uri(),
- remote_uri :: nksip:uri(),
- local_target :: nksip:uri(), % Only for use in proxy
- remote_target :: nksip:uri(),
- route_set :: [nksip:uri()],
- blocked_route_set :: boolean(),
- early :: boolean(),
- secure :: boolean(),
- caller_tag :: nksip:tag(),
- invite :: nksip:invite(),
- subscriptions = [] :: [nksip:subscription()],
- supported = [] :: [nksip:token()],
- meta = [] :: nksip:optslist()
-}).
-
-
-record(invite, {
status :: nksip_dialog:invite_status(),
answered :: nksip_lib:timestamp(),
@@ -263,6 +236,34 @@
}).
+%% Meta current uses:
+%% - {nksip_min_se, MinSE}
+
+-record(dialog, {
+ id :: nksip_dialog_lib:id(),
+ app_id :: nksip:app_id(),
+ call_id :: nksip:call_id(),
+ created :: nksip_lib:timestamp(),
+ updated :: nksip_lib:timestamp(),
+ local_seq :: 0 | nksip:cseq(),
+ remote_seq :: 0 | nksip:cseq(),
+ local_uri :: nksip:uri(),
+ remote_uri :: nksip:uri(),
+ local_target :: nksip:uri(), % Only for use in proxy
+ remote_target :: nksip:uri(),
+ route_set :: [nksip:uri()],
+ blocked_route_set :: boolean(),
+ early :: boolean(),
+ secure :: boolean(),
+ caller_tag :: nksip:tag(),
+ invite :: nksip:invite(),
+ subscriptions = [] :: [#subscription{}],
+ supported = [] :: [nksip:token()],
+ meta = [] :: nksip:optslist()
+}).
+
+
+
-record(sdp_m, {
media :: binary(), % <<"audio">>, ...
port = 0 :: inet:port_number(),
diff --git a/plugins/src/nksip_100rel_callbacks.erl b/plugins/src/nksip_100rel_callbacks.erl
index 83b87007..e20e3ead 100644
--- a/plugins/src/nksip_100rel_callbacks.erl
+++ b/plugins/src/nksip_100rel_callbacks.erl
@@ -122,7 +122,7 @@ nkcb_parse_uas_opt(Req, Resp, Opts) ->
%% @doc Called when a new reponse is going to be sent
--spec nkcb_uas_send_reply({nksip:response(), nksip:optlist()},
+-spec nkcb_uas_send_reply({nksip:response(), nksip:optslist()},
nksip_call:trans(), nksip_call:call()) ->
{continue, list()} | {error, term()}.
diff --git a/plugins/src/nksip_event_compositor_callbacks.erl b/plugins/src/nksip_event_compositor_callbacks.erl
index 7f8aa8a4..da51c663 100644
--- a/plugins/src/nksip_event_compositor_callbacks.erl
+++ b/plugins/src/nksip_event_compositor_callbacks.erl
@@ -35,7 +35,7 @@
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
- {reply, nksip:sip_reply()} | noreply.
+ {reply, nksip:sipreply()} | noreply.
nkcb_sip_method(#trans{method='PUBLISH', request=Req}, #call{app_id=AppId}) ->
diff --git a/plugins/src/nksip_refer_callbacks.erl b/plugins/src/nksip_refer_callbacks.erl
index 9e302cc9..91691402 100644
--- a/plugins/src/nksip_refer_callbacks.erl
+++ b/plugins/src/nksip_refer_callbacks.erl
@@ -50,7 +50,7 @@ nkcb_parse_uac_opts(Req, Opts) ->
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
- {reply, nksip:sip_reply()} | noreply.
+ {reply, nksip:sipreply()} | noreply.
nkcb_sip_method(#trans{method='REFER', request=Req}, #call{app_id=AppId}=Call) ->
Module = AppId:module(),
diff --git a/plugins/src/nksip_registrar_callbacks.erl b/plugins/src/nksip_registrar_callbacks.erl
index f6581a13..234ec00e 100644
--- a/plugins/src/nksip_registrar_callbacks.erl
+++ b/plugins/src/nksip_registrar_callbacks.erl
@@ -37,7 +37,7 @@
%% @private This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
- {reply, nksip:sip_reply()} | noreply.
+ {reply, nksip:sipreply()} | noreply.
nkcb_sip_method(#trans{method='REGISTER', request=Req}, #call{app_id=AppId}) ->
diff --git a/plugins/src/nksip_timers_callbacks.erl b/plugins/src/nksip_timers_callbacks.erl
index 78d6a260..ecdaf04d 100644
--- a/plugins/src/nksip_timers_callbacks.erl
+++ b/plugins/src/nksip_timers_callbacks.erl
@@ -140,7 +140,7 @@ nkcb_make_uac_dialog(Method, Uri, Opts, #call{dialogs=[Dialog|_]}=Call) ->
%% @doc Called when the UAC is preparing a request to be sent
--spec nkcb_uac_pre_request(nksip:request(), nksip:optlist(),
+-spec nkcb_uac_pre_request(nksip:request(), nksip:optslist(),
nksip_call_uac:uac_from(), nksip:call()) ->
{continue, list()}.
@@ -186,7 +186,7 @@ nkcb_uac_response(Req, Resp, UAC, Call) ->
%% @doc Called when preparing a UAS dialog response
-spec nkcb_uas_dialog_response(nksip:request(), nksip:response(),
- nksip:optlist(), nksip:call()) ->
+ nksip:optslist(), nksip:call()) ->
{ok, nksip:response(), nksip:optslist()} | continue.
nkcb_uas_dialog_response(Req, Resp, Opts, Call) ->
@@ -202,7 +202,7 @@ nkcb_uas_dialog_response(Req, Resp, Opts, Call) ->
%% @doc Called when the UAS is proceesing a request
--spec nkcb_uas_process(nksip_trans:trans(), nksip_call:call()) ->
+-spec nkcb_uas_process(nksip_call:trans(), nksip_call:call()) ->
{ok, nksip:call()} | {continue, list()}.
nkcb_uas_process(#trans{request=Req}=UAS, Call) ->
diff --git a/src/nksip_auth.erl b/src/nksip_auth.erl
index aeff7bd3..bb201e16 100644
--- a/src/nksip_auth.erl
+++ b/src/nksip_auth.erl
@@ -50,12 +50,12 @@ realms(#sipmsg{headers=Headers}) ->
get_realms(Headers, []);
realms(RespId) ->
- {ok, Hd1} = case nksip_response:header(RespId, ?RESP_WWW) of
- WWW when is_list(WWW) -> [{?RESP_WWW, Data} || Data <- WWW];
+ Hd1 = case nksip_response:header(RespId, ?RESP_WWW) of
+ {ok, WWW} when is_list(WWW) -> [{?RESP_WWW, Data} || Data <- WWW];
_ -> []
end,
- {ok, Hd2} = case nksip_response:header(RespId, ?RESP_PROXY) of
- Proxy when is_list(Proxy) -> [{?RESP_PROXY, Data} || Data <- Proxy];
+ Hd2 = case nksip_response:header(RespId, ?RESP_PROXY) of
+ {ok, Proxy} when is_list(Proxy) -> [{?RESP_PROXY, Data} || Data <- Proxy];
_ -> []
end,
get_realms(Hd1++Hd2, []).
diff --git a/src/nksip_call.erl b/src/nksip_call.erl
index b01e4223..8bae4a39 100644
--- a/src/nksip_call.erl
+++ b/src/nksip_call.erl
@@ -51,7 +51,7 @@
-type trans() :: #trans{}.
--type trans_id() :: binary().
+-type trans_id() :: integer().
-type fork() :: #fork{}.
@@ -83,7 +83,7 @@ call_id(#call{call_id=CallId}) ->
%% @private Sends a new request.
-spec send(nksip:request(), nksip:optslist()) ->
- nksip_uac:result() | nksip_uac:ack_result().
+ nksip_uac:uac_result() | nksip_uac:uac_ack_result().
send(#sipmsg{app_id=AppId, call_id=CallId}=Req, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send, Req, Opts}).
@@ -92,7 +92,7 @@ send(#sipmsg{app_id=AppId, call_id=CallId}=Req, Opts) ->
%% @private Generates and sends a new request.
-spec send(nksip:app_id(), nksip:call_id(), nksip:method(),
nksip:user_uri(), nksip:optslist()) ->
- nksip_uac:result() | nksip_uac:ack_result().
+ nksip_uac:uac_result() | nksip_uac:uac_ack_result().
send(AppId, CallId, Method, Uri, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send, Method, Uri, Opts}).
@@ -100,8 +100,8 @@ send(AppId, CallId, Method, Uri, Opts) ->
%% @private Generates and sends a new in-dialog request.
-spec send_dialog(nksip:app_id(), nksip:call_id(), nksip:method(),
- nksip_dialog:id(), nksip:optslist()) ->
- nksip_uac:result() | nksip_uac:ack_result().
+ nksip_dialog_lib:id(), nksip:optslist()) ->
+ nksip_uac:uac_result() | nksip_uac:uac_ack_result().
send_dialog(AppId, CallId, Method, DialogId, Opts) ->
nksip_router:send_work_sync(AppId, CallId, {send_dialog, DialogId, Method, Opts}).
@@ -109,7 +109,7 @@ send_dialog(AppId, CallId, Method, DialogId, Opts) ->
%% @private Cancels an ongoing INVITE request.
-spec send_cancel(nksip:app_id(), nksip:call_id(), nksip_sipmsg:id(),
- nksip:optlist()) ->
+ nksip:optslist()) ->
nksip_uac:uac_cancel_result().
send_cancel(AppId, CallId, RequestId, Opts) ->
@@ -178,7 +178,7 @@ get_all_dialogs(AppId, CallId) ->
%% @private Deletes a dialog
--spec stop_dialog(nksip:app_id(), nksip:call_id(), nksip_dialog:id()) ->
+-spec stop_dialog(nksip:app_id(), nksip:call_id(), nksip_dialog_lib:id()) ->
ok | {error, term()}.
stop_dialog(AppId, CallId, DialogId) ->
diff --git a/src/nksip_call_event.erl b/src/nksip_call_event.erl
index 3f74c149..2a248558 100644
--- a/src/nksip_call_event.erl
+++ b/src/nksip_call_event.erl
@@ -98,7 +98,7 @@ uac_response(_Req, _Resp, Dialog, _Call) ->
%% @private
-spec uac_do_response(nksip:method(), nksip:sip_code(), nksip:request(),
- nksip:response(), nksip:subscription(), nksip:dialog(),
+ nksip:response(), #subscription{}, nksip:dialog(),
nksip_call:call()) ->
nksip:dialog().
@@ -212,7 +212,7 @@ uas_response(_Req, _Resp, Dialog, _Call) ->
%% @private
-spec uas_do_response(nksip:method(), nksip:sip_code(), nksip:request(),
- nksip:response(), nksip:subscription(), nksip:dialog(),
+ nksip:response(), #subscription{}, nksip:dialog(),
nksip_call:call()) ->
nksip:dialog().
@@ -256,7 +256,7 @@ uas_do_response(_, _Code, _Req, _Resp, _Subs, Dialog, _Call) ->
%% @private
--spec update(term(), nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
+-spec update(term(), #subscription{}, nksip:dialog(), nksip_call:call()) ->
nksip:dialog().
update({subscribe, #sipmsg{class={req, Method}}=Req, Resp}, Subs, Dialog, Call) ->
@@ -409,7 +409,7 @@ stop(#subscription{id=Id}, Dialog, Call) ->
%% @private
-spec request_uac_opts(nksip:method(), nksip:optslist(),
- nksip:dialog() | nksip:subscription()) ->
+ nksip:dialog() | #subscription{}) ->
{ok, nksip:optslist()} | {error, unknown_subscription}.
request_uac_opts(Method, Opts, #dialog{}=Dialog) ->
@@ -455,7 +455,8 @@ request_uac_opts('NOTIFY', Opts, #subscription{event=Event, timer_expire=Timer})
%% @private Called when a dialog timer is fired
--spec timer({middle|timeout, nksip_subscription:id()}, nksip:dialog(), nksip_call:call()) ->
+-spec timer({middle|timeout, nksip_subscription_lib:id()},
+ nksip:dialog(), nksip_call:call()) ->
nksip_call:call().
timer({Type, Id}, Dialog, Call) ->
@@ -479,7 +480,7 @@ timer({Type, Id}, Dialog, Call) ->
%% @private Creates a new event
-spec create(uac|uas, nksip:request(), nksip:dialog(), nksip_call:call()) ->
- nksip:subscription().
+ #subscription{}.
create(Class, #sipmsg{class={req, Method}}=Req, Dialog, Call) ->
Event = case Method of
@@ -522,7 +523,7 @@ do_is_prov_event(Id, [_|Rest]) -> do_is_prov_event(Id, Rest).
%% @private Updates an updated event into dialog
--spec store(nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
+-spec store(#subscription{}, nksip:dialog(), nksip_call:call()) ->
nksip:dialog().
store(Subs, Dialog, _Call) ->
@@ -554,7 +555,7 @@ store(Subs, Dialog, _Call) ->
%% @private
--spec dialog_update(term(), nksip:subscription(), nksip:dialog(), nksip_call:call()) ->
+-spec dialog_update(term(), #subscription{}, nksip:dialog(), nksip_call:call()) ->
ok.
dialog_update(Status, Subs, Dialog, #call{app_id=AppId}=Call) ->
@@ -572,7 +573,7 @@ cancel_timer(Ref) ->
%% @private
--spec start_timer(integer(), {atom(), nksip_subscription:id()}, nksip:dialog()) ->
+-spec start_timer(integer(), {atom(), nksip_subscription_lib:id()}, nksip:dialog()) ->
reference().
start_timer(Time, Tag, #dialog{id=Id}) ->
diff --git a/src/nksip_call_uac_dialog.erl b/src/nksip_call_uac_dialog.erl
index 16429029..ede1694f 100644
--- a/src/nksip_call_uac_dialog.erl
+++ b/src/nksip_call_uac_dialog.erl
@@ -95,16 +95,16 @@ pre_request(Req, Call) ->
true ->
ok
end;
- false ->
+ not_found ->
{error, unknown_dialog}
end.
%% @private
--spec request(nksip:request(), boolean(), nksip_call:call()) ->
+-spec request(nksip:request(), true|false|undefined, nksip_call:call()) ->
nksip_call:call().
-request(#sipmsg{class={req, 'ACK'}}=Req, _, Call) ->
+request(#sipmsg{class={req, 'ACK'}}=Req, undefined, Call) ->
do_ack(Req, Call);
request(#sipmsg{class={req, Method}, dialog_id=DialogId}=Req, IsProxy, Call) ->
@@ -463,7 +463,7 @@ do_response(_, _Code, _Req, _Resp, Dialog, Call) ->
%% @private
--spec make(integer(), nksip:method(), nksip:optslist(), nksip_call:call()) ->
+-spec make(nksip_dialog_lib:id(), nksip:method(), nksip:optslist(), nksip_call:call()) ->
{ok, RUri::nksip:uri(), nksip:optslist(), nksip_call:call()} | {error, Error}
when Error :: invalid_dialog | unknown_dialog | unknown_subscription.
@@ -564,7 +564,7 @@ get_sdp(#sipmsg{body=Body}, #invite{sdp_offer=Offer, sdp_answer=Answer}) ->
%% @private
-spec generate(nksip:method(), nksip:optslist(), nksip:dialog(), nksip_call:call()) ->
- {{RUri, Opts}, nksip:dialog()}
+ {RUri, Opts, nksip:dialog()}
when RUri::nksip:uri(), Opts::nksip:optslist().
generate(Method, Opts, Dialog, _Call) ->
diff --git a/src/nksip_call_uac_make.erl b/src/nksip_call_uac_make.erl
index d3730ee5..4c48deeb 100644
--- a/src/nksip_call_uac_make.erl
+++ b/src/nksip_call_uac_make.erl
@@ -145,7 +145,7 @@ do_remove_local_routes(AppId, [Route|RestRoutes]) ->
%% @doc Generates a CANCEL request from an INVITE request.
--spec make_cancel(nksip:request(), nksip:optlist()) ->
+-spec make_cancel(nksip:request(), nksip:optslist()) ->
nksip:request().
make_cancel(Req, Opts) ->
@@ -438,7 +438,7 @@ parse_opts([Term|Rest], Req, Opts) ->
parse_opts(Rest, Req, Opts);
error when is_tuple(Term) ->
throw({invalid_config, element(1, Term)});
- error_ ->
+ error ->
throw({invalid_config, Term})
end.
diff --git a/src/nksip_call_uas.erl b/src/nksip_call_uas.erl
index 2465c9f8..843511b7 100644
--- a/src/nksip_call_uas.erl
+++ b/src/nksip_call_uas.erl
@@ -24,9 +24,8 @@
-export([request/2, reply/3, do_reply/3]).
-export_type([status/0, incoming/0]).
--import(nksip_call_lib, [update/2]).
-
+-import(nksip_call_lib, [update/2]).
-include("nksip.hrl").
-include("nksip_call.hrl").
@@ -229,7 +228,7 @@ process_request(Req, UASTransId, Call) ->
code = 0,
to_tags = [],
stateless = true,
- iter = undefined,
+ iter = 1,
cancel = undefined,
loop_id = LoopId,
timeout_timer = undefined,
diff --git a/src/nksip_call_uas_reply.erl b/src/nksip_call_uas_reply.erl
index a55b0008..a5a43e48 100644
--- a/src/nksip_call_uas_reply.erl
+++ b/src/nksip_call_uas_reply.erl
@@ -34,7 +34,7 @@
%% ===================================================================
%% @doc Sends a transaction reply
--spec reply(nksip_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
+-spec reply(nksip_call_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
{ok | {error, term()}, nksip_call:call()}.
@@ -84,7 +84,7 @@ reply(SipReply, #trans{id=Id, method=Method, status=Status}, Call) ->
%% @private
--spec send(nksip_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
+-spec send(nksip_call_uas:incoming(), nksip_call:trans(), nksip_call:call()) ->
{ok, nksip_call:call()} | {error, term()}.
send({Resp, SendOpts}, UAS, Call) ->
diff --git a/src/nksip_call_worker.erl b/src/nksip_call_worker.erl
index 70c321f2..e7ce01b4 100644
--- a/src/nksip_call_worker.erl
+++ b/src/nksip_call_worker.erl
@@ -39,6 +39,7 @@
{send, nksip:request(), nksip:optslist()} |
{send, nksip:method(), nksip:user_uri(), nksip:optslist()} |
{send_dialog, nksip_dialog_lib:id(), nksip:method(), nksip:optslist()} |
+ {send_cancel, nksip_sipmsg:id(), nksip:sipreply()} |
{cancel, nksip_sipmsg:id()} |
{send_reply, nksip_sipmsg:id(), nksip:sipreply()} |
{incoming, #sipmsg{}} |
diff --git a/src/nksip_callbacks.erl b/src/nksip_callbacks.erl
index c3fca53b..8c0bb942 100644
--- a/src/nksip_callbacks.erl
+++ b/src/nksip_callbacks.erl
@@ -59,7 +59,7 @@ nkcb_call(Fun, Args, AppId) ->
%% @doc This plugin callback is called when a call to one of the method specific
%% application-level SipApp callbacks is needed.
-spec nkcb_sip_method(nksip_call:trans(), nksip_call:call()) ->
- {reply, nksip:sip_reply()} | noreply | nkcb_common().
+ {reply, nksip:sipreply()} | noreply | nkcb_common().
nkcb_sip_method(#trans{method='ACK', request=Req}, #call{app_id=AppId}=Call) ->
@@ -155,7 +155,7 @@ nkcb_make_uac_dialog(Method, Uri, Opts, Call) ->
%% @doc Called when the UAC is preparing a request to be sent
--spec nkcb_uac_pre_request(nksip:request(), nksip:optlist(),
+-spec nkcb_uac_pre_request(nksip:request(), nksip:optslist(),
nksip_call_uac:uac_from(), nksip:call()) ->
{continue, list()}.
@@ -165,7 +165,7 @@ nkcb_uac_pre_request(Req, Opts, From, Call) ->
%% @doc Called when the UAC transaction must send a reply to the user
-spec nkcb_uac_reply({req, nksip:request()} | {resp, nksip:response()} | {error, term()},
- nksip_trans:trans(), nksip_call:call()) ->
+ nksip_call:trans(), nksip_call:call()) ->
{ok, nksip:call()} | {continue, list()}.
nkcb_uac_reply(Class, UAC, Call) ->
@@ -183,7 +183,7 @@ nkcb_transport_uac_headers(Req, Opts, Scheme, Proto, Host, Port) ->
%% @doc Called when a new reponse is going to be sent
--spec nkcb_uas_send_reply({nksip:response(), nksip:optlist()},
+-spec nkcb_uas_send_reply({nksip:response(), nksip:optslist()},
nksip_call:trans(), nksip_call:call()) ->
{error, term()} | nkcb_common().
@@ -226,7 +226,7 @@ nkcb_parse_uas_opt(Req, Resp, Opts) ->
%% @doc Called when preparing a UAS dialog response
-spec nkcb_uas_dialog_response(nksip:request(), nksip:response(),
- nksip:optlist(), nksip:call()) ->
+ nksip:optslist(), nksip:call()) ->
{ok, nksip:response(), nksip:optslist()}.
nkcb_uas_dialog_response(_Req, Resp, Opts, _Call) ->
@@ -234,7 +234,7 @@ nkcb_uas_dialog_response(_Req, Resp, Opts, _Call) ->
%% @doc Called when the UAS is proceesing a request
--spec nkcb_uas_process(nksip_trans:trans(), nksip_call:call()) ->
+-spec nkcb_uas_process(nksip_call:trans(), nksip_call:call()) ->
{ok, nksip:call()} | {continue, list()}.
nkcb_uas_process(UAS, Call) ->
diff --git a/src/nksip_code_util.erl b/src/nksip_code_util.erl
index 68741389..6c2e3772 100644
--- a/src/nksip_code_util.erl
+++ b/src/nksip_code_util.erl
@@ -61,7 +61,7 @@ getter(Fun, Value) ->
%% @doc Generates a function expression (fun(A1,B1,..) -> Value)
%% Vers represents the suffix to use in the variable names
--spec fun_expr(atom(), pos_integer(), pos_integer(), term()) ->
+-spec fun_expr(atom(), integer(), integer(), term()) ->
erl_syntax:syntaxTree().
fun_expr(Fun, Arity, Vers, Value) ->
@@ -72,7 +72,7 @@ fun_expr(Fun, Arity, Vers, Value) ->
%% @doc Generates a call expression (mod:fun(A1,B1,..))
%% Vers represents the suffix to use in the variable names.
--spec call_expr(atom(), atom(), pos_integer(), pos_integer()) ->
+-spec call_expr(atom(), atom(), integer(), integer()) ->
erl_syntax:syntaxTree().
call_expr(Mod, Fun, Arity, Vers) ->
@@ -83,7 +83,7 @@ call_expr(Mod, Fun, Arity, Vers) ->
%% @doc Generates a call expression (fun(A0,B0...) -> mod:fun(A0,B0,..))
--spec callback_expr(atom(), atom(), pos_integer()) ->
+-spec callback_expr(atom(), atom(), integer()) ->
erl_syntax:syntaxTree().
callback_expr(Mod, Fun, Arity) ->
@@ -97,7 +97,7 @@ callback_expr(Mod, Fun, Arity) ->
%% Other -> Other
%% end
%% Vers represents the suffix to use in the variable names.
--spec case_expr(atom(), atom(), pos_integer(), pos_integer(),
+-spec case_expr(atom(), atom(), integer(), integer(),
[erl_syntax:syntaxTree()]) ->
erl_syntax:syntaxTree().
@@ -180,7 +180,7 @@ write(Mod, Tree) ->
%% @doc Gets the list of exported functions of a module
-spec get_funs(atom()) ->
- [{atom(), pos_integer()}] | error.
+ [{atom(), integer()}] | error.
get_funs(Mod) ->
case catch Mod:module_info() of
diff --git a/src/nksip_config_cache.erl b/src/nksip_config_cache.erl
index 042b0996..76d4804f 100644
--- a/src/nksip_config_cache.erl
+++ b/src/nksip_config_cache.erl
@@ -42,6 +42,8 @@ main_ip6() -> nksip_config:get(main_ip6).
sync_call_time() -> nksip_config:get(sync_call_time).
+msg_routers() -> nksip_config:get(msg_routers).
+
dns_cache_ttl() -> nksip_config:get(dns_cache_ttl).
local_data_path() -> nksip_config:get(local_data_path).
@@ -52,4 +54,7 @@ global_max_calls() -> nksip_config:get(global_max_calls).
app_config() -> nksip_config:get(app_config).
+re_call_id() -> nksip_config:get(re_call_id).
+
+re_content_length() -> nksip_config:get(re_content_length).
diff --git a/src/nksip_dialog.erl b/src/nksip_dialog.erl
index a62c9994..97500966 100644
--- a/src/nksip_dialog.erl
+++ b/src/nksip_dialog.erl
@@ -115,7 +115,7 @@ call_id(Handle) ->
%% @doc Get a specific metadata
--spec meta(field(), nksip:dialog()) ->
+-spec meta(field(), nksip:dialog()|nksip:handle()) ->
{ok, term()} | {error, term()}.
meta(Field, #dialog{}=Dialog) ->
@@ -130,7 +130,7 @@ meta(Field, Handle) ->
%% @doc Get a group of specific metadata
--spec metas([field()], nksip:dialog()) ->
+-spec metas([field()], nksip:dialog()|nksip:handle()) ->
{ok, [{field(), term()}]} | {error, term()}.
metas(Fields, #dialog{}=Dialog) when is_list(Fields) ->
diff --git a/src/nksip_dialog_lib.erl b/src/nksip_dialog_lib.erl
index 22b9775f..512b31b9 100644
--- a/src/nksip_dialog_lib.erl
+++ b/src/nksip_dialog_lib.erl
@@ -67,7 +67,7 @@ get_handle(_) ->
%% @doc
-spec parse_handle(nksip:handle()) ->
- {nksip:app_id(), id(), nksip:call_id()} | error.
+ {nksip:app_id(), id(), nksip:call_id()}.
parse_handle(<<$D, $_, _/binary>>=Bin) ->
<<$D, $_, Id:6/binary, $_, App:7/binary, $_, CallId/binary>> = Bin,
@@ -82,7 +82,7 @@ parse_handle(_) ->
meta(Field, #dialog{invite=I}=D) ->
case Field of
- handle -> element(2, get_handle(D));
+ handle -> get_handle(D);
internal_id -> D#dialog.id;
app_id -> D#dialog.app_id;
app_name -> apply(D#dialog.app_id, name, []);
@@ -146,26 +146,22 @@ remote_meta(Field, Handle) ->
{ok, [{nksip_dialog:field(), term()}]} | {error, term()}.
remote_metas(Fields, Handle) when is_list(Fields) ->
- case parse_handle(Handle) of
- {AppId, DialogId, CallId} ->
- Fun = fun(Dialog) ->
- case catch metas(Fields, Dialog) of
- {'EXIT', {{invalid_field, Field}, _}} ->
- {error, {invalid_field, Field}};
- Values ->
- {ok, Values}
- end
- end,
- case nksip_call:apply_dialog(AppId, CallId, DialogId, Fun) of
- {apply, {ok, Values}} ->
- {ok, Values};
- {apply, {error, {invalid_field, Field}}} ->
- error({invalid_field, Field});
- {error, Error} ->
- {error, Error}
- end;
- _ ->
- error(invalid_handle)
+ {AppId, DialogId, CallId} = parse_handle(Handle),
+ Fun = fun(Dialog) ->
+ case catch metas(Fields, Dialog) of
+ {'EXIT', {{invalid_field, Field}, _}} ->
+ {error, {invalid_field, Field}};
+ Values ->
+ {ok, Values}
+ end
+ end,
+ case nksip_call:apply_dialog(AppId, CallId, DialogId, Fun) of
+ {apply, {ok, Values}} ->
+ {ok, Values};
+ {apply, {error, {invalid_field, Field}}} ->
+ error({invalid_field, Field});
+ {error, Error} ->
+ {error, Error}
end.
@@ -215,7 +211,7 @@ remote_id(<<$D, _/binary>>=DialogId, App) ->
FromTag = nksip_lib:get_binary(<<"tag">>, LUri#uri.ext_opts),
ToTag = nksip_lib:get_binary(<<"tag">>, RUri#uri.ext_opts),
Id = case make_id(uac, FromTag, ToTag) of
- BaseId -> make_id(uas, FromTag,ToTag);
+ BaseId -> make_id(uas, FromTag, ToTag);
RemoteId -> RemoteId
end,
BinApp = atom_to_binary(AppId, latin1),
diff --git a/src/nksip_sipapp_config.erl b/src/nksip_sipapp_config.erl
index 91fa51f5..dc309caf 100644
--- a/src/nksip_sipapp_config.erl
+++ b/src/nksip_sipapp_config.erl
@@ -66,10 +66,7 @@ start(Opts) ->
AppName = nksip_lib:get_value(name, Opts, nksip),
AppId = nksip_sipapp_srv:get_appid(AppName),
BasePath = nksip_config_cache:local_data_path(),
- case nksip_sipapp_srv:update_uuid(AppId, AppName, BasePath) of
- {ok, UUID} -> ok;
- {error, Error} -> UUID = throw(Error)
- end,
+ {ok, UUID} = nksip_sipapp_srv:update_uuid(AppId, AppName, BasePath),
Environment = nksip_config_cache:app_config(),
Defaults = nksip_lib:defaults(Environment, default_config()),
Opts1 = lists:map(
@@ -330,8 +327,8 @@ parse_opts([Term|Rest], Opts) ->
_ ->
{Key, Val} = case Op of
update -> {element(1, Term), element(2, Term)};
- {update, Val1} -> {element(1, Term), Val1};
- {update, Key1, Val1} -> {Key1, Val1}
+ {update, Val1} -> {element(1, Term), Val1}
+ % {update, Key1, Val1} -> {Key1, Val1}
end,
case lists:keymember(Key, 1, Opts) of
true -> throw({invalid_config, {duplicated_key, Key}});
diff --git a/src/nksip_sipmsg.erl b/src/nksip_sipmsg.erl
index 411196a9..74bb9c17 100644
--- a/src/nksip_sipmsg.erl
+++ b/src/nksip_sipmsg.erl
@@ -27,7 +27,7 @@
-export([meta/2, metas/2, header/2, header/3, all_headers/1]).
-export([supported/2, require/2, is_dialog_forming/1, get_handle/1, parse_handle/1]).
-export([remote_meta/2, remote_metas/2]).
--export_type([id/0]).
+-export_type([id/0, field/0]).
-include("nksip.hrl").
-type id() :: binary().
@@ -151,7 +151,7 @@ meta(Name, #sipmsg{class=Class, ruri=RUri, from=From, to=To}=S) ->
undefined
end;
all_headers -> all_headers(S);
- {header, Name} -> header(Name, S);
+ {header, HeaderName} -> header(HeaderName, S);
_ -> error({invalid_field, Name})
end.
@@ -263,7 +263,7 @@ all_headers(SipMsg) ->
_ -> {<<"require">>, header(<<"require">>, SipMsg)}
end,
case SipMsg#sipmsg.supported of
- <<>> -> [];
+ [] -> [];
_ -> {<<"supported">>, header(<<"supported">>, SipMsg)}
end,
case SipMsg#sipmsg.expires of
@@ -392,26 +392,22 @@ remote_meta(Field, Handle) ->
{ok, [{field(), term()}]} | {error, term()}.
remote_metas(Fields, Handle) when is_list(Fields) ->
- case parse_handle(Handle) of
- {_Class, AppId, MsgId, CallId} ->
- Fun = fun(SipMsg) ->
- case catch metas(Fields, SipMsg) of
- {'EXIT', {{invalid_field, Field}, _}} ->
- {error, {invalid_field, Field}};
- Values ->
- {ok, Values}
- end
- end,
- case nksip_call:apply_sipmsg(AppId, CallId, MsgId, Fun) of
- {apply, {ok, Values}} ->
- {ok, Values};
- {apply, {error, {invalid_field, Field}}} ->
- error({invalid_field, Field});
- {error, Error} ->
- {error, Error}
- end;
- _ ->
- error(invalid_handle)
+ {_Class, AppId, MsgId, CallId} = parse_handle(Handle),
+ Fun = fun(SipMsg) ->
+ case catch metas(Fields, SipMsg) of
+ {'EXIT', {{invalid_field, Field}, _}} ->
+ {error, {invalid_field, Field}};
+ Values ->
+ {ok, Values}
+ end
+ end,
+ case nksip_call:apply_sipmsg(AppId, CallId, MsgId, Fun) of
+ {apply, {ok, Values}} ->
+ {ok, Values};
+ {apply, {error, {invalid_field, Field}}} ->
+ error({invalid_field, Field});
+ {error, Error} ->
+ {error, Error}
end.
diff --git a/src/nksip_subscription.erl b/src/nksip_subscription.erl
index a665330d..7aa59622 100644
--- a/src/nksip_subscription.erl
+++ b/src/nksip_subscription.erl
@@ -25,8 +25,8 @@
-author('Carlos Gonzalez ').
-export([get_handle/1, app_id/1, app_name/1, call_id/1, meta/2, metas/2]).
--export([get_all/0, get_all/2, get_subscription/2]).
--export_type([status/0, subscription_state/0, terminated_reason/0]).
+-export([get_all/0, get_all/2]).
+-export_type([field/0, status/0, subscription_state/0, terminated_reason/0]).
-include("nksip.hrl").
-include("nksip_call.hrl").
@@ -106,7 +106,7 @@ call_id(Id) ->
%% @doc Get a specific metadata
--spec meta(field(), nksip:subscription()) ->
+-spec meta(field(), nksip:subscription()|nksip:handle()) ->
{ok, term()} | {error, term()}.
meta(Field, {user_subs, _, _}=Subs) ->
@@ -121,7 +121,7 @@ meta(Field, Handle) ->
%% @doc Get a group of specific metadata
--spec metas([field()], nksip:subscription()) ->
+-spec metas([field()], nksip:subscription()|nksip:handle()) ->
{ok, [{field(), term()}]} | {error, term()}.
metas(Fields, {user_subs, _, _}=Subs) when is_list(Fields) ->
@@ -135,15 +135,15 @@ metas(Fields, Handle) when is_list(Fields) ->
nksip_subscription_lib:remote_metas(Fields, Handle).
-%% @doc Gets the subscription object corresponding to a request or subscription and a call
--spec get_subscription(nksip:request()|nksip:response()|nksip:subscription(), nksip:call()) ->
- {ok, nksip:subscription()} | {error, term()}.
+% %% @doc Gets the subscription object corresponding to a request or subscription and a call
+% -spec get_subscription(nksip:request()|nksip:response()|nksip:subscription(), nksip:call()) ->
+% {ok, nksip:subscription()} | {error, term()}.
-get_subscription({uses_subs, _Subs, _Dialog}=UserSubs, _) ->
- UserSubs;
+% get_subscription({uses_subs, _Subs, _Dialog}=UserSubs, _) ->
+% UserSubs;
-get_subscription(#sipmsg{}=SipMsg, #call{}=Call) ->
- nksip_subscription_lib:get_subscription(SipMsg, Call).
+% get_subscription(#sipmsg{}=SipMsg, #call{}=Call) ->
+% nksip_subscription_lib:get_subscription(SipMsg, Call).
%% @doc Gets all started subscription ids.
diff --git a/src/nksip_subscription_lib.erl b/src/nksip_subscription_lib.erl
index dfa2bf6c..bd05b77a 100644
--- a/src/nksip_subscription_lib.erl
+++ b/src/nksip_subscription_lib.erl
@@ -128,31 +128,27 @@ remote_meta(Field, Handle) ->
{ok, [{nksip_dialog:field(), term()}]} | {error, term()}.
remote_metas(Fields, Handle) when is_list(Fields) ->
- case parse_handle(Handle) of
- {AppId, SubsId, DialogId, CallId} ->
- Fun = fun(Dialog) ->
- case find(SubsId, Dialog) of
- #subscription{} = U ->
- case catch metas(Fields, {user_subs, U, Dialog}) of
- {'EXIT', {{invalid_field, Field}, _}} ->
- {error, {invalid_field, Field}};
- Values ->
- {ok, Values}
- end;
- not_found ->
- {error, invalid_subscription}
- end
- end,
- case nksip_call:apply_dialog(AppId, CallId, DialogId, Fun) of
- {apply, {ok, Values}} ->
- {ok, Values};
- {apply, {error, {invalid_field, Field}}} ->
- error({invalid_field, Field});
- {error, Error} ->
- {error, Error}
- end;
- _ ->
- error(invalid_handle)
+ {AppId, SubsId, DialogId, CallId} = parse_handle(Handle),
+ Fun = fun(Dialog) ->
+ case find(SubsId, Dialog) of
+ #subscription{} = U ->
+ case catch metas(Fields, {user_subs, U, Dialog}) of
+ {'EXIT', {{invalid_field, Field}, _}} ->
+ {error, {invalid_field, Field}};
+ Values ->
+ {ok, Values}
+ end;
+ not_found ->
+ {error, invalid_subscription}
+ end
+ end,
+ case nksip_call:apply_dialog(AppId, CallId, DialogId, Fun) of
+ {apply, {ok, Values}} ->
+ {ok, Values};
+ {apply, {error, {invalid_field, Field}}} ->
+ error({invalid_field, Field});
+ {error, Error} ->
+ {error, Error}
end.