aboutsummaryrefslogtreecommitdiffstats
path: root/main/kamailio/mohqueue-1.8.patch
blob: 1f490a08c348d80e1b2ca01ac784d3c7ee7bed9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
From c576631b899ded661bbfede48fa92fd03dbc7e88 Mon Sep 17 00:00:00 2001
From: Robert Boisvert <Robert.Boisvert@sequentialtech.com>
Date: Mon, 22 Mar 2021 10:43:12 -0400
Subject: [PATCH] mohqueue: use ptime

- version 1.7
- match ptime of incoming call; otherwise, default to 20ms
- update copyright dates
---
 src/modules/mohqueue/README                 |   2 +-
 src/modules/mohqueue/doc/mohqueue.xml       |   2 +-
 src/modules/mohqueue/doc/mohqueue_admin.xml |  11 +-
 src/modules/mohqueue/mohq_common.h          |   2 +-
 src/modules/mohqueue/mohq_db.c              |   2 +-
 src/modules/mohqueue/mohq_db.h              |   2 +-
 src/modules/mohqueue/mohq_funcs.c           | 112 +++++++++++++-------
 src/modules/mohqueue/mohq_funcs.h           |   2 +-
 src/modules/mohqueue/mohq_locks.c           |   2 +-
 src/modules/mohqueue/mohq_locks.h           |   2 +-
 src/modules/mohqueue/mohqueue_mod.c         |   4 +-
 src/modules/mohqueue/mohqueue_mod.h         |   2 +-
 12 files changed, 93 insertions(+), 52 deletions(-)

diff --git a/src/modules/mohqueue/README b/src/modules/mohqueue/README
index fa845da0f8..a0f30357ae 100644
--- a/src/modules/mohqueue/README
+++ b/src/modules/mohqueue/README
@@ -2,7 +2,7 @@ mohqueue Module
 
 Robert Boisvert
 
-   Copyright © 2013-2019 Robert Boisvert, rdbprog@gmail.com
+   Copyright © 2013-2021 Robert Boisvert, rdbprog@gmail.com
      __________________________________________________________________
 
    Table of Contents
diff --git a/src/modules/mohqueue/doc/mohqueue.xml b/src/modules/mohqueue/doc/mohqueue.xml
index e4c1563c66..5498c1b57b 100644
--- a/src/modules/mohqueue/doc/mohqueue.xml
+++ b/src/modules/mohqueue/doc/mohqueue.xml
@@ -21,7 +21,7 @@
       </author>
     </authorgroup>
     <copyright>
-      <year>2013-2019</year>
+      <year>2013-2021</year>
       <holder>Robert Boisvert, rdbprog@gmail.com</holder>
     </copyright>
   </bookinfo>
diff --git a/src/modules/mohqueue/doc/mohqueue_admin.xml b/src/modules/mohqueue/doc/mohqueue_admin.xml
index 112b1f4fa4..37cc02e1a0 100644
--- a/src/modules/mohqueue/doc/mohqueue_admin.xml
+++ b/src/modules/mohqueue/doc/mohqueue_admin.xml
@@ -387,10 +387,13 @@ Duplicate names are not allowed.
           </listitem>
           <listitem>
 <emphasis>uri</emphasis> (100-character string, required): the URI of
-the queue. It should not include any parameters or headers (e.g.
-"sip:user@host;maddr=239.255.255.1" or "sip:user@host?subject=project")
-although it will match any RURI that contains this URI even if the
-RURI has parameters or headers. Duplicates are not allowed.
+the queue. Duplicates are not allowed. It should not include any parameters
+or headers (e.g. "sip:user@host;maddr=239.255.255.1" or
+"sip:user@host?subject=project") although it will match any RURI that
+contains this URI even if the RURI has parameters or headers. The server
+name of the URI must uniquely identify the server. If the RURI server name
+does not uniquely identify the server then it should be rewritten to one
+the does before calling mohq_send ().
           </listitem>
           <listitem>
 <emphasis>mohdir</emphasis> (100-character string, optional): path to
diff --git a/src/modules/mohqueue/mohq_common.h b/src/modules/mohqueue/mohq_common.h
index 88fed7fc51..228587cc98 100644
--- a/src/modules/mohqueue/mohq_common.h
+++ b/src/modules/mohqueue/mohq_common.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohq_db.c b/src/modules/mohqueue/mohq_db.c
index 3f70b0bf11..7c62ee6d4c 100644
--- a/src/modules/mohqueue/mohq_db.c
+++ b/src/modules/mohqueue/mohq_db.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohq_db.h b/src/modules/mohqueue/mohq_db.h
index 41b0a3f24c..565f0ae141 100644
--- a/src/modules/mohqueue/mohq_db.h
+++ b/src/modules/mohqueue/mohq_db.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohq_funcs.c b/src/modules/mohqueue/mohq_funcs.c
index 54ee87486c..c9c8d6704e 100644
--- a/src/modules/mohqueue/mohq_funcs.c
+++ b/src/modules/mohqueue/mohq_funcs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
@@ -32,7 +32,7 @@
 #define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK"
 #define CLENHDR "Content-Length"
 #define SIPEOL  "\r\n"
