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_cbypass(char *output, int maxlen, void *value, int len)
120 strncpy(output, "Bypass Caches", maxlen);
121 output[maxlen] = '\0';
124 static void dump_eid(char *output, int maxlen, void *value, int len)
127 dundi_eid_to_str(output, maxlen, (dundi_eid *)value);
129 snprintf(output, maxlen, "Invalid EID len %d", len);
132 char *dundi_hint2str(char *buf, int bufsiz, int flags)
135 buf[bufsiz-1] = '\0';
136 if (flags & DUNDI_HINT_TTL_EXPIRED) {
137 strncat(buf, "TTLEXPIRED|", bufsiz - strlen(buf) - 1);
139 if (flags & DUNDI_HINT_DONT_ASK) {
140 strncat(buf, "DONTASK|", bufsiz - strlen(buf) - 1);
142 if (flags & DUNDI_HINT_UNAFFECTED) {
143 strncat(buf, "UNAFFECTED|", bufsiz - strlen(buf) - 1);
145 /* Get rid of trailing | */
146 if (ast_strlen_zero(buf))
147 strcpy(buf, "NONE|");
148 buf[strlen(buf)-1] = '\0';
152 static void dump_hint(char *output, int maxlen, void *value, int len)
154 unsigned short flags;
158 strncpy(output, "<invalid contents>", maxlen);
161 memcpy(&flags, value, sizeof(flags));
162 flags = ntohs(flags);
163 memset(tmp, 0, sizeof(tmp));
164 dundi_hint2str(tmp2, sizeof(tmp2), flags);
165 snprintf(tmp, sizeof(tmp), "[%s] ", tmp2);
166 memcpy(tmp + strlen(tmp), value + 2, len - 2);
167 strncpy(output, tmp, maxlen - 1);
170 static void dump_cause(char *output, int maxlen, void *value, int len)
172 static char *causes[] = {
183 strncpy(output, "<invalid contents>", maxlen);
186 cause = *((unsigned char *)value);
187 memset(tmp2, 0, sizeof(tmp2));
191 memcpy(tmp2, value + 1, mlen);
192 if (cause < sizeof(causes) / sizeof(causes[0])) {
194 snprintf(tmp, sizeof(tmp), "%s: %s", causes[cause], tmp2);
196 snprintf(tmp, sizeof(tmp), "%s", causes[cause]);
199 snprintf(tmp, sizeof(tmp), "%d: %s", cause, tmp2);
201 snprintf(tmp, sizeof(tmp), "%d", cause);
204 strncpy(output,tmp, maxlen);
205 output[maxlen] = '\0';
208 static void dump_int(char *output, int maxlen, void *value, int len)
210 if (len == (int)sizeof(unsigned int))
211 snprintf(output, maxlen, "%lu", (unsigned long)ntohl(*((unsigned int *)value)));
213 snprintf(output, maxlen, "Invalid INT");
216 static void dump_short(char *output, int maxlen, void *value, int len)
218 if (len == (int)sizeof(unsigned short))
219 snprintf(output, maxlen, "%d", ntohs(*((unsigned short *)value)));
221 snprintf(output, maxlen, "Invalid SHORT");
224 static void dump_byte(char *output, int maxlen, void *value, int len)
226 if (len == (int)sizeof(unsigned char))
227 snprintf(output, maxlen, "%d", *((unsigned char *)value));
229 snprintf(output, maxlen, "Invalid BYTE");
232 static char *proto2str(int proto, char *buf, int bufsiz)
235 case DUNDI_PROTO_NONE:
236 strncpy(buf, "None", bufsiz - 1);
238 case DUNDI_PROTO_IAX:
239 strncpy(buf, "IAX", bufsiz - 1);
241 case DUNDI_PROTO_SIP:
242 strncpy(buf, "SIP", bufsiz - 1);
244 case DUNDI_PROTO_H323:
245 strncpy(buf, "H.323", bufsiz - 1);
248 snprintf(buf, bufsiz, "Unknown Proto(%d)", proto);
250 buf[bufsiz-1] = '\0';
254 char *dundi_flags2str(char *buf, int bufsiz, int flags)
257 buf[bufsiz-1] = '\0';
258 if (flags & DUNDI_FLAG_EXISTS) {
259 strncat(buf, "EXISTS|", bufsiz - strlen(buf) - 1);
261 if (flags & DUNDI_FLAG_MATCHMORE) {
262 strncat(buf, "MATCHMORE|", bufsiz - strlen(buf) - 1);
264 if (flags & DUNDI_FLAG_CANMATCH) {
265 strncat(buf, "CANMATCH|", bufsiz - strlen(buf) - 1);
267 if (flags & DUNDI_FLAG_IGNOREPAT) {
268 strncat(buf, "IGNOREPAT|", bufsiz - strlen(buf) - 1);
270 if (flags & DUNDI_FLAG_RESIDENTIAL) {
271 strncat(buf, "RESIDENCE|", bufsiz - strlen(buf) - 1);
273 if (flags & DUNDI_FLAG_COMMERCIAL) {
274 strncat(buf, "COMMERCIAL|", bufsiz - strlen(buf) - 1);
276 if (flags & DUNDI_FLAG_MOBILE) {
277 strncat(buf, "MOBILE", bufsiz - strlen(buf) - 1);
279 if (flags & DUNDI_FLAG_NOUNSOLICITED) {
280 strncat(buf, "NOUNSLCTD|", bufsiz - strlen(buf) - 1);
282 if (flags & DUNDI_FLAG_NOCOMUNSOLICIT) {
283 strncat(buf, "NOCOMUNSLTD|", bufsiz - strlen(buf) - 1);
285 /* Get rid of trailing | */
286 if (ast_strlen_zero(buf))
287 strcpy(buf, "NONE|");
288 buf[strlen(buf)-1] = '\0';
292 static void dump_answer(char *output, int maxlen, void *value, int len)
294 struct dundi_answer *answer;
300 answer = (struct dundi_answer *)(value);
301 memcpy(tmp, answer->data, (len >= 500) ? 500 : len - 10);
302 dundi_eid_to_str(eid_str, sizeof(eid_str), &answer->eid);
303 snprintf(output, maxlen, "[%s] %d <%s/%s> from [%s]",
304 dundi_flags2str(flags, sizeof(flags), ntohs(answer->flags)),
305 ntohs(answer->weight),
306 proto2str(answer->protocol, proto, sizeof(proto)),
309 strncpy(output, "Invalid Answer", maxlen - 1);
312 static void dump_encrypted(char *output, int maxlen, void *value, int len)
316 if ((len > 16) && !(len % 16)) {
319 snprintf(iv + (x << 1), 3, "%02x", ((unsigned char *)value)[x]);
321 snprintf(output, maxlen, "[IV %s] %d encrypted blocks\n", iv, len / 16);
323 snprintf(output, maxlen, "Invalid Encrypted Datalen %d", len);
326 static void dump_raw(char *output, int maxlen, void *value, int len)
329 unsigned char *u = value;
330 output[maxlen - 1] = '\0';
331 strcpy(output, "[ ");
332 for (x=0;x<len;x++) {
333 snprintf(output + strlen(output), maxlen - strlen(output) - 1, "%02x ", u[x]);
335 strncat(output + strlen(output), "]", maxlen - strlen(output) - 1);
338 static struct dundi_ie {
341 void (*dump)(char *output, int maxlen, void *value, int len);
343 { DUNDI_IE_EID, "ENTITY IDENT", dump_eid },
344 { DUNDI_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string },
345 { DUNDI_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string },
346 { DUNDI_IE_EID_DIRECT, "DIRECT EID", dump_eid },
347 { DUNDI_IE_ANSWER, "ANSWER", dump_answer },
348 { DUNDI_IE_TTL, "TTL", dump_short },
349 { DUNDI_IE_VERSION, "VERSION", dump_short },
350 { DUNDI_IE_EXPIRATION, "EXPIRATION", dump_short },
351 { DUNDI_IE_UNKNOWN, "UKWN DUNDI CMD", dump_byte },
352 { DUNDI_IE_CAUSE, "CAUSE", dump_cause },
353 { DUNDI_IE_REQEID, "REQUEST EID", dump_eid },
354 { DUNDI_IE_ENCDATA, "ENCDATA", dump_encrypted },
355 { DUNDI_IE_SHAREDKEY, "SHAREDKEY", dump_raw },
356 { DUNDI_IE_SIGNATURE, "SIGNATURE", dump_raw },
357 { DUNDI_IE_KEYCRC32, "KEYCRC32", dump_int },
358 { DUNDI_IE_HINT, "HINT", dump_hint },
359 { DUNDI_IE_DEPARTMENT, "DEPARTMENT", dump_string },
360 { DUNDI_IE_ORGANIZATION, "ORGANIZTN", dump_string },
361 { DUNDI_IE_LOCALITY, "LOCALITY", dump_string },
362 { DUNDI_IE_STATE_PROV, "STATEPROV", dump_string },
363 { DUNDI_IE_COUNTRY, "COUNTRY", dump_string },
364 { DUNDI_IE_EMAIL, "EMAIL", dump_string },
365 { DUNDI_IE_PHONE, "PHONE", dump_string },
366 { DUNDI_IE_IPADDR, "ADDRESS", dump_string },
367 { DUNDI_IE_CACHEBYPASS, "CBYPASS", dump_cbypass },
370 const char *dundi_ie2str(int ie)
373 for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
380 static void dump_ies(unsigned char *iedata, int spaces, int len)
393 /* Encrypted data is the remainder */
394 if (ie == DUNDI_IE_ENCDATA)
396 if (ielen + 2> len) {
397 snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
402 for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
403 if (ies[x].ie == ie) {
405 ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
406 snprintf(tmp, (int)sizeof(tmp), " %s%-15.15s : %s\n", (spaces ? " " : "" ), ies[x].name, interp);
410 snprintf(interp, (int)sizeof(interp), "%d bytes", ielen);
412 strcpy(interp, "Present");
413 snprintf(tmp, (int)sizeof(tmp), " %s%-15.15s : %s\n", (spaces ? " " : "" ), ies[x].name, interp);
420 snprintf(tmp, (int)sizeof(tmp), " %sUnknown IE %03d : Present\n", (spaces ? " " : "" ), ie);
423 iedata += (2 + ielen);
429 void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen)
459 char iabuf[INET_ADDRSTRLEN];
460 if (ntohs(fhi->dtrans) & DUNDI_FLAG_RETRANS)
461 strcpy(retries, "Yes");
463 strcpy(retries, "No");
464 if ((ntohs(fhi->strans) & DUNDI_FLAG_RESERVED)) {
465 /* Ignore frames with high bit set to 1 */
468 if ((fhi->cmdresp & 0x3f) > (int)sizeof(commands)/(int)sizeof(char *)) {
469 snprintf(class2, (int)sizeof(class2), "(%d?)", fhi->cmdresp);
472 class = commands[(int)(fhi->cmdresp & 0x3f)];
474 snprintf(subclass2, (int)sizeof(subclass2), "%02x", fhi->cmdflags);
475 subclass = subclass2;
476 snprintf(tmp, (int)sizeof(tmp),
477 "%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s (%s)\n",
479 retries, fhi->oseqno, fhi->iseqno, class, fhi->cmdresp & 0x40 ? "Response" : "Command");
481 snprintf(tmp, (int)sizeof(tmp),
482 "%s Flags: %s STrans: %5.5d DTrans: %5.5d [%s:%d]%s\n", (rx > 1) ? " " : "",
483 subclass, ntohs(fhi->strans) & ~DUNDI_FLAG_RESERVED, ntohs(fhi->dtrans) & ~DUNDI_FLAG_RETRANS,
484 ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port),
485 fhi->cmdresp & 0x80 ? " (Final)" : "");
487 dump_ies(fhi->ies, rx > 1, datalen);
490 int dundi_ie_append_raw(struct dundi_ie_data *ied, unsigned char ie, void *data, int datalen)
493 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
494 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);
498 ied->buf[ied->pos++] = ie;
499 ied->buf[ied->pos++] = datalen;
500 memcpy(ied->buf + ied->pos, data, datalen);
505 int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, unsigned char *data)
508 int datalen = data ? strlen(data) + 1 : 1;
509 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
510 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);
514 ied->buf[ied->pos++] = ie;
515 ied->buf[ied->pos++] = datalen;
516 ied->buf[ied->pos++] = cause;
517 memcpy(ied->buf + ied->pos, data, datalen-1);
518 ied->pos += datalen-1;
522 int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, unsigned char *data)
525 int datalen = data ? strlen(data) + 2 : 2;
526 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
527 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);
531 ied->buf[ied->pos++] = ie;
532 ied->buf[ied->pos++] = datalen;
533 flags = htons(flags);
534 memcpy(ied->buf + ied->pos, &flags, sizeof(flags));
536 memcpy(ied->buf + ied->pos, data, datalen-1);
537 ied->pos += datalen-2;
541 int dundi_ie_append_encdata(struct dundi_ie_data *ied, unsigned char ie, unsigned char *iv, void *data, int datalen)
545 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
546 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);
550 ied->buf[ied->pos++] = ie;
551 ied->buf[ied->pos++] = datalen;
552 memcpy(ied->buf + ied->pos, iv, 16);
555 memcpy(ied->buf + ied->pos, data, datalen-16);
556 ied->pos += datalen-16;
561 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)
564 int datalen = data ? strlen(data) + 11 : 11;
567 if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
568 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);
572 ied->buf[ied->pos++] = ie;
573 ied->buf[ied->pos++] = datalen;
575 ied->buf[ied->pos++] = eid->eid[x];
576 ied->buf[ied->pos++] = protocol;
578 memcpy(ied->buf + ied->pos, &myw, 2);
581 memcpy(ied->buf + ied->pos, &myw, 2);
583 memcpy(ied->buf + ied->pos, data, datalen-11);
584 ied->pos += datalen-11;
588 int dundi_ie_append_addr(struct dundi_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
590 return dundi_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
593 int dundi_ie_append_int(struct dundi_ie_data *ied, unsigned char ie, unsigned int value)
596 newval = htonl(value);
597 return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
600 int dundi_ie_append_short(struct dundi_ie_data *ied, unsigned char ie, unsigned short value)
602 unsigned short newval;
603 newval = htons(value);
604 return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
607 int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, unsigned char *str)
609 return dundi_ie_append_raw(ied, ie, str, strlen(str));
612 int dundi_ie_append_eid(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid)
614 return dundi_ie_append_raw(ied, ie, (unsigned char *)eid, sizeof(dundi_eid));
617 int dundi_ie_append_byte(struct dundi_ie_data *ied, unsigned char ie, unsigned char dat)
619 return dundi_ie_append_raw(ied, ie, &dat, 1);
622 int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie)
624 return dundi_ie_append_raw(ied, ie, NULL, 0);
627 void dundi_set_output(void (*func)(const char *))
632 void dundi_set_error(void (*func)(const char *))
637 int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen)
639 /* Parse data into information elements */
643 memset(ies, 0, (int)sizeof(struct dundi_ies));
645 ies->expiration = -1;
646 ies->unknowncmd = -1;
648 while(datalen >= 2) {
651 if (len > datalen - 2) {
652 errorf("Information element length exceeds message size\n");
657 case DUNDI_IE_EID_DIRECT:
658 if (len != (int)sizeof(dundi_eid)) {
659 errorf("Improper entity identifer, expecting 6 bytes!\n");
660 } else if (ies->eidcount < DUNDI_MAX_STACK) {
661 ies->eids[ies->eidcount] = (dundi_eid *)(data + 2);
662 ies->eid_direct[ies->eidcount] = (ie == DUNDI_IE_EID_DIRECT);
665 errorf("Too many entities in stack!\n");
667 case DUNDI_IE_REQEID:
668 if (len != (int)sizeof(dundi_eid)) {
669 errorf("Improper requested entity identifer, expecting 6 bytes!\n");
671 ies->reqeid = (dundi_eid *)(data + 2);
673 case DUNDI_IE_CALLED_CONTEXT:
674 ies->called_context = data + 2;
676 case DUNDI_IE_CALLED_NUMBER:
677 ies->called_number = data + 2;
679 case DUNDI_IE_ANSWER:
680 if (len < sizeof(struct dundi_answer)) {
681 snprintf(tmp, (int)sizeof(tmp), "Answer expected to be >=%d bytes long but was %d\n", (int)sizeof(struct dundi_answer), len);
684 if (ies->anscount < DUNDI_MAX_ANSWERS)
685 ies->answers[ies->anscount++]= (struct dundi_answer *)(data + 2);
687 errorf("Ignoring extra answers!\n");
691 if (len != (int)sizeof(unsigned short)) {
692 snprintf(tmp, (int)sizeof(tmp), "Expecting ttl to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
695 ies->ttl = ntohs(*((unsigned short *)(data + 2)));
697 case DUNDI_IE_VERSION:
698 if (len != (int)sizeof(unsigned short)) {
699 snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
702 ies->version = ntohs(*((unsigned short *)(data + 2)));
704 case DUNDI_IE_EXPIRATION:
705 if (len != (int)sizeof(unsigned short)) {
706 snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
709 ies->expiration = ntohs(*((unsigned short *)(data + 2)));
711 case DUNDI_IE_KEYCRC32:
712 if (len != (int)sizeof(unsigned int)) {
713 snprintf(tmp, (int)sizeof(tmp), "Expecting expiration to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
716 ies->keycrc32 = ntohl(*((unsigned int *)(data + 2)));
718 case DUNDI_IE_UNKNOWN:
720 ies->unknowncmd = data[2];
722 snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
728 ies->cause = data[2];
729 ies->causestr = data + 3;
731 snprintf(tmp, (int)sizeof(tmp), "Expected at least one byte cause, but was %d long\n", len);
737 ies->hint = (struct dundi_hint *)(data + 2);
739 snprintf(tmp, (int)sizeof(tmp), "Expected at least two byte hint, but was %d long\n", len);
743 case DUNDI_IE_DEPARTMENT:
744 ies->q_dept = data + 2;
746 case DUNDI_IE_ORGANIZATION:
747 ies->q_org = data + 2;
749 case DUNDI_IE_LOCALITY:
750 ies->q_locality = data + 2;
752 case DUNDI_IE_STATE_PROV:
753 ies->q_stateprov = data + 2;
755 case DUNDI_IE_COUNTRY:
756 ies->q_country = data + 2;
759 ies->q_email = data + 2;
762 ies->q_phone = data + 2;
764 case DUNDI_IE_IPADDR:
765 ies->q_ipaddr = data + 2;
767 case DUNDI_IE_ENCDATA:
768 /* Recalculate len as the remainder of the message, regardless of
769 theoretical length */
771 if ((len > 16) && !(len % 16)) {
772 ies->encblock = (struct dundi_encblock *)(data + 2);
773 ies->enclen = len - 16;
775 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted data length %d\n", len);
779 case DUNDI_IE_SHAREDKEY:
781 ies->encsharedkey = (unsigned char *)(data + 2);
783 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted shared key length %d\n", len);
787 case DUNDI_IE_SIGNATURE:
789 ies->encsig = (unsigned char *)(data + 2);
791 snprintf(tmp, (int)sizeof(tmp), "Invalid encrypted signature length %d\n", len);
795 case DUNDI_IE_CACHEBYPASS:
799 snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", dundi_ie2str(ie), ie, len);
802 /* Overwrite information element with 0, to null terminate previous portion */
804 datalen -= (len + 2);
807 /* Null-terminate last field */
810 errorf("Invalid information element contents, strange boundary\n");