Beispiel #1
0
static void dccp_print_ack_no(const u_char *bp)
{
	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
	const struct dccp_hdr_ack_bits *dh_ack =
		(struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
	u_int32_t ack_high;
	u_int64_t ackno;

	TCHECK2(*dh_ack,4);
	ack_high = DCCPH_ACK(dh_ack);
	ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;

	if (DCCPH_X(dh) != 0) {
		u_int32_t ack_low;

		TCHECK2(*dh_ack,8);
		ack_low = dh_ack->dccph_ack_nr_low;

		ackno &= 0x00FFFF;  /* clear reserved field */
		ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
	}

	(void)printf("(ack=%" PRIu64 ") ", ackno);
trunc:
	return;
}
Beispiel #2
0
static int
print_neighbors(register const u_char *bp, register const u_char *ep,
    register u_int len)
{
	const u_char *laddr;
	register u_char metric;
	register u_char thresh;
	register int ncount;

	while (len > 0 && bp < ep) {
		TCHECK2(bp[0], 7);
		laddr = bp;
		bp += 4;
		metric = *bp++;
		thresh = *bp++;
		ncount = *bp++;
		len -= 7;
		while (--ncount >= 0) {
			TCHECK2(bp[0], 4);
			printf(" [%s ->", ipaddr_string(laddr));
			printf(" %s, (%d/%d)]",
				   ipaddr_string(bp), metric, thresh);
			bp += 4;
			len -= 4;
		}
	}
	return (0);
trunc:
	return (-1);
}
/* [OF10] Section 5.4.4 */
static const u_char *
of10_error_print(const u_char *cp, const u_char *ep, const u_int len) {
	uint16_t type;
	const struct tok *code_str;

	/* type */
	TCHECK2(*cp, 2);
	type = EXTRACT_16BITS(cp);
	cp += 2;
	printf("\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type));
	/* code */
	TCHECK2(*cp, 2);
	code_str =
		type == OFPET_HELLO_FAILED    ? ofphfc_str  :
		type == OFPET_BAD_REQUEST     ? ofpbrc_str  :
		type == OFPET_BAD_ACTION      ? ofpbac_str  :
		type == OFPET_FLOW_MOD_FAILED ? ofpfmfc_str :
		type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
		type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
		empty_str;
	printf(", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp)));
	cp += 2;
	/* data */
	return of10_data_print(cp, ep, len - sizeof(struct ofp_error_msg));

trunc:
	printf(" [|openflow]");
	return ep;
}
static void
print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
{
    u_int bcc;
    const char *f1, *f2, *f3, *f4;
    const u_char *data, *param;
    const u_char *w = words + 1;
    int datalen, paramlen;

    if (request) {
	TCHECK2(w[12 * 2], 2);
	paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
	param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
	datalen = EXTRACT_LE_16BITS(w + 11 * 2);
	data = buf + EXTRACT_LE_16BITS(w + 12 * 2);
	f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
	f2 = "|Name=[S]\n";
	f3 = "|Param ";
	f4 = "|Data ";
    } else {
	TCHECK2(w[7 * 2], 2);
	paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
	param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
	datalen = EXTRACT_LE_16BITS(w + 6 * 2);
	data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
	f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
	f2 = "|Unknown ";
	f3 = "|Param ";
	f4 = "|Data ";
    }

    smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf),
        unicodestr);

    TCHECK2(*data1, 2);
    bcc = EXTRACT_LE_16BITS(data1);
    printf("smb_bcc=%u\n", bcc);
    if (bcc > 0) {
	smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);

	if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
	    print_browse(param, paramlen, data, datalen);
	    return;
	}

	if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
	    print_ipc(param, paramlen, data, datalen);
	    return;
	}

	if (paramlen)
	    smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr);
	if (datalen)
	    smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr);
    }
    return;