-#define USRAGNT "Kamailio MOH Queue v1.6"
+#define USRAGNT "Kamailio MOH Queue v1.7"
 
 /**********
 * local constants
@@ -122,17 +122,6 @@ char prefermsg [] =
   "Referred-By: <%s>" SIPEOL
   };
 
-char preinvitemsg [] =
-  {
-  "%s"
-  "Max-Forwards: 70" SIPEOL
-  "Contact: <%s>" SIPEOL
-  ALLOWHDR SIPEOL
-  "Supported: 100rel" SIPEOL
-  "Accept-Language: en" SIPEOL
-  "Content-Type: application/sdp" SIPEOL
-  };
-
 char prtpsdp [] =
   {
   "v=0" SIPEOL
@@ -185,7 +174,6 @@ void ack_msg (sip_msg_t *pmsg, call_lst *pcall)
 char *pfncname = "ack_msg: ";
 struct cell *ptrans;
 tm_api_t *ptm = pmod_data->ptm;
-tm_cell_t *t = 0;
 if (pcall->call_state != CLSTA_INVITED)
   {
   /**********
@@ -203,9 +191,7 @@ if (pcall->call_state != CLSTA_INVITED)
   }
 
 /**********
-* o release INVITE transaction
-* o save SDP address info
-* o put in queue
+* release INVITE transaction
 **********/
 
 if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0)
@@ -216,28 +202,39 @@ if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0)
   }
 else
   {
-  t = ptm->t_gett();
-  if (t==NULL || t==T_UNDEFINED)
+  /**********
+  * create new transaction if current missing
+  **********/
+
+  tm_cell_t *ptcell;
+  ptcell = ptm->t_gett ();
+  if ((ptcell == NULL) || (ptcell == T_UNDEFINED))
     {
-      if (ptm->t_newtran(pmsg)<0)
-        {
-          LM_ERR("cannot create the transaction\n");
-          return;
-        }
-      t = ptm->t_gett();
-      if (t==NULL || t==T_UNDEFINED)
-        {
-          LM_ERR("cannot lookup the transaction\n");
-          return;
-        }
+    if (ptm->t_newtran (pmsg) < 0)
+      {
+      LM_ERR ("%sUnable to create temporary transaction!\n", pfncname);
+      return;
+      }
+    ptcell = ptm->t_gett ();
+  if ((ptcell == NULL) || (ptcell == T_UNDEFINED))
+      {
+      LM_ERR ("%sUnable to find temporary transaction!\n", pfncname);
+      return;
+      }
     }
-  if (ptm->t_release_transaction(t) < 0)
+  if (ptm->t_release (ptcell) < 0)
     {
     LM_ERR ("%sRelease transaction failed for call (%s)!\n",
       pfncname, pcall->call_from);
     return;
     }
   }
+
+/**********
+* o save SDP address info
+* o put in queue
+**********/
+
 pcall->call_hash = pcall->call_label = 0;
 sprintf (pcall->call_addr, "%s %s",
   pmsg->rcv.dst_ip.af == AF_INET ? "IP4" : "IP6",
@@ -538,14 +535,19 @@ int
 create_call (sip_msg_t *pmsg, call_lst *pcall, int ncall_idx, int mohq_idx)
 
 {
+char *pfncname = "create_call: ";
+char *pbuf;
+str *pstr;
+
 /**********
 * add values to new entry
+* o call ID
+* o from
 **********/
 
-char *pfncname = "create_call: ";
 pcall->pmohq = &pmod_data->pmohq_lst [mohq_idx];
-str *pstr = &pmsg->callid->body;
-char *pbuf = pcall->call_buffer;
+pstr = &pmsg->callid->body;
+pbuf = pcall->call_buffer;
 pcall->call_buflen = sizeof (pcall->call_buffer);
 pcall->call_id = pbuf;
 if (!addstrbfr (pstr->s, pstr->len, &pbuf, &pcall->call_buflen, 1))
@@ -1036,7 +1038,6 @@ char *pfncname = "first_invite_msg: ";
 /**********
 * o SDP exists?
 * o accepts REFER?
-* o send RTP offer
 **********/
 
 if (!(pmsg->msg_flags & FL_SDP_BODY))
@@ -1069,6 +1070,11 @@ if (pmsg->allow)
     return;
     }
   }
