|
|
c3c2b35 |
From 56f5144dca1f95b75d78f4fa0ce8e1048a119fc6 Mon Sep 17 00:00:00 2001
|
|
|
4e4a6c4 |
From: Jeffrey C. Ollie <jeff@ocjtech.us>
|
|
|
4e4a6c4 |
Date: Wed, 2 Jul 2008 10:15:41 -0500
|
|
|
4e4a6c4 |
Subject: [PATCH] Update cdr_tds to latest.
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
---
|
|
|
4e4a6c4 |
UPGRADE.txt | 3 +
|
|
|
4e4a6c4 |
cdr/cdr_tds.c | 462 +++++++++++++++++++-------------------
|
|
|
4e4a6c4 |
configure.ac | 29 +---
|
|
|
4e4a6c4 |
doc/tex/freetds.tex | 20 +--
|
|
|
4e4a6c4 |
include/asterisk/autoconfig.h.in | 3 -
|
|
|
4e4a6c4 |
5 files changed, 238 insertions(+), 279 deletions(-)
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
diff --git a/UPGRADE.txt b/UPGRADE.txt
|
|
|
4e4a6c4 |
index 70a0f81..d5e97a1 100644
|
|
|
4e4a6c4 |
--- a/UPGRADE.txt
|
|
|
4e4a6c4 |
+++ b/UPGRADE.txt
|
|
|
4e4a6c4 |
@@ -123,6 +123,9 @@ CDR:
|
|
|
4e4a6c4 |
username and password parameters in cdr_odbc.conf, therefore, are no
|
|
|
4e4a6c4 |
longer used. The dsn parameter now points to an entry in res_odbc.conf.
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
+* The cdr_tds module now supports all versions of FreeTDS that contain
|
|
|
4e4a6c4 |
+ the db-lib frontend.
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
Formats:
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
* format_wav: The GAIN preprocessor definition and source code that used it
|
|
|
4e4a6c4 |
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
|
|
|
4e4a6c4 |
index 9d322fd..8654c80 100644
|
|
|
4e4a6c4 |
--- a/cdr/cdr_tds.c
|
|
|
4e4a6c4 |
+++ b/cdr/cdr_tds.c
|
|
|
4e4a6c4 |
@@ -66,72 +66,76 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
4e4a6c4 |
#include <time.h>
|
|
|
4e4a6c4 |
#include <math.h>
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-#include <tds.h>
|
|
|
4e4a6c4 |
-#include <tdsconvert.h>
|
|
|
4e4a6c4 |
-#include <ctype.h>
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
#include "asterisk/config.h"
|
|
|
4e4a6c4 |
#include "asterisk/channel.h"
|
|
|
4e4a6c4 |
#include "asterisk/cdr.h"
|
|
|
4e4a6c4 |
#include "asterisk/module.h"
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-#ifdef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
-#warning "You have older TDS, you should upgrade!"
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
+#include <sqlfront.h>
|
|
|
4e4a6c4 |
+#include <sybdb.h>
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
#define DATE_FORMAT "%Y/%m/%d %T"
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-static char *name = "mssql";
|
|
|
4e4a6c4 |
+static char *name = "FreeTDS (MSSQL)";
|
|
|
4e4a6c4 |
static char *config = "cdr_tds.conf";
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *charset = NULL, *language = NULL;
|
|
|
4e4a6c4 |
-static char *table = NULL;
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-static int connected = 0;
|
|
|
4e4a6c4 |
+struct cdr_tds_config {
|
|
|
4e4a6c4 |
+ AST_DECLARE_STRING_FIELDS(
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(hostname);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(database);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(username);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(password);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(table);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(charset);
|
|
|
4e4a6c4 |
+ AST_STRING_FIELD(language);
|
|
|
4e4a6c4 |
+ );
|
|
|
4e4a6c4 |
+ DBPROCESS *dbproc;
|
|
|
4e4a6c4 |
+ unsigned int connected:1;
|
|
|
4e4a6c4 |
+};
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
AST_MUTEX_DEFINE_STATIC(tds_lock);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-static TDSSOCKET *tds;
|
|
|
4e4a6c4 |
-static TDSLOGIN *login;
|
|
|
4e4a6c4 |
-static TDSCONTEXT *context;
|
|
|
4e4a6c4 |
+static struct cdr_tds_config *settings;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static char *anti_injection(const char *, int);
|
|
|
4e4a6c4 |
-static void get_date(char *, struct timeval);
|
|
|
4e4a6c4 |
+static void get_date(char *, size_t len, struct timeval);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int mssql_connect(void);
|
|
|
4e4a6c4 |
static int mssql_disconnect(void);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int tds_log(struct ast_cdr *cdr)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- char sqlcmd[2048], start[80], answer[80], end[80];
|
|
|
4e4a6c4 |
+ char start[80], answer[80], end[80];
|
|
|
4e4a6c4 |
char *accountcode, *src, *dst, *dcontext, *clid, *channel, *dstchannel, *lastapp, *lastdata, *uniqueid;
|
|
|
4e4a6c4 |
- int res = 0;
|
|
|
4e4a6c4 |
- int retried = 0;
|
|
|
4e4a6c4 |
-#ifdef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
- TDS_INT result_type;
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
+ RETCODE erc;
|
|
|
4e4a6c4 |
+ int res = -1;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ accountcode = anti_injection(cdr->accountcode, 20);
|
|
|
4e4a6c4 |
+ src = anti_injection(cdr->src, 80);
|
|
|
4e4a6c4 |
+ dst = anti_injection(cdr->dst, 80);
|
|
|
4e4a6c4 |
+ dcontext = anti_injection(cdr->dcontext, 80);
|
|
|
4e4a6c4 |
+ clid = anti_injection(cdr->clid, 80);
|
|
|
4e4a6c4 |
+ channel = anti_injection(cdr->channel, 80);
|
|
|
4e4a6c4 |
+ dstchannel = anti_injection(cdr->dstchannel, 80);
|
|
|
4e4a6c4 |
+ lastapp = anti_injection(cdr->lastapp, 80);
|
|
|
4e4a6c4 |
+ lastdata = anti_injection(cdr->lastdata, 80);
|
|
|
4e4a6c4 |
+ uniqueid = anti_injection(cdr->uniqueid, 32);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ get_date(start, sizeof(start), cdr->start);
|
|
|
4e4a6c4 |
+ get_date(answer, sizeof(answer), cdr->answer);
|
|
|
4e4a6c4 |
+ get_date(end, sizeof(end), cdr->end);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ast_mutex_lock(&tds_lock);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- memset(sqlcmd, 0, 2048);
|
|
|
4e4a6c4 |
+ /* Ensure that we are connected */
|
|
|
4e4a6c4 |
+ if (!settings->connected) {
|
|
|
4e4a6c4 |
+ if (mssql_connect()) {
|
|
|
4e4a6c4 |
+ /* Connect failed */
|
|
|
4e4a6c4 |
+ goto done;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- accountcode = anti_injection(cdr->accountcode, 20);
|
|
|
4e4a6c4 |
- src = anti_injection(cdr->src, 80);
|
|
|
4e4a6c4 |
- dst = anti_injection(cdr->dst, 80);
|
|
|
4e4a6c4 |
- dcontext = anti_injection(cdr->dcontext, 80);
|
|
|
4e4a6c4 |
- clid = anti_injection(cdr->clid, 80);
|
|
|
4e4a6c4 |
- channel = anti_injection(cdr->channel, 80);
|
|
|
4e4a6c4 |
- dstchannel = anti_injection(cdr->dstchannel, 80);
|
|
|
4e4a6c4 |
- lastapp = anti_injection(cdr->lastapp, 80);
|
|
|
4e4a6c4 |
- lastdata = anti_injection(cdr->lastdata, 80);
|
|
|
4e4a6c4 |
- uniqueid = anti_injection(cdr->uniqueid, 32);
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- get_date(start, cdr->start);
|
|
|
4e4a6c4 |
- get_date(answer, cdr->answer);
|
|
|
4e4a6c4 |
- get_date(end, cdr->end);
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- sprintf(
|
|
|
4e4a6c4 |
- sqlcmd,
|
|
|
4e4a6c4 |
+ erc = dbfcmd(settings->dbproc,
|
|
|
4e4a6c4 |
"INSERT INTO %s "
|
|
|
4e4a6c4 |
"("
|
|
|
4e4a6c4 |
"accountcode, "
|
|
|
4e4a6c4 |
@@ -172,7 +176,7 @@ static int tds_log(struct ast_cdr *cdr)
|
|
|
4e4a6c4 |
"'%s', " /* amaflags */
|
|
|
4e4a6c4 |
"'%s'" /* uniqueid */
|
|
|
4e4a6c4 |
")",
|
|
|
4e4a6c4 |
- table,
|
|
|
4e4a6c4 |
+ settings->table,
|
|
|
4e4a6c4 |
accountcode,
|
|
|
4e4a6c4 |
src,
|
|
|
4e4a6c4 |
dst,
|
|
|
4e4a6c4 |
@@ -192,27 +196,26 @@ static int tds_log(struct ast_cdr *cdr)
|
|
|
4e4a6c4 |
uniqueid
|
|
|
4e4a6c4 |
);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- do {
|
|
|
4e4a6c4 |
- if (!connected) {
|
|
|
4e4a6c4 |
- if (mssql_connect())
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Failed to reconnect to SQL database.\n");
|
|
|
4e4a6c4 |
- else
|
|
|
4e4a6c4 |
- ast_log(LOG_WARNING, "Reconnected to SQL database.\n");
|
|
|
4e4a6c4 |
+ if (erc == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to build INSERT statement, no CDR was logged.\n");
|
|
|
4e4a6c4 |
+ goto done;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- retried = 1; /* note that we have now tried */
|
|
|
4e4a6c4 |
- }
|
|
|
4e4a6c4 |
+ if (dbsqlexec(settings->dbproc) == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to execute INSERT statement, no CDR was logged.\n");
|
|
|
4e4a6c4 |
+ goto done;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-#ifdef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
- if (!connected || (tds_submit_query(tds, sqlcmd) != TDS_SUCCEED) || (tds_process_simple_query(tds, &result_type) != TDS_SUCCEED || result_type != TDS_CMD_SUCCEED))
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- if (!connected || (tds_submit_query(tds, sqlcmd) != TDS_SUCCEED) || (tds_process_simple_query(tds) != TDS_SUCCEED))
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Failed to insert Call Data Record into SQL database.\n");
|
|
|
4e4a6c4 |
+ /* Consume any results we might get back (this is more of a sanity check than
|
|
|
4e4a6c4 |
+ * anything else, since an INSERT shouldn't return results). */
|
|
|
4e4a6c4 |
+ while (dbresults(settings->dbproc) != NO_MORE_RESULTS) {
|
|
|
4e4a6c4 |
+ while (dbnextrow(settings->dbproc) != NO_MORE_ROWS);
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- mssql_disconnect(); /* this is ok even if we are already disconnected */
|
|
|
4e4a6c4 |
- }
|
|
|
4e4a6c4 |
- } while (!connected && !retried);
|
|
|
4e4a6c4 |
+ res = 0;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+done:
|
|
|
4e4a6c4 |
+ ast_mutex_unlock(&tds_lock);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ast_free(accountcode);
|
|
|
4e4a6c4 |
ast_free(src);
|
|
|
4e4a6c4 |
@@ -225,285 +228,252 @@ static int tds_log(struct ast_cdr *cdr)
|
|
|
4e4a6c4 |
ast_free(lastdata);
|
|
|
4e4a6c4 |
ast_free(uniqueid);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- ast_mutex_unlock(&tds_lock);
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
return res;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static char *anti_injection(const char *str, int len)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
/* Reference to http://www.nextgenss.com/papers/advanced_sql_injection.pdf */
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
char *buf;
|
|
|
4e4a6c4 |
char *buf_ptr, *srh_ptr;
|
|
|
4e4a6c4 |
char *known_bad[] = {"select", "insert", "update", "delete", "drop", ";", "--", "\0"};
|
|
|
4e4a6c4 |
int idx;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- if ((buf = ast_malloc(len + 1)) == NULL)
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "cdr_tds: Out of memory error\n");
|
|
|
4e4a6c4 |
+ if (!(buf = ast_calloc(1, len + 1))) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Out of memory\n");
|
|
|
4e4a6c4 |
return NULL;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
- memset(buf, 0, len);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
buf_ptr = buf;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
/* Escape single quotes */
|
|
|
4e4a6c4 |
- for (; *str && strlen(buf) < len; str++)
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- if (*str == '\'')
|
|
|
4e4a6c4 |
+ for (; *str && strlen(buf) < len; str++) {
|
|
|
4e4a6c4 |
+ if (*str == '\'') {
|
|
|
4e4a6c4 |
*buf_ptr++ = '\'';
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
*buf_ptr++ = *str;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
*buf_ptr = '\0';
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
/* Erase known bad input */
|
|
|
4e4a6c4 |
- for (idx=0; *known_bad[idx]; idx++)
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- while((srh_ptr = strcasestr(buf, known_bad[idx])))
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- memmove(srh_ptr, srh_ptr+strlen(known_bad[idx]), strlen(srh_ptr+strlen(known_bad[idx]))+1);
|
|
|
4e4a6c4 |
+ for (idx = 0; *known_bad[idx]; idx++) {
|
|
|
4e4a6c4 |
+ while ((srh_ptr = strcasestr(buf, known_bad[idx]))) {
|
|
|
4e4a6c4 |
+ memmove(srh_ptr, srh_ptr + strlen(known_bad[idx]), strlen(srh_ptr + strlen(known_bad[idx])) + 1);
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
return buf;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-static void get_date(char *dateField, struct timeval tv)
|
|
|
4e4a6c4 |
+static void get_date(char *dateField, size_t len, struct timeval tv)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- struct ast_tm tm;
|
|
|
4e4a6c4 |
- char buf[80];
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
/* To make sure we have date variable if not insert null to SQL */
|
|
|
4e4a6c4 |
- if (!ast_tvzero(tv))
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
+ if (!ast_tvzero(tv)) {
|
|
|
4e4a6c4 |
+ struct ast_tm tm;
|
|
|
4e4a6c4 |
ast_localtime(&tv, &tm, NULL);
|
|
|
4e4a6c4 |
- ast_strftime(buf, 80, DATE_FORMAT, &tm;;
|
|
|
4e4a6c4 |
- sprintf(dateField, "'%s'", buf);
|
|
|
4e4a6c4 |
- }
|
|
|
4e4a6c4 |
- else
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- strcpy(dateField, "null");
|
|
|
4e4a6c4 |
+ ast_strftime(dateField, len, "'" DATE_FORMAT "'", &tm;;
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_copy_string(dateField, "null", len);
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int mssql_disconnect(void)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- if (tds) {
|
|
|
4e4a6c4 |
- tds_free_socket(tds);
|
|
|
4e4a6c4 |
- tds = NULL;
|
|
|
4e4a6c4 |
+ if (settings->dbproc) {
|
|
|
4e4a6c4 |
+ dbclose(settings->dbproc);
|
|
|
4e4a6c4 |
+ settings->dbproc = NULL;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- if (context) {
|
|
|
4e4a6c4 |
- tds_free_context(context);
|
|
|
4e4a6c4 |
- context = NULL;
|
|
|
4e4a6c4 |
- }
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- if (login) {
|
|
|
4e4a6c4 |
- tds_free_login(login);
|
|
|
4e4a6c4 |
- login = NULL;
|
|
|
4e4a6c4 |
- }
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- connected = 0;
|
|
|
4e4a6c4 |
+ settings->connected = 0;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int mssql_connect(void)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
|
|
|
4e4a6c4 |
- TDSCONNECTION *connection = NULL;
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- TDSCONNECTINFO *connection = NULL;
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- char query[128];
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- /* Connect to M$SQL Server */
|
|
|
4e4a6c4 |
- if (!(login = tds_alloc_login()))
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "tds_alloc_login() failed.\n");
|
|
|
4e4a6c4 |
+ LOGINREC *login;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if ((login = dblogin()) == NULL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Unable to allocate login structure for db-lib\n");
|
|
|
4e4a6c4 |
return -1;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- tds_set_server(login, hostname);
|
|
|
4e4a6c4 |
- tds_set_user(login, dbuser);
|
|
|
4e4a6c4 |
- tds_set_passwd(login, password);
|
|
|
4e4a6c4 |
- tds_set_app(login, "TSQL");
|
|
|
4e4a6c4 |
- tds_set_library(login, "TDS-Library");
|
|
|
4e4a6c4 |
-#ifndef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
- tds_set_client_charset(login, charset);
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- tds_set_language(login, language);
|
|
|
4e4a6c4 |
- tds_set_packet(login, 512);
|
|
|
4e4a6c4 |
- tds_set_version(login, 7, 0);
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-#ifdef FREETDS_0_64
|
|
|
4e4a6c4 |
- if (!(context = tds_alloc_context(NULL)))
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- if (!(context = tds_alloc_context()))
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "tds_alloc_context() failed.\n");
|
|
|
4e4a6c4 |
- goto connect_fail;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ DBSETLAPP(login, "TSQL");
|
|
|
4e4a6c4 |
+ DBSETLUSER(login, (char *) settings->username);
|
|
|
4e4a6c4 |
+ DBSETLPWD(login, (char *) settings->password);
|
|
|
4e4a6c4 |
+ DBSETLCHARSET(login, (char *) settings->charset);
|
|
|
4e4a6c4 |
+ DBSETLNATLANG(login, (char *) settings->language);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if ((settings->dbproc = dbopen(login, (char *) settings->hostname)) == NULL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Unable to connect to %s\n", settings->hostname);
|
|
|
4e4a6c4 |
+ dbloginfree(login);
|
|
|
4e4a6c4 |
+ return -1;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- if (!(tds = tds_alloc_socket(context, 512))) {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "tds_alloc_socket() failed.\n");
|
|
|
4e4a6c4 |
- goto connect_fail;
|
|
|
4e4a6c4 |
+ dbloginfree(login);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if (dbuse(settings->dbproc, (char *) settings->database) == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Unable to select database %s\n", settings->database);
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- tds_set_parent(tds, NULL);
|
|
|
4e4a6c4 |
- connection = tds_read_config_info(tds, login, context->locale);
|
|
|
4e4a6c4 |
- if (!connection)
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "tds_read_config() failed.\n");
|
|
|
4e4a6c4 |
- goto connect_fail;
|
|
|
4e4a6c4 |
+ if (dbfcmd(settings->dbproc, "SELECT 1 FROM [%s]", settings->table) == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Unable to build query while verifying the existence of table '%s'\n", settings->table);
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- if (tds_connect(tds, connection) == TDS_FAIL)
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Failed to connect to MSSQL server.\n");
|
|
|
4e4a6c4 |
- tds = NULL; /* freed by tds_connect() on error */
|
|
|
4e4a6c4 |
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
|
|
|
4e4a6c4 |
- tds_free_connection(connection);
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- tds_free_connect(connection);
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- connection = NULL;
|
|
|
4e4a6c4 |
- goto connect_fail;
|
|
|
4e4a6c4 |
+ if (dbsqlexec(settings->dbproc) == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Unable to verify existence of table '%s'\n", settings->table);
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
|
|
|
4e4a6c4 |
- tds_free_connection(connection);
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- tds_free_connect(connection);
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- connection = NULL;
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- sprintf(query, "USE %s", dbname);
|
|
|
4e4a6c4 |
-#ifdef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
- if ((tds_submit_query(tds, query) != TDS_SUCCEED) || (tds_process_simple_query(tds, &result_type) != TDS_SUCCEED || result_type != TDS_CMD_SUCCEED))
|
|
|
4e4a6c4 |
-#else
|
|
|
4e4a6c4 |
- if ((tds_submit_query(tds, query) != TDS_SUCCEED) || (tds_process_simple_query(tds) != TDS_SUCCEED))
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
- {
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Could not change database (%s)\n", dbname);
|
|
|
4e4a6c4 |
- goto connect_fail;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ /* Consume the result set (we don't really care about the result, though) */
|
|
|
4e4a6c4 |
+ while (dbresults(settings->dbproc) != NO_MORE_RESULTS) {
|
|
|
4e4a6c4 |
+ while (dbnextrow(settings->dbproc) != NO_MORE_ROWS);
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- connected = 1;
|
|
|
4e4a6c4 |
+ settings->connected = 1;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-connect_fail:
|
|
|
4e4a6c4 |
- mssql_disconnect();
|
|
|
4e4a6c4 |
+failed:
|
|
|
4e4a6c4 |
+ dbclose(settings->dbproc);
|
|
|
4e4a6c4 |
+ settings->dbproc = NULL;
|
|
|
4e4a6c4 |
return -1;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int tds_unload_module(void)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- mssql_disconnect();
|
|
|
4e4a6c4 |
+ if (settings) {
|
|
|
4e4a6c4 |
+ ast_mutex_lock(&tds_lock);
|
|
|
4e4a6c4 |
+ mssql_disconnect();
|
|
|
4e4a6c4 |
+ ast_mutex_unlock(&tds_lock);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ ast_string_field_free_memory(settings);
|
|
|
4e4a6c4 |
+ ast_free(settings);
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ast_cdr_unregister(name);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- if (hostname) ast_free(hostname);
|
|
|
4e4a6c4 |
- if (dbname) ast_free(dbname);
|
|
|
4e4a6c4 |
- if (dbuser) ast_free(dbuser);
|
|
|
4e4a6c4 |
- if (password) ast_free(password);
|
|
|
4e4a6c4 |
- if (charset) ast_free(charset);
|
|
|
4e4a6c4 |
- if (language) ast_free(language);
|
|
|
4e4a6c4 |
- if (table) ast_free(table);
|
|
|
4e4a6c4 |
+ dbexit();
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ return 0;
|
|
|
4e4a6c4 |
+}
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+static int tds_error_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
|
|
|
4e4a6c4 |
+{
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "%s (%d)\n", dberrstr, dberr);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if (oserr != DBNOERR) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "%s (%d)\n", oserrstr, oserr);
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ return INT_CANCEL;
|
|
|
4e4a6c4 |
+}
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+static int tds_message_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line)
|
|
|
4e4a6c4 |
+{
|
|
|
4e4a6c4 |
+ ast_debug(1, "Msg %d, Level %d, State %d, Line %d\n", msgno, severity, msgstate, line);
|
|
|
4e4a6c4 |
+ ast_log(LOG_NOTICE, "%s\n", msgtext);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int tds_load_module(int reload)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- int res = 0;
|
|
|
4e4a6c4 |
struct ast_config *cfg;
|
|
|
4e4a6c4 |
- struct ast_variable *var;
|
|
|
4e4a6c4 |
const char *ptr = NULL;
|
|
|
4e4a6c4 |
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
|
|
|
4e4a6c4 |
-#ifdef FREETDS_PRE_0_62
|
|
|
4e4a6c4 |
- TDS_INT result_type;
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
cfg = ast_config_load(config, config_flags);
|
|
|
4e4a6c4 |
if (!cfg) {
|
|
|
4e4a6c4 |
- ast_log(LOG_NOTICE, "Unable to load config for MSSQL CDR's: %s\n", config);
|
|
|
4e4a6c4 |
+ ast_log(LOG_NOTICE, "Unable to load TDS config for CDRs: %s\n", config);
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- var = ast_variable_browse(cfg, "global");
|
|
|
4e4a6c4 |
- if (!var) /* nothing configured */ {
|
|
|
4e4a6c4 |
+ if (!ast_variable_browse(cfg, "global")) {
|
|
|
4e4a6c4 |
+ /* nothing configured */
|
|
|
4e4a6c4 |
ast_config_destroy(cfg);
|
|
|
4e4a6c4 |
return 0;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ ast_mutex_lock(&tds_lock);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ /* Clear out any existing settings */
|
|
|
4e4a6c4 |
+ ast_string_field_init(settings, 0);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "hostname");
|
|
|
4e4a6c4 |
if (ptr) {
|
|
|
4e4a6c4 |
- if (hostname)
|
|
|
4e4a6c4 |
- ast_free(hostname);
|
|
|
4e4a6c4 |
- hostname = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- } else
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Database server hostname not specified.\n");
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, hostname, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to connect: Database server hostname not specified.\n");
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "dbname");
|
|
|
4e4a6c4 |
if (ptr) {
|
|
|
4e4a6c4 |
- if (dbname)
|
|
|
4e4a6c4 |
- ast_free(dbname);
|
|
|
4e4a6c4 |
- dbname = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- } else
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Database dbname not specified.\n");
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, database, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to connect: Database dbname not specified.\n");
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "user");
|
|
|
4e4a6c4 |
if (ptr) {
|
|
|
4e4a6c4 |
- if (dbuser)
|
|
|
4e4a6c4 |
- ast_free(dbuser);
|
|
|
4e4a6c4 |
- dbuser = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- } else
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR, "Database dbuser not specified.\n");
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, username, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to connect: Database dbuser not specified.\n");
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "password");
|
|
|
4e4a6c4 |
if (ptr) {
|
|
|
4e4a6c4 |
- if (password)
|
|
|
4e4a6c4 |
- ast_free(password);
|
|
|
4e4a6c4 |
- password = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- } else
|
|
|
4e4a6c4 |
- ast_log(LOG_ERROR,"Database password not specified.\n");
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, password, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to connect: Database password not specified.\n");
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "charset");
|
|
|
4e4a6c4 |
- if (charset)
|
|
|
4e4a6c4 |
- ast_free(charset);
|
|
|
4e4a6c4 |
- if (ptr)
|
|
|
4e4a6c4 |
- charset = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- else
|
|
|
4e4a6c4 |
- charset = ast_strdup("iso_1");
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
- if (language)
|
|
|
4e4a6c4 |
- ast_free(language);
|
|
|
4e4a6c4 |
+ if (ptr) {
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, charset, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, charset, "iso_1");
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "language");
|
|
|
4e4a6c4 |
- if (ptr)
|
|
|
4e4a6c4 |
- language = ast_strdup(ptr);
|
|
|
4e4a6c4 |
- else
|
|
|
4e4a6c4 |
- language = ast_strdup("us_english");
|
|
|
4e4a6c4 |
+ if (ptr) {
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, language, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, language, "us_english");
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
ptr = ast_variable_retrieve(cfg, "global", "table");
|
|
|
4e4a6c4 |
- if (ptr == NULL) {
|
|
|
4e4a6c4 |
- ast_debug(1, "cdr_tds: table not specified. Assuming cdr\n");
|
|
|
4e4a6c4 |
- ptr = "cdr";
|
|
|
4e4a6c4 |
+ if (ptr) {
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, table, ptr);
|
|
|
4e4a6c4 |
+ } else {
|
|
|
4e4a6c4 |
+ ast_log(LOG_NOTICE, "Table name not specified, using 'cdr' by default.\n");
|
|
|
4e4a6c4 |
+ ast_string_field_set(settings, table, "cdr");
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ mssql_disconnect();
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if (mssql_connect()) {
|
|
|
4e4a6c4 |
+ /* We failed to connect (mssql_connect takes care of logging it) */
|
|
|
4e4a6c4 |
+ goto failed;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
- if (table)
|
|
|
4e4a6c4 |
- ast_free(table);
|
|
|
4e4a6c4 |
- table = ast_strdup(ptr);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
+ ast_mutex_unlock(&tds_lock);
|
|
|
4e4a6c4 |
ast_config_destroy(cfg);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- ast_mutex_lock(&tds_lock);
|
|
|
4e4a6c4 |
- mssql_disconnect();
|
|
|
4e4a6c4 |
- mssql_connect();
|
|
|
4e4a6c4 |
+ return 1;
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+failed:
|
|
|
4e4a6c4 |
ast_mutex_unlock(&tds_lock);
|
|
|
4e4a6c4 |
+ ast_config_destroy(cfg);
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
- return res;
|
|
|
4e4a6c4 |
+ return 0;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int reload(void)
|
|
|
4e4a6c4 |
@@ -513,9 +483,35 @@ static int reload(void)
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
static int load_module(void)
|
|
|
4e4a6c4 |
{
|
|
|
4e4a6c4 |
- if (!tds_load_module(0))
|
|
|
4e4a6c4 |
+ if (dbinit() == FAIL) {
|
|
|
4e4a6c4 |
+ ast_log(LOG_ERROR, "Failed to initialize FreeTDS db-lib\n");
|
|
|
4e4a6c4 |
return AST_MODULE_LOAD_DECLINE;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ dberrhandle(tds_error_handler);
|
|
|
4e4a6c4 |
+ dbmsghandle(tds_message_handler);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ settings = ast_calloc(1, sizeof(*settings));
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if (!settings || ast_string_field_init(settings, 256)) {
|
|
|
4e4a6c4 |
+ if (settings) {
|
|
|
4e4a6c4 |
+ ast_free(settings);
|
|
|
4e4a6c4 |
+ settings = NULL;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+ dbexit();
|
|
|
4e4a6c4 |
+ return AST_MODULE_LOAD_DECLINE;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
+ if (!tds_load_module(0)) {
|
|
|
4e4a6c4 |
+ ast_string_field_free_memory(settings);
|
|
|
4e4a6c4 |
+ ast_free(settings);
|
|
|
4e4a6c4 |
+ settings = NULL;
|
|
|
4e4a6c4 |
+ dbexit();
|
|
|
4e4a6c4 |
+ return AST_MODULE_LOAD_DECLINE;
|
|
|
4e4a6c4 |
+ }
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
ast_cdr_register(name, ast_module_info->description, tds_log);
|
|
|
4e4a6c4 |
+
|
|
|
4e4a6c4 |
return AST_MODULE_LOAD_SUCCESS;
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
@@ -524,7 +520,7 @@ static int unload_module(void)
|
|
|
4e4a6c4 |
return tds_unload_module();
|
|
|
4e4a6c4 |
}
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MSSQL CDR Backend",
|
|
|
4e4a6c4 |
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "FreeTDS CDR Backend",
|
|
|
4e4a6c4 |
.load = load_module,
|
|
|
4e4a6c4 |
.unload = unload_module,
|
|
|
4e4a6c4 |
.reload = reload,
|
|
|
4e4a6c4 |
diff --git a/configure.ac b/configure.ac
|
|
|
c3c2b35 |
index c72e9c2..6c692f8 100644
|
|
|
4e4a6c4 |
--- a/configure.ac
|
|
|
4e4a6c4 |
+++ b/configure.ac
|
|
|
c3c2b35 |
@@ -1376,34 +1376,7 @@ fi
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
AST_EXT_TOOL_CHECK([GMIME], [gmime])
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
-AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
|
|
|
4e4a6c4 |
-if test "${PBX_FREETDS}" != "0";
|
|
|
4e4a6c4 |
-then
|
|
|
4e4a6c4 |
- if test "${FREETDS_DIR}x" = "x";
|
|
|
4e4a6c4 |
- then
|
|
|
4e4a6c4 |
- for tds_dir in /usr /usr/local;
|
|
|
4e4a6c4 |
- do
|
|
|
4e4a6c4 |
- if test -f "${tds_dir}/include/tdsver.h";
|
|
|
4e4a6c4 |
- then
|
|
|
4e4a6c4 |
- FREETDS_DIR="${tds_dir}"
|
|
|
4e4a6c4 |
- fi
|
|
|
4e4a6c4 |
- done
|
|
|
4e4a6c4 |
- fi
|
|
|
4e4a6c4 |
- case `${GREP} TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
|
|
|
4e4a6c4 |
- *0.64*)
|
|
|
4e4a6c4 |
- FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
|
|
|
4e4a6c4 |
- ;;
|
|
|
4e4a6c4 |
- *0.63*)
|
|
|
4e4a6c4 |
- FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
|
|
|
4e4a6c4 |
- ;;
|
|
|
4e4a6c4 |
- *0.62*)
|
|
|
4e4a6c4 |
- FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
|
|
|
4e4a6c4 |
- ;;
|
|
|
4e4a6c4 |
- *)
|
|
|
4e4a6c4 |
- FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
|
|
|
4e4a6c4 |
- ;;
|
|
|
4e4a6c4 |
- esac
|
|
|
4e4a6c4 |
-fi
|
|
|
4e4a6c4 |
+AST_EXT_LIB_CHECK([FREETDS], [sybdb], [dbinit], [sybdb.h])
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
diff --git a/doc/tex/freetds.tex b/doc/tex/freetds.tex
|
|
|
4e4a6c4 |
index 8dcbec2..8db589f 100644
|
|
|
4e4a6c4 |
--- a/doc/tex/freetds.tex
|
|
|
4e4a6c4 |
+++ b/doc/tex/freetds.tex
|
|
|
4e4a6c4 |
@@ -1,16 +1,6 @@
|
|
|
4e4a6c4 |
-The cdr\_tds module is NOT compatible with version 0.63 of FreeTDS.
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-The cdr\_tds module is known to work with FreeTDS version 0.62.1;
|
|
|
4e4a6c4 |
-it should also work with 0.62.2, 0.62.3 and 0.62.4, which are bug
|
|
|
4e4a6c4 |
-fix releases.
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-The cdr\_tds module uses the raw "libtds" API of FreeTDS. It appears
|
|
|
4e4a6c4 |
-that from 0.63 onwards, this is not considered a published API
|
|
|
4e4a6c4 |
-of FreeTDS and is subject to change without notice.
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-Between 0.62.x and 0.63 of FreeTDS, many incompatible changes
|
|
|
4e4a6c4 |
-have been made to the libtds API.
|
|
|
4e4a6c4 |
-
|
|
|
4e4a6c4 |
-For newer versions of FreeTDS, it is recommended that you use the
|
|
|
4e4a6c4 |
-ODBC driver.
|
|
|
4e4a6c4 |
+The cdr\_tds module now works with most modern release versions of FreeTDS (from
|
|
|
4e4a6c4 |
+at least 0.60 through 0.82). Although versions of FreeTDS prior to 0.82 will
|
|
|
4e4a6c4 |
+work, we recommend using the latest available version for performance and
|
|
|
4e4a6c4 |
+stability reasons.
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
+The latest release of FreeTDS is available from http://www.freetds.org/
|
|
|
4e4a6c4 |
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
|
|
|
4e4a6c4 |
index b368c8d..3a76722 100644
|
|
|
4e4a6c4 |
--- a/include/asterisk/autoconfig.h.in
|
|
|
4e4a6c4 |
+++ b/include/asterisk/autoconfig.h.in
|
|
|
4e4a6c4 |
@@ -1193,9 +1193,6 @@
|
|
|
4e4a6c4 |
#ifndef _POSIX_PTHREAD_SEMANTICS
|
|
|
4e4a6c4 |
# undef _POSIX_PTHREAD_SEMANTICS
|
|
|
4e4a6c4 |
#endif
|
|
|
4e4a6c4 |
-#ifndef _TANDEM_SOURCE
|
|
|
4e4a6c4 |
-# undef _TANDEM_SOURCE
|
|
|
4e4a6c4 |
-#endif
|
|
|
4e4a6c4 |
|
|
|
4e4a6c4 |
/* Define like PROTOTYPES; this can be used by system headers. */
|
|
|
4e4a6c4 |
#undef __PROTOTYPES
|
|
|
4e4a6c4 |
--
|
|
|
4e4a6c4 |
1.5.5.2
|
|
|
4e4a6c4 |
|