C/drv_madwifing.c
/* 
 * Change the local interface to the specified MAC address to let the 
 * Atheros chip ACK for us.
 * Procedure is:
 *   + Delete all VAPs
 *   + ifconfig wifi0 down
 *   + SIOCSIFHWADDR
 *   + Create new VAP
 *   + ifconfig lor0 up
 */
Change the local interface to the specified MAC address to let the
Atheros chip ACK for us.
Change the local interface to the specified MAC address to let the Atheros chip ACK for us .
int madwifing_selfack(struct tx80211 *in_tx, uint8_t *addr)
{
	struct madwifi_vaps *vaplist = NULL;
	int n;
	if (in_tx->extra == NULL) {
                snprintf(in_tx->errstr, TX80211_STATUS_MAX,
				"MADWIFI SelfACK: Cannot set MAC address for "
				"sub-interface, must specify master name");
		return TX80211_ENOTSUPP;
	}
	wtinj_close(in_tx);
	vaplist = madwifing_list_vaps(in_tx->extra, in_tx->errstr);
	if (vaplist != NULL) {
		for (n = 0; n < vaplist->vaplen; n++) {
			if (madwifing_destroy_vap(vaplist->vaplist[n], 
					in_tx->errstr) < 0) {
				madwifing_free_vaps(vaplist);
				return -1;
			}
		}
		madwifing_free_vaps(vaplist);
	}
	if (ifconfig_ifupdown(in_tx->extra, in_tx->errstr, 
			TX80211_IFDOWN) < 0) {
		snprintf(in_tx->errstr, TX80211_STATUS_MAX,
			"MADWIFI SelfACK: Failed to place interface %d in the "
			"DOWN state before changing MAC address.", 
			in_tx->ifname);
		return -1;
	}
	if (ifconfig_set_hwaddr(in_tx->extra, in_tx->errstr, addr) < 0) {
		return -1;
	}
	if (ifconfig_ifupdown(in_tx->extra, in_tx->errstr, TX80211_IFUP) < 0) {
		snprintf(in_tx->errstr, TX80211_STATUS_MAX,
			"MADWIFI SelfACK: Failed to place interface %d in the "
			"UP state after changing MAC address.", 
			in_tx->extra);
		return -1;
	}
	if (madwifing_build_vap(in_tx->extra, in_tx->errstr, "lorcon", 
			in_tx->ifname, IEEE80211_M_MONITOR,
			IEEE80211_CLONE_BSSID) < 0) {
		snprintf(in_tx->errstr, TX80211_STATUS_MAX,
				"MADWIFI SelfACK: Failed to build a new VAP");
		return -1;
	}
	if (ifconfig_ifupdown(in_tx->ifname, in_tx->errstr, 
			TX80211_IFUP) < 0) {
		snprintf(in_tx->errstr, TX80211_STATUS_MAX,
			"MADWIFI SelfACK: Failed to place interface %s"
			"in the UP state after changing MAC address.",
			in_tx->ifname);
		return -1;
	}
	if (wtinj_open(in_tx) != 0) {
		return -1;
	}
	return 0;
}
int madwifing_selfack ( struct tx80211 * in_tx , uint8_t * addr ) { struct madwifi_vaps * vaplist = NULL ; int n ; if ( in_tx -> extra == NULL ) { snprintf ( in_tx -> errstr , TX80211_STATUS_MAX , " " " " ) ; return TX80211_ENOTSUPP ; } wtinj_close ( in_tx ) ; vaplist = madwifing_list_vaps ( in_tx -> extra , in_tx -> errstr ) ; if ( vaplist != NULL ) { for ( n = 0 ; n < vaplist -> vaplen ; n ++ ) { if ( madwifing_destroy_vap ( vaplist -> vaplist [ n ] , in_tx -> errstr ) < 0 ) { madwifing_free_vaps ( vaplist ) ; return -1 ; } } madwifing_free_vaps ( vaplist ) ; } if ( ifconfig_ifupdown ( in_tx -> extra , in_tx -> errstr , TX80211_IFDOWN ) < 0 ) { snprintf ( in_tx -> errstr , TX80211_STATUS_MAX , " " " " , in_tx -> ifname ) ; return -1 ; } if ( ifconfig_set_hwaddr ( in_tx -> extra , in_tx -> errstr , addr ) < 0 ) { return -1 ; } if ( ifconfig_ifupdown ( in_tx -> extra , in_tx -> errstr , TX80211_IFUP ) < 0 ) { snprintf ( in_tx -> errstr , TX80211_STATUS_MAX , " " " " , in_tx -> extra ) ; return -1 ; } if ( madwifing_build_vap ( in_tx -> extra , in_tx -> errstr , " " , in_tx -> ifname , IEEE80211_M_MONITOR , IEEE80211_CLONE_BSSID ) < 0 ) { snprintf ( in_tx -> errstr , TX80211_STATUS_MAX , " " ) ; return -1 ; } if ( ifconfig_ifupdown ( in_tx -> ifname , in_tx -> errstr , TX80211_IFUP ) < 0 ) { snprintf ( in_tx -> errstr , TX80211_STATUS_MAX , " " " " , in_tx -> ifname ) ; return -1 ; } if ( wtinj_open ( in_tx ) != 0 ) { return -1 ; } return 0 ; }
Change the local interface to the specified MAC address to let the
 Atheros chip ACK for us.
Change the local interface to the specified MAC address to let the Atheros chip ACK for us .
/* User specified sub-interface, not master; 
		 * This doesn't help us
		 */ /* Close the socket for the interface */ /* Get a list of all VAP's (should be only one) */ /* Delete all VAPs */ /* Retain message from set_hwaddr */ /* Build the vap and put the name into ifname */