+
+/**********
+* send RTP offer
+**********/
+
 mohq_debug (pcall->pmohq,
   "%sMaking offer for RTP link for call (%s) from queue (%s)",
   pfncname, pcall->call_from, pcall->pmohq->mohq_name);
@@ -2146,6 +2152,38 @@ struct sip_msg pnmsg [1];
 build_sip_msg_from_buf (pnmsg, pbuf->s, pbuf->len, 0);
 memcpy (&pnmsg->rcv, &pmsg->rcv, sizeof (struct receive_info));
 
+/**********
+* ptime set?
+**********/
+
+int nsession;
+sdp_session_cell_t *psession;
+char pflagbuf [5];
+strcpy (pflagbuf, "z20");
+fparam_t pzflag [1] = {0, FPARAM_STRING, {pflagbuf}, 0};
+for (nsession = 0; (psession = get_sdp_session (pmsg, nsession)); nsession++)
+  {
+  int nstream;
+  sdp_stream_cell_t *pstream;
+  for (nstream = 0; (pstream = get_sdp_stream (pmsg, nsession, nstream));
+    nstream++)
+    {
+    /**********
+    * ptime set?
+    **********/
+
+    if ((pstream->ptime.len < 1) || (pstream->ptime.len > 3))
+      { continue; }
+    strncpy (&pzflag->v.asciiz [1], pstream->ptime.s, pstream->ptime.len);
+    pzflag->v.asciiz [pstream->ptime.len + 1] = 0;
+    mohq_debug (pcall->pmohq,
+      "%sSet ptime (%s) for RTP link for call (%s) from queue (%s)",
+      pfncname,
+      &pzflag->v.asciiz [1], pcall->call_from, pcall->pmohq->mohq_name);
+    break;
+    }
+  }
+
 /**********
 * o send RTP answer
 * o form stream file
@@ -2154,7 +2192,7 @@ memcpy (&pnmsg->rcv, &pmsg->rcv, sizeof (struct receive_info));
 
 mohq_debug (pcall->pmohq, "%sAnswering RTP link for call (%s)",
   pfncname, pcall->call_from);
-if (pmod_data->fn_rtp_answer (pnmsg, 0, 0) != 1)
+if (pmod_data->fn_rtp_answer (pnmsg, (char *) pzflag, 0) != 1)
   {
   LM_ERR ("%srtpproxy_answer refused for call (%s)!\n",
     pfncname, pcall->call_from);
@@ -2961,4 +2999,4 @@ if (pmod_data->ptm->t_relay (pmsg, 0, 0) < 0)
   return -1;
   }
 return 1;
-}
+}
\ No newline at end of file
diff --git a/src/modules/mohqueue/mohq_funcs.h b/src/modules/mohqueue/mohq_funcs.h
index cc99185306..35d55edaa0 100644
--- a/src/modules/mohqueue/mohq_funcs.h
+++ b/src/modules/mohqueue/mohq_funcs.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohq_locks.c b/src/modules/mohqueue/mohq_locks.c
index 080dd39486..b31e052cb8 100644
--- a/src/modules/mohqueue/mohq_locks.c
+++ b/src/modules/mohqueue/mohq_locks.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohq_locks.h b/src/modules/mohqueue/mohq_locks.h
index 2ae41b7192..20deed8b02 100644
--- a/src/modules/mohqueue/mohq_locks.h
+++ b/src/modules/mohqueue/mohq_locks.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
diff --git a/src/modules/mohqueue/mohqueue_mod.c b/src/modules/mohqueue/mohqueue_mod.c
index a9ec155097..8a17dfc45e 100644
--- a/src/modules/mohqueue/mohqueue_mod.c
+++ b/src/modules/mohqueue/mohqueue_mod.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
@@ -313,7 +313,7 @@ int mod_child_init (int rank)
 
 {
 /**********
-* o make sure DB initialized
+* make sure DB initialized
 **********/
 
 if (rank == PROC_INIT || rank == PROC_TCP_MAIN || rank == PROC_MAIN)
diff --git a/src/modules/mohqueue/mohqueue_mod.h b/src/modules/mohqueue/mohqueue_mod.h
index b783b03f40..61d2f98c9c 100644
--- a/src/modules/mohqueue/mohqueue_mod.h
+++ b/src/modules/mohqueue/mohqueue_mod.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-19 Robert Boisvert
+ * Copyright (C) 2013-21 Robert Boisvert
  *
  * This file is part of the mohqueue module for Kamailio, a free SIP server.
  *
From 1001e9e1dbfdec525f4a5f96f7dd3fcc22e51888 Mon Sep 17 00:00:00 2001
From: Robert Boisvert <rdboisvert@gmail.com>
Date: Wed, 24 Mar 2021 12:17:20 -0400
Subject: [PATCH] mohqueue: use ptime

    - version 1.7
    - match ptime of incoming call; otherwise, default to 20ms
    - update copyright dates
