

Go to the source code of this file.
Data Structures | |
| struct | dundi_ie_data |
| struct | dundi_ies |
Defines | |
| #define | DUNDI_MAX_ANSWERS 100 |
| #define | DUNDI_MAX_STACK 512 |
Functions | |
| char * | dundi_eid_to_str_short (char *s, int maxlen, dundi_eid *eid) |
| int | dundi_eid_zero (dundi_eid *eid) |
| char * | dundi_flags2str (char *s, int maxlen, int flags) |
| char * | dundi_hint2str (char *s, int maxlen, int flags) |
| const char * | dundi_ie2str (int ie) |
| int | dundi_ie_append (struct dundi_ie_data *ied, unsigned char ie) |
| int | dundi_ie_append_addr (struct dundi_ie_data *ied, unsigned char ie, struct sockaddr_in *sin) |
| 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 *desc) |
| int | dundi_ie_append_byte (struct dundi_ie_data *ied, unsigned char ie, unsigned char dat) |
| int | dundi_ie_append_cause (struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, char *desc) |
| int | dundi_ie_append_eid (struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid) |
| int | dundi_ie_append_encdata (struct dundi_ie_data *ied, unsigned char ie, unsigned char *iv, void *data, int datalen) |
| int | dundi_ie_append_hint (struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, char *data) |
| int | dundi_ie_append_int (struct dundi_ie_data *ied, unsigned char ie, unsigned int value) |
| int | dundi_ie_append_raw (struct dundi_ie_data *ied, unsigned char ie, void *data, int datalen) |
| int | dundi_ie_append_short (struct dundi_ie_data *ied, unsigned char ie, unsigned short value) |
| int | dundi_ie_append_str (struct dundi_ie_data *ied, unsigned char ie, char *str) |
| int | dundi_parse_ies (struct dundi_ies *ies, unsigned char *data, int datalen) |
| void | dundi_set_error (void(*output)(const char *data)) |
| void | dundi_set_output (void(*output)(const char *data)) |
| void | dundi_showframe (struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen) |
| int | dundi_str_short_to_eid (dundi_eid *eid, const char *s) |
| #define DUNDI_MAX_ANSWERS 100 |
Definition at line 19 of file dundi-parser.h.
Referenced by dundi_parse_ies().
| #define DUNDI_MAX_STACK 512 |
Definition at line 18 of file dundi-parser.h.
Referenced by append_transaction(), dundi_parse_ies(), and optimize_transactions().
| char* dundi_eid_to_str_short | ( | char * | s, |
| int | maxlen, | ||
| dundi_eid * | eid | ||
| ) |
Definition at line 55 of file dundi-parser.c.
References ast_eid::eid.
Referenced by cache_lookup(), cache_save(), cache_save_hint(), and handle_command_response().
{
int x;
char *os = s;
if (maxlen < 13) {
if (s && (maxlen > 0))
*s = '\0';
} else {
for (x=0;x<6;x++) {
sprintf(s, "%02X", eid->eid[x]);
s += 2;
}
}
return os;
}
| int dundi_eid_zero | ( | dundi_eid * | eid | ) |
Definition at line 83 of file dundi-parser.c.
References ARRAY_LEN, and ast_eid::eid.
Referenced by build_transactions(), dundi_discover(), dundi_query(), dundi_show_cache(), dundi_show_requests(), and precache_trans().
| char* dundi_flags2str | ( | char * | s, |
| int | maxlen, | ||
| int | flags | ||
| ) |
Definition at line 247 of file dundi-parser.c.
References ast_strlen_zero(), DUNDI_FLAG_CANMATCH, DUNDI_FLAG_COMMERCIAL, DUNDI_FLAG_EXISTS, DUNDI_FLAG_IGNOREPAT, DUNDI_FLAG_MATCHMORE, DUNDI_FLAG_MOBILE, DUNDI_FLAG_NOCOMUNSOLICIT, DUNDI_FLAG_NOUNSOLICITED, and DUNDI_FLAG_RESIDENTIAL.
Referenced by cache_lookup_internal(), dump_answer(), dundi_do_lookup(), dundi_show_cache(), and dundi_show_mappings().
{
strcpy(buf, "");
buf[bufsiz-1] = '\0';
if (flags & DUNDI_FLAG_EXISTS) {
strncat(buf, "EXISTS|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_MATCHMORE) {
strncat(buf, "MATCHMORE|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_CANMATCH) {
strncat(buf, "CANMATCH|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_IGNOREPAT) {
strncat(buf, "IGNOREPAT|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_RESIDENTIAL) {
strncat(buf, "RESIDENCE|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_COMMERCIAL) {
strncat(buf, "COMMERCIAL|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_MOBILE) {
strncat(buf, "MOBILE", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_NOUNSOLICITED) {
strncat(buf, "NOUNSLCTD|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_FLAG_NOCOMUNSOLICIT) {
strncat(buf, "NOCOMUNSLTD|", bufsiz - strlen(buf) - 1);
}
/* Get rid of trailing | */
if (ast_strlen_zero(buf))
strcpy(buf, "NONE|");
buf[strlen(buf)-1] = '\0';
return buf;
}
| char* dundi_hint2str | ( | char * | s, |
| int | maxlen, | ||
| int | flags | ||
| ) |
Definition at line 112 of file dundi-parser.c.
References ast_strlen_zero(), DUNDI_HINT_DONT_ASK, DUNDI_HINT_TTL_EXPIRED, and DUNDI_HINT_UNAFFECTED.
Referenced by dump_hint().
{
strcpy(buf, "");
buf[bufsiz-1] = '\0';
if (flags & DUNDI_HINT_TTL_EXPIRED) {
strncat(buf, "TTLEXPIRED|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_HINT_DONT_ASK) {
strncat(buf, "DONTASK|", bufsiz - strlen(buf) - 1);
}
if (flags & DUNDI_HINT_UNAFFECTED) {
strncat(buf, "UNAFFECTED|", bufsiz - strlen(buf) - 1);
}
/* Get rid of trailing | */
if (ast_strlen_zero(buf))
strcpy(buf, "NONE|");
buf[strlen(buf)-1] = '\0';
return buf;
}
| const char* dundi_ie2str | ( | int | ie | ) |
Definition at line 374 of file dundi-parser.c.
References ARRAY_LEN, infoelts, and dundi_ie::name.
Referenced by dundi_ie_append_answer(), dundi_ie_append_cause(), dundi_ie_append_encdata(), dundi_ie_append_hint(), dundi_ie_append_raw(), and dundi_parse_ies().
| int dundi_ie_append | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie | ||
| ) |
Definition at line 619 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by dundi_discover().
{
return dundi_ie_append_raw(ied, ie, NULL, 0);
}
| int dundi_ie_append_addr | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| struct sockaddr_in * | sin | ||
| ) |
Definition at line 585 of file dundi-parser.c.
References dundi_ie_append_raw().
{
return dundi_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
}
| 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 * | desc | ||
| ) |
Definition at line 558 of file dundi-parser.c.
References dundi_ie_data::buf, dundi_ie2str(), ast_eid::eid, errorf, and dundi_ie_data::pos.
Referenced by dundi_lookup_thread(), and precache_trans().
{
char tmp[256];
int datalen = data ? strlen(data) + 11 : 11;
int x;
unsigned short myw;
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", dundi_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
errorf(tmp);
return -1;
}
ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen;
for (x=0;x<6;x++)
ied->buf[ied->pos++] = eid->eid[x];
ied->buf[ied->pos++] = protocol;
myw = htons(flags);
memcpy(ied->buf + ied->pos, &myw, 2);
ied->pos += 2;
myw = htons(weight);
memcpy(ied->buf + ied->pos, &myw, 2);
ied->pos += 2;
memcpy(ied->buf + ied->pos, data, datalen-11);
ied->pos += datalen-11;
return 0;
}
| int dundi_ie_append_byte | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned char | dat | ||
| ) |
Definition at line 614 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by handle_command_response().
{
return dundi_ie_append_raw(ied, ie, &dat, 1);
}
| int dundi_ie_append_cause | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned char | cause, | ||
| char * | desc | ||
| ) |
Definition at line 498 of file dundi-parser.c.
References dundi_ie_data::buf, dundi_ie2str(), errorf, and dundi_ie_data::pos.
Referenced by dundi_answer_entity(), dundi_answer_query(), dundi_lookup_thread(), dundi_prop_precache(), and handle_command_response().
{
char tmp[256];
int datalen = data ? strlen(data) + 1 : 1;
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", dundi_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
errorf(tmp);
return -1;
}
ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen;
ied->buf[ied->pos++] = cause;
if (data) {
memcpy(ied->buf + ied->pos, data, datalen-1);
ied->pos += datalen-1;
}
return 0;
}
| int dundi_ie_append_eid | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| dundi_eid * | eid | ||
| ) |
Definition at line 609 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by do_register(), dundi_discover(), dundi_encrypt(), dundi_ie_append_eid_appropriately(), dundi_query(), handle_command_response(), and precache_trans().
{
return dundi_ie_append_raw(ied, ie, (unsigned char *)eid, sizeof(dundi_eid));
}
| int dundi_ie_append_encdata | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned char * | iv, | ||
| void * | data, | ||
| int | datalen | ||
| ) |
Definition at line 538 of file dundi-parser.c.
References dundi_ie_data::buf, dundi_ie2str(), errorf, and dundi_ie_data::pos.
Referenced by dundi_encrypt(), and handle_command_response().
{
char tmp[256];
datalen += 16;
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", dundi_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
errorf(tmp);
return -1;
}
ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen;
memcpy(ied->buf + ied->pos, iv, 16);
ied->pos += 16;
if (data) {
memcpy(ied->buf + ied->pos, data, datalen-16);
ied->pos += datalen-16;
}
return 0;
}
| int dundi_ie_append_hint | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned short | flags, | ||
| char * | data | ||
| ) |
Definition at line 517 of file dundi-parser.c.
References dundi_ie_data::buf, dundi_ie2str(), errorf, and dundi_ie_data::pos.
Referenced by dundi_lookup_thread(), dundi_query_thread(), and precache_trans().
{
char tmp[256];
int datalen = data ? strlen(data) + 2 : 2;
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", dundi_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
errorf(tmp);
return -1;
}
ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen;
flags = htons(flags);
memcpy(ied->buf + ied->pos, &flags, sizeof(flags));
ied->pos += 2;
if (data) {
memcpy(ied->buf + ied->pos, data, datalen-2);
ied->pos += datalen-2;
}
return 0;
}
| int dundi_ie_append_int | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned int | value | ||
| ) |
Definition at line 590 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by dundi_encrypt().
{
unsigned int newval;
newval = htonl(value);
return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
}
| int dundi_ie_append_raw | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| void * | data, | ||
| int | datalen | ||
| ) |
Definition at line 483 of file dundi-parser.c.
References dundi_ie_data::buf, dundi_ie2str(), errorf, and dundi_ie_data::pos.
Referenced by dundi_encrypt(), dundi_ie_append(), dundi_ie_append_addr(), dundi_ie_append_byte(), dundi_ie_append_eid(), dundi_ie_append_int(), dundi_ie_append_short(), dundi_ie_append_str(), and handle_command_response().
{
char tmp[256];
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", dundi_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
errorf(tmp);
return -1;
}
ied->buf[ied->pos++] = ie;
ied->buf[ied->pos++] = datalen;
memcpy(ied->buf + ied->pos, data, datalen);
ied->pos += datalen;
return 0;
}
| int dundi_ie_append_short | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| unsigned short | value | ||
| ) |
Definition at line 597 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by do_register(), dundi_discover(), dundi_lookup_thread(), dundi_query(), handle_command_response(), and precache_trans().
{
unsigned short newval;
newval = htons(value);
return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
}
| int dundi_ie_append_str | ( | struct dundi_ie_data * | ied, |
| unsigned char | ie, | ||
| char * | str | ||
| ) |
Definition at line 604 of file dundi-parser.c.
References dundi_ie_append_raw().
Referenced by dundi_discover(), dundi_query(), dundi_query_thread(), and precache_trans().
{
return dundi_ie_append_raw(ied, ie, str, strlen(str));
}
| int dundi_parse_ies | ( | struct dundi_ies * | ies, |
| unsigned char * | data, | ||
| int | datalen | ||
| ) |
Definition at line 634 of file dundi-parser.c.
References dundi_ies::anscount, dundi_ies::answers, dundi_ies::called_context, dundi_ies::called_number, dundi_ies::cause, dundi_ies::causestr, dundi_ies::cbypass, dundi_ie2str(), DUNDI_IE_ANSWER, DUNDI_IE_CACHEBYPASS, DUNDI_IE_CALLED_CONTEXT, DUNDI_IE_CALLED_NUMBER, DUNDI_IE_CAUSE, DUNDI_IE_COUNTRY, DUNDI_IE_DEPARTMENT, DUNDI_IE_EID, DUNDI_IE_EID_DIRECT, DUNDI_IE_EMAIL, DUNDI_IE_ENCDATA, DUNDI_IE_EXPIRATION, DUNDI_IE_HINT, DUNDI_IE_IPADDR, DUNDI_IE_KEYCRC32, DUNDI_IE_LOCALITY, DUNDI_IE_ORGANIZATION, DUNDI_IE_PHONE, DUNDI_IE_REQEID, DUNDI_IE_SHAREDKEY, DUNDI_IE_SIGNATURE, DUNDI_IE_STATE_PROV, DUNDI_IE_TTL, DUNDI_IE_UNKNOWN, DUNDI_IE_VERSION, DUNDI_MAX_ANSWERS, DUNDI_MAX_STACK, dundi_ies::eid_direct, dundi_ies::eidcount, dundi_ies::eids, dundi_ies::encblock, dundi_ies::enclen, dundi_ies::encsharedkey, dundi_ies::encsig, errorf, dundi_ies::expiration, dundi_ies::hint, dundi_ies::keycrc32, len(), outputf, dundi_ies::q_country, dundi_ies::q_dept, dundi_ies::q_email, dundi_ies::q_ipaddr, dundi_ies::q_locality, dundi_ies::q_org, dundi_ies::q_phone, dundi_ies::q_stateprov, dundi_ies::reqeid, dundi_ies::ttl, dundi_ies::unknowncmd, and dundi_ies::version.
Referenced by handle_command_response().
{
/* Parse data into information elements */
int len;
int ie;
char tmp[256];
memset(ies, 0, (int)sizeof(struct dundi_ies));
ies->ttl = -1;
ies->expiration = -1;
ies->unknowncmd = -1;
ies->cause = -1;
while(datalen >= 2) {
ie = data[0];
len = data[1];
if (len > datalen - 2) {
errorf("Information element length exceeds message size\n");
return -1;
}
switch(ie) {
case DUNDI_IE_EID:
case DUNDI_IE_EID_DIRECT:
if (len != (int)sizeof(dundi_eid)) {
errorf("Improper entity identifer, expecting 6 bytes!\n");
} else if (ies->eidcount < DUNDI_MAX_STACK) {
ies->eids[ies->eidcount] = (dundi_eid *)(data + 2);
ies->eid_direct[ies->eidcount] = (ie == DUNDI_IE_EID_DIRECT);
ies->eidcount++;
} else
errorf("Too many entities in stack!\n");
break;
case DUNDI_IE_REQEID:
if (len != (int)sizeof(dundi_eid)) {
errorf("Improper requested entity identifer, expecting 6 bytes!\n");
} else
ies->reqeid = (dundi_eid *)(data + 2);
break;
case DUNDI_IE_CALLED_CONTEXT:
ies->called_context = (char *)data + 2;
break;
case DUNDI_IE_CALLED_NUMBER:
ies->called_number = (char *)data + 2;
break;
case DUNDI_IE_ANSWER:
if (len < sizeof(struct dundi_answer)) {
snprintf(tmp, (int)sizeof(tmp), "Answer expected to be >=%d bytes long but was %d\n", (int)sizeof(struct dundi_answer), len);
errorf(tmp);
} else {
if (ies->anscount < DUNDI_MAX_ANSWERS)
ies->answers[ies->anscount++]= (struct dundi_answer *)(data + 2);
else
errorf("Ignoring extra answers!\n");
}
break;
case DUNDI_IE_TTL:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting ttl to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
ies->ttl = ntohs(*((unsigned short *)(data + 2)));
break;
case DUNDI_IE_VERSION:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
ies->version = ntohs(*((unsigned short *)(data + 2)));
break;
case DUNDI_IE_EXPIRATION:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
ies->expiration = ntohs(*((unsigned short *)(data + 2)));
break;
case DUNDI_IE_KEYCRC32:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
ies->keycrc32 = ntohl(*((unsigned int *)(data + 2)));
break;
case DUNDI_IE_UNKNOWN:
if (len == 1)
ies->unknowncmd = data[2];
else {
snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
errorf(tmp);
}
break;
case DUNDI_IE_CAUSE:
if (len >= 1) {
ies->cause = data[2];
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_HINT:
if (len >= 2) {
ies->hint = (struct dundi_hint *)(data + 2);
} else {
snprintf(tmp, (int)sizeof(tmp), "Expected at least two byte hint, but was %d long\n", len);
errorf(tmp);
}
break;
case DUNDI_IE_DEPARTMENT:
ies->q_dept = (char *)data + 2;
break;
case DUNDI_IE_ORGANIZATION:
ies->q_org = (char *)data + 2;
break;
case DUNDI_IE_LOCALITY:
ies->q_locality = (char *)data + 2;
break;
case DUNDI_IE_STATE_PROV:
ies->q_stateprov = (char *)data + 2;
break;
case DUNDI_IE_COUNTRY:
ies->q_country = (char *)data + 2;
break;
case DUNDI_IE_EMAIL:
ies->q_email = (char *)data + 2;
break;
case DUNDI_IE_PHONE:
ies->q_phone = (char *)data + 2;
break;
case DUNDI_IE_IPADDR:
ies->q_ipaddr = (char *)data + 2;
break;
case DUNDI_IE_ENCDATA:
/* Recalculate len as the remainder of the message, regardless of
theoretical length */
len = datalen - 2;
if ((len > 16) && !(len % 16)) {
ies->encblock = (struct dundi_encblock *)(data + 2);
ies->enclen = len - 16;
} else {
snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted data length %d\n", len);
errorf(tmp);
}
break;
case DUNDI_IE_SHAREDKEY:
if (len == 128) {
ies->encsharedkey = (unsigned char *)(data + 2);
} else {
snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted shared key length %d\n", len);
errorf(tmp);
}
break;
case DUNDI_IE_SIGNATURE:
if (len == 128) {
ies->encsig = (unsigned char *)(data + 2);
} else {
snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted signature length %d\n", len);
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);
}
/* Overwrite information element with 0, to null terminate previous portion */
data[0] = 0;
datalen -= (len + 2);
data += (len + 2);
}
/* Null-terminate last field */
*data = '\0';
if (datalen) {
errorf("Invalid information element contents, strange boundary\n");
return -1;
}
return 0;
}
| void dundi_set_error | ( | void(*)(const char *data) | output | ) |
| void dundi_set_output | ( | void(*)(const char *data) | output | ) |
| void dundi_showframe | ( | struct dundi_hdr * | fhi, |
| int | rx, | ||
| struct sockaddr_in * | sin, | ||
| int | datalen | ||
| ) |
Definition at line 433 of file dundi-parser.c.
References ast_inet_ntoa(), dundi_hdr::cmdflags, dundi_hdr::cmdresp, commands, dundi_hdr::dtrans, dump_ies(), DUNDI_FLAG_RESERVED, DUNDI_FLAG_RETRANS, dundi_hdr::ies, dundi_hdr::iseqno, dundi_hdr::oseqno, outputf, and dundi_hdr::strans.
Referenced by dundi_send(), dundi_xmit(), handle_command_response(), and socket_read().
{
char *pref[] = {
"Tx",
"Rx",
" ETx",
" Erx" };
char *commands[] = {
"ACK ",
"DPDISCOVER ",
"DPRESPONSE ",
"EIDQUERY ",
"EIDRESPONSE ",
"PRECACHERQ ",
"PRECACHERP ",
"INVALID ",
"UNKNOWN CMD ",
"NULL ",
"REQREQ ",
"REGRESPONSE ",
"CANCEL ",
"ENCRYPT ",
"ENCREJ " };
char class2[20];
char *class;
char subclass2[20];
char *subclass;
char tmp[256];
if ((fhi->cmdresp & 0x3f) > (int)sizeof(commands)/(int)sizeof(char *)) {
snprintf(class2, (int)sizeof(class2), "(%d?)", fhi->cmdresp);
class = class2;
} else {
class = commands[(int)(fhi->cmdresp & 0x3f)];
}
snprintf(subclass2, (int)sizeof(subclass2), "%02x", fhi->cmdflags);
subclass = subclass2;
snprintf(tmp, (int)sizeof(tmp),
"%s-Frame -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
pref[rx],
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,
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port),
fhi->cmdresp & 0x80 ? " (Final)" : "");
outputf(tmp);
dump_ies(fhi->ies, rx > 1, datalen);
}
| int dundi_str_short_to_eid | ( | dundi_eid * | eid, |
| const char * | s | ||
| ) |
Definition at line 71 of file dundi-parser.c.
References ast_eid::eid.
Referenced by cache_lookup_internal(), dundi_show_cache(), and dundi_show_hints().
{
unsigned int eid_int[6];
int x;
if (sscanf(s, "%2x%2x%2x%2x%2x%2x", &eid_int[0], &eid_int[1], &eid_int[2],
&eid_int[3], &eid_int[4], &eid_int[5]) != 6)
return -1;
for (x = 0; x < 6; x++)
eid->eid[x] = eid_int[x];
return 0;
}