Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions modules/catch_dtmf/rtpp_catch_dtmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,14 @@ rtpp_catch_dtmf_worker(const struct rtpp_wthrdata *wp)
/* we received the end of the DTMF */
/* all good - send the notification */
eip->pending = 0;
rtpp_str_const_t notify_tag = {.s = buf};
notify_tag.len = snprintf(buf, RTPP_MAX_NOTIFY_BUF, "%.*s %c %u %u %d",
int tlen = snprintf(buf, RTPP_MAX_NOTIFY_BUF, "%.*s %c %u %u %d",
FMTSTR(wip->rtdp->notify_tag), ei.digit, dtmf->volume, eip->duration,
(wip->edata->side == RTPP_SSIDE_CALLER) ? 0 : 1);
if (tlen < 0)
goto skip;
if (tlen >= RTPP_MAX_NOTIFY_BUF)
tlen = RTPP_MAX_NOTIFY_BUF - 1;
rtpp_str_const_t notify_tag = {.s = buf, .len = tlen};
CALL_METHOD(pvt->notifier, schedule, wip->rtdp->notify_target,
rtpp_str_fix(&notify_tag), notyfy_type);

Expand Down
19 changes: 19 additions & 0 deletions tests/catch_dtmf/basic
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,22 @@ do
report "checking ${prefix}.rlog for \"${msg}\""
done
done

# The long callee tags must be clamped to 511 bytes: expect exactly six such
# notifications per mode plus the timeout one, comparing the whole log so
# that extra or longer lines are caught. Sort to ignore interleaving.
LC_ALL=C awk 'BEGIN {
n = split("fixedlong: wildcardlong:", pfx, " ")
for (m = 1; m <= n; m++) {
line = pfx[m]
while (length(line) < 511)
line = line "A"
for (i = 0; i < 6; i++)
print line
print pfx[m] "DTAG"
}
}' | LC_ALL=C sort > "${OUT}.long.etlog"
grep '^[a-z]*long:' "${OUT}.tlog" | LC_ALL=C sort > "${OUT}.long.tlog"
report "collecting long tag notifications"
${DIFF} "${OUT}.long.etlog" "${OUT}.long.tlog"
report "checking clamped 511-byte notifications for fixed and wildcard modes"
10 changes: 10 additions & 0 deletions tests/catch_dtmf/basic.rptl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ socket rtpp_wildcard: udp: -d dbug -n %%NS_wildcard%% -T3 -W3 --dso %%DSO%% -> %

.sleep: 4
.foreach: MODE in fixed wildcard do finish.rptl

# Long callee tags in extra sessions on the same daemons, after the final
# statistics were taken so that they are not affected.
.exec: awk 'BEGIN { for (i = 0; i < 512; i++) printf "A" }' -> LONG_TAG
.foreach: MODE in fixed wildcard do long.rptl
.wait: LREPLAY_fixed 30
.wait: LREPLAY_wildcard 30
# Let the sessions time out, so that their notifications are flushed.
.sleep: 4
.foreach: MODE in fixed wildcard do close.rptl
.close: sink
.exec: %%PYINT%% %%CHECK_RELAYED%% %%RECORD_DIR%%/%%ROOT_OUT%%.fixed.sink=from_tag_1.a.rtp %%PORT_U_fixed%% %%PCAP%% 24272
.exec: %%PYINT%% %%CHECK_RELAYED%% %%RECORD_DIR%%/%%ROOT_OUT%%.wildcard.sink=from_tag_1.a.rtp %%PORT_U_wildcard%% %%PCAP%% 24272
Expand Down
2 changes: 2 additions & 0 deletions tests/catch_dtmf/catch_dtmf.output
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ npkts_rcvd=203 npkts_played=0 npkts_relayed=158 npkts_discard=45 nplrs_created=0
rtpa_nsent=394 rtpa_nrcvd=151 rtpa_ndups=52 rtpa_nlost=243 rtpa_perrs=0
nsess_created=1 nsess_destroyed=1 nsess_timeout=1 nsess_complete=1 nsess_nortp=0 nsess_owrtp=0 nsess_nortcp=1 nsess_owrtcp=0
ncmds_rcvd=22 ncmds_succd=16 ncmds_errs=5 ncmds_repld=21
24274
24276
MEMDEB(rtpproxy): all clear
7 changes: 7 additions & 0 deletions tests/catch_dtmf/close.rptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Close one setup and release its recorder session.
.eval: rtpp_%%MODE%% -> R
.eval: %%ROOT_OUT%%.%%MODE%%.sink -> SINK_CID
.close: %%R%%
.echo: OK: %%R%% has exited

sink: D %%SINK_CID%% from_tag_1 -> str_compare(RES_OK)
4 changes: 0 additions & 4 deletions tests/catch_dtmf/finish.rptl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@
%%R%%: Gv ncmds_rcvd ncmds_succd ncmds_errs ncmds_repld
.echo: OK: queried global stats

.close: %%R%%
.echo: OK: %%R%% has exited

sink: D %%SINK_CID%% from_tag_1 -> str_compare(RES_OK)
9 changes: 9 additions & 0 deletions tests/catch_dtmf/long.rptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Replay into a session whose callee notification tag exceeds the notify
# buffer. The "long" suffix keeps these lines apart from the regular ones.
.eval: %%ROOT_OUT%%.%%MODE%%.long -> OUT
.eval: rtpp_%%MODE%% -> R
.eval: NS_%%MODE%% -> deref(NS)
%%R%%: U %%CALLID%%_long 127.0.0.1 0 from_tag_1 %%NS%% %%MODE%%long:DTAG -> validate_port(LPORT_U)
%%R%%: L %%CALLID%%_long 127.0.0.1 0 from_tag_1 to_tag_1 && M3:1 %%MODE%%long:%%LONG_TAG%% 101 H -> validate_port(LPORT_L)
.exec: tcprewrite --portmap=24270:%%LPORT_U%%,24272:%%LPORT_L%% -i %%PCAP%% -o %%OUT%%.pcap
.spawn: exec udpreplay %%OUT%%.pcap -> LREPLAY_%%MODE%%
Loading