trunc:
    printf("[|SMB]");
    return;
}
static int
ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
{
	const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
	u_int wordlen;
	struct in6_addr prefix;

	if (lsa_length < sizeof (*lsapp) - 4)
		goto trunc;
	lsa_length -= sizeof (*lsapp) - 4;
	TCHECK2(*lsapp, sizeof (*lsapp) - 4);
	wordlen = (lsapp->lsa_p_len + 31) / 32;
	if (wordlen * 4 > sizeof(struct in6_addr)) {
		printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
		goto trunc;
	}
	if (lsa_length < wordlen * 4)
		goto trunc;
	lsa_length -= wordlen * 4;
	TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
	memset(&prefix, 0, sizeof(prefix));
	memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
	printf("\n\t\t%s/%d", ip6addr_string(&prefix),
		lsapp->lsa_p_len);
        if (lsapp->lsa_p_opt) {
            printf(", Options [%s]",
                   bittok2str(ospf6_lsa_prefix_option_values,
                              "none", lsapp->lsa_p_opt));
        }
        printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric));
	return sizeof(*lsapp) - 4 + wordlen * 4;

trunc:
	return -1;
}
/* [OF10] Section 5.4.1 */
static const u_char *
of10_packet_in_print(const u_char *cp, const u_char *ep, const u_int len) {
	/* buffer_id */
	TCHECK2(*cp, 4);
	printf("\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp)));
	cp += 4;
	/* total_len */
	TCHECK2(*cp, 2);
	printf(", total_len %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* in_port */
	TCHECK2(*cp, 2);
	printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
	cp += 2;
	/* reason */
	TCHECK2(*cp, 1);
	printf(", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp));
	cp += 1;
	/* pad */
	TCHECK2(*cp, 1);
	cp += 1;
	/* data */
	/* 2 mock octets count in sizeof() but not in len */
	return of10_data_print(cp, ep, len - (sizeof(struct ofp_packet_in) - 2));

trunc:
	printf(" [|openflow]");
	return ep;
}
/* [OF10] Section 5.3.6 */
static const u_char *
of10_packet_out_print(const u_char *cp, const u_char *ep, const u_int len) {
	const u_char *cp0 = cp;
	const u_int len0 = len;
	uint16_t actions_len;

	/* buffer_id */
	TCHECK2(*cp, 4);
	printf("\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp));
	cp += 4;
	/* in_port */
	TCHECK2(*cp, 2);
	printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
	cp += 2;
	/* actions_len */
	TCHECK2(*cp, 2);
	actions_len = EXTRACT_16BITS(cp);
	cp += 2;
	if (actions_len > len - sizeof(struct ofp_packet_out))
		goto corrupt;
	/* actions */
	if (ep == (cp = of10_actions_print("\n\t ", cp, ep, actions_len)))
		return ep; /* end of snapshot */
	/* data */
	return of10_data_print(cp, ep, len - sizeof(struct ofp_packet_out) - actions_len);

corrupt: /* skip the rest of the message body */
	printf(" (corrupt)");
	TCHECK2(*cp0, len0);
	return cp0 + len0;
trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #8
0
static int
print_probe(register const u_char *bp, register const u_char *ep,
    register u_int len)
{
	register u_int32_t genid;

	TCHECK2(bp[0], 4);
	if ((len < 4) || ((bp + 4) > ep)) {
		/* { (ctags) */
		printf(" [|}");
		return (0);
	}
	genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
	bp += 4;
	len -= 4;
	if (vflag > 1)
		printf("\n\t");
	else
		printf(" ");
	printf("genid %u", genid);
	if (vflag < 2)
		return (0);

	while ((len > 0) && (bp < ep)) {
		TCHECK2(bp[0], 4);
		printf("\n\tneighbor %s", ipaddr_string(bp));
		bp += 4; len -= 4;
	}
	return (0);
trunc:
	return (-1);
}
/* ibid */
static const u_char *
of10_aggregate_stats_reply_print(const u_char *cp, const u_char *ep,
                                 const u_int len) {
	if (len != sizeof(struct ofp_aggregate_stats_reply))
		goto corrupt;
	/* packet_count */
	TCHECK2(*cp, 8);
	printf("\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp));
	cp += 8;
	/* byte_count */
	TCHECK2(*cp, 8);
	printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
	cp += 8;
	/* flow_count */
	TCHECK2(*cp, 4);
	printf(", flow_count %u", EXTRACT_32BITS(cp));
	cp += 4;
	/* pad */
	TCHECK2(*cp, 4);
	return cp + 4;

corrupt: /* skip the message body */
	printf(" (corrupt)");
	TCHECK2(*cp, len);
	return cp + len;
trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #10
0
static void
print_vendor_attr(register 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;
    TCHECK2(*data, 4);
    vendor_id = EXTRACT_32BITS(data);
    data+=4;
    length-=4;

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

    while (length >= 2) {
	TCHECK2(*data, 2);

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

        if (vendor_length < 2)
        {
            printf("\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
                   vendor_type,
                   vendor_length);
            return;
        }
        if (vendor_length > length)
        {
            printf("\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;
	TCHECK2(*data, vendor_length);

        printf("\n\t    Vendor Attribute: %u, Length: %u, Value: ",
               vendor_type,
               vendor_length);
        for (idx = 0; idx < vendor_length ; idx++, data++)
            printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
        length-=vendor_length;
    }
    return;

   trunc:
     printf(" [|radius]");
}
Beispiel #11
0
/* ibid */
static const u_char *
of10_table_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
	const u_char *cp0 = cp;
	const u_int len0 = len;

	while (len) {
		if (len < sizeof(struct ofp_table_stats))
			goto corrupt;
		/* table_id */
		TCHECK2(*cp, 1);
		printf("\n\t table_id %s", tok2str(tableid_str, "%u", *cp));
		cp += 1;
		/* pad */
		TCHECK2(*cp, 3);
		cp += 3;
		/* name */
		TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
		printf(", name '");
		fn_print(cp, cp + OFP_MAX_TABLE_NAME_LEN);
		printf("'");
		cp += OFP_MAX_TABLE_NAME_LEN;
		/* wildcards */
		TCHECK2(*cp, 4);
		printf("\n\t  wildcards 0x%08x", EXTRACT_32BITS(cp));
		of10_bitmap_print(ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
		cp += 4;
		/* max_entries */
		TCHECK2(*cp, 4);
		printf("\n\t  max_entries %u", EXTRACT_32BITS(cp));
		cp += 4;
		/* active_count */
		TCHECK2(*cp, 4);
		printf(", active_count %u", EXTRACT_32BITS(cp));
		cp += 4;
		/* lookup_count */
		TCHECK2(*cp, 8);
		printf(", lookup_count %" PRIu64, EXTRACT_64BITS(cp));
		cp += 8;
		/* matched_count */
		TCHECK2(*cp, 8);
		printf(", matched_count %" PRIu64, EXTRACT_64BITS(cp));
		cp += 8;

		len -= sizeof(struct ofp_table_stats);
	} /* while */
	return cp;

corrupt: /* skip the undersized trailing data */
	printf(" (corrupt)");
	TCHECK2(*cp0, len0);
	return cp0 + len0;
trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #12
0
/* [OF10] Section 5.4.2 */
static const u_char *
of10_flow_removed_print(const u_char *cp, const u_char *ep) {
	/* match */
	if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
		return ep; /* end of snapshot */
	/* cookie */
	TCHECK2(*cp, 8);
	printf("\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
	cp += 8;
	/* priority */
	TCHECK2(*cp, 2);
	if (EXTRACT_16BITS(cp))
		printf(", priority %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* reason */
	TCHECK2(*cp, 1);
	printf(", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp));
	cp += 1;
	/* pad */
	TCHECK2(*cp, 1);
	cp += 1;
	/* duration_sec */
	TCHECK2(*cp, 4);
	printf(", duration_sec %u", EXTRACT_32BITS(cp));
	cp += 4;
	/* duration_nsec */
	TCHECK2(*cp, 4);
	printf(", duration_nsec %u", EXTRACT_32BITS(cp));
	cp += 4;
	/* idle_timeout */
	TCHECK2(*cp, 2);
	if (EXTRACT_16BITS(cp))
		printf(", idle_timeout %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* pad2 */
	TCHECK2(*cp, 2);
	cp += 2;
	/* packet_count */
	TCHECK2(*cp, 8);
	printf(", packet_count %" PRIu64, EXTRACT_64BITS(cp));
	cp += 8;
	/* byte_count */
	TCHECK2(*cp, 8);
	printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
	return cp + 8;

trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #13
0
static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_)
{
   time_t attr_time;
   char string[26];
   const char *p;

   if (length != 4)
   {
       printf("ERROR: length %u != 4", length);
       return;
   }

   TCHECK2(data[0],4);

   attr_time = EXTRACT_32BITS(data);
   if ((p = ctime(&attr_time)) == NULL)
	p = "?";
   strlcpy(string, p, sizeof(string));
   /* Get rid of the newline */
   string[24] = '\0';
   printf("%.24s", string);
   return;

   trunc:
     printf(" [|radius]");
}
Beispiel #14
0
/*
 * Print out a file name and return pointer to 32-bit word past it.
 * If packet was truncated, return 0.
 */
static const u_int32_t *
parsefn(register const u_int32_t *dp)
{
	register u_int32_t len;
	register const u_char *cp;

	/* Bail if we don't have the string length */
	TCHECK(*dp);

	/* Fetch string length; convert to host order */
	len = *dp++;
	NTOHL(len);

	TCHECK2(*dp, ((len + 3) & ~3));

	cp = (u_char *)dp;
	/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
	dp += ((len + 3) & ~3) / sizeof(*dp);
	putchar('"');
	if (fn_printn(cp, len, snapend)) {
		putchar('"');
		goto trunc;
	}
	putchar('"');

	return (dp);
trunc:
	return NULL;
}
Beispiel #15
0
/*
 * Return a pointer to the first file handle in the packet.
 * If the packet was truncated, return 0.
 */
static const u_int32_t *
parsereq(register const struct sunrpc_msg *rp, register u_int length)
{
	register const u_int32_t *dp;
	register u_int len;

	/*
	 * find the start of the req data (if we captured it)
	 */
	dp = (u_int32_t *)&rp->rm_call.cb_cred;
	TCHECK(dp[1]);
	len = EXTRACT_32BITS(&dp[1]);
	if (len < length) {
		dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
		TCHECK(dp[1]);
		len = EXTRACT_32BITS(&dp[1]);
		if (len < length) {
			dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
			TCHECK2(dp[0], 0);
			return (dp);
		}
	}
trunc:
	return (NULL);
}
static const u_char *
isakmp_sa_print(const struct isakmp_gen *ext,
		u_int item_len _U_,
		const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
		u_int32_t proto0, int depth)
{
	const struct isakmp_pl_sa *p;
	struct isakmp_pl_sa sa;
	const u_int32_t *q;
	u_int32_t doi, sit, ident;
	const u_char *cp, *np;
	int t;

	printf("%s:", NPSTR(ISAKMP_NPTYPE_SA));

	p = (struct isakmp_pl_sa *)ext;
	TCHECK(*p);
	safememcpy(&sa, ext, sizeof(sa));
	doi = ntohl(sa.doi);
	sit = ntohl(sa.sit);
	if (doi != 1) {
		printf(" doi=%d", doi);
		printf(" situation=%u", (u_int32_t)ntohl(sa.sit));
		return (u_char *)(p + 1);
	}

	printf(" doi=ipsec");
	q = (u_int32_t *)&sa.sit;
	printf(" situation=");
	t = 0;
	if (sit & 0x01) {
		printf("identity");
		t++;
	}
	if (sit & 0x02) {
		printf("%ssecrecy", t ? "+" : "");
		t++;
	}
	if (sit & 0x04)
		printf("%sintegrity", t ? "+" : "");

	np = (u_char *)ext + sizeof(sa);
	if (sit != 0x01) {
		TCHECK2(*(ext + 1), sizeof(ident));
		safememcpy(&ident, ext + 1, sizeof(ident));
		printf(" ident=%u", (u_int32_t)ntohl(ident));
		np += sizeof(ident);
	}

	ext = (struct isakmp_gen *)np;
	TCHECK(*ext);

	cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0,
		depth);

	return cp;
trunc:
	printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SA));
	return NULL;
}
Beispiel #17
0
static int
print_l2_routes(const char *rp, u_int len)
{
	int count;
	int area;
	int info;

	/* The last short is a checksum */
	while (len > (3 * sizeof(short))) {
	    TCHECK2(*rp, 3 * sizeof(short));
	    count = EXTRACT_LE_16BITS(rp);
	    if (count > 1024)
		return (1);	/* seems to be bogus from here on */
	    rp += sizeof(short);
	    len -= sizeof(short);
	    area = EXTRACT_LE_16BITS(rp);
	    rp += sizeof(short);
	    len -= sizeof(short);
	    info = EXTRACT_LE_16BITS(rp);
	    rp += sizeof(short);
	    len -= sizeof(short);
	    (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
			    RI_COST(info), RI_HOPS(info));
	}
	return (1);

trunc:
	return (0);
}
Beispiel #18
0
static void
print_attr_address(register u_char *data, u_int length, u_short attr_code )
{
   if (length != 4)
   {
       printf("ERROR: length %u != 4", length);
       return;
   }

   TCHECK2(data[0],4);

   switch(attr_code)
   {
      case FRM_IPADDR:
      case LOG_IPHOST:
           if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
              printf("User Selected");
           else
              if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
                 printf("NAS Select");
              else
                 printf("%s",ipaddr_string(data));
      break;

      default:
          printf("%s",ipaddr_string(data) );
      break;
   }

   return;

   trunc:
     printf(" [|radius]");
}
Beispiel #19
0
void
babel_print(const u_char *cp, u_int length) {
    printf("babel");

    TCHECK2(*cp, 4);

    if(cp[0] != 42) {
        printf(" malformed header");
        return;
    } else {
        printf(" %d", cp[1]);
    }

    switch(cp[1]) {
    case 2:
        babel_print_v2(cp,length);
        break;
    default:
        printf(" unknown version");
        break;
    }

    return;

 trunc:
    printf(" [|babel]");
    return;
}
void
rpki_rtr_print(register const u_char *pptr, register u_int len) {

    u_int tlen, pdu_type, pdu_len;
    const u_char *tptr;
    const rpki_rtr_pdu *pdu_header;

    tptr = pptr;
    tlen = len;

    if (!vflag) {
        printf(", RPKI-RTR");
        return;
    }

    while (tlen >= sizeof(rpki_rtr_pdu)) {

        TCHECK2(*tptr, sizeof(rpki_rtr_pdu));

        pdu_header = (rpki_rtr_pdu *)tptr;
        pdu_type = pdu_header->pdu_type;
        pdu_len = EXTRACT_32BITS(pdu_header->length);

        /* infinite loop check */
        if (!pdu_type || !pdu_len) {
            break;
        }

        TCHECK2(*tptr, pdu_len);
        if (tlen < pdu_len) {
            goto trunc;
        }

        /*
         * Print the PDU.
         */
        rpki_rtr_pdu_print(tptr, 8);

        tlen -= pdu_len;
        tptr += pdu_len;
    }
    return;
trunc:
    printf("\n\t[|RPKI-RTR]");
}
Beispiel #21
0
static void dccp_print_ack_no(const u_char *bp)
{
	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
	const u_char *ackp = bp + dccp_basic_hdr_len(dh);
	u_int64_t ackno;

	if (DCCPH_X(dh) != 0) {
		TCHECK2(*ackp, 8);
		ackno = EXTRACT_48BITS(ackp + 2);
	} else {
		TCHECK2(*ackp, 4);
		ackno = EXTRACT_24BITS(ackp + 1);
	}

	(void)printf("(ack=%" PRIu64 ") ", ackno);
trunc:
	return;
}
Beispiel #22
0
static int
print_graft_ack(register const u_char *bp)
{
	TCHECK2(bp[0], 8);
	printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
	return (0);
trunc:
	return (-1);
}
Beispiel #23
0
/* ibid */
static const u_char *
of10_queues_print(const u_char *cp, const u_char *ep, u_int len) {
	const u_char *cp0 = cp;
	const u_int len0 = len;
	uint16_t desclen;

	while (len) {
		if (len < sizeof(struct ofp_packet_queue))
			goto corrupt;
		/* queue_id */
		TCHECK2(*cp, 4);
		printf("\n\t  queue_id %u", EXTRACT_32BITS(cp));
		cp += 4;
		/* len */
		TCHECK2(*cp, 2);
		desclen = EXTRACT_16BITS(cp);
		cp += 2;
		printf(", len %u", desclen);
		if (desclen < sizeof(struct ofp_packet_queue) || desclen > len)
			goto corrupt;
		/* pad */
		TCHECK2(*cp, 2);
		cp += 2;
		/* properties */
		if (vflag < 2) {
			TCHECK2(*cp, desclen - sizeof(struct ofp_packet_queue));
			cp += desclen - sizeof(struct ofp_packet_queue);
			goto next_queue;
		}
		if (ep == (cp = of10_queue_props_print(cp, ep, desclen - sizeof(struct ofp_packet_queue))))
			return ep; /* end of snapshot */
next_queue:
		len -= desclen;
	} /* while */
	return cp;

corrupt: /* skip the rest of queues */
	printf(" (corrupt)");
	TCHECK2(*cp0, len0);
	return cp0 + len0;
trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #24
0
/* [OF10] Section 5.3.3 */
static const u_char *
of10_flow_mod_print(const u_char *cp, const u_char *ep, const u_int len) {
	uint16_t command;

	/* match */
	if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
		return ep; /* end of snapshot */
	/* cookie */
	TCHECK2(*cp, 8);
	printf("\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
	cp += 8;
	/* command */
	TCHECK2(*cp, 2);
	command = EXTRACT_16BITS(cp);
	printf(", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command));
	cp += 2;
	/* idle_timeout */
	TCHECK2(*cp, 2);
	if (EXTRACT_16BITS(cp))
		printf(", idle_timeout %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* hard_timeout */
	TCHECK2(*cp, 2);
	if (EXTRACT_16BITS(cp))
		printf(", hard_timeout %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* priority */
	TCHECK2(*cp, 2);
	if (EXTRACT_16BITS(cp))
		printf(", priority %u", EXTRACT_16BITS(cp));
	cp += 2;
	/* buffer_id */
	TCHECK2(*cp, 4);
	if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
	    command == OFPFC_MODIFY_STRICT)
		printf(", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp)));
	cp += 4;
	/* out_port */
	TCHECK2(*cp, 2);
	if (command == OFPFC_DELETE || command == OFPFC_DELETE_STRICT)
		printf(", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
	cp += 2;
	/* flags */
	TCHECK2(*cp, 2);
	printf(", flags 0x%04x", EXTRACT_16BITS(cp));
	of10_bitmap_print(ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
	cp += 2;
	/* actions */
	return of10_actions_print("\n\t ", cp, ep, len - sizeof(struct ofp_flow_mod));

trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #25
0
static int 
print_report(register const u_char *bp, register const u_char *ep,
    register u_int len)
{
	register u_int32_t mask, origin;
	register int metric, done;
	register u_int i, width;

	while (len > 0) {
		if (len < 3) {
			printf(" [|]");
			return (0);
		}
		TCHECK2(bp[0], 3);
		mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
		width = 1;
		if (bp[0])
			width = 2;
		if (bp[1])
			width = 3;
		if (bp[2])
			width = 4;

		printf("\n\tMask %s", intoa(htonl(mask)));
		bp += 3;
		len -= 3;
		do {
			if (bp + width + 1 > ep) {
				printf(" [|]");
				return (0);
			}
			if (len < width + 1) {
				printf("\n\t  [Truncated Report]");
				return (0);
			}
			origin = 0;
			for (i = 0; i < width; ++i) {
				TCHECK(*bp);
				origin = origin << 8 | *bp++;
			}
			for ( ; i < 4; ++i)
				origin <<= 8;

			TCHECK(*bp);
			metric = *bp++;
			done = metric & 0x80;
			metric &= 0x7f;
			printf("\n\t  %s metric %d", intoa(htonl(origin)),
				metric);
			len -= width + 1;
		} while (!done);
	}
	return (0);
trunc:
	return (-1);
}
Beispiel #26
0
/* Vendor ID is mandatory, data is optional. */
static const u_char *
of10_vendor_data_print(const u_char *cp, const u_char *ep, const u_int len) {
	if (len < 4)
		goto corrupt;
	/* vendor */
	TCHECK2(*cp, 4);
	printf(", vendor 0x%08x", EXTRACT_32BITS(cp));
	cp += 4;
	/* data */
	return of10_data_print(cp, ep, len - 4);

corrupt: /* skip the undersized data */
	printf(" (corrupt)");
	TCHECK2(*cp, len);
	return cp + len;
trunc:
	printf(" [|openflow]");
	return ep;
}
Beispiel #27
0
int
asttlv_print(register const u_char * pptr, register u_int len,
	     u_int16_t op_msk _U_, int indent)
{
	u_int32_t rescode;
	u_int dlen;
	char *ib = indent_pr(indent, 0);

	/*
	 * forces_type_print() has ensured that len (the TLV length)
	 * >= TLV_HDRL.
	 */
	dlen = len - TLV_HDRL;
	if (dlen != ASTDLN) {
		printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
		return -1;
	}
	TCHECK2(*pptr, 4);
	rescode = EXTRACT_32BITS(pptr);
	if (rescode > ASTMCD) {
		printf("illegal ASTresult result code: %d!\n", rescode);
		return -1;
	}

	if (vflag >= 3) {
		printf("Teardown reason:\n%s", ib);
		switch (rescode) {
		case 0:
			printf("Normal Teardown");
			break;
		case 1:
			printf("Loss of Heartbeats");
			break;
		case 2:
			printf("Out of bandwidth");
			break;
		case 3:
			printf("Out of Memory");
			break;
		case 4:
			printf("Application Crash");
			break;
		default:
			printf("Unknown Teardown reason");
			break;
		}
		printf("(%x)\n%s", rescode, ib);
	}
	return 0;

trunc:
	fputs("[|forces]", stdout);
	return -1;
}
Beispiel #28
0
const u_char *
krb4_print_hdr(const u_char *cp)
{
	cp += 2;

#define PRINT		if ((cp = c_print(cp, snapend)) == NULL) goto trunc

	TCHECK2(cp, 0);
	PRINT;
	TCHECK2(cp, 0);
	putchar('.'); PRINT;
	TCHECK2(cp, 0);
	putchar('@'); PRINT;
	return(cp);

trunc:
	fputs(tstr, stdout);
	return (NULL);

#undef PRINT
}
Beispiel #29
0
static int
print_prune(register const u_char *bp)
{
	TCHECK2(bp[0], 12);
	printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
	bp += 8;
	(void)printf(" timer ");
	relts_print(EXTRACT_32BITS(bp));
	return (0);
trunc:
	return (-1);
}
Beispiel #30
0
/* ibid */
static const u_char *
of10_port_mod_print(const u_char *cp, const u_char *ep) {
	/* port_no */
	TCHECK2(*cp, 2);
	printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
	cp += 2;
	/* hw_addr */
	TCHECK2(*cp, OFP_ETH_ALEN);
	printf(", hw_addr %s", etheraddr_string(cp));
	cp += OFP_ETH_ALEN;
	/* config */
	TCHECK2(*cp, 4);
	printf("\n\t config 0x%08x", EXTRACT_32BITS(cp));
	of10_bitmap_print(ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
	cp += 4;
	/* mask */
	TCHECK2(*cp, 4);
	printf("\n\t mask 0x%08x", EXTRACT_32BITS(cp));
	of10_bitmap_print(ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
	cp += 4;
	/* advertise */
	TCHECK2(*cp, 4);
	printf("\n\t advertise 0x%08x", EXTRACT_32BITS(cp));
	of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
	cp += 4;
	/* pad */
	TCHECK2(*cp, 4);
	return cp + 4;

trunc:
	printf(" [|openflow]");
	return ep;
}