Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

cdr.h File Reference

#include <asterisk/channel.h>
#include <sys/time.h>

Include dependency graph for cdr.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  ast_cdr
 Responsible for call detail data. More...


Defines

#define AST_CDR_NOANSWER   (1 << 0)
#define AST_CDR_BUSY   (1 << 1)
#define AST_CDR_ANSWERED   (1 << 2)
#define AST_CDR_FAILED   (1 << 3)
#define AST_CDR_OMIT   (1)
 AMA Flags.

#define AST_CDR_BILLING   (2)
#define AST_CDR_DOCUMENTATION   (3)
#define AST_MAX_USER_FIELD   256

Typedefs

typedef int(* ast_cdrbe )(struct ast_cdr *cdr)

Functions

ast_cdrast_cdr_alloc (void)
 Allocate a record.

void ast_cdr_free (struct ast_cdr *cdr)
 Free a record.

int ast_cdr_init (struct ast_cdr *cdr, struct ast_channel *chan)
 Initialize based on a channel.

int ast_cdr_setcid (struct ast_cdr *cdr, struct ast_channel *chan)
 Initialize based on a channel.

int ast_cdr_register (char *name, char *desc, ast_cdrbe be)
 Register a CDR handling engine.

void ast_cdr_unregister (char *name)
 Unregister a CDR handling engine.

void ast_cdr_start (struct ast_cdr *cdr)
 Start a call.

void ast_cdr_answer (struct ast_cdr *cdr)
 Answer a call.

void ast_cdr_busy (struct ast_cdr *cdr)
 Busy a call.

void ast_cdr_failed (struct ast_cdr *cdr)
 Fail a call.

int ast_cdr_disposition (struct ast_cdr *cdr, int cause)
 Save the result of the call based on the AST_CAUSE_*.

void ast_cdr_end (struct ast_cdr *cdr)
 End a call.

void ast_cdr_post (struct ast_cdr *cdr)
 Post the detail record.

void ast_cdr_setdestchan (struct ast_cdr *cdr, char *chan)
 Set the destination channel, if there was one.

void ast_cdr_setapp (struct ast_cdr *cdr, char *app, char *data)
 Set the last executed application.

int ast_cdr_amaflags2int (char *flag)
 Convert a string to a detail record AMA flag.

char * ast_cdr_disp2str (int disposition)
 Disposition to a string.

void ast_cdr_reset (struct ast_cdr *cdr, int post)
 Reset the detail record, optionally posting it first.

char * ast_cdr_flags2str (int flags)
 Flags to a string.

int ast_cdr_setaccount (struct ast_channel *chan, char *account)
int ast_cdr_setuserfield (struct ast_channel *chan, char *userfield)
int ast_cdr_appenduserfield (struct ast_channel *chan, char *userfield)
int ast_cdr_update (struct ast_channel *chan)

Variables

int ast_default_amaflags
char ast_default_accountcode [20]


Define Documentation

#define AST_CDR_ANSWERED   (1 << 2)
 

Definition at line 25 of file cdr.h.

Referenced by ast_cdr_answer(), ast_cdr_disp2str(), and ast_cdr_init().

#define AST_CDR_BILLING   (2)
 

Definition at line 30 of file cdr.h.

Referenced by ast_cdr_amaflags2int(), and ast_cdr_flags2str().

#define AST_CDR_BUSY   (1 << 1)
 

Definition at line 24 of file cdr.h.

Referenced by ast_cdr_busy(), and ast_cdr_disp2str().

#define AST_CDR_DOCUMENTATION   (3)
 

Definition at line 31 of file cdr.h.

Referenced by ast_cdr_amaflags2int(), and ast_cdr_flags2str().

#define AST_CDR_FAILED   (1 << 3)
 

Definition at line 26 of file cdr.h.

Referenced by ast_cdr_disp2str(), and ast_cdr_failed().

#define AST_CDR_NOANSWER   (1 << 0)
 

Definition at line 23 of file cdr.h.

