コード例 #1
0
void
capture_wlancap(const guchar *pd, int offset, int len, packet_counts *ld)
{
  guint32 length;

  if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32)*2)) {
    ld->other++;
    return;
  }

  length = pntohl(pd+sizeof(guint32));

  if (!BYTES_ARE_IN_FRAME(offset, len, length)) {
    ld->other++;
    return;
  }

  offset += length;

  /* 802.11 header follows */
  capture_ieee80211(pd, offset, len, ld);
}
コード例 #2
0
void
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
{
    guint16 it_len;
    guint32 present;
    guint8 rflags;

    if(!BYTES_ARE_IN_FRAME(offset, len, RADIOTAP_MIN_HEADER_LEN)) {
        ld->other ++;
        return;
    }
    it_len = pletohs(&pd[RADIOTAP_LENGTH_OFFSET]);
    if(!BYTES_ARE_IN_FRAME(offset, len, it_len)) {
        ld->other ++;
        return;
    }

    if(it_len > len) {
        /* Header length is bigger than total packet length */
        ld->other ++;
        return;
    }

    if(it_len < RADIOTAP_MIN_HEADER_LEN) {
        /* Header length is shorter than fixed-length portion of header */
        ld->other ++;
        return;
    }

    present = pletohl(&pd[RADIOTAP_PRESENT_OFFSET]);
    offset += RADIOTAP_MIN_HEADER_LEN;
    it_len -= RADIOTAP_MIN_HEADER_LEN;

    rflags = 0;

    /*
     * IEEE80211_RADIOTAP_TSFT is the lowest-order bit.
     */
    if (present & BIT(IEEE80211_RADIOTAP_TSFT)) {
    	if (it_len < 8) {
	    /* No room in header for this field. */
	    ld->other ++;
	    return;
	}
	/* That field is present, and it's 8 bits long. */
	offset += 8;
	it_len -= 8;
    }

    /*
     * IEEE80211_RADIOTAP_FLAGS is the next bit.
     */
    if (present & BIT(IEEE80211_RADIOTAP_FLAGS)) {
    	if (it_len < 1) {
	    /* No room in header for this field. */
	    ld->other ++;
	    return;
	}
	/* That field is present; fetch it. */
	if(!BYTES_ARE_IN_FRAME(offset, len, 1)) {
	    ld->other ++;
	    return;
	}
	rflags = pd[offset];
    }

    /* 802.11 header follows */
    if (rflags & IEEE80211_RADIOTAP_F_DATAPAD)
	capture_ieee80211_datapad(pd, offset + it_len, len, ld);
    else
	capture_ieee80211(pd, offset + it_len, len, ld);
}
コード例 #3
0
static void
capture_info_packet(packet_counts *counts, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header)
{
    counts->total++;
    switch (wtap_linktype) {
    case WTAP_ENCAP_ETHERNET:
        capture_eth(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_FDDI:
    case WTAP_ENCAP_FDDI_BITSWAPPED:
        capture_fddi(pd, caplen, counts);
        break;
    case WTAP_ENCAP_IEEE_802_11_PRISM:
        capture_prism(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_TOKEN_RING:
        capture_tr(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_NULL:
        capture_null(pd, caplen, counts);
        break;
    case WTAP_ENCAP_PPP:
        capture_ppp_hdlc(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_RAW_IP:
        capture_raw(pd, caplen, counts);
        break;
    case WTAP_ENCAP_SLL:
        capture_sll(pd, caplen, counts);
        break;
    case WTAP_ENCAP_LINUX_ATM_CLIP:
        capture_clip(pd, caplen, counts);
        break;
    case WTAP_ENCAP_IEEE_802_11:
    case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
        capture_ieee80211(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_IEEE_802_11_RADIOTAP:
        capture_radiotap(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_IEEE_802_11_AVS:
        capture_wlancap(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_CHDLC:
        capture_chdlc(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_LOCALTALK:
        capture_llap(counts);
        break;
    case WTAP_ENCAP_ATM_PDUS:
        capture_atm(pseudo_header, pd, caplen, counts);
        break;
    case WTAP_ENCAP_IP_OVER_FC:
        capture_ipfc(pd, caplen, counts);
        break;
    case WTAP_ENCAP_ARCNET:
        capture_arcnet(pd, caplen, counts, FALSE, TRUE);
        break;
    case WTAP_ENCAP_ARCNET_LINUX:
        capture_arcnet(pd, caplen, counts, TRUE, FALSE);
        break;
    case WTAP_ENCAP_APPLE_IP_OVER_IEEE1394:
        capture_ap1394(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_FRELAY:
    case WTAP_ENCAP_FRELAY_WITH_PHDR:
        capture_fr(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_ENC:
        capture_enc(pd, caplen, counts);
        break;
    case WTAP_ENCAP_PPI:
        capture_ppi(pd, caplen, counts);
        break;
    case WTAP_ENCAP_I2C:
        capture_i2c(pseudo_header, counts);
        break;
    case WTAP_ENCAP_AX25_KISS:
        capture_ax25_kiss(pd, 0, caplen, counts);
        break;
    case WTAP_ENCAP_AX25:
        capture_ax25(pd, 0, caplen, counts);
        break;
        /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM
           pseudo-header to DLT_ATM_RFC1483, with LLC header following;
           we might have to implement that at some point. */
    }
}