ca54b1e429c199409800374ab1e4fe204a175dfd
[asterisk/asterisk.git] / funcs / func_cdr.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999-2006, Digium, Inc.
5  *
6  * Portions Copyright (C) 2005, Anthony Minessale II
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 /*! \file
20  *
21  * \brief  Call Detail Record related dialplan functions
22  *
23  * \author Anthony Minessale II
24  *
25  * \ingroup functions
26  */
27
28 /*** MODULEINFO
29         <support_level>core</support_level>
30  ***/
31
32 #include "asterisk.h"
33
34 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
35
36 #include "asterisk/module.h"
37 #include "asterisk/channel.h"
38 #include "asterisk/pbx.h"
39 #include "asterisk/utils.h"
40 #include "asterisk/app.h"
41 #include "asterisk/cdr.h"
42 #include "asterisk/stasis.h"
43 #include "asterisk/stasis_message_router.h"
44
45 /*** DOCUMENTATION
46         <function name="CDR" language="en_US">
47                 <synopsis>
48                         Gets or sets a CDR variable.
49                 </synopsis>
50                 <syntax>
51                         <parameter name="name" required="true">
52                                 <para>CDR field name:</para>
53                                 <enumlist>
54                                         <enum name="clid">
55                                                 <para>Caller ID.</para>
56                                         </enum>
57                                         <enum name="lastdata">
58                                                 <para>Last application arguments.</para>
59                                         </enum>
60                                         <enum name="disposition">
61                                                 <para>The final state of the CDR.</para>
62                                                 <enumlist>
63                                                         <enum name="0">
64                                                                 <para><literal>NO ANSWER</literal></para>
65                                                         </enum>
66                                                         <enum name="1">
67                                                                 <para><literal>NO ANSWER</literal> (NULL record)</para>
68                                                         </enum>
69                                                         <enum name="2">
70                                                                 <para><literal>FAILED</literal></para>
71                                                         </enum>
72                                                         <enum name="4">
73                                                                 <para><literal>BUSY</literal></para>
74                                                         </enum>
75                                                         <enum name="8">
76                                                                 <para><literal>ANSWERED</literal></para>
77                                                         </enum>
78                                                         <enum name="16">
79                                                                 <para><literal>CONGESTION</literal></para>
80                                                         </enum>
81                                                 </enumlist>
82                                         </enum>
83                                         <enum name="src">
84                                                 <para>Source.</para>
85                                         </enum>
86                                         <enum name="start">
87                                                 <para>Time the call started.</para>
88                                         </enum>
89                                         <enum name="amaflags">
90                                                 <para>R/W the Automatic Message Accounting (AMA) flags on the channel.
91                                                 When read from a channel, the integer value will always be returned.
92                                                 When written to a channel, both the string format or integer value
93                                                 is accepted.</para>
94                                                 <enumlist>
95                                                         <enum name="1"><para><literal>OMIT</literal></para></enum>
96                                                         <enum name="2"><para><literal>BILLING</literal></para></enum>
97                                                         <enum name="3"><para><literal>DOCUMENTATION</literal></para></enum>
98                                                 </enumlist>
99                                                 <warning><para>Accessing this setting is deprecated in CDR. Please use the CHANNEL function instead.</para></warning>
100                                         </enum>
101                                         <enum name="dst">
102                                                 <para>Destination.</para>
103                                         </enum>
104                                         <enum name="answer">
105                                                 <para>Time the call was answered.</para>
106                                         </enum>
107                                         <enum name="accountcode">
108                                                 <para>The channel's account code.</para>
109                                                 <warning><para>Accessing this setting is deprecated in CDR. Please use the CHANNEL function instead.</para></warning>
110                                         </enum>
111                                         <enum name="dcontext">
112                                                 <para>Destination context.</para>
113                                         </enum>
114                                         <enum name="end">
115                                                 <para>Time the call ended.</para>
116                                         </enum>
117                                         <enum name="uniqueid">
118                                                 <para>The channel's unique id.</para>
119                                         </enum>
120                                         <enum name="dstchannel">
121                                                 <para>Destination channel.</para>
122                                         </enum>
123                                         <enum name="duration">
124                                                 <para>Duration of the call.</para>
125                                         </enum>
126                                         <enum name="userfield">
127                                                 <para>The channel's user specified field.</para>
128                                         </enum>
129                                         <enum name="lastapp">
130                                                 <para>Last application.</para>
131                                         </enum>
132                                         <enum name="billsec">
133                                                 <para>Duration of the call once it was answered.</para>
134                                         </enum>
135                                         <enum name="channel">
136                                                 <para>Channel name.</para>
137                                         </enum>
138                                         <enum name="sequence">
139                                                 <para>CDR sequence number.</para>
140                                         </enum>
141                                 </enumlist>
142                         </parameter>
143                         <parameter name="options" required="false">
144                                 <optionlist>
145                                         <option name="f">
146                                                 <para>Returns billsec or duration fields as floating point values.</para>
147                                         </option>
148                                         <option name="u">
149                                                 <para>Retrieves the raw, unprocessed value.</para>
150                                                 <para>For example, 'start', 'answer', and 'end' will be retrieved as epoch
151                                                 values, when the <literal>u</literal> option is passed, but formatted as YYYY-MM-DD HH:MM:SS
152                                                 otherwise.  Similarly, disposition and amaflags will return their raw
153                                                 integral values.</para>
154                                         </option>
155                                 </optionlist>
156                         </parameter>
157                 </syntax>
158                 <description>
159                         <para>All of the CDR field names are read-only, except for <literal>accountcode</literal>,
160                         <literal>userfield</literal>, and <literal>amaflags</literal>. You may, however, supply
161                         a name not on the above list, and create your own variable, whose value can be changed
162                         with this function, and this variable will be stored on the CDR.</para>
163                         <note><para>CDRs can only be modified before the bridge between two channels is
164                         torn down. For example, CDRs may not be modified after the <literal>Dial</literal>
165                         application has returned.</para></note>
166                         <para>Example: exten => 1,1,Set(CDR(userfield)=test)</para>
167                 </description>
168         </function>
169         <function name="CDR_PROP" language="en_US">
170                 <synopsis>
171                         Set a property on a channel's CDR.
172                 </synopsis>
173                 <syntax>
174                         <parameter name="name" required="true">
175                                 <para>The property to set on the CDR.</para>
176                                 <enumlist>
177                                         <enum name="party_a">
178                                                 <para>Set this channel as the preferred Party A when
179                                                 channels are associated together.</para>
180                                                 <para>Write-Only</para>
181                                         </enum>
182                                         <enum name="disable">
183                                                 <para>Disable CDRs for this channel.</para>
184                                                 <para>Write-Only</para>
185                                         </enum>
186                                 </enumlist>
187                         </parameter>
188                 </syntax>
189                 <description>
190                         <para>This function sets a property on a channel's CDR. Properties
191                         alter the behavior of how the CDR operates for that channel.</para>
192                 </description>
193         </function>
194  ***/
195
196 enum cdr_option_flags {
197         OPT_UNPARSED = (1 << 1),
198         OPT_FLOAT = (1 << 2),
199 };
200
201 AST_APP_OPTIONS(cdr_func_options, {
202         AST_APP_OPTION('f', OPT_FLOAT),
203         AST_APP_OPTION('u', OPT_UNPARSED),
204 });
205
206 struct cdr_func_payload {
207         struct ast_channel *chan;
208         const char *cmd;
209         const char *arguments;
210         const char *value;
211         void *data;
212 };
213
214 struct cdr_func_data {
215         char *buf;
216         size_t len;
217 };
218
219 STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_read_message_type);
220 STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_write_message_type);
221 STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_prop_write_message_type);
222
223 static void cdr_read_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
224 {
225         struct cdr_func_payload *payload = stasis_message_data(message);
226         struct cdr_func_data *output;
227         char *info;
228         char *value = NULL;
229         struct ast_flags flags = { 0 };
230         char tempbuf[512];
231         AST_DECLARE_APP_ARGS(args,
232                 AST_APP_ARG(variable);
233                 AST_APP_ARG(options);
234         );
235
236         if (cdr_read_message_type() != stasis_message_type(message)) {
237                 return;
238         }
239
240         ast_assert(payload != NULL);
241         output = payload->data;
242         ast_assert(output != NULL);
243
244         if (ast_strlen_zero(payload->arguments)) {
245                 ast_log(AST_LOG_WARNING, "%s requires a variable (%s(variable[,option]))\n)",
246                         payload->cmd, payload->cmd);
247                 return;
248         }
249         info = ast_strdupa(payload->arguments);
250         AST_STANDARD_APP_ARGS(args, info);
251
252         if (!ast_strlen_zero(args.options)) {
253                 ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
254         }
255
256         if (ast_strlen_zero(ast_channel_name(payload->chan))) {
257                 /* Format request on a dummy channel */
258                 ast_cdr_format_var(ast_channel_cdr(payload->chan), args.variable, &value, tempbuf, sizeof(tempbuf), 0);
259                 if (ast_strlen_zero(value)) {
260                         return;
261                 }
262                 ast_copy_string(tempbuf, value, sizeof(tempbuf));
263                 ast_set_flag(&flags, OPT_UNPARSED);
264         } else if (ast_cdr_getvar(ast_channel_name(payload->chan), args.variable, tempbuf, sizeof(tempbuf))) {
265                 return;
266         }
267
268         if (ast_test_flag(&flags, OPT_FLOAT)
269                 && (!strcasecmp("billsec", args.variable) || !strcasecmp("duration", args.variable))) {
270                 long ms;
271                 double dtime;
272
273                 if (sscanf(tempbuf, "%30ld", &ms) != 1) {
274                         ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
275                                 args.variable, tempbuf, ast_channel_name(payload->chan));
276                         return;
277                 }
278                 dtime = (double)(ms / 1000.0);
279                 snprintf(tempbuf, sizeof(tempbuf), "%lf", dtime);
280         } else if (!ast_test_flag(&flags, OPT_UNPARSED)) {
281                 if (!strcasecmp("start", args.variable)
282                         || !strcasecmp("end", args.variable)
283                         || !strcasecmp("answer", args.variable)) {
284                         struct timeval fmt_time;
285                         struct ast_tm tm;
286                         /* tv_usec is suseconds_t, which could be int or long */
287                         long int tv_sec;
288                         long int tv_usec;
289
290                         if (sscanf(tempbuf, "%ld.%ld", &tv_sec, &tv_usec) != 2) {
291                                 ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
292                                         args.variable, tempbuf, ast_channel_name(payload->chan));
293                                 return;
294                         }
295                         if (tv_sec) {
296                                 fmt_time.tv_sec = tv_sec;
297                                 fmt_time.tv_usec = tv_usec;
298                                 ast_localtime(&fmt_time, &tm, NULL);
299                                 ast_strftime(tempbuf, sizeof(tempbuf), "%Y-%m-%d %T", &tm);
300                         } else {
301                                 tempbuf[0] = '\0';
302                         }
303                 } else if (!strcasecmp("disposition", args.variable)) {
304                         int disposition;
305
306                         if (sscanf(tempbuf, "%8d", &disposition) != 1) {
307                                 ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
308                                         args.variable, tempbuf, ast_channel_name(payload->chan));
309                                 return;
310                         }
311                         snprintf(tempbuf, sizeof(tempbuf), "%s", ast_cdr_disp2str(disposition));
312                 } else if (!strcasecmp("amaflags", args.variable)) {
313                         int amaflags;
314
315                         if (sscanf(tempbuf, "%8d", &amaflags) != 1) {
316                                 ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
317                                         args.variable, tempbuf, ast_channel_name(payload->chan));
318                                 return;
319                         }
320                         snprintf(tempbuf, sizeof(tempbuf), "%s", ast_channel_amaflags2string(amaflags));
321                 }
322         }
323
324         ast_copy_string(output->buf, tempbuf, output->len);
325 }
326
327 static void cdr_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
328 {
329         struct cdr_func_payload *payload = stasis_message_data(message);
330         struct ast_flags flags = { 0 };
331         AST_DECLARE_APP_ARGS(args,
332                 AST_APP_ARG(variable);
333                 AST_APP_ARG(options);
334         );
335         char *parse;
336
337         if (cdr_write_message_type() != stasis_message_type(message)) {
338                 return;
339         }
340
341         if (!payload) {
342                 return;
343         }
344
345         if (ast_strlen_zero(payload->arguments)) {
346                 ast_log(AST_LOG_WARNING, "%s requires a variable (%s(variable)=value)\n)",
347                         payload->cmd, payload->cmd);
348                 return;
349         }
350         if (ast_strlen_zero(payload->value)) {
351                 ast_log(AST_LOG_WARNING, "%s requires a value (%s(variable)=value)\n)",
352                         payload->cmd, payload->cmd);
353                 return;
354         }
355         parse = ast_strdupa(payload->arguments);
356         AST_STANDARD_APP_ARGS(args, parse);
357
358         if (!ast_strlen_zero(args.options)) {
359                 ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
360         }
361
362         if (!strcasecmp(args.variable, "accountcode")) {
363                 ast_log(AST_LOG_WARNING, "Using the CDR function to set 'accountcode' is deprecated. Please use the CHANNEL function instead.\n");
364                 ast_channel_lock(payload->chan);
365                 ast_channel_accountcode_set(payload->chan, payload->value);
366                 ast_channel_unlock(payload->chan);
367         } else if (!strcasecmp(args.variable, "peeraccount")) {
368                 ast_log(AST_LOG_WARNING, "The 'peeraccount' setting is not supported. Please set the 'accountcode' on the appropriate channel using the CHANNEL function.\n");
369         } else if (!strcasecmp(args.variable, "userfield")) {
370                 ast_cdr_setuserfield(ast_channel_name(payload->chan), payload->value);
371         } else if (!strcasecmp(args.variable, "amaflags")) {
372                 ast_log(AST_LOG_WARNING, "Using the CDR function to set 'amaflags' is deprecated. Please use the CHANNEL function instead.\n");
373                 if (isdigit(*payload->value)) {
374                         int amaflags;
375                         sscanf(payload->value, "%30d", &amaflags);
376                         ast_channel_lock(payload->chan);
377                         ast_channel_amaflags_set(payload->chan, amaflags);
378                         ast_channel_unlock(payload->chan);
379                 } else {
380                         ast_channel_lock(payload->chan);
381                         ast_channel_amaflags_set(payload->chan, ast_channel_string2amaflag(payload->value));
382                         ast_channel_unlock(payload->chan);
383                 }
384         } else {
385                 ast_cdr_setvar(ast_channel_name(payload->chan), args.variable, payload->value);
386         }
387         return;
388 }
389
390 static void cdr_prop_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
391 {
392         struct cdr_func_payload *payload = stasis_message_data(message);
393         enum ast_cdr_options option;
394         char *parse;
395         AST_DECLARE_APP_ARGS(args,
396                 AST_APP_ARG(variable);
397                 AST_APP_ARG(options);
398         );
399
400         if (cdr_prop_write_message_type() != stasis_message_type(message)) {
401                 return;
402         }
403
404         if (!payload) {
405                 return;
406         }
407
408         if (ast_strlen_zero(payload->arguments)) {
409                 ast_log(AST_LOG_WARNING, "%s requires a variable (%s(variable)=value)\n)",
410                         payload->cmd, payload->cmd);
411                 return;
412         }
413         if (ast_strlen_zero(payload->value)) {
414                 ast_log(AST_LOG_WARNING, "%s requires a value (%s(variable)=value)\n)",
415                         payload->cmd, payload->cmd);
416                 return;
417         }
418         parse = ast_strdupa(payload->arguments);
419         AST_STANDARD_APP_ARGS(args, parse);
420
421         if (!strcasecmp("party_a", args.variable)) {
422                 option = AST_CDR_FLAG_PARTY_A;
423         } else if (!strcasecmp("disable", args.variable)) {
424                 option = AST_CDR_FLAG_DISABLE_ALL;
425         } else {
426                 ast_log(AST_LOG_WARNING, "Unknown option %s used with %s\n", args.variable, payload->cmd);
427                 return;
428         }
429
430         if (ast_true(payload->value)) {
431                 ast_cdr_set_property(ast_channel_name(payload->chan), option);
432         } else {
433                 ast_cdr_clear_property(ast_channel_name(payload->chan), option);
434         }
435 }
436
437
438 static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
439                     char *buf, size_t len)
440 {
441         RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
442         RAII_VAR(struct cdr_func_payload *, payload, NULL, ao2_cleanup);
443         struct cdr_func_data output = { 0, };
444
445         if (!chan) {
446                 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
447                 return -1;
448         }
449
450         if (!cdr_read_message_type()) {
451                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n",
452                         ast_channel_name(chan));
453                 return -1;
454         }
455
456         payload = ao2_alloc(sizeof(*payload), NULL);
457         if (!payload) {
458                 return -1;
459         }
460         payload->chan = chan;
461         payload->cmd = cmd;
462         payload->arguments = parse;
463         payload->data = &output;
464
465         buf[0] = '\0';/* Ensure the buffer is initialized. */
466         output.buf = buf;
467         output.len = len;
468
469         message = stasis_message_create(cdr_read_message_type(), payload);
470         if (!message) {
471                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: unable to create message\n",
472                         ast_channel_name(chan));
473                 return -1;
474         }
475
476         /* If this is a request on a dummy channel, we're doing post-processing on an
477          * already dispatched CDR. Simply call the callback to calculate the value and
478          * return, instead of posting to Stasis as we would for a running channel.
479          */
480         if (ast_strlen_zero(ast_channel_name(chan))) {
481                 cdr_read_callback(NULL, NULL, message);
482         } else {
483                 RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
484
485                 if (!router) {
486                         ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",
487                                 ast_channel_name(chan));
488                         return -1;
489                 }
490                 stasis_message_router_publish_sync(router, message);
491         }
492
493         return 0;
494 }
495
496 static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse,
497                      const char *value)
498 {
499         RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
500         RAII_VAR(struct cdr_func_payload *, payload, NULL, ao2_cleanup);
501         RAII_VAR(struct stasis_message_router *, router,
502                      ast_cdr_message_router(), ao2_cleanup);
503
504         if (!chan) {
505                 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
506                 return -1;
507         }
508
509         if (!router) {
510                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",
511                         ast_channel_name(chan));
512                 return -1;
513         }
514
515         if (!cdr_write_message_type()) {
516                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n",
517                         ast_channel_name(chan));
518                 return -1;
519         }
520
521         payload = ao2_alloc(sizeof(*payload), NULL);
522         if (!payload) {
523                 return -1;
524         }
525         payload->chan = chan;
526         payload->cmd = cmd;
527         payload->arguments = parse;
528         payload->value = value;
529
530         message = stasis_message_create(cdr_write_message_type(), payload);
531         if (!message) {
532                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: unable to create message\n",
533                         ast_channel_name(chan));
534                 return -1;
535         }
536         stasis_message_router_publish_sync(router, message);
537
538         return 0;
539 }
540
541 static int cdr_prop_write(struct ast_channel *chan, const char *cmd, char *parse,
542                      const char *value)
543 {
544         RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
545         RAII_VAR(struct cdr_func_payload *, payload, NULL, ao2_cleanup);
546         RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
547
548         if (!chan) {
549                 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
550                 return -1;
551         }
552
553         if (!router) {
554                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",
555                         ast_channel_name(chan));
556                 return -1;
557         }
558
559         if (!cdr_write_message_type()) {
560                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n",
561                         ast_channel_name(chan));
562                 return -1;
563         }
564
565         payload = ao2_alloc(sizeof(*payload), NULL);
566         if (!payload) {
567                 return -1;
568         }
569         payload->chan = chan;
570         payload->cmd = cmd;
571         payload->arguments = parse;
572         payload->value = value;
573
574         message = stasis_message_create(cdr_prop_write_message_type(), payload);
575         if (!message) {
576                 ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: unable to create message\n",
577                         ast_channel_name(chan));
578                 return -1;
579         }
580         stasis_message_router_publish_sync(router, message);
581
582         return 0;
583 }
584
585 static struct ast_custom_function cdr_function = {
586         .name = "CDR",
587         .read = cdr_read,
588         .write = cdr_write,
589 };
590
591 static struct ast_custom_function cdr_prop_function = {
592         .name = "CDR_PROP",
593         .read = NULL,
594         .write = cdr_prop_write,
595 };
596
597 static int unload_module(void)
598 {
599         RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
600         int res = 0;
601
602         if (router) {
603                 stasis_message_router_remove(router, cdr_prop_write_message_type());
604                 stasis_message_router_remove(router, cdr_write_message_type());
605                 stasis_message_router_remove(router, cdr_read_message_type());
606         }
607         STASIS_MESSAGE_TYPE_CLEANUP(cdr_read_message_type);
608         STASIS_MESSAGE_TYPE_CLEANUP(cdr_write_message_type);
609         STASIS_MESSAGE_TYPE_CLEANUP(cdr_prop_write_message_type);
610         res |= ast_custom_function_unregister(&cdr_function);
611         res |= ast_custom_function_unregister(&cdr_prop_function);
612
613         return res;
614 }
615
616 static int load_module(void)
617 {
618         RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
619         int res = 0;
620
621         if (!router) {
622                 return AST_MODULE_LOAD_FAILURE;
623         }
624
625         res |= STASIS_MESSAGE_TYPE_INIT(cdr_read_message_type);
626         res |= STASIS_MESSAGE_TYPE_INIT(cdr_write_message_type);
627         res |= STASIS_MESSAGE_TYPE_INIT(cdr_prop_write_message_type);
628         res |= ast_custom_function_register(&cdr_function);
629         res |= ast_custom_function_register(&cdr_prop_function);
630         res |= stasis_message_router_add(router, cdr_prop_write_message_type(),
631                                          cdr_prop_write_callback, NULL);
632         res |= stasis_message_router_add(router, cdr_write_message_type(),
633                                          cdr_write_callback, NULL);
634         res |= stasis_message_router_add(router, cdr_read_message_type(),
635                                          cdr_read_callback, NULL);
636
637         if (res) {
638                 return AST_MODULE_LOAD_FAILURE;
639         }
640         return AST_MODULE_LOAD_SUCCESS;
641 }
642
643 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Detail Record (CDR) dialplan functions");