Referenced by ast_cdr_disp2str(), ast_cdr_init(), and ast_cdr_reset().

#define AST_CDR_OMIT   (1)
 

AMA Flags.

Definition at line 29 of file cdr.h.

Referenced by ast_cdr_amaflags2int(), and ast_cdr_flags2str().

#define AST_MAX_USER_FIELD   256
 

Definition at line 33 of file cdr.h.


Typedef Documentation

typedef int(* ast_cdrbe)(struct ast_cdr *cdr)
 

Definition at line 79 of file cdr.h.


Function Documentation

struct ast_cdr* ast_cdr_alloc void   ) 
 

Allocate a record.

Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)

Definition at line 121 of file cdr.c.

References malloc.

Referenced by __ast_request_and_dial(), and ast_pbx_run().

00122 { 00123 struct ast_cdr *cdr; 00124 cdr = malloc(sizeof(struct ast_cdr)); 00125 if (cdr) { 00126 memset(cdr, 0, sizeof(struct ast_cdr)); 00127 } 00128 return cdr; 00129 }

int ast_cdr_amaflags2int char *  flag  ) 
 

Convert a string to a detail record AMA flag.

Parameters:
flag string form of flag Converts the string form of the flag to the binary form. Returns the binary form of the flag

Definition at line 404 of file cdr.c.

References AST_CDR_BILLING, AST_CDR_DOCUMENTATION, and AST_CDR_OMIT.

00405 { 00406 if (!strcasecmp(flag, "default")) 00407 return 0; 00408 if (!strcasecmp(flag, "omit")) 00409 return AST_CDR_OMIT; 00410 if (!strcasecmp(flag, "billing")) 00411 return AST_CDR_BILLING; 00412 if (!strcasecmp(flag, "documentation")) 00413 return AST_CDR_DOCUMENTATION; 00414 return -1; 00415 }

void ast_cdr_answer struct ast_cdr cdr  ) 
 

Answer a call.

Parameters:
cdr the cdr you wish to associate with the call Starts all CDR stuff necessary for doing CDR when answering a call

Definition at line 144 of file cdr.c.

References ast_cdr::answer, AST_CDR_ANSWERED, ast_log(), ast_cdr::channel, ast_cdr::disposition, LOG_WARNING, and ast_cdr::posted.

Referenced by ast_answer(), and ast_read().

00145 { 00146 char *chan; 00147 if (cdr) { 00148 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00149 if (cdr->posted) 00150 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00151 if (cdr->disposition < AST_CDR_ANSWERED) 00152 cdr->disposition = AST_CDR_ANSWERED; 00153 if (!cdr->answer.tv_sec && !cdr->answer.tv_usec) { 00154 gettimeofday(&cdr->answer, NULL); 00155 } 00156 } 00157 }

int ast_cdr_appenduserfield struct ast_channel chan,
char *  userfield
 

Definition at line 361 of file cdr.c.

References ast_channel::cdr.

00362 { 00363 struct ast_cdr *cdr = chan->cdr; 00364 00365 if (cdr) 00366 { 00367 int len = strlen(cdr->userfield); 00368 strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1); 00369 } 00370 return 0; 00371 }

void ast_cdr_busy struct ast_cdr cdr  ) 
 

Busy a call.

Parameters:
cdr the cdr you wish to associate with the call Returns nothing important

Definition at line 159 of file cdr.c.

References AST_CDR_BUSY, ast_log(), ast_cdr::channel, ast_cdr::disposition, LOG_WARNING, and ast_cdr::posted.

Referenced by ast_cdr_disposition().

00160 { 00161 char *chan; 00162 if (cdr) { 00163 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00164 if (cdr->posted) 00165 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00166 if (cdr->disposition < AST_CDR_BUSY) 00167 cdr->disposition = AST_CDR_BUSY; 00168 } 00169 }

char* ast_cdr_disp2str int  disposition  ) 
 

Disposition to a string.

