@@ -60,6 +60,7 @@ static int child_init(int rank);
60
60
static int fixup_init_flags (void * * param );
61
61
static int fixup_free_init_flags (void * * param );
62
62
static int fixup_bridge_flags (void * * param );
63
+ static int fixup_bridge_request_flags (void * * param );
63
64
static int fixup_init_id (void * * param );
64
65
static int fixup_check_avp (void * * param );
65
66
static int fixup_route (void * * param );
@@ -79,7 +80,9 @@ static mi_response_t *mi_b2b_list(const mi_params_t *params,
79
80
static mi_response_t * mi_b2b_terminate_call (const mi_params_t * params ,
80
81
struct mi_handler * async_hdl );
81
82
static void b2bl_clean (unsigned int ticks , void * param );
83
+ void b2bl_term_entities_timer (unsigned int ticks , void * param );
82
84
static void b2bl_db_timer_update (unsigned int ticks , void * param );
85
+ static int init_entities_term_timer (void );
83
86
84
87
int b2bl_script_init_request (struct sip_msg * msg , str * id , struct b2b_params * init_params ,
85
88
void * req_routeid , void * reply_routeid );
@@ -93,7 +96,7 @@ int b2b_delete_entity(struct sip_msg *msg);
93
96
int b2b_end_dlg_leg (struct sip_msg * msg );
94
97
int b2b_send_reply (struct sip_msg * msg , int * code , str * reason , str * headers , str * body );
95
98
int b2bl_script_bridge_msg (struct sip_msg * msg , str * key , int * entity_no ,
96
- str * adv_contact );
99
+ str * adv_contact , void * flags );
97
100
int script_trigger_scenario (struct sip_msg * msg , str * id , str * params ,
98
101
str * ent1 , pv_spec_t * ent1_hnames , pv_spec_t * ent1_hvals ,
99
102
str * ent2 , pv_spec_t * ent2_hnames , pv_spec_t * ent2_hvals );
@@ -191,6 +194,9 @@ b2bl_tuple_t *local_ctx_tuple;
191
194
* MI cmd, when the tuple is not created yet */
192
195
struct b2b_ctx_val * local_ctx_vals ;
193
196
197
+ unsigned int ent_term_interval ;
198
+ struct b2b_term_timer * ent_term_timer ;
199
+
194
200
static const cmd_export_t cmds []=
195
201
{
196
202
{"b2b_init_request" , (cmd_function )b2bl_script_init_request , {
@@ -257,7 +263,9 @@ static const cmd_export_t cmds[]=
257
263
{"b2b_bridge_request" , (cmd_function )b2bl_script_bridge_msg , {
258
264
{CMD_PARAM_STR ,0 ,0 },
259
265
{CMD_PARAM_INT ,0 ,0 },
260
- {CMD_PARAM_STR |CMD_PARAM_OPT ,0 ,0 }, {0 ,0 ,0 }},
266
+ {CMD_PARAM_STR |CMD_PARAM_OPT ,0 ,0 },
267
+ {CMD_PARAM_STR |CMD_PARAM_OPT , fixup_bridge_request_flags , 0 },
268
+ {0 ,0 ,0 }},
261
269
REQUEST_ROUTE },
262
270
{"b2b_logic_bind" , (cmd_function )b2b_logic_bind , {{0 ,0 ,0 }}, 0 },
263
271
{0 ,0 ,{{0 ,0 ,0 }},0 }
@@ -288,6 +296,7 @@ static const param_export_t params[]=
288
296
{"db_mode" , INT_PARAM , & b2bl_db_mode },
289
297
{"b2bl_th_init_timeout" ,INT_PARAM , & b2bl_th_init_timeout },
290
298
{"b2bl_early_update" ,INT_PARAM , & b2b_early_update },
299
+ {"old_entity_term_delay" ,INT_PARAM , & ent_term_interval },
291
300
{0 , 0 , 0 }
292
301
};
293
302
@@ -667,6 +676,16 @@ static int mod_init(void)
667
676
register_timer ("b2bl-bridge-retry" , b2bl_timer_bridge_retry , 0 , 1 ,
668
677
TIMER_FLAG_SKIP_ON_DELAY );
669
678
679
+ if (ent_term_interval ) {
680
+ register_timer ("b2bl-term-entities" , b2bl_term_entities_timer , 0 , 1 ,
681
+ TIMER_FLAG_DELAY_ON_DELAY );
682
+
683
+ if (init_entities_term_timer () < 0 ) {
684
+ LM_ERR ("Failed to init entities termination timer\n" );
685
+ return -1 ;
686
+ }
687
+ }
688
+
670
689
if (b2b_api .register_cb (entity_event_trigger ,
671
690
B2BCB_TRIGGER_EVENT , & b2bl_mod_name ) < 0 ) {
672
691
LM_ERR ("could not register entity event trigger callback!\n" );
@@ -684,6 +703,29 @@ static int mod_init(void)
684
703
return 0 ;
685
704
}
686
705
706
+ static int init_entities_term_timer (void )
707
+ {
708
+ ent_term_timer = shm_malloc (sizeof * ent_term_timer );
709
+ if (!ent_term_timer ) {
710
+ LM_ERR ("no more shm memory\n" );
711
+ return -1 ;
712
+ }
713
+ memset (ent_term_timer , 0 , sizeof * ent_term_timer );
714
+
715
+ ent_term_timer -> lock = lock_alloc ();
716
+ if (ent_term_timer -> lock == 0 ) {
717
+ LM_ERR ("failed to alloc lock\n" );
718
+ return -1 ;
719
+ }
720
+
721
+ if (lock_init (ent_term_timer -> lock )== 0 ) {
722
+ LM_ERR ("failed to init lock\n" );
723
+ return -1 ;
724
+ }
725
+
726
+ return 0 ;
727
+ }
728
+
687
729
void b2bl_db_timer_update (unsigned int ticks , void * param )
688
730
{
689
731
b2b_logic_dump (0 );
@@ -768,6 +810,18 @@ void b2bl_clean(unsigned int ticks, void* param)
768
810
}
769
811
}
770
812
813
+ void destroy_entities_term_timer (void )
814
+ {
815
+ if (ent_term_timer == 0 )
816
+ return ;
817
+
818
+ lock_destroy (ent_term_timer -> lock );
819
+ lock_dealloc (ent_term_timer -> lock );
820
+
821
+ shm_free (ent_term_timer );
822
+ ent_term_timer = 0 ;
823
+ }
824
+
771
825
static void mod_destroy (void )
772
826
{
773
827
if (b2bl_db_mode == WRITE_BACK ) {
@@ -795,6 +849,9 @@ static void mod_destroy(void)
795
849
if (server_address_pve )
796
850
pv_elem_free_all (server_address_pve );
797
851
852
+ if (ent_term_interval )
853
+ destroy_entities_term_timer ();
854
+
798
855
destroy_b2bl_htable ();
799
856
b2bl_free_bridge_retry ();
800
857
}
@@ -945,6 +1002,29 @@ static int fixup_bridge_flags(void** param)
945
1002
return 0 ;
946
1003
}
947
1004
1005
+
1006
+ static str bridge_req_kv_flags [] =
1007
+ {
1008
+ str_init ("late_bye" ),
1009
+ STR_NULL
1010
+ };
1011
+
1012
+ static int fixup_bridge_request_flags (void * * param )
1013
+ {
1014
+ if (fixup_named_flags (param , bridge_req_kv_flags , NULL , NULL )< 0 ) {
1015
+ LM_ERR ("Failed to parse flags\n" );
1016
+ return -1 ;
1017
+ }
1018
+
1019
+ /* ugly hack to move the flag on its right position (as the
1020
+ fixup_named_flags() will set it with index 0 (as in the def array))
1021
+ WARNING: this works only because we have a single flag!!!! */
1022
+ if (param )
1023
+ * param = (void * )(unsigned long )B2BL_BR_FLAG_BR_MSG_LATE_BYE ;
1024
+
1025
+ return 0 ;
1026
+ }
1027
+
948
1028
static int fixup_init_id (void * * param )
949
1029
{
950
1030
str * s = (str * )* param ;
@@ -1180,20 +1260,25 @@ mi_response_t *mi_trigger_scenario(const mi_params_t *params,
1180
1260
}
1181
1261
1182
1262
int b2bl_script_bridge_msg (struct sip_msg * msg , str * key , int * entity_no ,
1183
- str * adv_contact )
1263
+ str * adv_contact , void * flags_p )
1184
1264
{
1265
+ unsigned int flags = 0 ;
1266
+
1185
1267
if (cur_route_ctx .flags & (B2BL_RT_REQ_CTX |B2BL_RT_RPL_CTX )) {
1186
1268
LM_ERR ("The 'b2b_bridge_request' function cannot be used from the "
1187
1269
"b2b_logic dedicated routes\n" );
1188
1270
return -1 ;
1189
1271
}
1190
1272
1191
- return b2bl_bridge_msg (msg , key , * entity_no , adv_contact );
1273
+ if (flags_p )
1274
+ flags = (unsigned int )(unsigned long )flags_p ;
1275
+
1276
+ return b2bl_bridge_msg (msg , key , * entity_no , flags , adv_contact );
1192
1277
}
1193
1278
1194
1279
static int b2bl_api_bridge_msg (struct sip_msg * msg , str * key , int entity_no )
1195
1280
{
1196
- return b2bl_bridge_msg (msg , key , entity_no , NULL );
1281
+ return b2bl_bridge_msg (msg , key , entity_no , 0 , NULL );
1197
1282
}
1198
1283
1199
1284
static mi_response_t * mi_b2b_terminate_call (const mi_params_t * params ,
0 commit comments