diff -Naur madwifi-0.9.1/ath/if_ath.c madwifi-0.9.1-libmac/ath/if_ath.c
--- madwifi-0.9.1/ath/if_ath.c	2006-06-11 22:32:56.000000000 -0400
+++ madwifi-0.9.1-libmac/ath/if_ath.c	2006-08-02 04:56:30.000000000 -0400
@@ -91,6 +91,8 @@
 #include "ath_tx99.h"
 #endif
 
+#include <net80211/libmac.h>
+
 /* unaligned little endian access */
 #define LE_READ_2(p)							\
 	((u_int16_t)							\
@@ -903,6 +905,15 @@
 				dev->name, error);
 	}
 
+#ifdef CONFIG_MADWIFI_LIBMAC /* Should this go here of before ieee80211_create_vap() ? */
+	ic->mac_append_in_mode = APPEND_OFF;
+	ic->mac_append_out_mode = APPEND_OFF;
+	ic->mac_supported_params[0] = mac_rssi;
+	ic->mac_supported_params_flags[0] = WLGETONLY; 
+	/* we should eventually print supported params list .. */
+	printk("%s: libmac-%s supported\n", dev->name, LIBMAC_VERSION);
+#endif
+
 	return 0;
 bad3:
 	ieee80211_ifdetach(ic);
@@ -5100,6 +5111,11 @@
 	struct sk_buff *skb;
 	struct ath_desc *ds;
 
