Commit 00e22188 authored by Michael Jerris's avatar Michael Jerris

max_prodceeding

darcs-hash:20080227211149-16063-a3a6d7e9230aff0b9d194f796a390642ba7a2c05.gz
parent 447858c1
......@@ -345,7 +345,7 @@ su_log_t nta_log[] = { SU_LOG_INIT("nta", "NTA_DEBUG", SU_DEBUG) };
* NTATAG_SIP_T1X64(), NTATAG_SIP_T1(), NTATAG_SIP_T2(), NTATAG_SIP_T4(),
* NTATAG_STATELESS(),
* NTATAG_TAG_3261(), NTATAG_TCP_RPORT(), NTATAG_TIMEOUT_408(),
* NTATAG_TIMER_C(),
* NTATAG_TIMER_C(), NTATAG_MAX_PROCEEDING(),
* NTATAG_UA(), NTATAG_UDP_MTU(), NTATAG_USER_VIA(),
* NTATAG_USE_NAPTR(), NTATAG_USE_SRV() and NTATAG_USE_TIMESTAMP().
*
......@@ -884,7 +884,7 @@ void agent_kill_terminator(nta_agent_t *agent)
* INVITE transactions, or how the @Via headers are generated.
*
* @note
* Setting the parameters NTATAG_MAXSIZE(), NTATAG_UDP_MTU(),
* Setting the parameters NTATAG_MAXSIZE(), NTATAG_UDP_MTU(), NTATAG_MAX_PROCEEDING(),
* NTATAG_SIP_T1X64(), NTATAG_SIP_T1(), NTATAG_SIP_T2(), NTATAG_SIP_T4() to
* 0 selects the default value.
*
......@@ -902,7 +902,7 @@ void agent_kill_terminator(nta_agent_t *agent)
* NTATAG_SIP_T1X64(), NTATAG_SIP_T1(), NTATAG_SIP_T2(), NTATAG_SIP_T4(),
* NTATAG_STATELESS(),
* NTATAG_TAG_3261(), NTATAG_TCP_RPORT(), NTATAG_TIMEOUT_408(),
* NTATAG_TIMER_C(),
* NTATAG_TIMER_C(), NTATAG_MAX_PROCEEDING(),
* NTATAG_UA(), NTATAG_UDP_MTU(), NTATAG_USER_VIA(),
* NTATAG_USE_NAPTR(), NTATAG_USE_SRV() and NTATAG_USE_TIMESTAMP().
*
......@@ -935,6 +935,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
unsigned bad_req_mask = agent->sa_bad_req_mask;
unsigned bad_resp_mask = agent->sa_bad_resp_mask;
usize_t maxsize = agent->sa_maxsize;
usize_t max_proceeding = agent->sa_max_proceeding;
unsigned max_forwards = agent->sa_max_forwards->mf_count;
unsigned udp_mtu = agent->sa_udp_mtu;
unsigned sip_t1 = agent->sa_t1;
......@@ -988,6 +989,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_EXTRA_100_REF(extra_100),
NTATAG_GRAYLIST_REF(graylist),
NTATAG_MAXSIZE_REF(maxsize),
NTATAG_MAX_PROCEEDING_REF(max_proceeding),
NTATAG_MAX_FORWARDS_REF(max_forwards),
NTATAG_MCLASS_REF(mclass),
NTATAG_MERGE_482_REF(merge_482),
......@@ -1092,6 +1094,9 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
if (maxsize > NTA_TIME_MAX) maxsize = NTA_TIME_MAX;
agent->sa_maxsize = maxsize;
if (max_proceeding == 0) max_proceeding = SIZE_MAX;
agent->sa_max_proceeding = max_proceeding;
if (max_forwards == 0) max_forwards = 70; /* Default value */
agent->sa_max_forwards->mf_count = max_forwards;
......@@ -1206,7 +1211,7 @@ void agent_set_udp_params(nta_agent_t *self, usize_t udp_mtu)
* NTATAG_DEBUG_DROP_PROB_REF(), NTATAG_DEFAULT_PROXY_REF(),
* NTATAG_EXTRA_100_REF(), NTATAG_GRAYLIST_REF(),
* NTATAG_MAXSIZE_REF(), NTATAG_MAX_FORWARDS_REF(), NTATAG_MCLASS_REF(),
* NTATAG_MERGE_482_REF(),
* NTATAG_MERGE_482_REF(), NTATAG_MAX_PROCEEDING_REF(),
* NTATAG_PASS_100_REF(), NTATAG_PASS_408_REF(), NTATAG_PRELOAD_REF(),
* NTATAG_PROGRESS_REF(),
* NTATAG_REL100_REF(),
......@@ -1255,6 +1260,7 @@ int agent_get_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_EXTRA_100(agent->sa_extra_100),
NTATAG_GRAYLIST(agent->sa_graylist),
NTATAG_MAXSIZE(agent->sa_maxsize),
NTATAG_MAX_PROCEEDING(agent->sa_max_proceeding),
NTATAG_MAX_FORWARDS(agent->sa_max_forwards->mf_count),
NTATAG_MCLASS(agent->sa_mclass),
NTATAG_MERGE_482(agent->sa_merge_482),
......@@ -2432,9 +2438,16 @@ void agent_recv_request(nta_agent_t *agent,
leg_recv(leg, msg, sip, tport);
}
else if (!agent->sa_is_stateless && (leg = agent->sa_default_leg)) {
SU_DEBUG_5(("nta: %s (%u) %s\n",
method_name, cseq, "going to a default leg"));
leg_recv(leg, msg, sip, tport);
if (method == sip_method_invite && agent->sa_in.proceeding->q_length >= agent->sa_max_proceeding) {
SU_DEBUG_5(("nta: proceeding queue full for %s (%u)\n", method_name, cseq));
nta_msg_treply(agent, msg, SIP_503_SERVICE_UNAVAILABLE,
NTATAG_TPORT(tport),
TAG_END());
return;
} else {
SU_DEBUG_5(("nta: %s (%u) %s\n", method_name, cseq, "going to a default leg"));
leg_recv(leg, msg, sip, tport);
}
}
else if (agent->sa_callback) {
/* Stateless processing for request */
......
......@@ -145,6 +145,9 @@ struct nta_agent_s
/** Maximum size of incoming messages */
size_t sa_maxsize;
/** Maximum size of proceeding queue */
size_t sa_max_proceeding;
/** Maximum size of outgoing UDP requests */
unsigned sa_udp_mtu;
......
......@@ -400,6 +400,27 @@ tag_typedef_t ntatag_remote_cseq = UINTTAG_TYPEDEF(remote_cseq);
*/
tag_typedef_t ntatag_maxsize = USIZETAG_TYPEDEF(maxsize);
/**@def NTATAG_MAX_PROCEEDING(x)
*
* Maximum size of proceeding queue.
*
* If the size of the proceedng message queue would exceed the
* given limit, the stack will automatically respond with <i>503
* Service Unavailable</i>.
*
* @par Used with
* nua_create(), nua_set_params(),
* nta_agent_create(), nta_agent_set_params()
*
* @par Parameter type
* - #usize_t
*
* @par Values
* - Maximum acceptable size of a queue (size_t).
*
*/
tag_typedef_t ntatag_max_proceeding = USIZETAG_TYPEDEF(max_proceeding);
/**@def NTATAG_UDP_MTU(x)
*
* Maximum size of outgoing UDP request.
......
......@@ -155,6 +155,12 @@ NTA_DLL extern tag_typedef_t ntatag_udp_mtu;
NTA_DLL extern tag_typedef_t ntatag_udp_mtu_ref;
#define NTATAG_UDP_MTU_REF(x) ntatag_udp_mtu_ref, tag_uint_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_max_proceeding;
#define NTATAG_MAX_PROCEEDING(x) ntatag_max_proceeding, tag_usize_v((x))
NTA_DLL extern tag_typedef_t ntatag_max_proceeding_ref;
#define NTATAG_MAX_PROCEEDING_REF(x) ntatag_max_proceeding_ref, tag_usize_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_max_forwards;
#define NTATAG_MAX_FORWARDS(x) ntatag_max_forwards, tag_uint_v((x))
......
......@@ -1535,6 +1535,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
/* nta */
unsigned udp_mtu = 0;
usize_t max_proceeding = 0;
unsigned sip_t1 = 0, sip_t2 = 0, sip_t4 = 0, sip_t1x64 = 0;
unsigned debug_drop_prob = 0;
url_string_t const *proxy = NULL;
......@@ -1550,6 +1551,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
nta_agent_get_params(nua->nua_nta,
NTATAG_UDP_MTU_REF(udp_mtu),
NTATAG_MAX_PROCEEDING_REF(max_proceeding),
NTATAG_SIP_T1_REF(sip_t1),
NTATAG_SIP_T2_REF(sip_t2),
NTATAG_SIP_T4_REF(sip_t4),
......@@ -1691,6 +1693,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
#endif
NTATAG_UDP_MTU(udp_mtu),
NTATAG_MAX_PROCEEDING(max_proceeding),
NTATAG_SIP_T1(sip_t1),
NTATAG_SIP_T2(sip_t2),
NTATAG_SIP_T4(sip_t4),
......
......@@ -216,6 +216,8 @@ su_inline tag_value_t tag_filter_v(tag_filter_f *v) {return(tag_value_t)v;}
#define tag_uint_vr(v) (tag_value_t)(v)
#define tag_usize_v(v) (tag_value_t)(v)
#define tag_usize_vr(v) (tag_value_t)(v)
#define tag_size_v(v) (tag_value_t)(v)
#define tag_size_vr(v) (tag_value_t)(v)
#define tag_bool_v(v) (tag_value_t)(v != 0)
#define tag_bool_vr(v) (tag_value_t)(v)
#define tag_ptr_v(v) (tag_value_t)(v)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment