diff -Naurp madwifi-0.9.2/ath/if_ath.c madwifi-0.9.2-libmac/ath/if_ath.c
--- madwifi-0.9.2/ath/if_ath.c	2006-07-08 02:47:19.000000000 -0400
+++ madwifi-0.9.2-libmac/ath/if_ath.c	2006-10-11 14:44:09.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)							\
@@ -902,6 +904,15 @@ ath_attach(u_int16_t devid, struct net_d
 				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);
@@ -5102,6 +5113,11 @@ ath_rxbuf_init(struct ath_softc *sc, str
 	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) {
@@ -5133,6 +5149,27 @@ ath_rxbuf_init(struct ath_softc *sc, str
  			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
@@ -5583,7 +5620,7 @@ rx_accept:
 				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,
@@ -8998,7 +9035,7 @@ ath_ioctl(struct net_device *dev, struct
 {
 	struct ath_softc *sc = dev->priv;
 	struct ieee80211com *ic = &sc->sc_ic;
-	int error;
+	int error = 0;
 
 	ATH_LOCK(sc);
 	switch (cmd) {
diff -Naurp madwifi-0.9.2/Makefile madwifi-0.9.2-libmac/Makefile
--- madwifi-0.9.2/Makefile	2006-07-14 01:15:56.000000000 -0400
+++ madwifi-0.9.2-libmac/Makefile	2006-10-11 14:44:09.000000000 -0400
@@ -50,9 +50,10 @@ include $(obj)/Makefile.inc
 
 DIRS_MODULES = $(ATH) $(ATH_RATE) $(WLAN)
 
-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
@@ -80,8 +81,8 @@ svnversion.h:
 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 -Naurp madwifi-0.9.2/net80211/ieee80211_input.c madwifi-0.9.2-libmac/net80211/ieee80211_input.c
--- madwifi-0.9.2/net80211/ieee80211_input.c	2006-07-05 23:23:08.000000000 -0400
+++ madwifi-0.9.2-libmac/net80211/ieee80211_input.c	2006-10-11 14:44:09.000000000 -0400
@@ -57,6 +57,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
@@ -1092,6 +1096,18 @@ ieee80211_deliver_data(struct ieee80211_
 	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
@@ -1152,8 +1168,51 @@ ieee80211_deliver_data(struct ieee80211_
 		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 -Naurp madwifi-0.9.2/net80211/ieee80211_ioctl.h madwifi-0.9.2-libmac/net80211/ieee80211_ioctl.h
--- madwifi-0.9.2/net80211/ieee80211_ioctl.h	2006-07-05 23:23:08.000000000 -0400
+++ madwifi-0.9.2-libmac/net80211/ieee80211_ioctl.h	2006-10-11 14:44:09.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 @@ enum {
 	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 -Naurp madwifi-0.9.2/net80211/ieee80211_var.h madwifi-0.9.2-libmac/net80211/ieee80211_var.h
--- madwifi-0.9.2/net80211/ieee80211_var.h	2006-07-05 23:23:08.000000000 -0400
+++ madwifi-0.9.2-libmac/net80211/ieee80211_var.h	2006-10-11 14:44:09.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 @@ struct ieee80211com {
 	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 -Naurp madwifi-0.9.2/net80211/ieee80211_wireless.c madwifi-0.9.2-libmac/net80211/ieee80211_wireless.c
--- madwifi-0.9.2/net80211/ieee80211_wireless.c	2006-07-05 23:23:08.000000000 -0400
+++ madwifi-0.9.2-libmac/net80211/ieee80211_wireless.c	2006-10-11 14:44:09.000000000 -0400
@@ -61,6 +61,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) \
@@ -3296,8 +3301,89 @@ ieee80211_ioctl_setwmmparams(struct net_
 	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;
@@ -3375,20 +3461,135 @@ ieee80211_ioctl_setwmmparams(struct net_
 	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;
@@ -3408,6 +3609,7 @@ ieee80211_ioctl_getwmmparams(struct net_
 	default:
 		break;
 	}
+	
 	return 0;
 }
 
@@ -4507,6 +4709,15 @@ ieee80211_ioctl_siwencodeext(struct net_
 #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,
@@ -4540,56 +4751,29 @@ static const struct iw_priv_args ieee802
 	{ 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" },
@@ -4599,7 +4783,7 @@ static const struct iw_priv_args ieee802
 	  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" },
@@ -4611,8 +4795,8 @@ static const struct iw_priv_args ieee802
 	  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,
@@ -4903,6 +5087,7 @@ static const iw_handler ieee80211_handle
 	(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 */
@@ -4961,7 +5146,7 @@ ieee80211_ioctl(struct net_device *dev, 
 {
 	struct ieee80211vap *vap = dev->priv;
 	u_int unit;
-
+	
 	switch (cmd) {
 	case SIOCG80211STATS:
 		return copy_to_user(ifr->ifr_data, &vap->iv_stats,
diff -Naurp madwifi-0.9.2/net80211/libmac.h madwifi-0.9.2-libmac/net80211/libmac.h
--- madwifi-0.9.2/net80211/libmac.h	1969-12-31 19:00:00.000000000 -0500
+++ madwifi-0.9.2-libmac/net80211/libmac.h	2006-10-11 14:44:09.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 */