+	#ifdef CONFIG_MADWIFI_LIBMAC
+	struct ieee80211com *ic = &sc->sc_ic;
+	int tail_need = 0;
+	#endif
+	
 	skb = bf->bf_skb;
 	if (skb == NULL) {
  		if (sc->sc_nmonvaps > 0) {
@@ -5131,6 +5147,27 @@
  			if (off != 0)
  				skb_reserve(skb, sc->sc_cachelsz - off);
 		} else {
+#ifdef CONFIG_MADWIFI_LIBMAC
+			/* Make sure this has not been done before. */
+			if (ic->mac_rxbufsize_flag) {
+				if ( (ic->mac_append_in_mode==APPEND_ON) )
+					/* For each parameter, space needed is 3 bytes. In addition, 
+					 * 1 byte is needed for the no_of_params indicator and 2 bytes
+					 * more are needed for the length. Total number of bytes appended 
+					 * is 1 (for no. of params) + 3 (1(for key) + 2(for value)) * num_params + 
+					 * 2 (for length field).
+					 * */
+					tail_need = (3 * (ic->mac_in_params.len)) + 1 + 2;
+				/* For each parameter, space needed is 2 bytes 
+				 * for the length.
+				 */
+				else if ( (ic->mac_append_in_mode==APPEND_OFF) )
+					tail_need = 2;
+				sc->sc_rxbufsize += tail_need;
+				ic->mac_rxbufsize_flag = 1;
+			}
+#endif /* CONFIG_MADWIFI_LIBMAC */
+
 			/*
 			 * Cache-line-align.  This is important (for the
 			 * 5210 at least) as not doing so causes bogus data
@@ -5581,7 +5618,7 @@
 				keyix = ni->ni_ucastkey.wk_keyix;
 				if (keyix != IEEE80211_KEYIX_NONE &&
 				    sc->sc_keyixmap[keyix] == NULL)
-					sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni);
+				  sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni);
 				ieee80211_free_node(ni); 
 			} else
 				type = ieee80211_input_all(ic, skb,
@@ -8996,7 +9033,7 @@
 {
 	struct ath_softc *sc = dev->priv;
 	struct ieee80211com *ic = &sc->sc_ic;
-	int error;
+	int error = 0;
 
 	ATH_LOCK(sc);
 	switch (cmd) {
diff -Naur madwifi-0.9.1/Makefile madwifi-0.9.1-libmac/Makefile
--- madwifi-0.9.1/Makefile	2006-06-18 17:07:53.000000000 -0400
+++ madwifi-0.9.1-libmac/Makefile	2006-07-22 16:24:12.000000000 -0400
@@ -51,9 +51,10 @@
 # NB: the order is important here
 DIRS_MODULES=	${WLAN} ${ATH_RATE} ${ATH}
 
-obj-y := ath/ $(ATH_RATE)/ net80211/
+obj-y := ath/ $(ATH_RATE)/ net80211/ 
 
-all: modules tools
+#all: modules tools
+all: modules
 
 modules: configcheck svnversion.h
 ifdef LINUX24
@@ -81,8 +82,8 @@
 tools:
 	$(MAKE) -C ${TOOLS} all || exit 1
 
-install: install-modules install-tools
-
+#install: install-modules install-tools
+install: install-modules
 install-modules:
 	@# check if there are modules left from an old installation
 	@# might cause make to abort the build
diff -Naur madwifi-0.9.1/net80211/ieee80211_input.c madwifi-0.9.1-libmac/net80211/ieee80211_input.c
--- madwifi-0.9.1/net80211/ieee80211_input.c	2006-06-09 22:17:05.000000000 -0400
+++ madwifi-0.9.1-libmac/net80211/ieee80211_input.c	2006-08-02 04:56:33.000000000 -0400
@@ -54,6 +54,10 @@
 
 #include <net80211/ieee80211_var.h>
 
+/* Begin WINLAB */
+#include <net80211/libmac.h>
+/* End WINLAB */
+
 #ifdef IEEE80211_DEBUG
 /*
  * Decide if a received management frame should be
@@ -968,6 +972,18 @@
 	struct net_device *dev = vap->iv_dev;
 	struct ether_header *eh = (struct ether_header *) skb->data;
 
+	/* Begin WINLAB */
+#ifdef CONFIG_MADWIFI_LIBMAC
+	struct ieee80211com *ic = vap->iv_ic;
+	u8  *mac_skb_rx_8;      // 8-bit pointer to append values to end of packet
+        u32 *mac_skb_rx_32;     // 32-bit pointer to append values to end of packet
+        u8  *mac_skb_num_params;// 8-bit pointer to append number of parameters to end of packet
+        u16 *mac_skb_len_16;    // 16-bit pointer to append length of data to end of packet
+        int mac_i;              // counter
+        u_int16_t payload_len;
+#endif
+	/* End WINLAB */
+	
 #ifdef ATH_SUPERG_XR 
 	/*
 	 * if it is a XR vap, send the data to associated normal net
@@ -1028,8 +1044,51 @@
 		if (ni->ni_vlan != 0 && vap->iv_vlgrp != NULL) {
 			/* attach vlan tag */
 			vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan);
-		} else
-			netif_rx(skb);
+		} else {
+		  /* Begin WINLAB */
+#ifdef CONFIG_MADWIFI_LIBMAC
+		  payload_len = skb->len;
+		  if (ic->mac_append_in_mode==APPEND_ON)
+		    {
+			    printk("APPEND_ON detected, number params:\t%d\n", ic->mac_in_params.len);
+		      // First create space at the end of the buffer for number of params
+		      mac_skb_num_params = (u8*)skb_put(skb, 1);
+		      // Next fill in the number of parameters being appended
+		      mac_skb_num_params[0] = ic->mac_in_params.len;
+
+		      for(mac_i=0;mac_i<ic->mac_in_params.len; mac_i++)
+			{
+			  switch(ic->mac_in_params.key_array[mac_i])
+			    {
+			    case mac_rssi :
+			      mac_skb_rx_8 = (u8*)skb_put(skb,1);
+			      mac_skb_rx_32 = (u32*)skb_put(skb, 4);
+			      mac_skb_rx_8[0] = ic->mac_in_params.key_array[mac_i];
+			      //mac_skb_rx_32[0] = ni->ni_rssi;
+			      /* XXX: check to see differing values between
+			       * ni->ni_rssi and what ieee80211_getrssi(ic) gets */
+			      mac_skb_rx_32[0] = ieee80211_getrssi(ic);
+			      printk("RSSI reported:\t%d\n", mac_skb_rx_32[0]);
+			      break;
+			    default:
+			      printk("Unsupported param:\t%d\n", ic->mac_in_params.key_array[mac_i]);
+			      break;
+			    }
+			}
+		    }
+		  
+		  /* Do not append length to frame type 0x0900. */
+		  if (eh->ether_type != __constant_htons(0x0900))
+		    {
+		      // Create space at the end of the packet for length of data
+		      mac_skb_len_16 = (u16*)skb_put(skb,2);
+		      mac_skb_len_16[0] = payload_len;
+		    }
+#endif
+		  /* End WINLAB */
+		  
+		  netif_rx(skb);
+		}
 		dev->last_rx = jiffies;
 	}
 }
