mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
Add unique identifier
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -39,6 +39,7 @@ ${CHANNEL} Current channel name
|
|||||||
${ENV(VAR)} Environmental variable VAR
|
${ENV(VAR)} Environmental variable VAR
|
||||||
${EPOCH} Current unix style epoch
|
${EPOCH} Current unix style epoch
|
||||||
${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
|
${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
|
||||||
|
${UNIQUEID} Current call unique identifier
|
||||||
|
|
||||||
There are two reference modes - reference by value and reference by name.
|
There are two reference modes - reference by value and reference by name.
|
||||||
To refer to a variable with its name (as an argument to a function that
|
To refer to a variable with its name (as an argument to a function that
|
||||||
|
2
cdr.c
2
cdr.c
@@ -250,6 +250,8 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
|
|||||||
/* Destination information */
|
/* Destination information */
|
||||||
strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1);
|
strncpy(cdr->dst, c->exten, sizeof(cdr->dst) - 1);
|
||||||
strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1);
|
strncpy(cdr->dcontext, c->context, sizeof(cdr->dcontext) - 1);
|
||||||
|
/* Unique call identifier */
|
||||||
|
strncpy(cdr->uniqueid, c->uniqueid, sizeof(cdr->uniqueid) - 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#define DATE_FORMAT "%Y-%m-%d %T"
|
#define DATE_FORMAT "%Y-%m-%d %T"
|
||||||
|
|
||||||
|
/* #define CSV_LOGUNIQUEID 1 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@
|
|||||||
// "end time" minus "answer time"
|
// "end time" minus "answer time"
|
||||||
"disposition", // ANSWERED, NO ANSWER, BUSY
|
"disposition", // ANSWERED, NO ANSWER, BUSY
|
||||||
"amaflags", // DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
|
"amaflags", // DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
|
||||||
|
"uniqueid", // unique call identifier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *desc = "Comma Separated Values CDR Backend";
|
static char *desc = "Comma Separated Values CDR Backend";
|
||||||
@@ -158,6 +160,10 @@ static int build_csv_record(char *buf, int len, struct ast_cdr *cdr)
|
|||||||
/* AMA Flags */
|
/* AMA Flags */
|
||||||
append_string(buf, ast_cdr_flags2str(cdr->amaflags), len);
|
append_string(buf, ast_cdr_flags2str(cdr->amaflags), len);
|
||||||
|
|
||||||
|
#ifdef CSV_LOGUNIQUEID
|
||||||
|
/* Unique ID */
|
||||||
|
append_string(buf, cdr->uniqueid, len);
|
||||||
|
#endif
|
||||||
/* If we hit the end of our buffer, log an error */
|
/* If we hit the end of our buffer, log an error */
|
||||||
if (strlen(buf) < len - 5) {
|
if (strlen(buf) < len - 5) {
|
||||||
/* Trim off trailing comma */
|
/* Trim off trailing comma */
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static int shutting_down = 0;
|
static int shutting_down = 0;
|
||||||
|
static int uniqueint = 0;
|
||||||
|
|
||||||
/* XXX Lock appropriately in more functions XXX */
|
/* XXX Lock appropriately in more functions XXX */
|
||||||
|
|
||||||
@@ -322,6 +323,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
|
|||||||
tmp->data = NULL;
|
tmp->data = NULL;
|
||||||
tmp->fin = 0;
|
tmp->fin = 0;
|
||||||
tmp->fout = 0;
|
tmp->fout = 0;
|
||||||
|
snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", time(NULL), uniqueint++);
|
||||||
headp=&tmp->varshead;
|
headp=&tmp->varshead;
|
||||||
ast_pthread_mutex_init(&tmp->lock);
|
ast_pthread_mutex_init(&tmp->lock);
|
||||||
AST_LIST_HEAD_INIT(headp);
|
AST_LIST_HEAD_INIT(headp);
|
||||||
|
3
cli.c
3
cli.c
@@ -476,6 +476,7 @@ static int handle_showchan(int fd, int argc, char *argv[])
|
|||||||
" -- General --\n"
|
" -- General --\n"
|
||||||
" Name: %s\n"
|
" Name: %s\n"
|
||||||
" Type: %s\n"
|
" Type: %s\n"
|
||||||
|
" UniqueID: %s\n"
|
||||||
" Caller ID: %s\n"
|
" Caller ID: %s\n"
|
||||||
" DNID Digits: %s\n"
|
" DNID Digits: %s\n"
|
||||||
" State: %s (%d)\n"
|
" State: %s (%d)\n"
|
||||||
@@ -497,7 +498,7 @@ static int handle_showchan(int fd, int argc, char *argv[])
|
|||||||
" Data: %s\n"
|
" Data: %s\n"
|
||||||
" Stack: %d\n"
|
" Stack: %d\n"
|
||||||
" Blocking in: %s\n",
|
" Blocking in: %s\n",
|
||||||
c->name, c->type,
|
c->name, c->type, c->uniqueid,
|
||||||
(c->callerid ? c->callerid : "(N/A)"),
|
(c->callerid ? c->callerid : "(N/A)"),
|
||||||
(c->dnid ? c->dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, c->nativeformats, c->writeformat, c->readformat,
|
(c->dnid ? c->dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, c->nativeformats, c->writeformat, c->readformat,
|
||||||
c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "",
|
c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "",
|
||||||
|
@@ -39,6 +39,7 @@ ${CHANNEL} Current channel name
|
|||||||
${ENV(VAR)} Environmental variable VAR
|
${ENV(VAR)} Environmental variable VAR
|
||||||
${EPOCH} Current unix style epoch
|
${EPOCH} Current unix style epoch
|
||||||
${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
|
${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
|
||||||
|
${UNIQUEID} Current call unique identifier
|
||||||
|
|
||||||
There are two reference modes - reference by value and reference by name.
|
There are two reference modes - reference by value and reference by name.
|
||||||
To refer to a variable with its name (as an argument to a function that
|
To refer to a variable with its name (as an argument to a function that
|
||||||
|
@@ -67,6 +67,8 @@ struct ast_cdr {
|
|||||||
char accountcode[20];
|
char accountcode[20];
|
||||||
/*! Whether or not the record has been posted */
|
/*! Whether or not the record has been posted */
|
||||||
int posted;
|
int posted;
|
||||||
|
/* Unique Channel Identifier */
|
||||||
|
char uniqueid[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
|
typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
|
||||||
|
@@ -188,6 +188,9 @@ struct ast_channel {
|
|||||||
unsigned int fin;
|
unsigned int fin;
|
||||||
unsigned int fout;
|
unsigned int fout;
|
||||||
|
|
||||||
|
/* Unique Channel Identifier */
|
||||||
|
char uniqueid[32];
|
||||||
|
|
||||||
/* A linked list for variables */
|
/* A linked list for variables */
|
||||||
struct ast_var_t *vars;
|
struct ast_var_t *vars;
|
||||||
AST_LIST_HEAD(varshead,ast_var_t) varshead;
|
AST_LIST_HEAD(varshead,ast_var_t) varshead;
|
||||||
|
2
pbx.c
2
pbx.c
@@ -849,6 +849,8 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var,
|
|||||||
brokentime.tm_sec
|
brokentime.tm_sec
|
||||||
);
|
);
|
||||||
*ret = workspace;
|
*ret = workspace;
|
||||||
|
} else if (!strcmp(var, "UNIQUEID")) {
|
||||||
|
snprintf(workspace, workspacelen -1, "%s", c->uniqueid);
|
||||||
} else {
|
} else {
|
||||||
AST_LIST_TRAVERSE(headp,variables,entries) {
|
AST_LIST_TRAVERSE(headp,variables,entries) {
|
||||||
#if 0
|
#if 0
|
||||||
|
Reference in New Issue
Block a user