示例#1
0
int
_kvm_stat_udf(kvm_t *kd, struct kinfo_file *kf, struct vnode *vp)
{
	struct unode up;
	struct file_entry fentry;
	struct umount um;

	if (KREAD(kd, (u_long)VTOU(vp), &up)) {
		_kvm_err(kd, kd->program, "can't read unode at %p", VTOU(vp));
		return (-1);
	}
	if (KREAD(kd, (u_long)up.u_fentry, &fentry)) {
		_kvm_err(kd, kd->program, "can't read file_entry at %p",
		    up.u_fentry);
		return (-1);
	}
	if (KREAD(kd, (u_long)up.u_ump, &um)) {
		_kvm_err(kd, kd->program, "can't read umount at %p",
		    up.u_ump);
		return (-1);
	}
	kf->va_fsid = up.u_dev;
	kf->va_fileid = (long)up.u_ino;
	kf->va_mode = udf_permtomode(&up); /* XXX */
	kf->va_rdev = 0;
	if (vp->v_type & VDIR) {
		/*
		 * Directories that are recorded within their ICB will show
		 * as having 0 blocks recorded.  Since tradition dictates
		 * that directories consume at least one logical block,
		 * make it appear so.
		 */
		if (fentry.logblks_rec != 0) {
			kf->va_size =
			    letoh64(fentry.logblks_rec) * um.um_bsize;
		} else {
			kf->va_size = um.um_bsize;
		}
	} else {
		kf->va_size = letoh64(fentry.inf_len);
	}

	return (0);
}
示例#2
0
template < class T>STUB_UINT64 buff::Buffer< T >::getLetoh64 ( 
		actRawDataStruct *rawDataPacket , STUB_INT offset ){

	std::cout<<" File Name ["<<__FILE__<<" ] Function [ "<<__FUNCTION__<<"] Line ["
		<<__LINE__<<"] DateTime ["<<__DATE__<<"_"<<__TIME__<<"]\n";

	const u_char   *data;

	if ( types::isContiguous(  buff::Buffer<STUB_INT>::tvbLength , offset , 8 ) ){
		data = (u_char * )rawDataPacket->data ;
		return ( letoh64( data + offset ) );
	}
	exit(0);
}
示例#3
0
/* Get a vnode for the Virtual Allocation Table (VAT) */
int
udf_vat_get(struct umount *ump, uint32_t lb)
{
	struct vnode *vp;
	struct unode *up;
	int error;

	error = udf_vget(ump->um_mountp, lb - ump->um_start - 3, &vp);
	if (error)
		return (error);

	up = VTOU(vp);
	up->u_vatlen = (letoh64(up->u_fentry->inf_len) - 36) >> 2;

	ump->um_vat = malloc(sizeof(struct unode), M_UDFMOUNT, M_WAITOK);
       *ump->um_vat = *up;

	ump->um_flags &= ~UDF_MNT_FIND_VAT;
	ump->um_flags |=  UDF_MNT_USES_VAT;

	vput(vp);

	return (0);
}
示例#4
0
static int
ieee80211_do_slow_print(struct ieee80211com *ic, int *did_print)
{
	static const struct timeval merge_print_intvl = {
		.tv_sec = 1, .tv_usec = 0
	};
	if ((ic->ic_if.if_flags & IFF_LINK0) == 0)
		return 0;
	if (!*did_print && (ic->ic_if.if_flags & IFF_DEBUG) == 0 &&
	    !ratecheck(&ic->ic_last_merge_print, &merge_print_intvl))
		return 0;

	*did_print = 1;
	return 1;
}

/* ieee80211_ibss_merge helps merge 802.11 ad hoc networks.  The
 * convention, set by the Wireless Ethernet Compatibility Alliance
 * (WECA), is that an 802.11 station will change its BSSID to match
 * the "oldest" 802.11 ad hoc network, on the same channel, that
 * has the station's desired SSID.  The "oldest" 802.11 network
 * sends beacons with the greatest TSF timestamp.
 *
 * Return ENETRESET if the BSSID changed, 0 otherwise.
 *
 * XXX Perhaps we should compensate for the time that elapses
 * between the MAC receiving the beacon and the host processing it
 * in ieee80211_ibss_merge.
 */
