static int mysql_log(struct ast_cdr *cdr)
{
struct tm *tm;
- struct timeval *tv;
- struct timezone *tz;
- char *sqlcmd, *timestr;
+ struct timeval tv;
+ struct timezone tz;
+ char *sqlcmd, timestr[128];
time_t t;
- tv = (struct timeval *)malloc(sizeof(struct timeval));
- tz = (struct timezone *)malloc(sizeof(struct timezone));
sqlcmd = (char *)malloc(2048);
- timestr = (char*)malloc(128);
memset(sqlcmd,0,2048);
- gettimeofday(tv,tz);
- t = tv->tv_sec;
+ gettimeofday(&tv,&tz);
+ t = tv.tv_sec;
tm = localtime(&t);
strftime(timestr,128,DATE_FORMAT,tm);
return 0;
}
+static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
+{
+ char tmp[256] = "";
+ char *s, *e;
+ strncpy(tmp, get_header(req, "Contact"), sizeof(tmp) - 1);
+ s = tmp;
+ e = strchr(tmp, '@');
+ if (e)
+ *e = '\0';
+ if (!strncasecmp(s, "sip:", 4))
+ s += 4;
+ ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
+ if (p->owner)
+ strncpy(p->owner->call_forward, s, sizeof(p->owner->call_forward) - 1);
+}
+
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req)
{
char *to;
}
/* XXX Locking issues?? XXX */
switch(resp) {
+ case 302: /* Moved temporarily */
+ parse_moved_contact(p, req);
+ if (p->owner)
+ ast_queue_control(p->owner, AST_CONTROL_BUSY, 0);
+ break;
case 486: /* Busy here */
case 600: /* Busy everywhere */
if (p->owner)
{
int match;
/* If they're the same return */
- if (!strcasecmp(pattern, data))
+ if (!strcmp(pattern, data))
return 1;
EXTENSION_MATCH_CORE(data,pattern,match);
/* Must be at the end of both */
tmp = contexts;
while(tmp) {
/* Match context */
- if (!strcasecmp(tmp->name, context)) {
+ if (!strcmp(tmp->name, context)) {
if (*status < STATUS_NO_EXTENSION)
*status = STATUS_NO_EXTENSION;
eroot = tmp->root;