Ticket #91: true_wds.diff
| File true_wds.diff, 9.8 kB (added by rudger@hopling.com, 7 years ago) |
|---|
-
net80211/ieee80211_ioctl.h
old new 517 517 #define IEEE80211_IOCTL_CHANSWITCH (SIOCIWFIRSTPRIV+16) 518 518 #define IEEE80211_IOCTL_SETMODE (SIOCIWFIRSTPRIV+17) 519 519 #define IEEE80211_IOCTL_GETMODE (SIOCIWFIRSTPRIV+18) 520 #define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+19) 521 #define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+20) 520 522 enum { 521 523 IEEE80211_WMMPARAMS_CWMIN = 1, 522 524 IEEE80211_WMMPARAMS_CWMAX = 2, -
net80211/ieee80211.c
old new 70 70 71 71 MALLOC_DEFINE(M_80211_VAP, "80211vap", "802.11 vap state"); 72 72 73 74 73 /* 75 74 * Country Code Table for code-to-string conversion. 76 75 */ … … 519 518 ieee80211_node_latevattach(vap); /* XXX move into vattach */ 520 519 ieee80211_power_latevattach(vap); /* XXX move into vattach */ 521 520 521 memset(vap->wds_mac, 0x00, IEEE80211_ADDR_LEN); 522 522 523 (void) ieee80211_media_setup(ic, &vap->iv_media, 523 524 vap->iv_caps, media_change, media_status); 524 525 ieee80211_media_status(dev, &imr); -
net80211/ieee80211_node.c
old new 850 850 /* Add wds address to the node table */ 851 851 int 852 852 ieee80211_add_wds_addr(struct ieee80211_node_table *nt, 853 struct ieee80211_node *ni, const u_int8_t *macaddr )853 struct ieee80211_node *ni, const u_int8_t *macaddr, u_int8_t wds_static) 854 854 { 855 855 int hash; 856 856 struct ieee80211_wds_addr *wds; … … 861 861 /* XXX msg */ 862 862 return 1; 863 863 } 864 wds->wds_agingcount = WDS_AGING_COUNT; 864 if (wds_static) 865 wds->wds_agingcount = WDS_AGING_STATIC; 866 else 867 wds->wds_agingcount = WDS_AGING_COUNT; 865 868 hash = IEEE80211_NODE_HASH(macaddr); 866 869 IEEE80211_ADDR_COPY(wds->wds_macaddr, macaddr); 867 870 ieee80211_ref_node(ni); /* Reference node */ … … 875 878 876 879 /* remove wds address from the wds hash table */ 877 880 void 878 ieee80211_remove_wds_addr(struct ieee80211_node_table *nt, 881 ieee80211_remove_wds_addr(struct ieee80211_node_table *nt, 879 882 const u_int8_t *macaddr) 880 883 { 881 884 int hash; … … 928 931 IEEE80211_NODE_LOCK_BH(nt); 929 932 for (hash=0; hash<IEEE80211_NODE_HASHSIZE; hash++) { 930 933 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 931 if (!wds->wds_agingcount) { 932 ieee80211_free_node(wds->wds_ni); /* Decrement ref count */ 933 LIST_REMOVE(wds, wds_hash); 934 FREE(wds, M_80211_WDS); 935 } else { 936 wds->wds_agingcount--; 937 } 934 if (wds->wds_agingcount != WDS_AGING_STATIC) { 935 if (!wds->wds_agingcount) { 936 ieee80211_free_node(wds->wds_ni); /* Decrement ref count */ 937 LIST_REMOVE(wds, wds_hash); 938 FREE(wds, M_80211_WDS); 939 } else { 940 wds->wds_agingcount--; 941 } 942 } 938 943 } 939 944 } 940 945 IEEE80211_NODE_UNLOCK_BH(nt); … … 1017 1022 LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 1018 1023 if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 1019 1024 ni = wds->wds_ni; 1020 wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ 1025 if (wds->wds_agingcount != WDS_AGING_STATIC) 1026 wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ 1021 1027 ieee80211_ref_node(ni); 1022 1028 return ni; 1023 1029 } -
net80211/ieee80211_node.h
old new 224 224 225 225 #define WDS_AGING_TIME 600 /* 10 minutes */ 226 226 #define WDS_AGING_COUNT 2 227 #define WDS_AGING_STATIC 0xffff 227 228 #define WDS_AGING_TIMER_VAL (WDS_AGING_TIME/2) 228 229 229 230 struct ieee80211_wds_addr { … … 291 292 struct ieee80211vap *, const u_int8_t *); 292 293 #endif 293 294 int ieee80211_add_wds_addr(struct ieee80211_node_table *, 294 struct ieee80211_node *, const u_int8_t * );295 struct ieee80211_node *, const u_int8_t *, u_int8_t); 295 296 void ieee80211_remove_wds_addr(struct ieee80211_node_table *, 296 297 const u_int8_t *); 297 298 void ieee80211_del_wds_node(struct ieee80211_node_table *, -
net80211/ieee80211_wireless.c
old new 2796 2796 } 2797 2797 2798 2798 static int 2799 ieee80211_ioctl_wdsmac(struct net_device *dev, struct iw_request_info *info, 2800 void *w, char *extra) 2801 { 2802 struct ieee80211vap *vap = dev->priv; 2803 struct sockaddr *sa = (struct sockaddr *)extra; 2804 struct ieee80211com *ic = vap->iv_ic; 2805 struct ieee80211_node *ni; 2806 2807 if (!IEEE80211_ADDR_NULL(vap->wds_mac)) { 2808 printk("%s: Device already has WDS mac address attached, remove first\n", dev->name); 2809 goto wdsmac_fail; 2810 } 2811 2812 memcpy(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN); 2813 2814 ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->wds_mac); 2815 if (ni != NULL) { 2816 if (ieee80211_add_wds_addr(&ic->ic_sta, ni, vap->wds_mac, 1) == 0) 2817 ieee80211_node_authorize(ni); 2818 else 2819 goto wdsmac_fail; 2820 } 2821 else 2822 goto wdsmac_fail; 2823 2824 printk("%s: Added WDS MAC: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dev->name, 2825 vap->wds_mac[0], vap->wds_mac[1], vap->wds_mac[2], 2826 vap->wds_mac[3], vap->wds_mac[4], vap->wds_mac[5]); 2827 2828 return 0; 2829 2830 wdsmac_fail: 2831 2832 printk("%s: Failed to add WDS MAC: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dev->name, 2833 sa->sa_data[0], sa->sa_data[1], sa->sa_data[2], 2834 sa->sa_data[3], sa->sa_data[4], sa->sa_data[5]); 2835 2836 return -1; 2837 } 2838 2839 static int 2840 ieee80211_ioctl_wdsdelmac(struct net_device *dev, struct iw_request_info *info, 2841 void *w, char *extra) 2842 { 2843 struct ieee80211vap *vap = dev->priv; 2844 struct sockaddr *sa = (struct sockaddr *)extra; 2845 struct ieee80211com *ic = vap->iv_ic; 2846 struct ieee80211_node *ni; 2847 2848 /* WDS Mac address filed already? */ 2849 if (IEEE80211_ADDR_NULL(vap->wds_mac)) { 2850 return 0; 2851 } 2852 2853 /* Compare suplied MAC address with WDS MAC of this interface 2854 * remove when mac address is known 2855 */ 2856 if (memcmp(vap->wds_mac, sa->sa_data, IEEE80211_ADDR_LEN) == 0) 2857 { 2858 ni = ieee80211_find_wds_node(&ic->ic_sta,vap->wds_mac); 2859 if(ni) { 2860 ieee80211_free_node(ni); /* Decr ref count */ 2861 } 2862 memset(vap->wds_mac, 0x00, IEEE80211_ADDR_LEN); 2863 return 0; 2864 } 2865 2866 printk("%s: WDS MAC address (%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x) not known by this interface\n", dev->name, 2867 sa->sa_data[0], sa->sa_data[1], sa->sa_data[2], 2868 sa->sa_data[3], sa->sa_data[4], sa->sa_data[5]); 2869 2870 return -1; 2871 } 2872 2873 static int 2799 2874 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info, 2800 2875 void *w, char *extra) 2801 2876 { … … 3423 3498 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"addmac" }, 3424 3499 { IEEE80211_IOCTL_DELMAC, 3425 3500 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"delmac" }, 3501 { IEEE80211_IOCTL_WDSADDMAC, 3502 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_add" }, 3503 { IEEE80211_IOCTL_WDSDELMAC, 3504 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,"wds_del" }, 3426 3505 { IEEE80211_IOCTL_SETCHANLIST, 3427 3506 IW_PRIV_TYPE_CHANLIST | IW_PRIV_SIZE_FIXED, 0,"setchanlist" }, 3428 3507 { IEEE80211_IOCTL_GETCHANLIST, … … 3799 3878 (iw_handler) ieee80211_ioctl_chanswitch, /* SIOCWFIRSTPRIV+16 */ 3800 3879 (iw_handler) ieee80211_ioctl_setmode, /* SIOCWFIRSTPRIV+17 */ 3801 3880 (iw_handler) ieee80211_ioctl_getmode, /* SIOCWFIRSTPRIV+18 */ 3881 (iw_handler) ieee80211_ioctl_wdsmac, /* SIOCWFIRSTPRIV+19 */ 3882 (iw_handler) ieee80211_ioctl_wdsdelmac, /* SIOCWFIRSTPRIV+20 */ 3802 3883 }; 3803 3884 static struct iw_handler_def ieee80211_iw_handler_def = { 3804 3885 #define N(a) (sizeof (a) / sizeof (a[0])) -
net80211/ieee80211_input.c
old new 463 463 station. remove the reference to the previous statation add 464 464 reference to the new one */ 465 465 (void) ieee80211_remove_wds_addr(nt,wh4->i_addr4); 466 ieee80211_add_wds_addr(nt, ni, wh4->i_addr4 );466 ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); 467 467 } 468 468 if (ni_wds == NULL) { 469 ieee80211_add_wds_addr(nt, ni, wh4->i_addr4 );469 ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); 470 470 } else 471 471 ieee80211_free_node(ni_wds); /* Decr ref count */ 472 472 } -
net80211/ieee80211_output.c
old new 236 236 * things like power save. 237 237 */ 238 238 eh = (struct ether_header *)skb->data; 239 ni = ieee80211_find_txnode(vap, eh->ether_dhost); 239 if (vap->iv_opmode == IEEE80211_M_WDS) 240 ni = ieee80211_find_txnode(vap, vap->wds_mac); 241 else 242 ni = ieee80211_find_txnode(vap, eh->ether_dhost); 243 240 244 if (ni == NULL) { 241 245 /* NB: ieee80211_find_txnode does stat+msg */ 242 246 goto bad; … … 831 835 if(ni_wds) { 832 836 ieee80211_free_node(ni_wds); /* Decr ref count */ 833 837 } else { 834 ieee80211_add_wds_addr(nt, ni, eh.ether_shost );838 ieee80211_add_wds_addr(nt, ni, eh.ether_shost, 0); 835 839 } 836 840 } 837 841 } -
net80211/ieee80211_var.h
old new 364 364 struct ieee80211_nsparams iv_nsparams; /* new state parameters for tasklet for stajoin1 */ 365 365 struct IEEE80211_TQ_STRUCT iv_stajoin1tq; /* tasklet for newstate action called from stajoin1tq */ 366 366 unsigned int iv_nsdone; /* Done with scheduled newstate tasklet */ 367 uint8_t wds_mac[IEEE80211_ADDR_LEN]; 367 368 }; 368 369 MALLOC_DECLARE(M_80211_VAP); 369 370 371 #define IEEE80211_ADDR_NULL(a1) (memcmp(a1, "\x00\x00\x00\x00\x00\x00", \ 372 IEEE80211_ADDR_LEN) == 0) 370 373 #define IEEE80211_ADDR_EQ(a1,a2) (memcmp(a1,a2,IEEE80211_ADDR_LEN) == 0) 371 374 #define IEEE80211_ADDR_COPY(dst,src) memcpy(dst,src,IEEE80211_ADDR_LEN) 372 375