int
ieee80211_ibss_merge(struct ieee80211com *ic, struct ieee80211_node *ni,
    u_int64_t local_tsft)
{
	u_int64_t beacon_tsft;
	int did_print = 0, sign;
	union {
		u_int64_t	word;
		u_int8_t	tstamp[8];
	} u;

	/* ensure alignment */
	(void)memcpy(&u, &ni->ni_tstamp[0], sizeof(u));
	beacon_tsft = letoh64(u.word);

	/* we are faster, let the other guy catch up */
	if (beacon_tsft < local_tsft)
		sign = -1;
	else
		sign = 1;

	if (IEEE80211_ADDR_EQ(ni->ni_bssid, ic->ic_bss->ni_bssid)) {
		if (!ieee80211_do_slow_print(ic, &did_print))
			return 0;
		printf("%s: tsft offset %s%llu\n", ic->ic_if.if_xname,
		    (sign < 0) ? "-" : "",
		    (sign < 0)
			? (local_tsft - beacon_tsft)
			: (beacon_tsft - local_tsft));
		return 0;
	}

	if (sign < 0)
		return 0;

	if (ieee80211_match_bss(ic, ni) != 0)
		return 0;

	if (ieee80211_do_slow_print(ic, &did_print)) {
		printf("%s: ieee80211_ibss_merge: bssid mismatch %s\n",
		    ic->ic_if.if_xname, ether_sprintf(ni->ni_bssid));
		printf("%s: my tsft %llu beacon tsft %llu\n",
		    ic->ic_if.if_xname, local_tsft, beacon_tsft);
		printf("%s: sync TSF with %s\n",
		    ic->ic_if.if_xname, ether_sprintf(ni->ni_macaddr));
	}

	ic->ic_flags &= ~IEEE80211_F_SIBSS;

	/* negotiate rates with new IBSS */
	ieee80211_fix_rate(ic, ni, IEEE80211_F_DOFRATE |
	    IEEE80211_F_DONEGO | IEEE80211_F_DODEL);
	if (ni->ni_rates.rs_nrates == 0) {
		if (ieee80211_do_slow_print(ic, &did_print)) {
			printf("%s: rates mismatch, BSSID %s\n",
			    ic->ic_if.if_xname, ether_sprintf(ni->ni_bssid));
		}
		return 0;
	}

	if (ieee80211_do_slow_print(ic, &did_print)) {
		printf("%s: sync BSSID %s -> ",
		    ic->ic_if.if_xname, ether_sprintf(ic->ic_bss->ni_bssid));
		printf("%s ", ether_sprintf(ni->ni_bssid));
		printf("(from %s)\n", ether_sprintf(ni->ni_macaddr));
	}

	ieee80211_node_newstate(ni, IEEE80211_STA_BSS);
	(*ic->ic_node_copy)(ic, ic->ic_bss, ni);

	return ENETRESET;
}
示例#5
0
void
ieee802_11_radio_if_print(u_int8_t *buf, u_int len)
{
	struct ieee80211_radiotap_header *rh =
	    (struct ieee80211_radiotap_header*)buf;
	struct ieee80211_frame *wh;
	u_int8_t *t;
	u_int32_t present;
	u_int rh_len;

	snapend = buf + len;

	TCHECK(*rh);

	rh_len = letoh16(rh->it_len);
	if (rh->it_version != 0) {
		PRINTF("[?radiotap + 802.11 v:%u]", rh->it_version);
		goto out;
	}

	wh = (struct ieee80211_frame *)(buf + rh_len);
	if (len <= rh_len || ieee80211_print(wh))
		PRINTF("[|802.11]");

	t = (u_int8_t*)buf + sizeof(struct ieee80211_radiotap_header);

	if ((present = letoh32(rh->it_present)) == 0)
		goto out;

	PRINTF(", <radiotap v%u", rh->it_version);

#define RADIOTAP(_x)	\
	(present & (1 << IEEE80211_RADIOTAP_##_x))

	if (RADIOTAP(TSFT)) {
		u_int64_t tsf;
		u_int32_t tsf_v[2];

		TCHECK2(*t, 8);

		tsf = letoh64(*(u_int64_t *)t);
		tsf_v[0] = (u_int32_t)(tsf >> 32);
		tsf_v[1] = (u_int32_t)(tsf & 0x00000000ffffffff);
		if (vflag > 1)
			PRINTF(", tsf 0x%08x%08x", tsf_v[0], tsf_v[1]);
		t += 8;
	}

	if (RADIOTAP(FLAGS)) {
		u_int8_t flags = *(u_int8_t*)t;
		TCHECK2(*t, 1);

		if (flags & IEEE80211_RADIOTAP_F_CFP)
			PRINTF(", CFP");
		if (flags & IEEE80211_RADIOTAP_F_SHORTPRE)
			PRINTF(", SHORTPRE");
		if (flags & IEEE80211_RADIOTAP_F_WEP)
			PRINTF(", WEP");
		if (flags & IEEE80211_RADIOTAP_F_FRAG)
			PRINTF(", FRAG");
		t += 1;
	}

	if (RADIOTAP(RATE)) {
		TCHECK2(*t, 1);
		if (vflag)
			PRINTF(", %uMbit/s", (*(u_int8_t*)t) / 2);
		t += 1;
	}

	if (RADIOTAP(CHANNEL)) {
		u_int16_t freq, flags;
		TCHECK2(*t, 2);

		freq = letoh16(*(u_int16_t*)t);
		t += 2;
		TCHECK2(*t, 2);
		flags = letoh16(*(u_int16_t*)t);
		t += 2;

		PRINTF(", chan %u", ieee80211_any2ieee(freq, flags));

		if (flags & IEEE80211_CHAN_DYN &&
		    flags & IEEE80211_CHAN_2GHZ)
			PRINTF(", 11g");
		else if (flags & IEEE80211_CHAN_CCK &&
		    flags & IEEE80211_CHAN_2GHZ)
			PRINTF(", 11b");
		else if (flags & IEEE80211_CHAN_OFDM &&
		    flags & IEEE80211_CHAN_2GHZ)
			PRINTF(", 11G");
		else if (flags & IEEE80211_CHAN_OFDM &&
		    flags & IEEE80211_CHAN_5GHZ)
			PRINTF(", 11a");

		if (flags & IEEE80211_CHAN_TURBO)
			PRINTF(", TURBO");
		if (flags & IEEE80211_CHAN_XR)
			PRINTF(", XR");
	}

	if (RADIOTAP(FHSS)) {
		TCHECK2(*t, 2);
		PRINTF(", fhss %u/%u", *(u_int8_t*)t, *(u_int8_t*)t + 1);
		t += 2;
	}

	if (RADIOTAP(DBM_ANTSIGNAL)) {
		TCHECK(*t);
		PRINTF(", sig %ddBm", *(int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(DBM_ANTNOISE)) {
		TCHECK(*t);
		PRINTF(", noise %ddBm", *(int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(LOCK_QUALITY)) {
		TCHECK2(*t, 2);
		if (vflag)
			PRINTF(", quality %u", letoh16(*(u_int16_t*)t));
		t += 2;
	}

	if (RADIOTAP(TX_ATTENUATION)) {
		TCHECK2(*t, 2);
		if (vflag)
			PRINTF(", txatt %u",
			    letoh16(*(u_int16_t*)t));
		t += 2;
	}

	if (RADIOTAP(DB_TX_ATTENUATION)) {
		TCHECK2(*t, 2);
		if (vflag)
			PRINTF(", txatt %udB",
			    letoh16(*(u_int16_t*)t));
		t += 2;
	}

	if (RADIOTAP(DBM_TX_POWER)) {
		TCHECK(*t);
		PRINTF(", txpower %ddBm", *(int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(ANTENNA)) {
		TCHECK(*t);
		if (vflag)
			PRINTF(", antenna %u", *(u_int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(DB_ANTSIGNAL)) {
		TCHECK(*t);
		PRINTF(", signal %udB", *(u_int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(DB_ANTNOISE)) {
		TCHECK(*t);
		PRINTF(", noise %udB", *(u_int8_t*)t);
		t += 1;
	}

	if (RADIOTAP(FCS)) {
		TCHECK2(*t, 4);
		if (vflag)
			PRINTF(", fcs %08x", letoh32(*(u_int32_t*)t));
		t += 4;
	}

	if (RADIOTAP(RSSI)) {
		u_int8_t rssi, max_rssi;
		TCHECK(*t);
		rssi = *(u_int8_t*)t;
		t += 1;
		TCHECK(*t);
		max_rssi = *(u_int8_t*)t;
		t += 1;

		PRINTF(", rssi %u/%u", rssi, max_rssi);
	}

#undef RADIOTAP

	PRINTF(">");
	goto out;

 trunc:
	/* Truncated frame */
	PRINTF("[|radiotap + 802.11]");

 out:
	PRINTF(NULL);
}
示例#6
0
uint64_t fmle64(uint64_t x) { return letoh64(x); }