Parameters:
flag input binary form Converts the binary form of a disposition to string form. Returns a pointer to the string form

Definition at line 313 of file cdr.c.

References AST_CDR_ANSWERED, AST_CDR_BUSY, AST_CDR_FAILED, and AST_CDR_NOANSWER.

00314 { 00315 switch (disposition) { 00316 case AST_CDR_NOANSWER: 00317 return "NO ANSWER"; 00318 case AST_CDR_FAILED: 00319 return "FAILED"; 00320 case AST_CDR_BUSY: 00321 return "BUSY"; 00322 case AST_CDR_ANSWERED: 00323 return "ANSWERED"; 00324 default: 00325 return "UNKNOWN"; 00326 } 00327 }

int ast_cdr_disposition struct ast_cdr cdr,
int  cause
 

Save the result of the call based on the AST_CAUSE_*.

Parameters:
cdr the cdr you wish to associate with the call Returns nothing important
cause the AST_CAUSE_*

Definition at line 182 of file cdr.c.

References AST_CAUSE_BUSY, AST_CAUSE_FAILURE, AST_CAUSE_NORMAL, AST_CAUSE_NOTDEFINED, ast_cdr_busy(), ast_cdr_failed(), ast_log(), and LOG_WARNING.

Referenced by __ast_request_and_dial().

00183 { 00184 int res = 0; 00185 if (cdr) { 00186 switch(cause) { 00187 case AST_CAUSE_BUSY: 00188 ast_cdr_busy(cdr); 00189 break; 00190 case AST_CAUSE_FAILURE: 00191 ast_cdr_failed(cdr); 00192 break; 00193 case AST_CAUSE_NORMAL: 00194 break; 00195 case AST_CAUSE_NOTDEFINED: 00196 res = -1; 00197 break; 00198 default: 00199 res = -1; 00200 ast_log(LOG_WARNING, "We don't handle that cause yet\n"); 00201 } 00202 } 00203 return res; 00204 }

void ast_cdr_end struct ast_cdr cdr  ) 
 

End a call.

Parameters:
cdr the cdr you have associated the call with Registers the end of call time in the cdr structure. Returns nothing important

Definition at line 299 of file cdr.c.

References ast_log(), ast_cdr::channel, ast_cdr::end, LOG_WARNING, ast_cdr::posted, and ast_cdr::start.

Referenced by __ast_request_and_dial(), ast_cdr_reset(), ast_hangup(), and ast_read().

00300 { 00301 char *chan; 00302 if (cdr) { 00303 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00304 if (cdr->posted) 00305 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00306 if (!cdr->start.tv_sec && !cdr->start.tv_usec) 00307 ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan); 00308 if (!cdr->end.tv_sec && !cdr->end.tv_usec) 00309 gettimeofday(&cdr->end, NULL); 00310 } 00311 }

void ast_cdr_failed struct ast_cdr cdr  ) 
 

Fail a call.

Parameters:
cdr the cdr you wish to associate with the call Returns nothing important

Definition at line 171 of file cdr.c.

References AST_CDR_FAILED, ast_log(), ast_cdr::channel, ast_cdr::disposition, LOG_WARNING, and ast_cdr::posted.

Referenced by __ast_request_and_dial(), and ast_cdr_disposition().

00172 { 00173 char *chan; 00174 if (cdr) { 00175 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00176 if (cdr->posted) 00177 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00178 cdr->disposition = AST_CDR_FAILED; 00179 } 00180 }

char* ast_cdr_flags2str int  flags  ) 
 

Flags to a string.

Parameters:
flags binary flag Converts binary flags to string flags Returns string with flag name

Definition at line 329 of file cdr.c.

References AST_CDR_BILLING, AST_CDR_DOCUMENTATION, and AST_CDR_OMIT.

00330 { 00331 switch(flag) { 00332 case AST_CDR_OMIT: 00333 return "OMIT"; 00334 case AST_CDR_BILLING: 00335 return "BILLING"; 00336 case AST_CDR_DOCUMENTATION: 00337 return "DOCUMENTATION"; 00338 } 00339 return "Unknown"; 00340 }

