/*
- * Distributed Universal Number Discovery (DUNDi)
+ * Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2004, Digium Inc.
+ * Copyright (C) 1999 - 2005, Digium, Inc.
*
- * Written by Mark Spencer <markster@digium.com>
+ * Mark Spencer <markster@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Distributed Universal Number Discovery (DUNDi)
*
- * This program is Free Software distributed under the terms of
- * of the GNU General Public License.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <netinet/in.h>
-#include <asterisk/frame.h>
-#include <asterisk/utils.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <asterisk/dundi.h>
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/frame.h"
+#include "asterisk/utils.h"
+#include "asterisk/dundi.h"
#include "dundi-parser.h"
-#include <asterisk/dundi.h>
+#include "asterisk/dundi.h"
+
static void internaloutput(const char *str)
{
- printf(str);
+ fputs(str, stdout);
}
static void internalerror(const char *str)
eid->eid[x] = eid_int[x];
return 0;
}
+
int dundi_eid_zero(dundi_eid *eid)
{
int x;
output[maxlen] = '\0';
}
+static void dump_cbypass(char *output, int maxlen, void *value, int len)
+{
+ maxlen--;
+ strncpy(output, "Bypass Caches", maxlen);
+ output[maxlen] = '\0';
+}
+
static void dump_eid(char *output, int maxlen, void *value, int len)
{
if (len == 6)
}
static char *proto2str(int proto, char *buf, int bufsiz)
-{
-
+{
switch(proto) {
case DUNDI_PROTO_NONE:
strncpy(buf, "None", bufsiz - 1);
{ DUNDI_IE_EMAIL, "EMAIL", dump_string },
{ DUNDI_IE_PHONE, "PHONE", dump_string },
{ DUNDI_IE_IPADDR, "ADDRESS", dump_string },
+ { DUNDI_IE_CACHEBYPASS, "CBYPASS", dump_cbypass },
};
const char *dundi_ie2str(int ie)
char tmp[1024];
if (len < 2)
return;
- while(len > 2) {
+ while(len >= 2) {
ie = iedata[0];
ielen = iedata[1];
/* Encrypted data is the remainder */
"DPRESPONSE ",
"EIDQUERY ",
"EIDRESPONSE ",
- "UNKNOWN (5)?",
- "UNKNOWN (6)?",
+ "PRECACHERQ ",
+ "PRECACHERP ",
"INVALID ",
"UNKNOWN CMD ",
"NULL ",
}
snprintf(subclass2, (int)sizeof(subclass2), "%02x", fhi->cmdflags);
subclass = subclass2;
-snprintf(tmp, (int)sizeof(tmp),
-"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
- pref[rx],
- retries, fhi->oseqno, fhi->iseqno, class, fhi->cmdresp & 0x40 ? "Response" : "Command");
+ snprintf(tmp, (int)sizeof(tmp),
+ "%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
+ pref[rx],
+ retries, fhi->oseqno, fhi->iseqno, class, fhi->cmdresp & 0x40 ? "Response" : "Command");
outputf(tmp);
-snprintf(tmp, (int)sizeof(tmp),
-"%s Flags: %s STrans: %5.5d DTrans: %5.5d [%s:%d]%s\n", (rx > 1) ? " " : "",
- subclass, ntohs(fhi->strans) & ~DUNDI_FLAG_RESERVED, ntohs(fhi->dtrans) & ~DUNDI_FLAG_RETRANS,
+ snprintf(tmp, (int)sizeof(tmp),
+ "%s Flags: %s STrans: %5.5d DTrans: %5.5d [%s:%d]%s\n", (rx > 1) ? " " : "",
+ subclass, ntohs(fhi->strans) & ~DUNDI_FLAG_RESERVED, ntohs(fhi->dtrans) & ~DUNDI_FLAG_RETRANS,
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port),
fhi->cmdresp & 0x80 ? " (Final)" : "");
outputf(tmp);
return 0;
}
-int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, unsigned char *data)
+int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, char *data)
{
char tmp[256];
int datalen = data ? strlen(data) + 1 : 1;
return 0;
}
-int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, unsigned char *data)
+int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, char *data)
{
char tmp[256];
int datalen = data ? strlen(data) + 2 : 2;
return 0;
}
-int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, unsigned char *data)
+int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, char *data)
{
char tmp[256];
int datalen = data ? strlen(data) + 11 : 11;
return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
}
-int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, unsigned char *str)
+int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, char *str)
{
return dundi_ie_append_raw(ied, ie, str, strlen(str));
}
ies->reqeid = (dundi_eid *)(data + 2);
break;
case DUNDI_IE_CALLED_CONTEXT:
- ies->called_context = data + 2;
+ ies->called_context = (char *)data + 2;
break;
case DUNDI_IE_CALLED_NUMBER:
- ies->called_number = data + 2;
+ ies->called_number = (char *)data + 2;
break;
case DUNDI_IE_ANSWER:
if (len < sizeof(struct dundi_answer)) {
case DUNDI_IE_CAUSE:
if (len >= 1) {
ies->cause = data[2];
- ies->causestr = data + 3;
+ ies->causestr = (char *)data + 3;
} else {
snprintf(tmp, (int)sizeof(tmp), "Expected at least one byte cause, but was %d long\n", len);
errorf(tmp);
}
break;
case DUNDI_IE_DEPARTMENT:
- ies->q_dept = data + 2;
+ ies->q_dept = (char *)data + 2;
break;
case DUNDI_IE_ORGANIZATION:
- ies->q_org = data + 2;
+ ies->q_org = (char *)data + 2;
break;
case DUNDI_IE_LOCALITY:
- ies->q_locality = data + 2;
+ ies->q_locality = (char *)data + 2;
break;
case DUNDI_IE_STATE_PROV:
- ies->q_stateprov = data + 2;
+ ies->q_stateprov = (char *)data + 2;
break;
case DUNDI_IE_COUNTRY:
- ies->q_country = data + 2;
+ ies->q_country = (char *)data + 2;
break;
case DUNDI_IE_EMAIL:
- ies->q_email = data + 2;
+ ies->q_email = (char *)data + 2;
break;
case DUNDI_IE_PHONE:
- ies->q_phone = data + 2;
+ ies->q_phone = (char *)data + 2;
break;
case DUNDI_IE_IPADDR:
- ies->q_ipaddr = data + 2;
+ ies->q_ipaddr = (char *)data + 2;
break;
case DUNDI_IE_ENCDATA:
/* Recalculate len as the remainder of the message, regardless of
errorf(tmp);
}
break;
+ case DUNDI_IE_CACHEBYPASS:
+ ies->cbypass = 1;
+ break;
default:
snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", dundi_ie2str(ie), ie, len);
outputf(tmp);