diff -Naur madwifi-0.9.1/net80211/ieee80211_ioctl.h madwifi-0.9.1-libmac/net80211/ieee80211_ioctl.h
--- madwifi-0.9.1/net80211/ieee80211_ioctl.h	2006-02-19 12:19:27.000000000 -0500
+++ madwifi-0.9.1-libmac/net80211/ieee80211_ioctl.h	2006-07-22 06:14:10.000000000 -0400
@@ -41,6 +41,10 @@
 #include <net80211/ieee80211.h>
 #include <net80211/ieee80211_crypto.h>
 
+/* Begin WINLAB */
+#include <net80211/libmac.h>
+/* End Winlab */
+
 /*
  * Per/node (station) statistics available when operating as an AP.
  */
@@ -532,6 +536,18 @@
 	IEEE80211_WMMPARAMS_TXOPLIMIT	= 4,
 	IEEE80211_WMMPARAMS_ACM		= 5,
 	IEEE80211_WMMPARAMS_NOACKPOLICY	= 6,	
+#ifdef CONFIG_MADWIFI_LIBMAC
+/* We're out of ioctls, and private ioctls, lets abuse this
+ * for now. Later on we can use configfs */
+	LIBMAC_INAPP			= 7,	/* */
+	LIBMAC_OUTAPP			= 8,	/* */
+	LIBMAC_ALLAPPOFF		= 9,	/* */
+	LIBMAC_PARAMS			= 10,	/* Get supported params with flags / Set flags for supported params */
+	LIBMAC_RSSI                     = 11,   /* */
+	LIBMAC_TXPOWER                  = 12,   /* */
+	LIBMAC_TXRATE                   = 13,   /* */
+	LIBMAC_NOISE                    = 14,   /* */
+#endif /* CONFIG_MADWIFI_LIBMAC */
 };
 enum {
 	IEEE80211_PARAM_TURBO		= 1,	/* turbo mode */
diff -Naur madwifi-0.9.1/net80211/ieee80211_var.h madwifi-0.9.1-libmac/net80211/ieee80211_var.h
--- madwifi-0.9.1/net80211/ieee80211_var.h	2006-05-31 16:35:17.000000000 -0400
+++ madwifi-0.9.1-libmac/net80211/ieee80211_var.h	2006-07-24 20:25:42.000000000 -0400
@@ -52,6 +52,9 @@
 #include <net80211/ieee80211_power.h>
 #include <net80211/ieee80211_proto.h>
 #include <net80211/ieee80211_scan.h>
+/* Begin WINLAB */
+#include <net80211/libmac.h>
+/* End WINLAB */
 
 #define	IEEE80211_TXPOWER_MAX	100	/* .5 dBm units */
 #define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
@@ -209,6 +212,18 @@
 	u_int8_t ic_chanchange_tbtt;
 	u_int8_t ic_chanchange_chan;
 
+#ifdef CONFIG_MADWIFI_LIBMAC
+	mac_params_list mac_in_params;
+	mac_params_list mac_out_params;
+	u_int8_t mac_append_in_mode;
+	u_int8_t mac_append_out_mode;
+	u_int8_t mac_rxbufsize_flag;
+	/* list of suppported mac params */
+	unsigned char mac_supported_params[1];
+	/* parameter attributes */ 
+	unsigned char mac_supported_params_flags[1];
+#endif /* CONFIG_MADWIFI_LIBMAC */
+
 	/* virtual ap create/delete */
 	struct ieee80211vap *(*ic_vap_create)(struct ieee80211com *,
 		const char *, int, int, int, struct net_device *);
diff -Naur madwifi-0.9.1/net80211/ieee80211_wireless.c madwifi-0.9.1-libmac/net80211/ieee80211_wireless.c
--- madwifi-0.9.1/net80211/ieee80211_wireless.c	2006-06-11 22:27:58.000000000 -0400
+++ madwifi-0.9.1-libmac/net80211/ieee80211_wireless.c	2006-10-11 14:41:49.000000000 -0400
@@ -60,6 +60,11 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_linux.h>
 
+/* Begin WINLAB */
+#include <net80211/libmac.h>
+#include <ath/if_athvar.h> /* for struct ath_softc */
+/* End WINLAB */
+
 #define	IS_UP(_dev) \
 	(((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
 #define	IS_UP_AUTO(_vap) \
@@ -3161,8 +3166,89 @@
 	int ac = (param[1] < WME_NUM_AC) ? param[1] : WME_AC_BE;
 	int bss = param[2]; 
 	struct ieee80211_wme_state *wme = &vap->iv_ic->ic_wme;
+#ifdef CONFIG_MADWIFI_LIBMAC
+	struct ath_softc *sc = dev->priv;
+	struct ieee80211com *ic = vap->iv_ic; 
+	int *compat = (int *) w;
+	struct iw_point *iwp = (struct iw_point *) w;
+	struct mac_params_list *p_in = (struct mac_params_list *) iwp->pointer;
+	struct mac_params_list *p = (struct mac_params_list *) extra;
+	//struct iw_param *iwparam = (struct iw_param *) extra;
+	union iwreq_data *wrqu = (union iwreq_data *) w;
+
+	/* Note: iwp->length is 0 when iwpriv is used */
+
+	/* If we have a Libmac sub-ioctl */
+	if((iwp->length == sizeof(struct mac_params_list)) && 
+			(p_in->si_num >= LIBMAC_INAPP) && (p_in->si_num <= LIBMAC_NOISE)) {
+		/* Libmac note: we only allow libmac sub-ioclts if magic flag was set to LIBMAC_MAGIC_FLAG */
+		if (p_in->si_flag != LIBMAC_MAGIC_FLAG) {
+			printk("%s: special get sub-ioctl (%d) for libmac called without magic flag (%d), do "
+				"not call directly using iwpriv or if you are unsure how to use this\n", 
+					dev->name, p_in->si_num, p_in->si_flag);
+			return -EINVAL;
+		}
+		switch (p_in->si_num) {
+			/* ioctl to turn on the append mode on all incoming packets */
+			case LIBMAC_INAPP:
+				memcpy(ic->mac_in_params.key_array, p->key_array, p->len);
+				memcpy(ic->mac_in_params.flags, p->flags, p->len);
+				ic->mac_in_params.len = p->len;
+				ic->mac_append_in_mode = APPEND_ON;
+				/* update ath_soft sc->sc_rxbufsize over here....other 
+				 * one only takes care of HW reset */
+				sc->sc_rxbufsize += (3 * (ic->mac_in_params.len)) + 1 + 2;
+				break;
+			/* Turn append off for both incomming and outgoing packets */
+			case LIBMAC_ALLAPPOFF:
+				ic->mac_append_in_mode = APPEND_OFF;
+				ic->mac_append_out_mode = APPEND_OFF;
+				break;
+#if 0
+			case LIBMAC_TXRATE:
+				if (ath_ioctl_siwrate(dev, (struct iw_request_info *)NULL, iwparam, (char *)NULL ))
+					printk("%s: libmac - Could not set txrate\n", dev->name);
+				break;
+			case LIBMAC_TXPOWER:
+				if (ath_ioctl_siwtxpow(dev,(struct iw_request_info *)NULL, iwparam, (char *)NULL))
+					printk("%s: libmac - Could not set txpower\n");
+				break;
+#endif
+			/* ioctl to turn on the append mode on all outgoing packets */
+			case LIBMAC_OUTAPP: /* Not supported yet */
+			case LIBMAC_PARAMS:
+			case LIBMAC_RSSI:
+			case LIBMAC_NOISE:
+			default:
+				printk("%s: Libmac set sub-ioctl (%d) detected but not supported\n", dev->name, p_in->si_num);
+				return -EFAULT;
+		}
+		return 0;
+	}
 
-	switch (param[0]) {
+	printk("Sorry, but set WMM private (%X) ioctls are not supported\n", compat[0]);
+	return 0;
+
+	/* To support Libmac through sub-iotls we needed to bastardize this handler, 
+	 * here is some backward compatiblity work */
+
+	/* Note: sizeof(extra) == 4 */
+
+	param[0] = compat[0];
+	param[1] = compat[1];
+	param[2] = compat[2];
+
+	wrqu->data.length = 525;
+
+	printk("%s: Libmac Compatibility at work - (param[0]: %d) (param[1]: %d) "
+			"(param[2]: %d) (data.length: %d)\n",
+			dev->name, param[0], param[1], param[2], wrqu->data.length);
+
+	ac = (param[1] < WME_NUM_AC) ? param[1] : WME_AC_BE; 
+	bss = param[2];
+
+#endif /* CONFIG_MADWIFI_LIBMAC */
+	switch (param[0]) { 
         case IEEE80211_WMMPARAMS_CWMIN:
 		if (param[3] < 0 || param[3] > 15) 
 			return -EINVAL;
@@ -3240,20 +3326,135 @@
 	return 0;
 }
 
+
 static int
 ieee80211_ioctl_getwmmparams(struct net_device *dev,
 	struct iw_request_info *info, void *w, char *extra)
 {
 	struct ieee80211vap *vap = dev->priv;
 	int *param = (int *) extra;
-	int ac = (param[1] < WME_NUM_AC) ? param[1] : WME_AC_BE;
+	int ac = (param[1] < WME_NUM_AC) ? param[1] : WME_AC_BE; 
 	struct ieee80211_wme_state *wme = &vap->iv_ic->ic_wme;
 	struct chanAccParams *chanParams = (param[2] == 0) ? 
 		&(wme->wme_chanParams) : &(wme->wme_bssChanParams);
+#ifdef CONFIG_MADWIFI_LIBMAC
+	struct ieee80211com *ic = vap->iv_ic; 
+	int *compat = (int *) w;
+	struct iw_point *iwp = (struct iw_point *) w;
+	struct mac_params_list *p_in = (struct mac_params_list *) iwp->pointer;
+	struct mac_params_list *p = (struct mac_params_list *) extra;
+	struct iw_param *iwparam = (struct iw_param *) extra;
+	union iwreq_data *wrqu = (union iwreq_data *) w;
+
+	/* Note: iwp->length is 0 when iwpriv is used */
+
+	/* If we have a Libmac sub-ioctl */
+	if((iwp->length == sizeof(struct mac_params_list)) && 
+			(p_in->si_num >= LIBMAC_INAPP) && (p_in->si_num <= LIBMAC_NOISE)) {
+		/* Libmac note: we only allow libmac sub-ioclts if magic flag was set to LIBMAC_MAGIC_FLAG */
+		if (p_in->si_flag != LIBMAC_MAGIC_FLAG) {
+			printk("%s: special get sub-ioctl (%d) for libmac called without magic flag (%d), "
+				"do not call directly using iwpriv or if you are unsure how to use this\n", 
+					dev->name, p_in->si_num, p_in->si_flag);
+			return -EINVAL;
+		}
+		switch (p_in->si_num) {
+			/* Retrieves all supported Libmac MAC parameters */
+			case LIBMAC_PARAMS:	
+				//memset(p, 0, sizeof(struct mac_params_list));
+				p->len = sizeof(ic->mac_supported_params);
+				memcpy(p->key_array, ic->mac_supported_params, 
+						sizeof(ic->mac_supported_params));
+				memcpy(p->flags, ic->mac_supported_params_flags, 
+						sizeof(ic->mac_supported_params_flags));
+				break;
+			case LIBMAC_RSSI:
+				/* XXX: Missing setting of length of sent data to user, required? */
+				iwparam->value = ieee80211_getrssi(ic);
+				printk("%s: RSSI returned is %d\n", dev->name, iwparam->value);
+				iwparam->fixed = 0; /* This has no meaning in this context */
+				iwparam->disabled = 0; /* This has no meaning in this context */
+				iwparam->flags = 0; /* This is not used currently */
+				break;
+			case LIBMAC_NOISE:
+				/* 161 (-95dB hard coded) */
+				iwparam->value = 161;
+				iwparam->fixed = 0;
+				iwparam->disabled = 0;
+				iwparam->flags = 0;
+				break;
+#if 0
+			case LIBMAC_TXRATE:
+				if (ath_ioctl_giwrate(dev, (struct iw_request_info *)NULL, iwparam, (char *)NULL ))
+					printk("%s: libmac - Could not retrieve txrate\n", dev->name)
+				break;
+			case LIBMAC_TXPOWER:
+				if (ath_ioctl_giwtxpow(dev,(struct iw_request_info *)NULL, iwparam, (char *)NULL))
+					printk("%s: libmac - Could not retrive txpower\n", dev->name);
+				break;
+#endif
+			case LIBMAC_INAPP:
+			case LIBMAC_OUTAPP:
+			case LIBMAC_ALLAPPOFF:
+			default:
+				printk("%s: Libmac get sub-ioctl (%d) detected but not supported\n", dev->name, p_in->si_num);
+				break;
+		}
+		return 0;
+	}
+
+	printk("Sorry, but get WMM private (%X) ioctls are not supported\n", compat[0]);
+	return 0;
+
+	/* To support Libmac through sub-iotls we needed to bastardize this handler, 
+	 * here is some backward compatiblity work */
+
+	/* Note: sizeof(extra) == 4 */
+
+	param[0] = compat[0];
+	param[1] = compat[1];
+	param[2] = compat[2];
+
+	wrqu->data.length = 525;
+
+	printk("%s: Libmac Compatibility at work - (param[0]: %d) (param[1]: %d) (param[2]: %d) (data.length: %d)\n",
+			dev->name, param[0], param[1], param[2], wrqu->data.length);
+
+	ac = (param[1] < WME_NUM_AC) ? param[1] : WME_AC_BE; 
+	chanParams = (param[2] == 0) ? &(wme->wme_chanParams) : &(wme->wme_bssChanParams);
+
+	/* Note: we are failing for iwpriv with BAD ADDRESS because wireless core tries this:
+	 *
+	 * err = copy_to_user(iwr->u.data.pointer, extra,
+	 * 	extra_size);
+	 *
+	 * At the end if (!ret && IW_IS_GET(cmd)) { } 
+	 *
+	 * The buffer it allocates from iwpriv is buffer[4096] so its not the size, 
+	 * as seen bellow eve if we try to copy 1 byte it doesn't work. The data which we
+	 * are trying to copy IS USERSPACE -- this has been verified with access_ok(), see bellow.
+	 */
+
+	/* From iwpriv: 
+	 *
+	 * iwpriv will not print data unless a value >= 0 is detected from ioctl. As mentioned above
+	 * we are going to get -EFAULT returnd (bad address) as the core cannot copy_to_user even 1 byte
+	 *
+	 *   if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
+	 *       {
+	 *		fprintf(stderr, "Interface doesn't accept private ioctl...\n");
+	 *		fprintf(stderr, "%s (%X): %s\n", cmdname, priv[k].cmd, strerror(errno));
+	 *		return(-1);
+	 *	}
+	 *
+	 */
+
+#endif /* CONFIG_MADWIFI_LIBMAC */
 
 	switch (param[0]) {
         case IEEE80211_WMMPARAMS_CWMIN: 
 		param[0] = chanParams->cap_wmeParams[ac].wmep_logcwmin;
+		param[0] = 123;
 		break;
         case IEEE80211_WMMPARAMS_CWMAX: 
 		param[0] = chanParams->cap_wmeParams[ac].wmep_logcwmax;
@@ -3273,6 +3474,7 @@
 	default:
 		break;
 	}
+	
 	return 0;
 }
 
@@ -4363,6 +4565,15 @@
 #define	IW_PRIV_TYPE_CHANINFO \
 	IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_chaninfo)
 
+#ifdef CONFIG_MADWIFI_LIBMAC
+#define	IW_PRIV_TYPE_LIBMAC_PARAMS\
+	IW_PRIV_TYPE_BYTE | sizeof(struct mac_params_list) 
+#endif /* CONFIG_MADWIFI_LIBMAC */
+
+#define WWM_GET_SIOCTL(ioctl, name) { ioctl, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_LIBMAC_PARAMS | IW_PRIV_SIZE_FIXED, name }
+#define WMM_SET_SIOCTL(ioctl, name) { ioctl, IW_PRIV_TYPE_LIBMAC_PARAMS | IW_PRIV_SIZE_FIXED, 0, name }
+#define WMM_GSET_SIOCTL(ioctl, name) WWM_GET_SIOCTL(ioctl, "g_"name), WMM_SET_SIOCTL(ioctl, "s_"name)
+ 
 static const struct iw_priv_args ieee80211_priv_args[] = {
 	/* NB: setoptie & getoptie are !IW_PRIV_SIZE_FIXED */
 	{ IEEE80211_IOCTL_SETOPTIE,
@@ -4396,56 +4607,29 @@
 	{ IEEE80211_IOCTL_GETMODE,
 	  0, IW_PRIV_TYPE_CHAR | 6, "get_mode" },
 #if WIRELESS_EXT >= 12	  
-	{ IEEE80211_IOCTL_SETWMMPARAMS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 4, 0,"setwmmparams" },
-	{ IEEE80211_IOCTL_GETWMMPARAMS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "getwmmparams" },
-	/*
-	 * These depends on sub-ioctl support which added in version 12.
-	 */
-	{ IEEE80211_IOCTL_SETWMMPARAMS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"" },
-	{ IEEE80211_IOCTL_GETWMMPARAMS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "" },
 	/* sub-ioctl handlers */
-	{ IEEE80211_WMMPARAMS_CWMIN,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"cwmin" },
-	{ IEEE80211_WMMPARAMS_CWMIN,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_cwmin" },
-	{ IEEE80211_WMMPARAMS_CWMAX,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"cwmax" },
-	{ IEEE80211_WMMPARAMS_CWMAX,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_cwmax" },
-	{ IEEE80211_WMMPARAMS_AIFS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"aifs" },
-	{ IEEE80211_WMMPARAMS_AIFS,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_aifs" },
-	{ IEEE80211_WMMPARAMS_TXOPLIMIT,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"txoplimit" },
-	{ IEEE80211_WMMPARAMS_TXOPLIMIT,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_txoplimit" },
-	{ IEEE80211_WMMPARAMS_ACM,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"acm" },
-	{ IEEE80211_WMMPARAMS_ACM,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_acm" },
-	{ IEEE80211_WMMPARAMS_NOACKPOLICY,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0,"noackpolicy" },
-	{ IEEE80211_WMMPARAMS_NOACKPOLICY,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 	
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,   "get_noackpolicy" },
+	WMM_SET_SIOCTL(IEEE80211_IOCTL_SETWMMPARAMS,	""),
+	WWM_GET_SIOCTL(IEEE80211_IOCTL_GETWMMPARAMS,	""),
+	/* sub-ioctl definitions */
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_CWMIN,	"cwmin"), 
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_CWMAX,	"cwmax"), 
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_AIFS,	"aifs"), 
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_TXOPLIMIT,	"txoplimit"), 
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_ACM,	"acm"), 
+	WMM_GSET_SIOCTL(IEEE80211_WMMPARAMS_NOACKPOLICY,"noackpolicy"), 
+#ifdef CONFIG_MADWIFI_LIBMAC
+	WMM_GSET_SIOCTL(LIBMAC_PARAMS,			"lbparams"), 
+#endif /* CONFIG_MADWIFI_LIBMAC */
+	/* raw access to sub-ioctl hanlders */
+	{IEEE80211_IOCTL_SETWMMPARAMS, IW_PRIV_TYPE_LIBMAC_PARAMS | IW_PRIV_SIZE_FIXED, 0, "setwmmparams"},
+	{IEEE80211_IOCTL_GETWMMPARAMS, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
+		IW_PRIV_TYPE_LIBMAC_PARAMS | IW_PRIV_SIZE_FIXED, "getwmmparams"},
 	
-	{ IEEE80211_IOCTL_SETPARAM,
-	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
 	/*
 	 * These depends on sub-ioctl support which added in version 12.
 	 */
+	{ IEEE80211_IOCTL_SETPARAM,
+	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
 	{ IEEE80211_IOCTL_GETPARAM,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,	"getparam" },
@@ -4455,7 +4639,7 @@
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
 	{ IEEE80211_IOCTL_GETPARAM,
 	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
-
+	
 	/* sub-ioctl definitions */
 	{ IEEE80211_PARAM_AUTHMODE,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "authmode" },
@@ -4467,8 +4651,8 @@
 	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_protmode" },
 	{ IEEE80211_PARAM_MCASTCIPHER,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "mcastcipher" },
-	{ IEEE80211_PARAM_MCASTCIPHER,
-	  0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_mcastcipher" },
+       { IEEE80211_PARAM_MCASTCIPHER,
+	 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_mcastcipher" },
 	{ IEEE80211_PARAM_MCASTKEYLEN,
 	  IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "mcastkeylen" },
 	{ IEEE80211_PARAM_MCASTKEYLEN,
@@ -4755,6 +4939,7 @@
 	(iw_handler) ieee80211_ioctl_giwencodeext,	/* SIOCGIWENCODEEXT */
 #endif /* WIRELESS_EXT >= 18 */
 };
+
 static const iw_handler ieee80211_priv_handlers[] = {
 	(iw_handler) ieee80211_ioctl_setparam,		/* SIOCIWFIRSTPRIV+0 */
 	(iw_handler) ieee80211_ioctl_getparam,		/* SIOCIWFIRSTPRIV+1 */
@@ -4813,7 +4998,7 @@
 {
 	struct ieee80211vap *vap = dev->priv;
 	u_int unit;
-
+	
 	switch (cmd) {
 	case SIOCG80211STATS:
 		return copy_to_user(ifr->ifr_data, &vap->iv_stats,
diff -Naur madwifi-0.9.1/net80211/libmac.h madwifi-0.9.1-libmac/net80211/libmac.h
--- madwifi-0.9.1/net80211/libmac.h	1969-12-31 19:00:00.000000000 -0500
+++ madwifi-0.9.1-libmac/net80211/libmac.h	2006-07-24 16:05:14.000000000 -0400
@@ -0,0 +1,37 @@
+/* WINLAB Libmac definitions and declarations. */
+#ifndef _MAC_MADWIFI_CMN_H
+#define _MAC_MADWIFI_CMN_H
+
+#define CONFIG_MADWIFI_LIBMAC 1 /* Enable/disable libmac on driver */
+#define LIBMAC_VERSION "1.2"
+#define LIBMAC_MAGIC_FLAG 12 /* This should be higher than WME_NUM_AC */
+#define START_PARAMS_KEY  0
+#define MAX_NO_PARAMS     256
+
+#define APPEND_ON         1 /* Append mode on */
+#define APPEND_OFF        0 /* Append mode off */
+#define WLGETONLY         0 /* Get only for parameter flags */
+#define WLSETNGET         1 /* Both set and get for parameter flags */
+#define WLALLPACKETS      0 /* Append parameters on all packets - true if 1 and false if 0 */
+
+/* Sample key structure */
+typedef enum 
+{
+  mac_priority=START_PARAMS_KEY, 
+  mac_txpower,
+  mac_rssi,
+  mac_noise,
+  mac_currentXmitRate,
+  mac_timestamp
+} mac_parameter_keys;
+
+typedef struct mac_params_list
+{
+  u32 si_num;
+  u32 si_flag;
+  unsigned char len;
+  unsigned char key_array[MAX_NO_PARAMS];
+  unsigned char flags[MAX_NO_PARAMS];
+} mac_params_list;
+
+#endif /* _MAC_MADWIFI_CMN_H */
