dialplan_functions.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2010, Digium, Inc.
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*!
  17. * \file
  18. * \brief sip channel dialplan functions and unit tests
  19. */
  20. /*** MODULEINFO
  21. <support_level>extended</support_level>
  22. ***/
  23. /*** DOCUMENTATION
  24. <info name="CHANNEL" language="en_US" tech="SIP">
  25. <enumlist>
  26. <enum name="peerip">
  27. <para>R/O Get the IP address of the peer.</para>
  28. </enum>
  29. <enum name="recvip">
  30. <para>R/O Get the source IP address of the peer.</para>
  31. </enum>
  32. <enum name="recvport">
  33. <para>R/O Get the source port of the peer.</para>
  34. </enum>
  35. <enum name="from">
  36. <para>R/O Get the URI from the From: header.</para>
  37. </enum>
  38. <enum name="uri">
  39. <para>R/O Get the URI from the Contact: header.</para>
  40. </enum>
  41. <enum name="ruri">
  42. <para>R/O Get the Request-URI from the INVITE header.</para>
  43. </enum>
  44. <enum name="useragent">
  45. <para>R/O Get the useragent.</para>
  46. </enum>
  47. <enum name="peername">
  48. <para>R/O Get the name of the peer.</para>
  49. </enum>
  50. <enum name="t38passthrough">
  51. <para>R/O <literal>1</literal> if T38 is offered or enabled in this channel,
  52. otherwise <literal>0</literal></para>
  53. </enum>
  54. <enum name="rtpqos">
  55. <para>R/O Get QOS information about the RTP stream</para>
  56. <para> This option takes two additional arguments:</para>
  57. <para> Argument 1:</para>
  58. <para> <literal>audio</literal> Get data about the audio stream</para>
  59. <para> <literal>video</literal> Get data about the video stream</para>
  60. <para> <literal>text</literal> Get data about the text stream</para>
  61. <para> Argument 2:</para>
  62. <para> <literal>local_ssrc</literal> Local SSRC (stream ID)</para>
  63. <para> <literal>local_lostpackets</literal> Local lost packets</para>
  64. <para> <literal>local_jitter</literal> Local calculated jitter</para>
  65. <para> <literal>local_maxjitter</literal> Local calculated jitter (maximum)</para>
  66. <para> <literal>local_minjitter</literal> Local calculated jitter (minimum)</para>
  67. <para> <literal>local_normdevjitter</literal>Local calculated jitter (normal deviation)</para>
  68. <para> <literal>local_stdevjitter</literal> Local calculated jitter (standard deviation)</para>
  69. <para> <literal>local_count</literal> Number of received packets</para>
  70. <para> <literal>remote_ssrc</literal> Remote SSRC (stream ID)</para>
  71. <para> <literal>remote_lostpackets</literal>Remote lost packets</para>
  72. <para> <literal>remote_jitter</literal> Remote reported jitter</para>
  73. <para> <literal>remote_maxjitter</literal> Remote calculated jitter (maximum)</para>
  74. <para> <literal>remote_minjitter</literal> Remote calculated jitter (minimum)</para>
  75. <para> <literal>remote_normdevjitter</literal>Remote calculated jitter (normal deviation)</para>
  76. <para> <literal>remote_stdevjitter</literal>Remote calculated jitter (standard deviation)</para>
  77. <para> <literal>remote_count</literal> Number of transmitted packets</para>
  78. <para> <literal>rtt</literal> Round trip time</para>
  79. <para> <literal>maxrtt</literal> Round trip time (maximum)</para>
  80. <para> <literal>minrtt</literal> Round trip time (minimum)</para>
  81. <para> <literal>normdevrtt</literal> Round trip time (normal deviation)</para>
  82. <para> <literal>stdevrtt</literal> Round trip time (standard deviation)</para>
  83. <para> <literal>all</literal> All statistics (in a form suited to logging,
  84. but not for parsing)</para>
  85. </enum>
  86. <enum name="rtpdest">
  87. <para>R/O Get remote RTP destination information.</para>
  88. <para> This option takes one additional argument:</para>
  89. <para> Argument 1:</para>
  90. <para> <literal>audio</literal> Get audio destination</para>
  91. <para> <literal>video</literal> Get video destination</para>
  92. <para> <literal>text</literal> Get text destination</para>
  93. <para> Defaults to <literal>audio</literal> if unspecified.</para>
  94. </enum>
  95. <enum name="rtpsource">
  96. <para>R/O Get source RTP destination information.</para>
  97. <para> This option takes one additional argument:</para>
  98. <para> Argument 1:</para>
  99. <para> <literal>audio</literal> Get audio destination</para>
  100. <para> <literal>video</literal> Get video destination</para>
  101. <para> <literal>text</literal> Get text destination</para>
  102. <para> Defaults to <literal>audio</literal> if unspecified.</para>
  103. </enum>
  104. </enumlist>
  105. </info>
  106. ***/
  107. #include "asterisk.h"
  108. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  109. #include <math.h>
  110. #include "asterisk/channel.h"
  111. #include "asterisk/rtp_engine.h"
  112. #include "asterisk/pbx.h"
  113. #include "asterisk/acl.h"
  114. #include "include/sip.h"
  115. #include "include/globals.h"
  116. #include "include/dialog.h"
  117. #include "include/dialplan_functions.h"
  118. #include "include/sip_utils.h"
  119. int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
  120. {
  121. struct sip_pvt *p = ast_channel_tech_pvt(chan);
  122. char *parse = ast_strdupa(preparse);
  123. int res = 0;
  124. AST_DECLARE_APP_ARGS(args,
  125. AST_APP_ARG(param);
  126. AST_APP_ARG(type);
  127. AST_APP_ARG(field);
  128. );
  129. /* Check for zero arguments */
  130. if (ast_strlen_zero(parse)) {
  131. ast_log(LOG_ERROR, "Cannot call %s without arguments\n", funcname);
  132. return -1;
  133. }
  134. AST_STANDARD_APP_ARGS(args, parse);
  135. /* Sanity check */
  136. if (!IS_SIP_TECH(ast_channel_tech(chan))) {
  137. ast_log(LOG_ERROR, "Cannot call %s on a non-SIP channel\n", funcname);
  138. return 0;
  139. }
  140. memset(buf, 0, buflen);
  141. if (p == NULL) {
  142. return -1;
  143. }
  144. if (!strcasecmp(args.param, "peerip")) {
  145. ast_copy_string(buf, ast_sockaddr_isnull(&p->sa) ? "" : ast_sockaddr_stringify_addr(&p->sa), buflen);
  146. } else if (!strcasecmp(args.param, "recvip")) {
  147. ast_copy_string(buf, ast_sockaddr_isnull(&p->recv) ? "" : ast_sockaddr_stringify_addr(&p->recv), buflen);
  148. } else if (!strcasecmp(args.param, "recvport")) {
  149. ast_copy_string(buf, ast_sockaddr_isnull(&p->recv) ? "" : ast_sockaddr_stringify_port(&p->recv), buflen);
  150. } else if (!strcasecmp(args.param, "from")) {
  151. ast_copy_string(buf, p->from, buflen);
  152. } else if (!strcasecmp(args.param, "uri")) {
  153. ast_copy_string(buf, p->uri, buflen);
  154. } else if (!strcasecmp(args.param, "ruri")) {
  155. char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);
  156. ast_copy_string(buf, tmpruri, buflen);
  157. } else if (!strcasecmp(args.param, "useragent")) {
  158. ast_copy_string(buf, p->useragent, buflen);
  159. } else if (!strcasecmp(args.param, "peername")) {
  160. ast_copy_string(buf, p->peername, buflen);
  161. } else if (!strcasecmp(args.param, "t38passthrough")) {
  162. ast_copy_string(buf, (p->t38.state == T38_DISABLED) ? "0" : "1", buflen);
  163. } else if (!strcasecmp(args.param, "rtpdest")) {
  164. struct ast_sockaddr addr;
  165. struct ast_rtp_instance *stream;
  166. if (ast_strlen_zero(args.type))
  167. args.type = "audio";
  168. if (!strcasecmp(args.type, "audio"))
  169. stream = p->rtp;
  170. else if (!strcasecmp(args.type, "video"))
  171. stream = p->vrtp;
  172. else if (!strcasecmp(args.type, "text"))
  173. stream = p->trtp;
  174. else
  175. return -1;
  176. /* Return 0 to suppress a console warning message */
  177. if (!stream) {
  178. return 0;
  179. }
  180. ast_rtp_instance_get_remote_address(stream, &addr);
  181. snprintf(buf, buflen, "%s", ast_sockaddr_stringify(&addr));
  182. } else if (!strcasecmp(args.param, "rtpsource")) {
  183. struct ast_sockaddr sa;
  184. struct ast_rtp_instance *stream;
  185. if (ast_strlen_zero(args.type))
  186. args.type = "audio";
  187. if (!strcasecmp(args.type, "audio"))
  188. stream = p->rtp;
  189. else if (!strcasecmp(args.type, "video"))
  190. stream = p->vrtp;
  191. else if (!strcasecmp(args.type, "text"))
  192. stream = p->trtp;
  193. else
  194. return -1;
  195. /* Return 0 to suppress a console warning message */
  196. if (!stream) {
  197. return 0;
  198. }
  199. ast_rtp_instance_get_local_address(stream, &sa);
  200. if (ast_sockaddr_isnull(&sa)) {
  201. struct ast_sockaddr dest_sa;
  202. ast_rtp_instance_get_remote_address(stream, &dest_sa);
  203. ast_ouraddrfor(&dest_sa, &sa);
  204. }
  205. snprintf(buf, buflen, "%s", ast_sockaddr_stringify(&sa));
  206. } else if (!strcasecmp(args.param, "rtpqos")) {
  207. struct ast_rtp_instance *rtp = NULL;
  208. if (ast_strlen_zero(args.type)) {
  209. args.type = "audio";
  210. }
  211. if (!strcasecmp(args.type, "audio")) {
  212. rtp = p->rtp;
  213. } else if (!strcasecmp(args.type, "video")) {
  214. rtp = p->vrtp;
  215. } else if (!strcasecmp(args.type, "text")) {
  216. rtp = p->trtp;
  217. } else {
  218. return -1;
  219. }
  220. if (ast_strlen_zero(args.field) || !strcasecmp(args.field, "all")) {
  221. char quality_buf[AST_MAX_USER_FIELD];
  222. if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) {
  223. return -1;
  224. }
  225. ast_copy_string(buf, quality_buf, buflen);
  226. return res;
  227. } else {
  228. struct ast_rtp_instance_stats stats;
  229. int i;
  230. struct {
  231. const char *name;
  232. enum { INT, DBL } type;
  233. union {
  234. unsigned int *i4;
  235. double *d8;
  236. };
  237. } lookup[] = {
  238. { "txcount", INT, { .i4 = &stats.txcount, }, },
  239. { "rxcount", INT, { .i4 = &stats.rxcount, }, },
  240. { "txjitter", DBL, { .d8 = &stats.txjitter, }, },
  241. { "rxjitter", DBL, { .d8 = &stats.rxjitter, }, },
  242. { "remote_maxjitter", DBL, { .d8 = &stats.remote_maxjitter, }, },
  243. { "remote_minjitter", DBL, { .d8 = &stats.remote_minjitter, }, },
  244. { "remote_normdevjitter", DBL, { .d8 = &stats.remote_normdevjitter, }, },
  245. { "remote_stdevjitter", DBL, { .d8 = &stats.remote_stdevjitter, }, },
  246. { "local_maxjitter", DBL, { .d8 = &stats.local_maxjitter, }, },
  247. { "local_minjitter", DBL, { .d8 = &stats.local_minjitter, }, },
  248. { "local_normdevjitter", DBL, { .d8 = &stats.local_normdevjitter, }, },
  249. { "local_stdevjitter", DBL, { .d8 = &stats.local_stdevjitter, }, },
  250. { "txploss", INT, { .i4 = &stats.txploss, }, },
  251. { "rxploss", INT, { .i4 = &stats.rxploss, }, },
  252. { "remote_maxrxploss", DBL, { .d8 = &stats.remote_maxrxploss, }, },
  253. { "remote_minrxploss", DBL, { .d8 = &stats.remote_minrxploss, }, },
  254. { "remote_normdevrxploss", DBL, { .d8 = &stats.remote_normdevrxploss, }, },
  255. { "remote_stdevrxploss", DBL, { .d8 = &stats.remote_stdevrxploss, }, },
  256. { "local_maxrxploss", DBL, { .d8 = &stats.local_maxrxploss, }, },
  257. { "local_minrxploss", DBL, { .d8 = &stats.local_minrxploss, }, },
  258. { "local_normdevrxploss", DBL, { .d8 = &stats.local_normdevrxploss, }, },
  259. { "local_stdevrxploss", DBL, { .d8 = &stats.local_stdevrxploss, }, },
  260. { "rtt", DBL, { .d8 = &stats.rtt, }, },
  261. { "maxrtt", DBL, { .d8 = &stats.maxrtt, }, },
  262. { "minrtt", DBL, { .d8 = &stats.minrtt, }, },
  263. { "normdevrtt", DBL, { .d8 = &stats.normdevrtt, }, },
  264. { "stdevrtt", DBL, { .d8 = &stats.stdevrtt, }, },
  265. { "local_ssrc", INT, { .i4 = &stats.local_ssrc, }, },
  266. { "remote_ssrc", INT, { .i4 = &stats.remote_ssrc, }, },
  267. { NULL, },
  268. };
  269. if (ast_rtp_instance_get_stats(rtp, &stats, AST_RTP_INSTANCE_STAT_ALL)) {
  270. return -1;
  271. }
  272. for (i = 0; !ast_strlen_zero(lookup[i].name); i++) {
  273. if (!strcasecmp(args.field, lookup[i].name)) {
  274. if (lookup[i].type == INT) {
  275. snprintf(buf, buflen, "%u", *lookup[i].i4);
  276. } else {
  277. snprintf(buf, buflen, "%f", *lookup[i].d8);
  278. }
  279. return 0;
  280. }
  281. }
  282. ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
  283. return -1;
  284. }
  285. } else if (!strcasecmp(args.param, "secure_signaling")) {
  286. snprintf(buf, buflen, "%s", p->socket.type == AST_TRANSPORT_TLS ? "1" : "");
  287. } else if (!strcasecmp(args.param, "secure_media")) {
  288. snprintf(buf, buflen, "%s", p->srtp ? "1" : "");
  289. } else {
  290. res = -1;
  291. }
  292. return res;
  293. }
  294. #ifdef TEST_FRAMEWORK
  295. static int test_sip_rtpqos_1_new(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *addr, void *data)
  296. {
  297. /* Needed to pass sanity checks */
  298. ast_rtp_instance_set_data(instance, data);
  299. return 0;
  300. }
  301. static int test_sip_rtpqos_1_destroy(struct ast_rtp_instance *instance)
  302. {
  303. /* Needed to pass sanity checks */
  304. return 0;
  305. }
  306. static struct ast_frame *test_sip_rtpqos_1_read(struct ast_rtp_instance *instance, int rtcp)
  307. {
  308. /* Needed to pass sanity checks */
  309. return &ast_null_frame;
  310. }
  311. static int test_sip_rtpqos_1_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
  312. {
  313. /* Needed to pass sanity checks */
  314. return 0;
  315. }
  316. static int test_sip_rtpqos_1_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
  317. {
  318. struct ast_rtp_instance_stats *s = ast_rtp_instance_get_data(instance);
  319. memcpy(stats, s, sizeof(*stats));
  320. return 0;
  321. }
  322. AST_TEST_DEFINE(test_sip_rtpqos_1)
  323. {
  324. int i, res = AST_TEST_PASS;
  325. static struct ast_rtp_engine test_engine = {
  326. .name = "test",
  327. .new = test_sip_rtpqos_1_new,
  328. .destroy = test_sip_rtpqos_1_destroy,
  329. .read = test_sip_rtpqos_1_read,
  330. .write = test_sip_rtpqos_1_write,
  331. .get_stat = test_sip_rtpqos_1_get_stat,
  332. };
  333. struct ast_sockaddr sa = { {0, } };
  334. struct ast_rtp_instance_stats mine = { 0, };
  335. struct sip_pvt *p = NULL;
  336. struct ast_channel *chan = NULL;
  337. struct ast_str *varstr = NULL, *buffer = NULL;
  338. struct {
  339. const char *name;
  340. enum { INT, DBL } type;
  341. union {
  342. unsigned int *i4;
  343. double *d8;
  344. };
  345. } lookup[] = {
  346. { "txcount", INT, { .i4 = &mine.txcount, }, },
  347. { "rxcount", INT, { .i4 = &mine.rxcount, }, },
  348. { "txjitter", DBL, { .d8 = &mine.txjitter, }, },
  349. { "rxjitter", DBL, { .d8 = &mine.rxjitter, }, },
  350. { "remote_maxjitter", DBL, { .d8 = &mine.remote_maxjitter, }, },
  351. { "remote_minjitter", DBL, { .d8 = &mine.remote_minjitter, }, },
  352. { "remote_normdevjitter", DBL, { .d8 = &mine.remote_normdevjitter, }, },
  353. { "remote_stdevjitter", DBL, { .d8 = &mine.remote_stdevjitter, }, },
  354. { "local_maxjitter", DBL, { .d8 = &mine.local_maxjitter, }, },
  355. { "local_minjitter", DBL, { .d8 = &mine.local_minjitter, }, },
  356. { "local_normdevjitter", DBL, { .d8 = &mine.local_normdevjitter, }, },
  357. { "local_stdevjitter", DBL, { .d8 = &mine.local_stdevjitter, }, },
  358. { "txploss", INT, { .i4 = &mine.txploss, }, },
  359. { "rxploss", INT, { .i4 = &mine.rxploss, }, },
  360. { "remote_maxrxploss", DBL, { .d8 = &mine.remote_maxrxploss, }, },
  361. { "remote_minrxploss", DBL, { .d8 = &mine.remote_minrxploss, }, },
  362. { "remote_normdevrxploss", DBL, { .d8 = &mine.remote_normdevrxploss, }, },
  363. { "remote_stdevrxploss", DBL, { .d8 = &mine.remote_stdevrxploss, }, },
  364. { "local_maxrxploss", DBL, { .d8 = &mine.local_maxrxploss, }, },
  365. { "local_minrxploss", DBL, { .d8 = &mine.local_minrxploss, }, },
  366. { "local_normdevrxploss", DBL, { .d8 = &mine.local_normdevrxploss, }, },
  367. { "local_stdevrxploss", DBL, { .d8 = &mine.local_stdevrxploss, }, },
  368. { "rtt", DBL, { .d8 = &mine.rtt, }, },
  369. { "maxrtt", DBL, { .d8 = &mine.maxrtt, }, },
  370. { "minrtt", DBL, { .d8 = &mine.minrtt, }, },
  371. { "normdevrtt", DBL, { .d8 = &mine.normdevrtt, }, },
  372. { "stdevrtt", DBL, { .d8 = &mine.stdevrtt, }, },
  373. { "local_ssrc", INT, { .i4 = &mine.local_ssrc, }, },
  374. { "remote_ssrc", INT, { .i4 = &mine.remote_ssrc, }, },
  375. { NULL, },
  376. };
  377. switch (cmd) {
  378. case TEST_INIT:
  379. info->name = "test_sip_rtpqos";
  380. info->category = "/channels/chan_sip/";
  381. info->summary = "Test retrieval of SIP RTP QOS stats";
  382. info->description =
  383. "Verify values in the RTP instance structure can be accessed through the dialplan.";
  384. return AST_TEST_NOT_RUN;
  385. case TEST_EXECUTE:
  386. break;
  387. }
  388. ast_rtp_engine_register2(&test_engine, NULL);
  389. /* Have to associate this with a SIP pvt and an ast_channel */
  390. if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, NULL))) {
  391. res = AST_TEST_NOT_RUN;
  392. goto done;
  393. }
  394. if (!(p->rtp = ast_rtp_instance_new("test", sched, &bindaddr, &mine))) {
  395. res = AST_TEST_NOT_RUN;
  396. goto done;
  397. }
  398. ast_rtp_instance_set_remote_address(p->rtp, &sa);
  399. if (!(chan = ast_dummy_channel_alloc())) {
  400. res = AST_TEST_NOT_RUN;
  401. goto done;
  402. }
  403. ast_channel_tech_set(chan, &sip_tech);
  404. ast_channel_tech_pvt_set(chan, dialog_ref(p, "Give the owner channel a reference to the dialog"));
  405. p->owner = chan;
  406. varstr = ast_str_create(16);
  407. buffer = ast_str_create(16);
  408. if (!varstr || !buffer) {
  409. res = AST_TEST_NOT_RUN;
  410. goto done;
  411. }
  412. /* Populate "mine" with values, then retrieve them with the CHANNEL dialplan function */
  413. for (i = 0; !ast_strlen_zero(lookup[i].name); i++) {
  414. ast_str_set(&varstr, 0, "${CHANNEL(rtpqos,audio,%s)}", lookup[i].name);
  415. if (lookup[i].type == INT) {
  416. int j;
  417. char cmpstr[256];
  418. for (j = 1; j < 25; j++) {
  419. *lookup[i].i4 = j;
  420. ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
  421. snprintf(cmpstr, sizeof(cmpstr), "%d", j);
  422. if (strcmp(cmpstr, ast_str_buffer(buffer))) {
  423. res = AST_TEST_FAIL;
  424. ast_test_status_update(test, "%s != %s != %s\n", ast_str_buffer(varstr), cmpstr, ast_str_buffer(buffer));
  425. break;
  426. }
  427. }
  428. } else {
  429. double j, cmpdbl = 0.0;
  430. for (j = 1.0; j < 10.0; j += 0.3) {
  431. *lookup[i].d8 = j;
  432. ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
  433. if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || fabs(j - cmpdbl) > .05) {
  434. res = AST_TEST_FAIL;
  435. ast_test_status_update(test, "%s != %f != %s\n", ast_str_buffer(varstr), j, ast_str_buffer(buffer));
  436. break;
  437. }
  438. }
  439. }
  440. }
  441. done:
  442. ast_free(varstr);
  443. ast_free(buffer);
  444. /* This unlink and unref will take care of destroying the channel, RTP instance, and SIP pvt */
  445. if (p) {
  446. dialog_unlink_all(p);
  447. dialog_unref(p, "Destroy test object");
  448. }
  449. if (chan) {
  450. ast_channel_unref(chan);
  451. }
  452. ast_rtp_engine_unregister(&test_engine);
  453. return res;
  454. }
  455. #endif
  456. /*! \brief SIP test registration */
  457. void sip_dialplan_function_register_tests(void)
  458. {
  459. AST_TEST_REGISTER(test_sip_rtpqos_1);
  460. }
  461. /*! \brief SIP test registration */
  462. void sip_dialplan_function_unregister_tests(void)
  463. {
  464. AST_TEST_UNREGISTER(test_sip_rtpqos_1);
  465. }