Lines Matching +full:mac +full:- +full:only

6  * WET STA and WET client are inter-exchangable in this file and refer to
12 * Tx: replace frames' source MAC address with wireless interface's;
13 * update the IP-MAC address mapping table entry.
15 * Rx: replace frames' the destination MAC address with what found in
16 * the IP-MAC address mapping table.
30 * uint8 mac[ETHER_ADDR_LEN];
51 * <<Broadcom-WL-IPTag/Open:>>
81 /* IP/MAC address mapping entry */
86 struct ether_addr mac; /* client MAC addr */ member
91 wet_sta_t *next_mac; /* hash link by MAC */
95 #define WET_STA_HASH_IP(ip) ((ip)[3]&(WET_STA_HASH_SIZE-1)) /* hash by IP */
96 #define WET_STA_HASH_MAC(ea) (((ea)[3]^(ea)[4]^(ea)[5])&(WET_STA_HASH_SIZE-1)) /* hash by MAC */
97 #define WET_STA_HASH_UNK -1 /* Unknown hash */
106 struct ether_addr mac; member
113 /* Used sta hash by MAC */
151 /* Protocol handlers hash table - hash by ether type */
159 #define WET_PROT_HASH(t) ((t)[1]&(WET_PROT_HASH_SIZE-1))
180 /* IPv4 handlers hash table - hash by protocol type */
188 #define WET_IPV4_HASH(p) ((p)&(WET_IPV4_HASH_SIZE-1))
200 /* UDP handlers hash table - hash by port number */
208 #define WET_UDP_HASH(p) ((p)[1]&(WET_UDP_HASH_SIZE-1))
220 #define WETHWADDR(weth) ((weth)->pub->mac.octet)
221 #define WETOSH(weth) ((weth)->pub->osh)
234 p = (dhd_wet_info_t *)MALLOCZ(pub->osh, sizeof(dhd_wet_info_t)); in dhd_get_wet_info()
238 for (i = 0; i < WET_NUMSTAS - 1; i ++) in dhd_get_wet_info()
239 p->sta[i].next = &p->sta[i + 1]; in dhd_get_wet_info()
240 p->stafree = &p->sta[0]; in dhd_get_wet_info()
241 p->pub = pub; in dhd_get_wet_info()
249 MFREE(pub->osh, wet, sizeof(dhd_wet_info_t)); in dhd_free_wet_info()
256 p = (dhd_wet_info_t *)pub->wet_info; in dhd_set_wet_host_ipv4()
257 bcopy(parms, p->ip, len); in dhd_set_wet_host_ipv4()
263 p = (dhd_wet_info_t *)pub->wet_info; in dhd_set_wet_host_mac()
264 bcopy(parms, &p->mac, len); in dhd_set_wet_host_mac()
295 return -1; in BCMFASTPATH()
298 length -= ph - frame; in BCMFASTPATH()
304 phdlr != NULL; phdlr = phdlr->next) { in BCMFASTPATH()
305 if (phdlr->type != type || !phdlr->prot_proc) in BCMFASTPATH()
307 return (phdlr->prot_proc)(weth, sdu, frame, ph, length, send); in BCMFASTPATH()
317 /* ignore unsupported protocol from different mac addr than us */ in BCMFASTPATH()
341 return -1; in BCMFASTPATH()
353 phdlr != NULL; phdlr = phdlr->next) { in BCMFASTPATH()
354 if (phdlr->type != type || !phdlr->prot_proc) in BCMFASTPATH()
356 return (phdlr->prot_proc)(weth, sdu, eh, in BCMFASTPATH()
384 /* IPv4 only */ in BCMFASTPATH()
388 return -1; in BCMFASTPATH()
397 return -1; in BCMFASTPATH()
403 iphdlr; iphdlr = iphdlr->next) { in BCMFASTPATH()
404 if (iphdlr->type != type || !iphdlr->ipv4_proc) in BCMFASTPATH()
406 if ((ret = (iphdlr->ipv4_proc)(weth, eh, in BCMFASTPATH()
407 iph, iph + ihl, length - ihl, send))) in BCMFASTPATH()
412 * Replace source MAC in Ethernet header with wireless's and in BCMFASTPATH()
413 * keep track of IP MAC mapping when sending frame. in BCMFASTPATH()
437 return -1; in BCMFASTPATH()
444 * Replace dest MAC in Ethernet header using the found one in BCMFASTPATH()
453 return -1; in BCMFASTPATH()
455 ea = &sta->mac; in BCMFASTPATH()
463 /* process ARP frame - ARP proxy */
485 * Replace source MAC in Ethernet header as well as source MAC in in BCMFASTPATH()
496 return -1; in BCMFASTPATH()
502 * Replace dest MAC in Ethernet header as well as dest MAC in in BCMFASTPATH()
513 return -1; in BCMFASTPATH()
515 bcopy(&sta->mac, arph + ARP_TGT_ETH_OFFSET, ETHER_ADDR_LEN); in BCMFASTPATH()
516 bcopy(&sta->mac, eh + ETHER_DEST_OFFSET, ETHER_ADDR_LEN); in BCMFASTPATH()
537 if ((length -= UDP_HDR_LEN) < 0) { in BCMFASTPATH()
540 return -1; in BCMFASTPATH()
550 udphdlr; udphdlr = udphdlr->next) { in BCMFASTPATH()
551 if (udphdlr->port != port || !udphdlr->udp_proc) in BCMFASTPATH()
553 return (udphdlr->udp_proc)(weth, eh, iph, udph, in BCMFASTPATH()
562 * uses its protocol body to convey IP/MAC info. It is impossible
574 * MAC address. Such replies will not be delivered simply
580 * table on the AP will have this device's MAC address only.
588 * 3. This device's MAC won't allow such frames pass
589 * through in non-promiscuous mode even when they made
594 * Once the WET is configured with the host MAC address it can
623 /* only interested in requests when sending to server */ in BCMFASTPATH()
626 /* only interested in replies when receiving from server as a relay agent */ in BCMFASTPATH()
632 /* find existing or alloc new IP/MAC mapping entry */ in BCMFASTPATH()
638 return -1; in BCMFASTPATH()
641 /* We can always relay the host's request when we know its MAC addr. */ in BCMFASTPATH()
642 if (!ETHER_ISNULLADDR(weth->mac.octet) && in BCMFASTPATH()
643 !bcmp(dhcp + DHCP_CHADDR_OFFSET, &weth->mac, ETHER_ADDR_LEN)) { in BCMFASTPATH()
644 /* replace chaddr with host's MAC */ in BCMFASTPATH()
653 else if (!IPV4_ADDR_NULL(weth->ip)) { in BCMFASTPATH()
654 /* we can only handle the first hop otherwise drop it */ in BCMFASTPATH()
657 return -1; in BCMFASTPATH()
662 weth->ip, IPV4_ADDR_LEN); in BCMFASTPATH()
663 bcopy(weth->ip, dhcp + DHCP_GIADDR_OFFSET, IPV4_ADDR_LEN); in BCMFASTPATH()
668 * Request comes in when we don't know the host's MAC and/or IP in BCMFASTPATH()
676 bcopy(dhcp + DHCP_FLAGS_OFFSET, sta->flags, DHCP_FLAGS_LEN); in BCMFASTPATH()
677 if (flags != *(uint16 *)sta->flags) { in BCMFASTPATH()
684 /* replace the Ethernet source MAC with ours */ in BCMFASTPATH()
688 else if (!IPV4_ADDR_NULL(weth->ip) && in BCMFASTPATH()
689 !bcmp(dhcp + DHCP_GIADDR_OFFSET, weth->ip, IPV4_ADDR_LEN)) { in BCMFASTPATH()
690 /* find IP/MAC mapping entry */ in BCMFASTPATH()
696 return -1; in BCMFASTPATH()
699 * XXX the following code works for the first hop only in BCMFASTPATH()
707 if (bcmp(dhcp + DHCP_FLAGS_OFFSET, sta->flags, DHCP_FLAGS_LEN)) { in BCMFASTPATH()
710 sta->flags, DHCP_FLAGS_LEN); in BCMFASTPATH()
711 bcopy(sta->flags, dhcp + DHCP_FLAGS_OFFSET, DHCP_FLAGS_LEN); in BCMFASTPATH()
719 /* replace the dest MAC & IP addr with the client's */ in BCMFASTPATH()
720 if (*(uint16 *)sta->flags & HTON16(DHCP_FLAG_BCAST)) { in BCMFASTPATH()
726 ether = &sta->mac; in BCMFASTPATH()
737 /* it should not recv non-relay reply at all, but just in case */ in BCMFASTPATH()
741 return -1; in BCMFASTPATH()
768 /* only interested in replies when receiving from server */ in BCMFASTPATH()
772 /* find IP/MAC mapping entry */ in BCMFASTPATH()
776 return -1; in BCMFASTPATH()
778 /* relay the reply to the host when we know the host's MAC addr */ in BCMFASTPATH()
779 if (!ETHER_ISNULLADDR(weth->mac.octet) && in BCMFASTPATH()
783 weth->mac.octet, ETHER_ADDR_LEN); in BCMFASTPATH()
784 bcopy(&weth->mac, dhcp + DHCP_CHADDR_OFFSET, ETHER_ADDR_LEN); in BCMFASTPATH()
787 if (bcmp(dhcp + DHCP_FLAGS_OFFSET, sta->flags, DHCP_FLAGS_LEN)) { in BCMFASTPATH()
790 sta->flags, DHCP_FLAGS_LEN); in BCMFASTPATH()
791 bcopy(sta->flags, dhcp + DHCP_FLAGS_OFFSET, DHCP_FLAGS_LEN); in BCMFASTPATH()
793 /* replace the dest MAC with that of client's */ in BCMFASTPATH()
794 if (*(uint16 *)sta->flags & HTON16(DHCP_FLAG_BCAST)) in BCMFASTPATH()
797 bcopy(&sta->mac, eh + ETHER_DEST_OFFSET, ETHER_ADDR_LEN); in BCMFASTPATH()
803 /* alloc IP/MAC mapping entry
812 if (!weth->stafree) { in wet_sta_alloc()
814 return -1; in wet_sta_alloc()
816 sta = weth->stafree; in wet_sta_alloc()
817 weth->stafree = sta->next; in wet_sta_alloc()
820 sta->next = NULL; in wet_sta_alloc()
821 sta->next_ip = NULL; in wet_sta_alloc()
822 sta->next_mac = NULL; in wet_sta_alloc()
828 /* update IP/MAC mapping entry and hash
842 i = WET_STA_HASH_IP(sta->ip); in BCMFASTPATH()
843 if (bcmp(sta->ip, iaddr, IPV4_ADDR_LEN)) { in BCMFASTPATH()
845 for (next = &weth->stahash_ip[i], sta2 = *next; in BCMFASTPATH()
846 sta2; sta2 = sta2->next_ip) { in BCMFASTPATH()
849 next = &sta2->next_ip; in BCMFASTPATH()
852 *next = sta2->next_ip; in BCMFASTPATH()
853 sta2->next_ip = NULL; in BCMFASTPATH()
858 /* allocate a new one and hash it by MAC */ in BCMFASTPATH()
860 i = WET_STA_HASH_MAC(eaddr->octet); in BCMFASTPATH()
861 bcopy(eaddr, &sta->mac, ETHER_ADDR_LEN); in BCMFASTPATH()
862 sta->next_mac = weth->stahash_mac[i]; in BCMFASTPATH()
863 weth->stahash_mac[i] = sta; in BCMFASTPATH()
871 return -1; in BCMFASTPATH()
877 bcopy(iaddr, sta->ip, IPV4_ADDR_LEN); in BCMFASTPATH()
878 sta->next_ip = weth->stahash_ip[i]; in BCMFASTPATH()
879 weth->stahash_ip[i] = sta; in BCMFASTPATH()
885 for (sta2 = sta->next_ip; sta2; sta2 = sta2->next_ip) { in BCMFASTPATH()
887 if (!bcmp(sta->ip, sta2->ip, IPV4_ADDR_LEN)) { in BCMFASTPATH()
890 prev->next_ip = sta2->next_ip; in BCMFASTPATH()
891 sta2->next_ip = NULL; in BCMFASTPATH()
892 /* now we need to find this guy in the MAC list and in BCMFASTPATH()
895 wet_sta_remove_mac_entry(weth, &sta2->mac); in BCMFASTPATH()
900 sta2->next = weth->stafree; in BCMFASTPATH()
901 weth->stafree = sta2; in BCMFASTPATH()
914 /* update IP/MAC mapping entry and hash */
928 i = WET_STA_HASH_MAC(eaddr->octet); in BCMFASTPATH()
929 bcopy(eaddr, &sta->mac, ETHER_ADDR_LEN); in BCMFASTPATH()
930 sta->next_mac = weth->stahash_mac[i]; in BCMFASTPATH()
931 weth->stahash_mac[i] = sta; in BCMFASTPATH()
937 return -1; in BCMFASTPATH()
944 /* Remove MAC entry from hash list
945 * NOTE: This only removes the entry matching "eaddr" from the MAC
954 int i = WET_STA_HASH_MAC(eaddr->octet); in BCMFASTPATH()
960 for (sta = prev = weth->stahash_mac[i]; sta; sta = sta->next_mac) { in BCMFASTPATH()
961 if (!bcmp(&sta->mac, eaddr, ETHER_ADDR_LEN)) { in BCMFASTPATH()
972 return -1; in BCMFASTPATH()
977 weth->stahash_mac[i] = sta->next_mac; /* removing first entry in this bucket */ in BCMFASTPATH()
979 prev->next_mac = sta->next_mac; in BCMFASTPATH()
984 /* find IP/MAC mapping entry by IP address
994 for (sta = weth->stahash_ip[i]; sta; sta = sta->next_ip) { in BCMFASTPATH()
995 if (bcmp(sta->ip, iaddr, IPV4_ADDR_LEN)) in BCMFASTPATH()
1004 return -1; in BCMFASTPATH()
1007 /* find IP/MAC mapping entry by MAC address
1013 int i = WET_STA_HASH_MAC(eaddr->octet); in BCMFASTPATH()
1018 /* find the existing one by MAC */ in BCMFASTPATH()
1019 for (sta = weth->stahash_mac[i]; sta; sta = sta->next_mac) { in BCMFASTPATH()
1020 if (bcmp(&sta->mac, eaddr, ETHER_ADDR_LEN)) in BCMFASTPATH()
1029 return -1; in BCMFASTPATH()
1032 /* Adjust 16 bit checksum - taken from RFC 3022.
1034 * The algorithm below is applicable only for even offsets (i.e., optr
1053 x -= old & 0xffff; in BCMFASTPATH()
1054 if (x <= 0) { x--; x &= 0xffff; } in BCMFASTPATH()
1055 olen -= 2; in BCMFASTPATH()
1062 nlen -= 2; in BCMFASTPATH()
1068 /* Process frames in transmit direction by replacing source MAC with
1069 * wireless's and keep track of IP MAC address mapping table.
1089 * FIXME: need to tell if buffer is shared and only in BCMFASTPATH()
1099 return -1; in BCMFASTPATH()
1105 return -1; in BCMFASTPATH()
1117 return wet_eth_proc(weth, sdu, frame, length, 1) < 0 ? -1 : 0; in BCMFASTPATH()
1121 * Process frames in receive direction by replacing destination MAC with
1122 * the one found in IP MAC address mapping table.
1133 PKTLEN(WETOSH(weth), sdu), 0) < 0 ? -1 : 0; in BCMFASTPATH()
1142 dhd_wet_info_t *weth = dhd_pub->wet_info; in dhd_wet_sta_delete_list()
1145 for (sta = weth->stahash_mac[i]; sta; sta = sta->next_mac) { in dhd_wet_sta_delete_list()
1147 j = WET_STA_HASH_IP(sta->ip); in dhd_wet_sta_delete_list()
1148 for (next = &weth->stahash_ip[j], sta2 = *next; in dhd_wet_sta_delete_list()
1149 sta2; sta2 = sta2->next_ip) { in dhd_wet_sta_delete_list()
1152 next = &sta2->next_ip; in dhd_wet_sta_delete_list()
1155 *next = sta2->next_ip; in dhd_wet_sta_delete_list()
1156 sta2->next_ip = NULL; in dhd_wet_sta_delete_list()
1160 wet_sta_remove_mac_entry(weth, &sta->mac); in dhd_wet_sta_delete_list()
1171 dhd_wet_info_t *weth = dhdp->wet_info; in dhd_wet_dump()
1173 bcm_bprintf(b, "Host MAC: %s\n", bcm_ether_ntoa(&weth->mac, eabuf)); in dhd_wet_dump()
1175 weth->ip[0], weth->ip[1], weth->ip[2], weth->ip[3]); in dhd_wet_dump()
1179 if (weth->sta[i].next) in dhd_wet_dump()
1182 sta = &weth->sta[i]; in dhd_wet_dump()
1184 i, bcm_ether_ntoa(&sta->mac, eabuf), in dhd_wet_dump()
1185 sta->ip[0], sta->ip[1], sta->ip[2], sta->ip[3]); in dhd_wet_dump()