void ast_cdr_free struct ast_cdr cdr  ) 
 

Free a record.

Definition at line 106 of file cdr.c.

References ast_log(), ast_cdr::channel, ast_cdr::end, free, LOG_WARNING, ast_cdr::posted, and ast_cdr::start.

Referenced by ast_hangup().

00107 { 00108 char *chan; 00109 if (cdr) { 00110 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00111 if (!cdr->posted) 00112 ast_log(LOG_WARNING, "CDR on channel '%s' not posted\n", chan); 00113 if (!cdr->end.tv_sec && !cdr->end.tv_usec) 00114 ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan); 00115 if (!cdr->start.tv_sec && !cdr->start.tv_usec) 00116 ast_log(LOG_WARNING, "CDR on channel '%s' lacks start\n", chan); 00117 free(cdr); 00118 } 00119 }

int ast_cdr_init struct ast_cdr cdr,
struct ast_channel chan
 

Initialize based on a channel.

Parameters:
cdr Call Detail Record to use for channel
chan Channel to bind CDR with Initializes a CDR and associates it with a particular channel Return is negligible. (returns 0 by default)

Definition at line 256 of file cdr.c.

References ast_channel::_state, ast_channel::accountcode, ast_cdr::accountcode, ast_cdr::amaflags, ast_channel::amaflags, ast_channel::ani, ast_callerid_parse(), AST_CDR_ANSWERED, AST_CDR_NOANSWER, ast_default_amaflags, ast_log(), AST_MAX_EXTENSION, ast_shrink_phone_number(), AST_STATE_UP, ast_channel::callerid, ast_cdr::channel, ast_cdr::clid, ast_channel::context, ast_cdr::dcontext, ast_cdr::disposition, ast_cdr::dst, ast_channel::exten, LOG_WARNING, ast_channel::name, ast_cdr::src, ast_channel::uniqueid, and ast_cdr::uniqueid.

Referenced by __ast_request_and_dial(), and ast_pbx_run().

00257 { 00258 char *chan; 00259 char *num, *name; 00260 char tmp[AST_MAX_EXTENSION] = ""; 00261 if (cdr) { 00262 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00263 if (!ast_strlen_zero(cdr->channel)) 00264 ast_log(LOG_WARNING, "CDR already initialized on '%s'\n", chan); 00265 strncpy(cdr->channel, c->name, sizeof(cdr->channel) - 1); 00266 /* Grab source from ANI or normal Caller*ID */ 00267 if (c->ani) 00268 strncpy(tmp, c->ani, sizeof(tmp) - 1); 00269 else if (c->callerid) 00270 strncpy(tmp, c->callerid, sizeof(tmp) - 1); 00271 if (c->callerid) 00272 strncpy(cdr->clid, c->callerid, sizeof(cdr->clid) - 1); 00273 name = NULL; 00274 num = NULL; 00275 ast_callerid_parse(tmp, &name, &num); 00276 if (num) { 00277 ast_shrink_phone_number(num); 00278 strncpy(cdr->src, num, sizeof(cdr->src) - 1); 00279 } 00280 00281 if (c->_state == AST_STATE_UP) 00282 cdr->disposition = AST_CDR_ANSWERED; 00283 else 00284 cdr->disposition = AST_CDR_NOANSWER; 00285 if (c->amaflags) 00286 cdr->amaflags = c->amaflags; 00287 else 00288 cdr->amaflags = ast_default_amaflags; 00289 strncpy(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode) - 1); 00290 /* Destination information */ 00291 strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1); 00292 strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1); 00293 /* Unique call identifier */ 00294 strncpy(cdr->uniqueid, c->uniqueid, sizeof(cdr->uniqueid) - 1); 00295 } 00296 return 0; 00297 }

void ast_cdr_post struct ast_cdr cdr  ) 
 

Post the detail record.

