コード例 #1
0
static const u_char *
c_print(register const u_char *s, register const u_char *ep)
{
	register u_char c;
	register int flag;

	flag = 1;
	while (s < ep) {
		c = *s++;
		if (c == '\0') {
			flag = 0;
			break;
		}
		if (!ND_ISASCII(c)) {
			c = ND_TOASCII(c);
			putchar('M');
			putchar('-');
		}
		if (!ND_ISPRINT(c)) {
			c ^= 0x40;	/* DEL to ?, others to alpha */
			putchar('^');
		}
		putchar(c);
	}
	if (flag)
		return NULL;
	return (s);
}
コード例 #2
0
ファイル: util-print.c プロジェクト: RichardsonAlex/cheribsd
/*
 * Print out a null-terminated filename (or other ascii string).
 * If ep is NULL, assume no truncation check is needed.
 * Return true if truncated.
 */
int
fn_print(netdissect_options *ndo,
         register const u_char *s, register const u_char *ep)
{
	register int ret;
	register u_char c;

	ret = 1;			/* assume truncated */
	while (ep == NULL || s < ep) {
		c = *s++;
		if (c == '\0') {
			ret = 0;
			break;
		}
		if (!ND_ISASCII(c)) {
			c = ND_TOASCII(c);
			ND_PRINT((ndo, "M-"));
		}
		if (!ND_ISPRINT(c)) {
			c ^= 0x40;	/* DEL to ?, others to alpha */
			ND_PRINT((ndo, "^"));
		}
		ND_PRINT((ndo, "%c", c));
	}
	return(ret);
}
コード例 #3
0
ファイル: print-krb.c プロジェクト: RTEMS/rtems-libbsd
static const u_char *
c_print(netdissect_options *ndo,
        register const u_char *s, register const u_char *ep)
{
	register u_char c;
	register int flag;

	flag = 1;
	while (s < ep) {
		c = *s++;
		if (c == '\0') {
			flag = 0;
			break;
		}
		if (!ND_ISASCII(c)) {
			c = ND_TOASCII(c);
			ND_PRINT((ndo, "M-"));
		}
		if (!ND_ISPRINT(c)) {
			c ^= 0x40;	/* DEL to ?, others to alpha */
			ND_PRINT((ndo, "^"));
		}
		ND_PRINT((ndo, "%c", c));
	}
	if (flag)
		return NULL;
	return (s);
}
コード例 #4
0
ファイル: parsenfsfh.c プロジェクト: fenner/tcpdump
/*
 * Is this a VMS UCX file handle?
 *	Check for:
 *	(1) leading code byte	[XXX not yet]
 *	(2) followed by string of printing chars & spaces
 *	(3) followed by string of nulls
 */
static int
is_UCX(netdissect_options *ndo, const unsigned char *fhp, u_int len)
{
	u_int i;
	int seen_null = 0;

	/*
	 * Require at least 28 bytes of file handle; it's variable-length
	 * in NFSv3.  "len" is in units of 32-bit words, not bytes.
	 */
	if (len < 28/4)
		return(0);

	for (i = 1; i < 14; i++) {
	    if (ND_ISPRINT(GET_U_1(fhp + i))) {
		if (seen_null)
		   return(0);
		else
		   continue;
	    }
	    else if (GET_U_1(fhp + i) == 0) {
		seen_null = 1;
		continue;
	    }
	    else
		return(0);
	}

	return(1);
}
コード例 #5
0
ファイル: print-radius.c プロジェクト: biot/tcpdump
static void
print_attr_string(netdissect_options *ndo,
                  const u_char *data, u_int length, u_short attr_code)
{
   u_int i;

   ND_TCHECK_LEN(data, length);

   switch(attr_code)
   {
      case TUNNEL_PASS:
           if (length < 3)
              goto trunc;
           if (EXTRACT_U_1(data) && (EXTRACT_U_1(data) <= 0x1F))
              ND_PRINT("Tag[%u] ", EXTRACT_U_1(data));
           else
              ND_PRINT("Tag[Unused] ");
           data++;
           length--;
           ND_PRINT("Salt %u ", EXTRACT_BE_U_2(data));
           data+=2;
           length-=2;
        break;
      case TUNNEL_CLIENT_END:
      case TUNNEL_SERVER_END:
      case TUNNEL_PRIV_GROUP:
      case TUNNEL_ASSIGN_ID:
      case TUNNEL_CLIENT_AUTH:
      case TUNNEL_SERVER_AUTH:
           if (EXTRACT_U_1(data) <= 0x1F)
           {
              if (length < 1)
                 goto trunc;
              if (EXTRACT_U_1(data))
                ND_PRINT("Tag[%u] ", EXTRACT_U_1(data));
              else
                ND_PRINT("Tag[Unused] ");
              data++;
              length--;
           }
        break;
      case EGRESS_VLAN_NAME:
           if (length < 1)
              goto trunc;
           ND_PRINT("%s (0x%02x) ",
                  tok2str(rfc4675_tagged,"Unknown tag",EXTRACT_U_1(data)),
                  EXTRACT_U_1(data));
           data++;
           length--;
        break;
   }

   for (i=0; i < length && EXTRACT_U_1(data); i++, data++)
       ND_PRINT("%c", ND_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');

   return;

   trunc:
      nd_print_trunc(ndo);
}
コード例 #6
0
ファイル: print-radius.c プロジェクト: biot/tcpdump
/*
 * print vendor specific attributes
 */
static void
print_vendor_attr(netdissect_options *ndo,
                  const u_char *data, u_int length, u_short attr_code _U_)
{
    u_int idx;
    u_int vendor_id;
    u_int vendor_type;
    u_int vendor_length;

    if (length < 4)
        goto trunc;
    ND_TCHECK_4(data);
    vendor_id = EXTRACT_BE_U_4(data);
    data+=4;
    length-=4;

    ND_PRINT("Vendor: %s (%u)",
           tok2str(smi_values,"Unknown",vendor_id),
           vendor_id);

    while (length >= 2) {
	ND_TCHECK_2(data);

        vendor_type = EXTRACT_U_1(data);
        vendor_length = EXTRACT_U_1(data + 1);

        if (vendor_length < 2)
        {
            ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
                   vendor_type,
                   vendor_length);
            return;
        }
        if (vendor_length > length)
        {
            ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
                   vendor_type,
                   vendor_length);
            return;
        }
        data+=2;
        vendor_length-=2;
        length-=2;
	ND_TCHECK_LEN(data, vendor_length);

        ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u, Value: ",
               vendor_type,
               vendor_length);
        for (idx = 0; idx < vendor_length ; idx++, data++)
            ND_PRINT("%c", ND_ISPRINT(EXTRACT_U_1(data)) ? EXTRACT_U_1(data) : '.');
        length-=vendor_length;
    }
    return;

   trunc:
     nd_print_trunc(ndo);
}
コード例 #7
0
ファイル: util-print.c プロジェクト: spirgiuz/tcpdump
/*
 * Print out a character, filtering out the non-printable ones
 */
