tm/config.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2008 iptelorg GmbH
00005  *
00006  * This file is part of SIP-router, a free SIP server.
00007  *
00008  * SIP-router is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * SIP-router is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * History
00023  * -------
00024  *  2008-02-05  adapting tm module for the configuration framework (Miklos)
00025  */
00026 
00033 #include "../../cfg/cfg.h"
00034 #include "../../parser/msg_parser.h" /* method types */
00035 #include "timer.h"
00036 #include "t_fwd.h"
00037 #include "t_cancel.h" /* cancel_b_flags_fixup() */
00038 #include "config.h"
00039 
00040 struct cfg_group_tm     default_tm_cfg = {
00041         /* should be request-uri matching used as a part of pre-3261
00042          * transaction matching, as the standard wants us to do so
00043          * (and is reasonable to do so, to be able to distinguish
00044          * spirals)? turn only off for better interaction with
00045          * devices that are broken and send different r-uri in
00046          * CANCEL/ACK than in original INVITE
00047          */
00048         1,      /* ruri_matching */
00049         1,      /* via1_matching */
00050         FR_TIME_OUT,    /* fr_timeout */
00051         INV_FR_TIME_OUT,        /* fr_inv_timeout */
00052         INV_FR_TIME_OUT_NEXT, /* fr_inv_timeout_next */
00053         WT_TIME_OUT,    /* wait_timeout */
00054         DEL_TIME_OUT,   /* delete_timeout */
00055         RETR_T1,        /* rt_t1_timeout_ms */
00056         RETR_T2,        /* rt_t2_timeout_ms */
00057 
00058         /* maximum time an invite or noninv transaction will live, from
00059          * the moment of creation (overrides larger fr/fr_inv timeouts,
00060          * extensions due to dns failover, fr_inv restart a.s.o)
00061          * Note: after this time the transaction will not be deleted
00062          *  immediately, but forced to go in the wait state or in wait for ack state
00063          *  and then wait state, so it will still be alive for either wait_timeout in
00064          *  the non-inv or "silent" inv. case and for fr_timeout + wait_timeout for an
00065          *  invite transaction (for which  we must wait for the neg. reply ack)
00066          */
00067         MAX_INV_LIFETIME,       /* tm_max_inv_lifetime */
00068         MAX_NONINV_LIFETIME,    /* tm_max_noninv_lifetime */
00069         1,      /* noisy_ctimer */
00070         1,      /* tm_auto_inv_100 */
00071         "trying -- your call is important to us",       /* tm_auto_inv_100_r */
00072         500,    /* tm_unix_tx_timeout -- 500 ms by default */
00073         1,      /* restart_fr_on_each_reply */
00074         0,      /* pass_provisional_replies */
00075         1,      /* tm_aggregate_auth */
00076         UM_CANCEL_STATEFULL,    /* unmatched_cancel */
00077         500,    /* default_code */
00078         "Server Internal Error",        /* default_reason */
00079         1,      /* reparse_invite */
00080         STR_NULL,       /* ac_extra_hdrs */
00081 
00082         0,      /* tm_blst_503 -- if 1 blacklist 503 sources, using tm_blst_503_min,
00083                  * tm_blst_503_max, tm_blst_503_default and the Retry-After header
00084                  * in the 503 reply */
00085         0,      /* tm_blst_503_default -- rfc conformant: do not blacklist if
00086                  * no retry-after header is present */
00087         0,      /* tm_blst_503 -- minimum 503 blacklist time is 0 sec */
00088         3600,   /* tm_blst_503_max -- maximum 503 blacklist time is 3600 sec */
00089         METHOD_INVITE,  /* tm_blst_methods_add -- backlist only INVITE
00090                          * timeouts by default */
00091         ~METHOD_BYE,    /* tm_blst_methods_lookup -- look-up the blacklist
00092                          * for every method except BYE by default */
00093         1,      /* cancel_b_method used for e2e and 6xx cancels*/
00094         1,      /* reparse_on_dns_failover */
00095         0, /* disable_6xx, by default off */
00096         0,  /* local_ack_mode, default 0 (rfc3261 conformant) */
00097         1, /* local_cancel_reason -- add Reason header to locally generated
00098                   CANCELs; on by default */
00099         1  /* e2e_cancel_reason -- copy the Reason headers from incoming CANCELs
00100                   into the corresp. hop-by-hop CANCELs, on by default */
00101 };
00102 
00103 void    *tm_cfg = &default_tm_cfg;
00104 
00105 cfg_def_t       tm_cfg_def[] = {
00106         {"ruri_matching",       CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00107                 "perform Request URI check in transaction matching"},
00108         {"via1_matching",       CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00109                 "perform first Via header check in transaction matching"},
00110         {"fr_timer",            CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00111                 "timer which hits if no final reply for a request "
00112                 "or ACK for a negative INVITE reply arrives "
00113                 "(in milliseconds)"},
00114         {"fr_inv_timer",        CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00115                 "timer which hits if no final reply for an INVITE arrives "
00116                 "after a provisional message was received (in milliseconds)"},
00117         {"fr_inv_timer_next",   CFG_VAR_INT,    0, 0, 0, 0,
00118                 "The value [ms] of fr_inv_timer for subsequent branches during serial forking."},
00119         {"wt_timer",            CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00120                 "time for which a transaction stays in memory to absorb "
00121                 "delayed messages after it completed"},
00122         {"delete_timer",        CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00123                 "time after which a to-be-deleted transaction currently "
00124                 "ref-ed by a process will be tried to be deleted again."},
00125         {"retr_timer1",         CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup_ms, 0,
00126                 "initial retransmission period (in milliseconds)"},
00127         {"retr_timer2",         CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup_ms, 0,
00128                 "maximum retransmission period (in milliseconds)"},
00129         {"max_inv_lifetime",    CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00130                 "maximum time an invite transaction can live "
00131                 "from the moment of creation"},
00132         {"max_noninv_lifetime", CFG_VAR_INT | CFG_ATOMIC,       0, 0, timer_fixup, 0,
00133                 "maximum time a non-invite transaction can live "
00134                 "from the moment of creation"},
00135         {"noisy_ctimer",        CFG_VAR_INT,    0, 1, 0, 0,
00136                 "if set, INVITE transactions that time-out (FR INV timer) "
00137                 "will be always replied"},
00138         {"auto_inv_100",        CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00139                 "automatically send 100 to an INVITE"},
00140         {"auto_inv_100_reason", CFG_VAR_STRING, 0, 0, 0, 0,
00141                 "reason text of the automatically send 100 to an INVITE"},   
00142         {"unix_tx_timeout",     CFG_VAR_INT,    0, 0, 0, 0,
00143                 "Unix socket transmission timeout, in milliseconds"},
00144         {"restart_fr_on_each_reply",    CFG_VAR_INT | CFG_ATOMIC ,      0, 1, 0, 0,
00145                 "restart final response timer on each provisional reply"},
00146         {"pass_provisional_replies",    CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00147                 "enable/disable passing of provisional replies "
00148                 "to TMCB_LOCAL_RESPONSE_OUT callbacks"},
00149         {"aggregate_challenges",        CFG_VAR_INT /* not atomic */,   0, 1, 0, 0,
00150                 "if the final response is a 401 or a 407, aggregate all the "
00151                 "authorization headers (challenges) "
00152                 "(rfc3261 requires this to be on)"},
00153         {"unmatched_cancel",    CFG_VAR_INT,    0, 2, 0, 0,
00154                 "determines how CANCELs with no matching transaction are handled "
00155                 "(0: statefull forwarding, 1: stateless forwarding, 2: drop)"},
00156         {"default_code",        CFG_VAR_INT | CFG_ATOMIC,       400, 699, 0, 0,
00157                 "default SIP response code sent by t_reply(), if the function "
00158                 "cannot retrieve its parameters"},
00159         {"default_reason",      CFG_VAR_STRING, 0, 0, 0, 0,
00160                 "default SIP reason phrase sent by t_reply(), if the function "
00161                 "cannot retrieve its parameters"},
00162         {"reparse_invite",      CFG_VAR_INT,    0, 1, 0, 0,
00163                 "if set to 1, the CANCEL and negative ACK requests are "
00164                 "constructed from the INVITE message which was sent out "
00165                 "instead of building them from the received request"},
00166         {"ac_extra_hdrs",       CFG_VAR_STR,    0, 0, 0, 0,
00167                 "header fields prefixed by this parameter value are included "
00168                 "in the CANCEL and negative ACK messages if they were present "
00169                 "in the outgoing INVITE (depends on reparse_invite)"},
00170         {"blst_503",            CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00171                 "if set to 1, blacklist 503 SIP response sources"},
00172         {"blst_503_def_timeout",        CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
00173                 "default 503 blacklist time (in s), when no Retry-After "
00174                 "header is present"},
00175         {"blst_503_min_timeout",        CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
00176                 "minimum 503 blacklist time (in s)"},
00177         {"blst_503_max_timeout",        CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
00178                 "maximum 503 blacklist time (in s)"},
00179         {"blst_methods_add",    CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
00180                 "bitmap of method types that trigger blacklisting on "
00181                 "transaction timeouts"},
00182         {"blst_methods_lookup", CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
00183                 "Bitmap of method types that are looked-up in the blacklist "
00184                 "before statefull forwarding"},
00185         {"cancel_b_method",     CFG_VAR_INT,    0, 2, cancel_b_flags_fixup, 0,
00186                 "How to cancel branches on which no replies were received: 0 - fake"
00187                 " reply, 1 - retransmitting the request, 2 - send cancel"},
00188         {"reparse_on_dns_failover",     CFG_VAR_INT | CFG_ATOMIC,       0, 1,
00189                 reparse_on_dns_failover_fixup, 0,
00190                 "if set to 1, the SIP message after a DNS failover is "
00191                 "constructed from the outgoing message buffer of the failed "
00192                 "branch instead of from the received request"},
00193         {"disable_6xx_block",   CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00194                 "if set to 1, 6xx is treated like a normal reply (breaks rfc)"},
00195         {"local_ack_mode",              CFG_VAR_INT | CFG_ATOMIC,       0, 2, 0, 0,
00196                 "if set to 1 or 2, local 200 ACKs are sent to the same address as the"
00197                 " corresponding INVITE (1) or the source of the 200 reply (2) instead"
00198                 " of using the contact and the route set (it breaks the rfc, if "
00199                 " it is not set to 0 but allows dealing with NATed contacts in some "
00200                 "simple cases)"
00201                 },
00202         {"local_cancel_reason", CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00203                 "if set to 1, a Reason header is added to locally generated CANCELs"
00204                 " (see RFC3326)" },
00205         {"e2e_cancel_reason",   CFG_VAR_INT | CFG_ATOMIC,       0, 1, 0, 0,
00206                 "if set to 1, Reason headers from received CANCELs are copied into"
00207                 " the corresponding generated hop-by-hop CANCELs"},
00208         {0, 0, 0, 0, 0, 0}
00209 };