---
 src/modules/mohqueue/mohq_funcs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/mohqueue/mohq_funcs.c b/src/modules/mohqueue/mohq_funcs.c
index c9c8d6704e..dd9f105bfc 100644
--- a/src/modules/mohqueue/mohq_funcs.c
+++ b/src/modules/mohqueue/mohq_funcs.c
@@ -222,7 +222,7 @@ else
       return;
       }
     }
-  if (ptm->t_release (ptcell) < 0)
+  if (ptm->t_release_transaction (ptcell) < 0)
     {
     LM_ERR ("%sRelease transaction failed for call (%s)!\n",
       pfncname, pcall->call_from);
@@ -2160,7 +2160,7 @@ int nsession;
 sdp_session_cell_t *psession;
 char pflagbuf [5];
 strcpy (pflagbuf, "z20");
-fparam_t pzflag [1] = {0, FPARAM_STRING, {pflagbuf}, 0};
+fparam_t pzflag [1] = {"", FPARAM_STRING, {pflagbuf}, 0};
 for (nsession = 0; (psession = get_sdp_session (pmsg, nsession)); nsession++)
   {
   int nstream;
From c7781edcb37a35193ccdb9414183919aaa614d3a Mon Sep 17 00:00:00 2001
From: Sergey Safarov <s.safarov@gmail.com>
Date: Tue, 27 Apr 2021 12:58:49 +0300
Subject: [PATCH] mohqueue: fixed compiler warning about array initialization

---
 src/modules/mohqueue/mohq_funcs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/modules/mohqueue/mohq_funcs.c b/src/modules/mohqueue/mohq_funcs.c
index dd9f105bfc..1f72c58c5a 100644
--- a/src/modules/mohqueue/mohq_funcs.c
+++ b/src/modules/mohqueue/mohq_funcs.c
@@ -2160,7 +2160,9 @@ int nsession;
 sdp_session_cell_t *psession;
 char pflagbuf [5];
 strcpy (pflagbuf, "z20");
-fparam_t pzflag [1] = {"", FPARAM_STRING, {pflagbuf}, 0};
+fparam_t pzflag [1] = {
+    {"", FPARAM_STRING, {pflagbuf}, 0}
+};
 for (nsession = 0; (psession = get_sdp_session (pmsg, nsession)); nsession++)
   {
   int nstream;
From 0e51ce1075f206a4441333f72c69fcc56f8d6855 Mon Sep 17 00:00:00 2001
From: Robert Boisvert <rdboisvert@gmail.com>
Date: Wed, 19 May 2021 16:19:24 -0400
Subject: [PATCH] modules/mohqueue: force RTP to follow SDP

  - version 1.8
  - use rtpproxy r flag to force RTP to follow SDP
  - fixed compiler warnings
---
 src/modules/mohqueue/mohq_funcs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/modules/mohqueue/mohq_funcs.c b/src/modules/mohqueue/mohq_funcs.c
index 1f72c58c5a..c46cb51a75 100644
--- a/src/modules/mohqueue/mohq_funcs.c
+++ b/src/modules/mohqueue/mohq_funcs.c
@@ -32,7 +32,7 @@
 #define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK"
 #define CLENHDR "Content-Length"
 #define SIPEOL  "\r\n"
-#define USRAGNT "Kamailio MOH Queue v1.7"
+#define USRAGNT "Kamailio MOH Queue v1.8"
 
 /**********
 * local constants
@@ -1075,10 +1075,11 @@ if (pmsg->allow)
 * send RTP offer
 **********/
 
+fparam_t rflag = {.orig="", .type=FPARAM_STRING, {.asciiz="r"}, .fixed=0};
 mohq_debug (pcall->pmohq,
   "%sMaking offer for RTP link for call (%s) from queue (%s)",
   pfncname, pcall->call_from, pcall->pmohq->mohq_name);
-if (pmod_data->fn_rtp_offer (pmsg, 0, 0) != 1)
+if (pmod_data->fn_rtp_offer (pmsg, (char *) &rflag, 0) != 1)
   {
   if (pmod_data->psl->freply (pmsg, 486, presp_busy) < 0)
     {
@@ -2160,9 +2161,8 @@ int nsession;
 sdp_session_cell_t *psession;
 char pflagbuf [5];
 strcpy (pflagbuf, "z20");
-fparam_t pzflag [1] = {
-    {"", FPARAM_STRING, {pflagbuf}, 0}
-};
+fparam_t zflag = {.orig="", .type=FPARAM_STRING, {.asciiz=pflagbuf}, .fixed=0};
+fparam_t *pzflag = &zflag;
 for (nsession = 0; (psession = get_sdp_session (pmsg, nsession)); nsession++)
   {
   int nstream;