2 * Distributed Universal Number Discovery (DUNDi)
4 * Copyright (C) 2004, Digium Inc.
6 * Written by Mark Spencer <markster@digium.com>
8 * This program is Free Software distributed under the terms of
9 * of the GNU General Public License.
12 #include <sys/types.h>
13 #include <sys/socket.h>
15 #include <netinet/in.h>
16 #include <asterisk/frame.h>
17 #include <asterisk/utils.h>
18 #include <arpa/inet.h>
22 #include <asterisk/dundi.h>
23 #include "dundi-parser.h"
24 #include <asterisk/dundi.h>
26 static void internaloutput(const char *str)
31 static void internalerror(const char *str)
33 fprintf(stderr, "WARNING: %s", str);
36 static void (*outputf)(const char *str) = internaloutput;
37 static void (*errorf)(const char *str) = internalerror;
39 char *dundi_eid_to_str(char *s, int maxlen, dundi_eid *eid)
44 if (s && (maxlen > 0))
48 sprintf(s, "%02x:", eid->eid[x]);
51 sprintf(s, "%02x", eid->eid[5]);
56 char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid)
61 if (s && (maxlen > 0))
65 sprintf(s, "%02X", eid->eid[x]);
72 int dundi_str_to_eid(dundi_eid *eid, char *s)
74 unsigned int eid_int[6];
76 if (sscanf(s, "%x:%x:%x:%x:%x:%x", &eid_int[0], &eid_int[1], &eid_int[2],
77 &eid_int[3], &eid_int[4], &eid_int[5]) != 6)
80 eid->eid[x] = eid_int[x];
84 int dundi_str_short_to_eid(dundi_eid *eid, char *s)
86 unsigned int eid_int[6];
88 if (sscanf(s, "%2x%2x%2x%2x%2x%2x", &eid_int[0], &eid_int[1], &eid_int[2],
89 &eid_int[3], &eid_int[4], &eid_int[5]) != 6)
92 eid->eid[x] = eid_int[x];
96 int dundi_eid_zero(dundi_eid *eid)
99 for (x=0;x<sizeof(eid->eid) / sizeof(eid->eid[0]);x++)
100 if (eid->eid[x]) return 0;
104 int dundi_eid_cmp(dundi_eid *eid1, dundi_eid *eid2)
106 return memcmp(eid1, eid2, sizeof(dundi_eid));
109 static void dump_string(char *output, int maxlen, void *value, int len)
114 strncpy(output,value, maxlen);
115 output[maxlen] = '\0';
118 static void dump_eid(char *output, int maxlen, void *value, int len)
121 dundi_eid_to_str(output, maxlen, (dundi_eid *)value);
123 snprintf(output, maxlen, "Invalid EID len %d", len);
126 char *dundi_hint2str(char *buf, int bufsiz, int flags)
129 buf[bufsiz-1] = '\0';
130 if (flags & DUNDI_HINT_TTL_EXPIRED) {
131 strncat(buf, "TTLEXPIRED|", bufsiz - strlen(buf) - 1);
133 if (flags & DUNDI_HINT_DONT_ASK) {
134 strncat(buf, "DONTASK|", bufsiz - strlen(buf) - 1);
136 if (flags & DUNDI_HINT_UNAFFECTED) {
137 strncat(buf, "UNAFFECTED|", bufsiz - strlen(buf) - 1);
139 /* Get rid of trailing | */
140 if (ast_strlen_zero(buf))
141 strcpy(buf, "NONE|");
142 buf[strlen(buf)-1] = '\0';
146 static void dump_hint(char *output, int maxlen, void *value, int len)
148 unsigned short flags;
152 strncpy(output, "<invalid contents>", maxlen);
155 memcpy(&flags, value, sizeof(flags));
156 flags = ntohs(flags);
157 memset(tmp, 0, sizeof(tmp));
158 dundi_hint2str(tmp2, sizeof(tmp2), flags);
159 snprintf(tmp, sizeof(tmp), "[%s] ", tmp2);
160 memcpy(tmp + strlen(tmp), value + 2, len - 2);
161 strncpy(output, tmp, maxlen - 1);
164 static void dump_cause(char *output, int maxlen, void *value, int len)
166 static char *causes[] = {
177 strncpy(output, "<invalid contents>", maxlen);
180 cause = *((unsigned char *)value);
181 memset(tmp2, 0, sizeof(tmp2));
185 memcpy(tmp2, value + 1, mlen);
186 if (cause < sizeof(causes) / sizeof(causes[0])) {
188 snprintf(tmp, sizeof(tmp), "%s: %s", causes[cause], tmp2);
190 snprintf(tmp, sizeof(tmp), "%s", causes[cause]);
193 snprintf(tmp, sizeof(tmp), "%d: %s", cause, tmp2);
195 snprintf(tmp, sizeof(tmp), "%d", cause);
198 strncpy(output,tmp, maxlen);
199 output[maxlen] = '\0';
202 static void dump_int(char *output, int maxlen, void *value, int len)
204 if (len == (int)sizeof(unsigned int))
205 snprintf(output, maxlen, "%lu", (unsigned long)ntohl(*((unsigned int *)value)));
207 snprintf(output, maxlen, "Invalid INT");
210 static void dump_short(char *output, int maxlen, void *value, int len)
212 if (len == (int)sizeof(unsigned short))
213 snprintf(output, maxlen, "%d", ntohs(*((unsigned short *)value)));
215 snprintf(output, maxlen, "Invalid SHORT");
218 static void dump_byte(char *output, int maxlen, void *value, int len)
220 if (len == (int)sizeof(unsigned char))
221 snprintf(output, maxlen, "%d", *((unsigned char *)value));
223 snprintf(output, maxlen, "Invalid BYTE");
226 static char *proto2str(int proto, char *buf, int bufsiz)
229 case DUNDI_PROTO_NONE:
230 strncpy(buf, "None", bufsiz - 1);
232 case DUNDI_PROTO_IAX:
233 strncpy(buf, "IAX", bufsiz - 1);
235 case DUNDI_PROTO_SIP:
236 strncpy(buf, "SIP", bufsiz - 1);
238 case DUNDI_PROTO_H323:
239 strncpy(buf, "H.323", bufsiz - 1);
242 snprintf(buf, bufsiz, "Unknown Proto(%d)", proto);
244 buf[bufsiz-1] = '\0';
248 char *dundi_flags2str(char *buf, int bufsiz, int flags)
251 buf[bufsiz-1] = '\0';
252 if (flags & DUNDI_FLAG_EXISTS) {
253 strncat(buf, "EXISTS|", bufsiz - strlen(buf) - 1);
255 if (flags & DUNDI_FLAG_MATCHMORE) {
256 strncat(buf, "MATCHMORE|", bufsiz - strlen(buf) - 1);
258 if (flags & DUNDI_FLAG_CANMATCH) {
259 strncat(buf, "CANMATCH|", bufsiz - strlen(buf) - 1);
261 if (flags & DUNDI_FLAG_IGNOREPAT) {
262 strncat(buf, "IGNOREPAT|", bufsiz - strlen(buf) - 1);
264 if (flags & DUNDI_FLAG_RESIDENTIAL) {
265 strncat(buf, "RESIDENCE|", bufsiz - strlen(buf) - 1);
267 if (flags & DUNDI_FLAG_COMMERCIAL) {
268 strncat(buf, "COMMERCIAL|", bufsiz - strlen(buf) - 1);
270 if (flags & DUNDI_FLAG_MOBILE) {
271 strncat(buf, "MOBILE", bufsiz - strlen(buf) - 1);
273 if (flags & DUNDI_FLAG_NOUNSOLICITED) {
274 strncat(buf, "NOUNSLCTD|", bufsiz - strlen(buf) - 1);
276 if (flags & DUNDI_FLAG_NOCOMUNSOLICIT) {
277 strncat(buf, "NOCOMUNSLTD|", bufsiz - strlen(buf) - 1);
279 /* Get rid of trailing | */
280 if (ast_strlen_zero(buf))
281 strcpy(buf, "NONE|");
282 buf[strlen(buf)-1] = '\0';
286 static void dump_answer(char *output, int maxlen, void *value, int len)
288 struct dundi_answer *answer;
294 answer = (struct dundi_answer *)(value);
295 memcpy(tmp, answer->data, (len >= 500) ? 500 : len - 10);
296 dundi_eid_to_str(eid_str, sizeof(eid_str), &answer->eid);
297 snprintf(output, maxlen, "[%s] %d <%s/%s> from [%s]",
298 dundi_flags2str(flags, sizeof(flags), ntohs(answer->flags)),
299 ntohs(answer->weight),
300 proto2str(answer->protocol, proto, sizeof(proto)),
303 strncpy(output, "Invalid Answer", maxlen - 1);
306 static void dump_encrypted(char *output, int maxlen, void *value, int len)
310 if ((len > 16) && !(len % 16)) {
313 snprintf(iv + (x << 1), 3, "%02x", ((unsigned char *)value)[x]);
315 snprintf(output, maxlen, "[IV %s] %d encrypted blocks\n", iv, len / 16);
317 snprintf(output, maxlen, "Invalid Encrypted Datalen %d", len);
320 static void dump_raw(char *output, int maxlen, void *value, int len)
323 unsigned char *u = value;
324 output[maxlen - 1] = '\0';
325 strcpy(output, "[ ");
326 for (x=0;x<len;x++) {
327 snprintf(output + strlen(output), maxlen - strlen(output) - 1, "%02x ", u[x]);
329 strncat(output + strlen(output), "]", maxlen - strlen(output) - 1);
332 static struct dundi_ie {
335 void (*dump)(char *output, int maxlen, void *value, int len);
337 { DUNDI_IE_EID, "ENTITY IDENT", dump_eid },
338 { DUNDI_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string },
339 { DUNDI_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string },
340 { DUNDI_IE_EID_DIRECT, "DIRECT EID", dump_eid },
341 { DUNDI_IE_ANSWER, "ANSWER", dump_answer },
342 { DUNDI_IE_TTL, "TTL", dump_short },
343 { DUNDI_IE_VERSION, "VERSION", dump_short },
344 { DUNDI_IE_EXPIRATION, "EXPIRATION", dump_short },
345 { DUNDI_IE_UNKNOWN, "UKWN DUNDI CMD", dump_byte },
346 { DUNDI_IE_CAUSE, "CAUSE", dump_cause },
347 { DUNDI_IE_REQEID, "REQUEST EID", dump_eid },
348 { DUNDI_IE_ENCDATA, "ENCDATA", dump_encrypted },
349 { DUNDI_IE_SHAREDKEY, "SHAREDKEY", dump_raw },
350 { DUNDI_IE_SIGNATURE, "SIGNATURE", dump_raw },
351 { DUNDI_IE_KEYCRC32, "KEYCRC32", dump_int },
352 { DUNDI_IE_HINT, "HINT", dump_hint },
353 { DUNDI_IE_DEPARTMENT, "DEPARTMENT", dump_string },
354 { DUNDI_IE_ORGANIZATION, "ORGANIZTN", dump_string },
355 { DUNDI_IE_LOCALITY, "LOCALITY", dump_string },
356 { DUNDI_IE_STATE_PROV, "STATEPROV", dump_string },
357 { DUNDI_IE_COUNTRY, "COUNTRY", dump_string },
358 { DUNDI_IE_EMAIL, "EMAIL", dump_string },
359 { DUNDI_IE_PHONE, "PHONE", dump_string },
360 { DUNDI_IE_IPADDR, "ADDRESS", dump_string },
363 const char *dundi_ie2str(int ie)
366 for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
373 static void dump_ies(unsigned char *iedata, int spaces, int len)
386 /* Encrypted data is the remainder */
387 if (ie == DUNDI_IE_ENCDATA)
389 if (ielen + 2> len) {
390 snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
395 for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
396 if (ies[x].ie == ie) {
398 ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
399 snprintf(tmp, (int)sizeof(tmp), " %s%-15.15s : %s\n", (spaces ? " " : "" ), ies[x].name, interp);
403 snprintf(interp, (int)sizeof(interp), "%d bytes", ielen);
405 strcpy(interp, "Present");
406 snprintf(tmp, (int)sizeof(tmp), " %s%-15.15s : %s\n", (spaces ? " " : "" ), ies[x].name, interp);
413 snprintf(tmp, (int)sizeof(tmp), " %sUnknown IE %03d : Present\n", (spaces ? " " : "" ), ie);
416 iedata += (2 + ielen);
422 void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen)
451 char iabuf[INET_ADDRSTRLEN];
452 if (ntohs(fhi->dtrans) & DUNDI_FLAG_RETRANS)
453 strcpy(retries, "Yes");
455 strcpy(retries, "No");
456 if ((ntohs(fhi->strans) & DUNDI_FLAG_RESERVED)) {
457 /* Ignore frames with high bit set to 1 */
460 if ((fhi->cmdresp & 0x3f) > (int)sizeof(commands)/(int)sizeof(char *)) {
461 snprintf(class2, (int)sizeof(class2), "(%d?)", fhi->cmdresp);
464 class = commands[(int)(fhi->cmdresp & 0x3f)];
466 snprintf(subclass2, (int)sizeof(subclass2), "%02x", fhi->cmdflags);
467 subclass = subclass2;
468 snprintf(tmp, (int)sizeof(tmp),
469 "%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
471 retries, fhi->oseqno, fhi->iseqno, class, fhi->cmdresp & 0x40 ? "Response" : "Command");
473 snprintf(tmp, (int)sizeof(tmp),
474 "%s Flags: %s STrans: %5.5d DTrans: %5.5d [%s:%d]%s\n", (rx > 1) ? " " : "",
475 subclass, ntohs(fhi->strans) & ~DUNDI_FLAG_RESERVED, ntohs(fhi->dtrans) & ~DUNDI_FLAG_RETRANS,
476 ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port),
477 fhi->cmdresp & 0x80 ? " (Final)" : "");
479 dump_ies(fhi->ies, rx > 1, datalen);
482 int dundi_ie_append_raw(struct dundi_ie_data *ied, unsigned char ie, void *data, int datalen)
485 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
486 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);
490 ied->buf[ied->pos++] = ie;
491 ied->buf[ied->pos++] = datalen;
492 memcpy(ied->buf + ied->pos, data, datalen);
497 int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, unsigned char *data)
500 int datalen = data ? strlen(data) + 1 : 1;
501 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
502 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);
506 ied->buf[ied->pos++] = ie;
507 ied->buf[ied->pos++] = datalen;
508 ied->buf[ied->pos++] = cause;
509 memcpy(ied->buf + ied->pos, data, datalen-1);
510 ied->pos += datalen-1;
514 int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, unsigned char *data)
517 int datalen = data ? strlen(data) + 2 : 2;
518 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
519 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);
523 ied->buf[ied->pos++] = ie;
524 ied->buf[ied->pos++] = datalen;
525 flags = htons(flags);
526 memcpy(ied->buf + ied->pos, &flags, sizeof(flags));
528 memcpy(ied->buf + ied->pos, data, datalen-1);
529 ied->pos += datalen-2;
533 int dundi_ie_append_encdata(struct dundi_ie_data *ied, unsigned char ie, unsigned char *iv, void *data, int datalen)
537 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
538 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);
542 ied->buf[ied->pos++] = ie;
543 ied->buf[ied->pos++] = datalen;
544 memcpy(ied->buf + ied->pos, iv, 16);
547 memcpy(ied->buf + ied->pos, data, datalen-16);
548 ied->pos += datalen-16;
553 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)
556 int datalen = data ? strlen(data) + 11 : 11;
559 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
560 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);
564 ied->buf[ied->pos++] = ie;
565 ied->buf[ied->pos++] = datalen;
567 ied->buf[ied->pos++] = eid->eid[x];
568 ied->buf[ied->pos++] = protocol;
570 memcpy(ied->buf + ied->pos, &myw, 2);
573 memcpy(ied->buf + ied->pos, &myw, 2);
575 memcpy(ied->buf + ied->pos, data, datalen-11);
576 ied->pos += datalen-11;
580 int dundi_ie_append_addr(struct dundi_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
582 return dundi_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
585 int dundi_ie_append_int(struct dundi_ie_data *ied, unsigned char ie, unsigned int value)
588 newval = htonl(value);
589 return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
592 int dundi_ie_append_short(struct dundi_ie_data *ied, unsigned char ie, unsigned short value)
594 unsigned short newval;
595 newval = htons(value);
596 return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
599 int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, unsigned char *str)
601 return dundi_ie_append_raw(ied, ie, str, strlen(str));
604 int dundi_ie_append_eid(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid)
606 return dundi_ie_append_raw(ied, ie, (unsigned char *)eid, sizeof(dundi_eid));
609 int dundi_ie_append_byte(struct dundi_ie_data *ied, unsigned char ie, unsigned char dat)
611 return dundi_ie_append_raw(ied, ie, &dat, 1);
614 int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie)
616 return dundi_ie_append_raw(ied, ie, NULL, 0);
619 void dundi_set_output(void (*func)(const char *))
624 void dundi_set_error(void (*func)(const char *))
629 int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen)
631 /* Parse data into information elements */
635 memset(ies, 0, (int)sizeof(struct dundi_ies));
637 ies->expiration = -1;
638 ies->unknowncmd = -1;
640 while(datalen >= 2) {
643 if (len > datalen - 2) {
644 errorf("Information element length exceeds message size\n");
649 case DUNDI_IE_EID_DIRECT:
650 if (len != (int)sizeof(dundi_eid)) {
651 errorf("Improper entity identifer, expecting 6 bytes!\n");
652 } else if (ies->eidcount < DUNDI_MAX_STACK) {
653 ies->eids[ies->eidcount] = (dundi_eid *)(data + 2);
654 ies->eid_direct[ies->eidcount] = (ie == DUNDI_IE_EID_DIRECT);
657 errorf("Too many entities in stack!\n");
659 case DUNDI_IE_REQEID:
660 if (len != (int)sizeof(dundi_eid)) {
661 errorf("Improper requested entity identifer, expecting 6 bytes!\n");
663 ies->reqeid = (dundi_eid *)(data + 2);
665 case DUNDI_IE_CALLED_CONTEXT:
666 ies->called_context = data + 2;
668 case DUNDI_IE_CALLED_NUMBER:
669 ies->called_number = data + 2;
671 case DUNDI_IE_ANSWER:
672 if (len < sizeof(struct dundi_answer)) {
673 snprintf(tmp, (int)sizeof(tmp), "Answer expected to be >=%d bytes long but was %d\n", (int)sizeof(struct dundi_answer), len);
676 if (ies->anscount < DUNDI_MAX_ANSWERS)
677 ies->answers[ies->anscount++]= (struct dundi_answer *)(data + 2);
679 errorf("Ignoring extra answers!\n");
683 if (len != (int)sizeof(unsigned short)) {
684 snprintf(tmp, (int)sizeof(tmp), "Expecting ttl to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
687 ies->ttl = ntohs(*((unsigned short *)(data + 2)));
689 case DUNDI_IE_VERSION:
690 if (len != (int)sizeof(unsigned short)) {
691 snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
694 ies->version = ntohs(*((unsigned short *)(data + 2)));
696 case DUNDI_IE_EXPIRATION:
697 if (len != (int)sizeof(unsigned short)) {
698 snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
701 ies->expiration = ntohs(*((unsigned short *)(data + 2)));
703 case DUNDI_IE_KEYCRC32:
704 if (len != (int)sizeof(unsigned int)) {
705 snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
708 ies->keycrc32 = ntohl(*((unsigned int *)(data + 2)));
710 case DUNDI_IE_UNKNOWN:
712 ies->unknowncmd = data[2];
714 snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
720 ies->cause = data[2];
721 ies->causestr = data + 3;
723 snprintf(tmp, (int)sizeof(tmp), "Expected at least one byte cause, but was %d long\n", len);
729 ies->hint = (struct dundi_hint *)(data + 2);
731 snprintf(tmp, (int)sizeof(tmp), "Expected at least two byte hint, but was %d long\n", len);
735 case DUNDI_IE_DEPARTMENT:
736 ies->q_dept = data + 2;
738 case DUNDI_IE_ORGANIZATION:
739 ies->q_org = data + 2;
741 case DUNDI_IE_LOCALITY:
742 ies->q_locality = data + 2;
744 case DUNDI_IE_STATE_PROV:
745 ies->q_stateprov = data + 2;
747 case DUNDI_IE_COUNTRY:
748 ies->q_country = data + 2;
751 ies->q_email = data + 2;
754 ies->q_phone = data + 2;
756 case DUNDI_IE_IPADDR:
757 ies->q_ipaddr = data + 2;
759 case DUNDI_IE_ENCDATA:
760 /* Recalculate len as the remainder of the message, regardless of
761 theoretical length */
763 if ((len > 16) && !(len % 16)) {
764 ies->encblock = (struct dundi_encblock *)(data + 2);
765 ies->enclen = len - 16;
767 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted data length %d\n", len);
771 case DUNDI_IE_SHAREDKEY:
773 ies->encsharedkey = (unsigned char *)(data + 2);
775 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted shared key length %d\n", len);
779 case DUNDI_IE_SIGNATURE:
781 ies->encsig = (unsigned char *)(data + 2);
783 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted signature length %d\n", len);
788 snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", dundi_ie2str(ie), ie, len);
791 /* Overwrite information element with 0, to null terminate previous portion */
793 datalen -= (len + 2);
796 /* Null-terminate last field */
799 errorf("Invalid information element contents, strange boundary\n");