Making T1, T2, etc. configurable without recompile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, mee too! ;-)

Christian, thanks for bringing up this issue. I've been having this 
ticket (http://www.pjsip.org/trac/ticket/7) for long time, but 
haven't had chance to do something about it. And thanks too for the 
idea.

I have been thinking about different way to do this though. I'm 
thinking of storing these compile time settings into a struct. This 
struct instance values would be initialized to their compile time 
value.

Then export the instance of this struct via a public API. Both 
application and pjsip can access each individual field by using 
something like "pjsip_cfg()->t1", and "pjsip_cfg()->t1 = 1000" to 
change the setting. Of course if application wants to override the 
default settings, it can only do that before creating the pjsip 
endpoint and modules.

Something like below:

----

//
// In sip_config.h, perhaps..
//
typedef struct pjsip_cfg_t
{
    /* Transaction settings: */
    struct {
      /** Maximum number of transactions */
      unsigned max_count;

      /* Timeout values */
      unsigned t1;   /**< T1 timeout, in msec */
      unsigned t2;   /**< .. fill up with doxygen comment .. */
      unsigned t4;
      unsigned td;
    } tsx;

    /* Dialog layer settings .. */

} pjsip_cfg_t;

/**
  * Get pjsip configuration instance. Application may modify the
  * settings before creating the SIP endpoint and modules.
  */
PJ_DECL(pjsip_cfg_t*) pjsip_cfg(void);

----

//
// In sip_config.c (new file), perhaps..
//

/* pjsip configuration instance, initialized with default values */
static struct pjsip_cfg_t =
{
    /* Transaction settings */
    {
       PJSIP_MAX_TSX_COUNT,
       PJSIP_T1_TIMEOUT,
       PJSIP_T2_TIMEOUT,
       PJSIP_T4_TIMEOUT,
       PJSIP_TD_TIMEOUT
    }
} sip_cfg;


PJ_DEF(pjsip_cfg_t*) pjsip_cfg(void)
{
    return &sip_cfg;
}

What do yo think?

regards,
  -benny

Alexander Agranovsky wrote:
> Hear, hear.
> 
> I'd appreciate this as well ;-)
> 
> - Alex
> 
> On Nov 20, 2007, at 11:22 AM, Christian Grigis wrote:
> 
>> Hello Benny,
>>
>> Pjsip, in accordance with the RFC, uses some values to determine timer
>> timeout values in transaction processing, namely T1, T2, T4 and TD.
>> Currently these values are #defines (in
>> ./pjsip/include/pjsip/sip_config.h) and consequently determined at
>> compile-time.
>>
>> We would like to be able to have the application change the default
>> values at runtime, during the initialization of the stack, without
>> requiring a recompilation of the SIP stack.
>>
>> We are perfectly willing to make the necessary changes, but are
>> wondering if you had any advice as to how these changes should be  
>> made.
>>
>> After some examination, it appears the constant values are used  
>> only in
>> the following files:
>>
>> ./pjsip/include/pjsip/sip_config.h
>> ./pjsip/src/pjsip/sip_transaction.c
>> ./pjsip/src/test-pjsip/tsx_uac_test.c
>> ./pjsip/src/test-pjsip/tsx_uas_test.c
>> ./pjsip/src/pjsip-ua/sip_100rel.c
>>
>> The first thing that comes to mind is to provide a function to  
>> override
>> the default values, and another function (or rather, one per value),
>> that returns either the default value if it has not been  
>> overridden, or
>> the override value. These last functions would then be used  
>> wherever the
>> constants were previously used.
>>
>> Something like:
>>
>> * a set of 4 values to be somehow passed to
>>   pjsip_tsx_layer_init_module(), indicating overrides for T1, T2,  
>> T4 and
>>   TD (0 meaning no override), stored in static variables
>>   pjsip_t1_timeout, pjsip_t2_timeout, pjsip_t4_timeout and
>>   pjsip_td_timeout;
>>
>> * 4 functions similar to:
>>
>> 	unsigned int pjsip_get_t1_timeout()
>> 	{
>> 		if (pjsip_t1_timeout > 0) {
>> 			return pjsip_t1_timeout;
>> 		} else {
>> 			return PJSIP_T1_TIMEOUT;
>> 		}
>> 	}
>>
>>
>> What do you think?
>>
>> Thanks and best regards,
>>
>> -Christian
>> -- 
>> Christian Grigis
>> Senior Software Engineer
>>
>> eyeP Media S.A. -- http://www.eyepmedia.com/





[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux