+ unsigned ascii_count = 0, garbage_count = 0;
+ const u_char *v;
+ char tag_str[MAXTAGPRINT];
+ unsigned tag_str_len = 0;
+
+ /* TODO print UTF-8 decoded text */
+ ND_TCHECK_LEN(p, tag_len);
+ for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
+ if (ND_ASCII_ISPRINT(GET_U_1(v))) {
+ tag_str[tag_str_len++] = GET_U_1(v);
+ ascii_count++;
+ } else {
+ tag_str[tag_str_len++] = '.';
+ garbage_count++;
+ }
+ tag_str[tag_str_len] = 0;
+
+ if (ascii_count > garbage_count) {
+ ND_PRINT(" [%s \"%*.*s\"]",
+ tok2str(pppoetag2str, "TAG-0x%x", tag_type),
+ (int)tag_str_len,
+ (int)tag_str_len,
+ tag_str);
+ } else {
+ /* Print hex, not fast to abuse printf but this doesn't get used much */
+ ND_PRINT(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ for (v=p; v<p+tag_len; v++) {
+ ND_PRINT("%02X", GET_U_1(v));