void
fn_print_char(netdissect_options *ndo, u_char c)
{
    if (!ND_ISASCII(c)) {
        c = ND_TOASCII(c);
        ND_PRINT((ndo, "M-"));
    }
    if (!ND_ISPRINT(c)) {
        c ^= 0x40;	/* DEL to ?, others to alpha */
        ND_PRINT((ndo, "^"));
    }
    ND_PRINT((ndo, "%c", c));
}
コード例 #8
0
ファイル: print-rip.c プロジェクト: Longinus00/tcpdump
static unsigned
rip_entry_print_v2(netdissect_options *ndo,
                   register const struct rip_netinfo *ni, const unsigned remaining)
{
	register u_short family;

	family = EXTRACT_16BITS(&ni->rip_family);
	if (family == 0xFFFF) { /* variable-sized authentication structures */
		uint16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
		if (auth_type == 2) {
			register u_char *p = (u_char *)&ni->rip_dest;
			u_int i = 0;
			ND_PRINT((ndo, "\n\t  Simple Text Authentication data: "));
			for (; i < RIP_AUTHLEN; p++, i++)
				ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
		} else if (auth_type == 3) {
			ND_PRINT((ndo, "\n\t  Auth header:"));
			ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((uint8_t *)ni + 4)));
			ND_PRINT((ndo, " Key-ID %u,", *((uint8_t *)ni + 6)));
			ND_PRINT((ndo, " Auth Data Len %u,", *((uint8_t *)ni + 7)));
			ND_PRINT((ndo, " SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask)));
			ND_PRINT((ndo, " MBZ %u,", EXTRACT_32BITS(&ni->rip_router)));
			ND_PRINT((ndo, " MBZ %u", EXTRACT_32BITS(&ni->rip_metric)));
		} else if (auth_type == 1) {
			ND_PRINT((ndo, "\n\t  Auth trailer:"));
			print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t  ", remaining);
			return remaining; /* AT spans till the packet end */
		} else {
			ND_PRINT((ndo, "\n\t  Unknown (%u) Authentication data:",
			       EXTRACT_16BITS(&ni->rip_tag)));
			print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t  ", remaining);
		}
	} else if (family != BSD_AFNUM_INET && family != 0) {
		ND_PRINT((ndo, "\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)));
                print_unknown_data(ndo, (uint8_t *)&ni->rip_tag, "\n\t  ", RIP_ROUTELEN-2);
	} else { /* BSD_AFNUM_INET or AFI 0 */
		ND_PRINT((ndo, "\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
                       tok2str(bsd_af_values, "%u", family),
                       ipaddr_string(ndo, &ni->rip_dest),
		       mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
                       EXTRACT_16BITS(&ni->rip_tag),
                       EXTRACT_32BITS(&ni->rip_metric)));
		if (EXTRACT_32BITS(&ni->rip_router))
			ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ni->rip_router)));
		else
			ND_PRINT((ndo, "self"));
	}
	return sizeof (*ni);
}
コード例 #9
0
ファイル: util-print.c プロジェクト: RichardsonAlex/cheribsd
/*
 * Print out a counted filename (or other ascii string).
 * If ep is NULL, assume no truncation check is needed.
 * Return true if truncated.
 */
int
fn_printn(netdissect_options *ndo,
          register const u_char *s, register u_int n, register const u_char *ep)
{
	register u_char c;

	while (n > 0 && (ep == NULL || s < ep)) {
		n--;
		c = *s++;
		if (!ND_ISASCII(c)) {
			c = ND_TOASCII(c);
			ND_PRINT((ndo, "M-"));
		}
		if (!ND_ISPRINT(c)) {
			c ^= 0x40;	/* DEL to ?, others to alpha */
			ND_PRINT((ndo, "^"));
		}
		ND_PRINT((ndo, "%c", c));
	}
	return (n == 0) ? 0 : 1;
}
コード例 #10
0
ファイル: util-print.c プロジェクト: RichardsonAlex/cheribsd
void
safeputchar(netdissect_options *ndo,
            const u_char c)
{
	ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
}