Parameters:
cdr Which cdr to post Actually outputs the CDR record to the CDR plugins installed Returns nothing

Definition at line 417 of file cdr.c.

References ast_cdr::answer, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_cdr::billsec, ast_cdr::channel, ast_cdr::duration, ast_cdr::end, LOG_WARNING, ast_cdr::posted, and ast_cdr::start.

Referenced by ast_cdr_reset(), and ast_hangup().

00418 { 00419 char *chan; 00420 struct ast_cdr_beitem *i; 00421 if (cdr) { 00422 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00423 if (cdr->posted) 00424 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00425 if (!cdr->end.tv_sec && !cdr->end.tv_usec) 00426 ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan); 00427 if (!cdr->start.tv_sec && !cdr->start.tv_usec) 00428 ast_log(LOG_WARNING, "CDR on channel '%s' lacks start\n", chan); 00429 cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec + (cdr->end.tv_usec - cdr->start.tv_usec) / 1000000; 00430 if (cdr->answer.tv_sec || cdr->answer.tv_usec) { 00431 cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000; 00432 } else 00433 cdr->billsec = 0; 00434 cdr->posted = 1; 00435 ast_mutex_lock(&cdrlock); 00436 i = bes; 00437 while(i) { 00438 i->be(cdr); 00439 i = i->next; 00440 } 00441 ast_mutex_unlock(&cdrlock); 00442 } 00443 }

int ast_cdr_register char *  name,
char *  desc,
ast_cdrbe  be
 

Register a CDR handling engine.

Parameters:
name name associated with the particular CDR handler
desc description of the CDR handler
be function pointer to a CDR handler Used to register a Call Detail Record handler. Returns -1 on error, 0 on success.

Definition at line 49 of file cdr.c.

References ast_log(), ast_mutex_lock, ast_mutex_unlock, LOG_WARNING, and malloc.

00050 { 00051 struct ast_cdr_beitem *i; 00052 if (!name) 00053 return -1; 00054 if (!be) { 00055 ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name); 00056 return -1; 00057 } 00058 ast_mutex_lock(&cdrlock); 00059 i = bes; 00060 while(i) { 00061 if (!strcasecmp(name, i->name)) 00062 break; 00063 i = i->next; 00064 } 00065 ast_mutex_unlock(&cdrlock); 00066 if (i) { 00067 ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name); 00068 return -1; 00069 } 00070 i = malloc(sizeof(struct ast_cdr_beitem)); 00071 if (!i) 00072 return -1; 00073 memset(i, 0, sizeof(struct ast_cdr_beitem)); 00074 strncpy(i->name, name, sizeof(i->name) - 1); 00075 strncpy(i->desc, desc, sizeof(i->desc) - 1); 00076 i->be = be; 00077 ast_mutex_lock(&cdrlock); 00078 i->next = bes; 00079 bes = i; 00080 ast_mutex_unlock(&cdrlock); 00081 return 0; 00082 }

void ast_cdr_reset struct ast_cdr cdr,
int  post
 

Reset the detail record, optionally posting it first.

Parameters:
cdr which cdr to act upon
post whether or not to post the cdr first before resetting it

Definition at line 445 of file cdr.c.

References ast_cdr::answer, ast_cdr_end(), AST_CDR_NOANSWER, ast_cdr_post(), ast_cdr_start(), ast_cdr::billsec, ast_cdr::disposition, ast_cdr::duration, ast_cdr::end, ast_cdr::posted, and ast_cdr::start.

00446 { 00447 if (cdr) { 00448 /* Post if requested */ 00449 if (post) { 00450 ast_cdr_end(cdr); 00451 ast_cdr_post(cdr); 00452 } 00453 /* Reset to initial state */ 00454 cdr->posted = 0; 00455 memset(&cdr->start, 0, sizeof(cdr->start)); 00456 memset(&cdr->end, 0, sizeof(cdr->end)); 00457 memset(&cdr->answer, 0, sizeof(cdr->answer)); 00458 cdr->billsec = 0; 00459 cdr->duration = 0; 00460 ast_cdr_start(cdr); 00461 cdr->disposition = AST_CDR_NOANSWER; 00462 } 00463 }

int ast_cdr_setaccount struct ast_channel chan,
char *  account
 

Definition at line 342 of file cdr.c.

References ast_channel::accountcode, and ast_channel::cdr.

Referenced by __ast_request_and_dial().

00343 { 00344 struct ast_cdr *cdr = chan->cdr; 00345 00346 strncpy(chan->accountcode, account, sizeof(chan->accountcode) - 1); 00347 if (cdr) 00348 strncpy(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode) - 1); 00349 return 0; 00350 }

void ast_cdr_setapp struct ast_cdr cdr,
char *  app,
char *  data
 

Set the last executed application.

Parameters:
cdr which cdr to act upon
app the name of the app you wish to change it to
data the data you want in the data field of app you set it to Changes the value of the last executed app Returns nothing

Definition at line 217 of file cdr.c.

References ast_log(), ast_cdr::channel, ast_cdr::lastapp, ast_cdr::lastdata, LOG_WARNING, and ast_cdr::posted.

Referenced by __ast_request_and_dial(), and pbx_exec().

00218 { 00219 char *chan; 00220 if (cdr) { 00221 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00222 if (cdr->posted) 00223 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00224 if (!app) 00225 app = ""; 00226 strncpy(cdr->lastapp, app, sizeof(cdr->lastapp) - 1); 00227 if (!data) 00228 data = ""; 00229 strncpy(cdr->lastdata, data, sizeof(cdr->lastdata) - 1); 00230 } 00231 }

int ast_cdr_setcid struct ast_cdr cdr,
struct ast_channel chan
 

Initialize based on a channel.

Parameters:
cdr Call Detail Record to use for channel
chan Channel to bind CDR with Initializes a CDR and associates it with a particular channel Return is negligible. (returns 0 by default)

Definition at line 233 of file cdr.c.

References ast_channel::ani, ast_callerid_parse(), AST_MAX_EXTENSION, ast_shrink_phone_number(), ast_channel::callerid, ast_cdr::clid, and ast_cdr::src.

Referenced by ast_set_callerid().

00234 { 00235 char tmp[AST_MAX_EXTENSION] = ""; 00236 char *num, *name; 00237 if (cdr) { 00238 /* Grab source from ANI or normal Caller*ID */ 00239 if (c->ani) 00240 strncpy(tmp, c->ani, sizeof(tmp) - 1); 00241 else if (c->callerid) 00242 strncpy(tmp, c->callerid, sizeof(tmp) - 1); 00243 if (c->callerid) 00244 strncpy(cdr->clid, c->callerid, sizeof(cdr->clid) - 1); 00245 name = NULL; 00246 num = NULL; 00247 ast_callerid_parse(tmp, &name, &num); 00248 if (num) { 00249 ast_shrink_phone_number(num); 00250 strncpy(cdr->src, num, sizeof(cdr->src) - 1); 00251 } 00252 } 00253 return 0; 00254 }

void ast_cdr_setdestchan struct ast_cdr cdr,
char *  chan
 

Set the destination channel, if there was one.

Parameters:
cdr Which cdr it's applied to Sets the destination channel the CDR is applied to Returns nothing

Definition at line 206 of file cdr.c.

References ast_log(), ast_cdr::channel, ast_cdr::dstchannel, LOG_WARNING, and ast_cdr::posted.

00207 { 00208 char *chan; 00209 if (cdr) { 00210 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00211 if (cdr->posted) 00212 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00213 strncpy(cdr->dstchannel, chann, sizeof(cdr->dstchannel) - 1); 00214 } 00215 }

int ast_cdr_setuserfield struct ast_channel chan,
char *  userfield
 

Definition at line 352 of file cdr.c.

References ast_channel::cdr.

00353 { 00354 struct ast_cdr *cdr = chan->cdr; 00355 00356 if (cdr) 00357 strncpy(cdr->userfield, userfield, sizeof(cdr->userfield) - 1); 00358 return 0; 00359 }

void ast_cdr_start struct ast_cdr cdr  ) 
 

Start a call.

Parameters:
cdr the cdr you wish to associate with the call Starts all CDR stuff necessary for monitoring a call Returns nothing important

Definition at line 131 of file cdr.c.

References ast_log(), ast_cdr::channel, LOG_WARNING, ast_cdr::posted, and ast_cdr::start.

Referenced by __ast_request_and_dial(), ast_cdr_reset(), and ast_pbx_run().

00132 { 00133 char *chan; 00134 if (cdr) { 00135 chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>"; 00136 if (cdr->posted) 00137 ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); 00138 if (cdr->start.tv_sec || cdr->start.tv_usec) 00139 ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", chan); 00140 gettimeofday(&cdr->start, NULL); 00141 } 00142 }

void ast_cdr_unregister char *  name  ) 
 

Unregister a CDR handling engine.

Parameters:
name name of CDR handler to unregister Unregisters a CDR by it's name

Definition at line 84 of file cdr.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verbose(), free, option_verbose, and VERBOSE_PREFIX_2.

00085 { 00086 struct ast_cdr_beitem *i, *prev = NULL; 00087 ast_mutex_lock(&cdrlock); 00088 i = bes; 00089 while(i) { 00090 if (!strcasecmp(name, i->name)) { 00091 if (prev) 00092 prev->next = i->next; 00093 else 00094 bes = i->next; 00095 break; 00096 } 00097 i = i->next; 00098 } 00099 if (option_verbose > 1) 00100 ast_verbose(VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend\n", name); 00101 ast_mutex_unlock(&cdrlock); 00102 if (i) 00103 free(i); 00104 }

int ast_cdr_update struct ast_channel chan  ) 
 

Definition at line 373 of file cdr.c.

References ast_channel::accountcode, ast_channel::ani, ast_callerid_parse(), AST_MAX_EXTENSION, ast_shrink_phone_number(), ast_channel::callerid, ast_channel::cdr, ast_channel::context, and ast_channel::exten.

Referenced by __ast_request_and_dial(), and ast_pbx_run().

00374 { 00375 struct ast_cdr *cdr = c->cdr; 00376 char *name, *num; 00377 char tmp[AST_MAX_EXTENSION] = ""; 00378 /* Grab source from ANI or normal Caller*ID */ 00379 if (cdr) { 00380 if (c->ani) 00381 strncpy(tmp, c->ani, sizeof(tmp) - 1); 00382 else if (c->callerid && !ast_strlen_zero(c->callerid)) 00383 strncpy(tmp, c->callerid, sizeof(tmp) - 1); 00384 if (c->callerid && !ast_strlen_zero(c->callerid)) 00385 strncpy(cdr->clid, c->callerid, sizeof(cdr->clid) - 1); 00386 else 00387 strcpy(cdr->clid, ""); 00388 name = NULL; 00389 num = NULL; 00390 ast_callerid_parse(tmp, &name, &num); 00391 if (num) { 00392 ast_shrink_phone_number(num); 00393 strncpy(cdr->src, num, sizeof(cdr->src) - 1); 00394 } 00395 /* Copy account code et-al */ 00396 strncpy(cdr->accountcode, c->accountcode, sizeof(cdr->accountcode) - 1); 00397 /* Destination information */ 00398 strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1); 00399 strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1); 00400 } 00401 return 0; 00402 }


Variable Documentation

char ast_default_accountcode[20]
 

Definition at line 243 of file cdr.h.

Referenced by ast_channel_alloc().

int ast_default_amaflags
 

Definition at line 241 of file cdr.h.

Referenced by ast_cdr_init(), and ast_channel_alloc().


Generated on Sat Jun 12 16:41:06 2004 for Asterisk by doxygen 1.3.7