1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _RTW_BR_EXT_C_
23 #include <linux/if_arp.h>
26 #include <linux/atalk.h>
27 #include <linux/udp.h>
28 #include <linux/if_pppox.h>
31 #if 1 // rtw_wifi_driver
32 #include <drv_types.h>
33 #else // rtw_wifi_driver
34 #include "./8192cd_cfg.h"
37 #include "./sys-support.h"
41 #include "./8192cd_headers.h"
42 #include "./8192cd_br_ext.h"
43 #include "./8192cd_debug.h"
44 #endif // rtw_wifi_driver
48 #include <linux/ipv6.h>
49 #include <linux/icmpv6.h>
50 #include <net/ndisc.h>
51 #include <net/checksum.h>
52 #include <net/ip6_checksum.h>
58 //#define BR_EXT_DEBUG
63 #define NAT25_APPLE 04
64 #define NAT25_PPPOE 05
66 #define RTL_RELAY_TAG_LEN (ETH_ALEN)
69 #define MAGIC_CODE 0x8186
70 #define MAGIC_CODE_LEN 2
71 #define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec
73 /*-----------------------------------------------------------------
74 How database records network address:
75 0 1 2 3 4 5 6 7 8 9 10
76 |----|----|----|----|----|----|----|----|----|----|----|
77 IPv4 |type| | IP addr |
78 IPX |type| Net addr | Node addr |
79 IPX |type| Net addr |Sckt addr|
80 Apple |type| Network |node|
81 PPPoE |type| SID | AC MAC |
82 -----------------------------------------------------------------*/
85 //Find a tag in pppoe frame and return the pointer
86 static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
88 unsigned char *cur_ptr, *start_ptr;
89 unsigned short tagLen, tagType;
91 start_ptr = cur_ptr = (unsigned char *)ph->tag;
92 while((cur_ptr - start_ptr) < ntohs(ph->length)) {
93 // prevent un-alignment access
94 tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
95 tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
98 cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen;
104 static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
106 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
109 data_len = tag->tag_len + TAG_HDR_LEN;
110 if (skb_tailroom(skb) < data_len) {
111 _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n");
115 skb_put(skb, data_len);
116 // have a room for new tag
117 memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
118 ph->length = htons(ntohs(ph->length) + data_len);
119 memcpy((unsigned char *)ph->tag, tag, data_len);
123 static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len)
126 unsigned long end, tail;
128 if ((src+len) > skb_tail_pointer(skb) || skb->len < len)
131 tail = (unsigned long)skb_tail_pointer(skb);
132 end = (unsigned long)src+len;
136 tail_len = (int)(tail-end);
138 memmove(src, src+len, tail_len);
140 skb_trim(skb, skb->len-len);
144 static __inline__ unsigned long __nat25_timeout(_adapter *priv)
146 unsigned long timeout;
148 timeout = jiffies - NAT25_AGEING_TIME*HZ;
154 static __inline__ int __nat25_has_expired(_adapter *priv,
155 struct nat25_network_db_entry *fdb)
157 if(time_before_eq(fdb->ageing_timer, __nat25_timeout(priv)))
164 static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr,
165 unsigned int *ipAddr)
167 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
169 networkAddr[0] = NAT25_IPV4;
170 memcpy(networkAddr+7, (unsigned char *)ipAddr, 4);
174 static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr,
175 unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr)
177 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
179 networkAddr[0] = NAT25_IPX;
180 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
181 memcpy(networkAddr+5, ipxNodeAddr, 6);
185 static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr,
186 unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr)
188 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
190 networkAddr[0] = NAT25_IPX;
191 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
192 memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2);
196 static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr,
197 unsigned short *network, unsigned char *node)
199 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
201 networkAddr[0] = NAT25_APPLE;
202 memcpy(networkAddr+1, (unsigned char *)network, 2);
203 networkAddr[3] = *node;
207 static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr,
208 unsigned char *ac_mac, unsigned short *sid)
210 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
212 networkAddr[0] = NAT25_PPPOE;
213 memcpy(networkAddr+1, (unsigned char *)sid, 2);
214 memcpy(networkAddr+3, (unsigned char *)ac_mac, 6);
219 static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr,
220 unsigned int *ipAddr)
222 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
224 networkAddr[0] = NAT25_IPV6;
225 memcpy(networkAddr+1, (unsigned char *)ipAddr, 16);
229 static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b)
232 if (*data == tag && *(data+1) == len8b && len >= len8b*8)
235 len -= (*(data+1))*8;
236 data += (*(data+1))*8;
242 static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac)
244 struct icmp6hdr *icmphdr = (struct icmp6hdr *)data;
247 if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) {
249 mac = scan_tlv(&data[8], len-8, 1, 1);
251 DBG_871X("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
252 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
253 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
254 memcpy(mac, replace_mac, 6);
259 else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) {
261 mac = scan_tlv(&data[16], len-16, 1, 1);
263 DBG_871X("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
264 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
265 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
266 memcpy(mac, replace_mac, 6);
271 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
273 mac = scan_tlv(&data[24], len-24, 1, 1);
275 DBG_871X("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
276 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
277 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
278 memcpy(mac, replace_mac, 6);
283 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
285 mac = scan_tlv(&data[24], len-24, 2, 1);
287 DBG_871X("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
288 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
289 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
290 memcpy(mac, replace_mac, 6);
295 else if (icmphdr->icmp6_type == NDISC_REDIRECT) {
297 mac = scan_tlv(&data[40], len-40, 2, 1);
299 DBG_871X("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
300 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
301 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
302 memcpy(mac, replace_mac, 6);
311 static void convert_ipv6_mac_to_mc(struct sk_buff *skb)
313 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
314 unsigned char *dst_mac = skb->data;
318 /*modified by qinjunjie,ipv6 multicast address ix 0x33-33-xx-xx-xx-xx*/
321 memcpy(&dst_mac[2], &iph->daddr.s6_addr32[3], 4);
322 #if defined(__LINUX_2_6__)
323 /*modified by qinjunjie,warning:should not remove next line*/
324 skb->pkt_type = PACKET_MULTICAST;
327 #endif /* CL_IPV6_PASS */
330 static __inline__ int __nat25_network_hash(unsigned char *networkAddr)
332 if(networkAddr[0] == NAT25_IPV4)
336 x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
338 return x & (NAT25_HASH_SIZE - 1);
340 else if(networkAddr[0] == NAT25_IPX)
344 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
345 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
347 return x & (NAT25_HASH_SIZE - 1);
349 else if(networkAddr[0] == NAT25_APPLE)
353 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3];
355 return x & (NAT25_HASH_SIZE - 1);
357 else if(networkAddr[0] == NAT25_PPPOE)
361 x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8];
363 return x & (NAT25_HASH_SIZE - 1);
366 else if(networkAddr[0] == NAT25_IPV6)
370 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
371 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^
372 networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^
375 return x & (NAT25_HASH_SIZE - 1);
383 for (i=0; i<MAX_NETWORK_ADDR_LEN; i++)
386 return x & (NAT25_HASH_SIZE - 1);
391 static __inline__ void __network_hash_link(_adapter *priv,
392 struct nat25_network_db_entry *ent, int hash)
394 // Caller must _enter_critical_bh already!
396 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
398 ent->next_hash = priv->nethash[hash];
399 if(ent->next_hash != NULL)
400 ent->next_hash->pprev_hash = &ent->next_hash;
401 priv->nethash[hash] = ent;
402 ent->pprev_hash = &priv->nethash[hash];
404 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
408 static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
410 // Caller must _enter_critical_bh already!
412 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
414 *(ent->pprev_hash) = ent->next_hash;
415 if(ent->next_hash != NULL)
416 ent->next_hash->pprev_hash = ent->pprev_hash;
417 ent->next_hash = NULL;
418 ent->pprev_hash = NULL;
420 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
424 static int __nat25_db_network_lookup_and_replace(_adapter *priv,
425 struct sk_buff *skb, unsigned char *networkAddr)
427 struct nat25_network_db_entry *db;
429 _enter_critical_bh(&priv->br_ext_lock, &irqL);
431 db = priv->nethash[__nat25_network_hash(networkAddr)];
434 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
436 if(!__nat25_has_expired(priv, db))
438 // replace the destination mac address
439 memcpy(skb->data, db->macAddr, ETH_ALEN);
440 atomic_inc(&db->use_count);
443 DBG_871X("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
444 "%02x%02x%02x%02x%02x%02x\n",
467 db->networkAddr[16]);
469 DBG_871X("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
486 db->networkAddr[10]);
489 _exit_critical_bh(&priv->br_ext_lock, &irqL);
496 _exit_critical_bh(&priv->br_ext_lock, &irqL);
501 static void __nat25_db_network_insert(_adapter *priv,
502 unsigned char *macAddr, unsigned char *networkAddr)
504 struct nat25_network_db_entry *db;
507 _enter_critical_bh(&priv->br_ext_lock, &irqL);
509 hash = __nat25_network_hash(networkAddr);
510 db = priv->nethash[hash];
513 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
515 memcpy(db->macAddr, macAddr, ETH_ALEN);
516 db->ageing_timer = jiffies;
517 _exit_critical_bh(&priv->br_ext_lock, &irqL);
524 db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db));
526 _exit_critical_bh(&priv->br_ext_lock, &irqL);
530 memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN);
531 memcpy(db->macAddr, macAddr, ETH_ALEN);
532 atomic_set(&db->use_count, 1);
533 db->ageing_timer = jiffies;
535 __network_hash_link(priv, db, hash);
537 _exit_critical_bh(&priv->br_ext_lock, &irqL);
541 static void __nat25_db_print(_adapter *priv)
544 _enter_critical_bh(&priv->br_ext_lock, &irqL);
547 static int counter = 0;
549 struct nat25_network_db_entry *db;
552 if((counter % 16) != 0)
555 for(i=0, j=0; i<NAT25_HASH_SIZE; i++)
557 db = priv->nethash[i];
562 panic_printk("NAT25: DB(%d) H(%02d) C(%d) M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
563 "%02x%02x%02x%02x%02x%02x\n",
566 atomic_read(&db->use_count),
589 db->networkAddr[16]);
591 panic_printk("NAT25: DB(%d) H(%02d) C(%d) M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
594 atomic_read(&db->use_count),
611 db->networkAddr[10]);
620 _exit_critical_bh(&priv->br_ext_lock, &irqL);
630 void nat25_db_cleanup(_adapter *priv)
634 _enter_critical_bh(&priv->br_ext_lock, &irqL);
636 for(i=0; i<NAT25_HASH_SIZE; i++)
638 struct nat25_network_db_entry *f;
639 f = priv->nethash[i];
641 struct nat25_network_db_entry *g;
644 if(priv->scdb_entry == f)
646 memset(priv->scdb_mac, 0, ETH_ALEN);
647 memset(priv->scdb_ip, 0, 4);
648 priv->scdb_entry = NULL;
650 __network_hash_unlink(f);
651 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
657 _exit_critical_bh(&priv->br_ext_lock, &irqL);
661 void nat25_db_expire(_adapter *priv)
665 _enter_critical_bh(&priv->br_ext_lock, &irqL);
667 //if(!priv->ethBrExtInfo.nat25_disable)
669 for (i=0; i<NAT25_HASH_SIZE; i++)
671 struct nat25_network_db_entry *f;
672 f = priv->nethash[i];
676 struct nat25_network_db_entry *g;
679 if(__nat25_has_expired(priv, f))
681 if(atomic_dec_and_test(&f->use_count))
685 panic_printk("NAT25 Expire H(%02d) M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
686 "%02x%02x%02x%02x%02x%02x\n",
713 panic_printk("NAT25 Expire H(%02d) M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
734 if(priv->scdb_entry == f)
736 memset(priv->scdb_mac, 0, ETH_ALEN);
737 memset(priv->scdb_ip, 0, 4);
738 priv->scdb_entry = NULL;
740 __network_hash_unlink(f);
741 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
750 _exit_critical_bh(&priv->br_ext_lock, &irqL);
754 #ifdef SUPPORT_TX_MCAST2UNI
755 static int checkIPMcAndReplace(_adapter *priv, struct sk_buff *skb, unsigned int *dst_ip)
757 struct stat_info *pstat;
758 struct list_head *phead, *plist;
761 phead = &priv->asoc_list;
764 while (plist != phead) {
765 pstat = list_entry(plist, struct stat_info, asoc_list);
768 if (pstat->ipmc_num == 0)
771 for (i=0; i<MAX_IP_MC_ENTRY; i++) {
772 if (pstat->ipmc[i].used && !memcmp(&pstat->ipmc[i].mcmac[3], ((unsigned char *)dst_ip)+1, 3)) {
773 memcpy(skb->data, pstat->ipmc[i].mcmac, ETH_ALEN);
782 int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
784 unsigned short protocol;
785 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
790 if((method <= NAT25_MIN) || (method >= NAT25_MAX))
793 protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
795 /*---------------------------------------------------*/
796 /* Handle IP frame */
797 /*---------------------------------------------------*/
798 if(protocol == __constant_htons(ETH_P_IP))
800 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
802 if(((unsigned char*)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len))
804 DEBUG_WARN("NAT25: malformed IP packet !\n");
815 //some muticast with source IP is all zero, maybe other case is illegal
816 //in class A, B, C, host address is all zero or all one is illegal
819 DBG_871X("NAT25: Insert IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
820 __nat25_generate_ipv4_network_addr(networkAddr, &iph->saddr);
821 //record source IP address and , source mac address into db
822 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
824 __nat25_db_print(priv);
830 DBG_871X("NAT25: Lookup IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
831 #ifdef SUPPORT_TX_MCAST2UNI
832 if (priv->pshare->rf_ft_var.mc2u_disable ||
833 ((((OPMODE & (WIFI_STATION_STATE|WIFI_ASOC_STATE))
834 == (WIFI_STATION_STATE|WIFI_ASOC_STATE)) &&
835 !checkIPMcAndReplace(priv, skb, &iph->daddr)) ||
836 (OPMODE & WIFI_ADHOC_STATE)))
839 __nat25_generate_ipv4_network_addr(networkAddr, &iph->daddr);
841 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
842 if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
843 // L2 is unicast but L3 is broadcast, make L2 bacome broadcast
844 DBG_871X("NAT25: Set DA as boardcast\n");
845 memset(skb->data, 0xff, ETH_ALEN);
848 // forward unknow IP packet to upper TCP/IP
849 DBG_871X("NAT25: Replace DA with BR's MAC\n");
850 if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) {
851 void netdev_br_init(struct net_device *netdev);
852 printk("Re-init netdev_br_init() due to br_mac==0!\n");
853 netdev_br_init(priv->pnetdev);
855 memcpy(skb->data, priv->br_mac, ETH_ALEN);
867 /*---------------------------------------------------*/
868 /* Handle ARP frame */
869 /*---------------------------------------------------*/
870 else if(protocol == __constant_htons(ETH_P_ARP))
872 struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
873 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
874 unsigned int *sender, *target;
876 if(arp->ar_pro != __constant_htons(ETH_P_IP))
878 DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", htons(arp->ar_pro));
885 return 0; // skb_copy for all ARP frame
889 DBG_871X("NAT25: Insert ARP, MAC=%02x%02x%02x%02x%02x%02x\n", arp_ptr[0],
890 arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]);
892 // change to ARP sender mac address to wlan STA address
893 memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
895 arp_ptr += arp->ar_hln;
896 sender = (unsigned int *)arp_ptr;
898 __nat25_generate_ipv4_network_addr(networkAddr, sender);
900 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
902 __nat25_db_print(priv);
908 DBG_871X("NAT25: Lookup ARP\n");
910 arp_ptr += arp->ar_hln;
911 sender = (unsigned int *)arp_ptr;
912 arp_ptr += (arp->ar_hln + arp->ar_pln);
913 target = (unsigned int *)arp_ptr;
915 __nat25_generate_ipv4_network_addr(networkAddr, target);
917 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
919 // change to ARP target mac address to Lookup result
920 arp_ptr = (unsigned char *)(arp + 1);
921 arp_ptr += (arp->ar_hln + arp->ar_pln);
922 memcpy(arp_ptr, skb->data, ETH_ALEN);
931 /*---------------------------------------------------*/
932 /* Handle IPX and Apple Talk frame */
933 /*---------------------------------------------------*/
934 else if((protocol == __constant_htons(ETH_P_IPX)) ||
935 (protocol == __constant_htons(ETH_P_ATALK)) ||
936 (protocol == __constant_htons(ETH_P_AARP)))
938 unsigned char ipx_header[2] = {0xFF, 0xFF};
939 struct ipxhdr *ipx = NULL;
940 struct elapaarp *ea = NULL;
941 struct ddpehdr *ddp = NULL;
942 unsigned char *framePtr = skb->data + ETH_HLEN;
944 if(protocol == __constant_htons(ETH_P_IPX))
946 DBG_871X("NAT25: Protocol=IPX (Ethernet II)\n");
947 ipx = (struct ipxhdr *)framePtr;
949 else //if(protocol <= __constant_htons(ETH_FRAME_LEN))
951 if(!memcmp(ipx_header, framePtr, 2))
953 DBG_871X("NAT25: Protocol=IPX (Ethernet 802.3)\n");
954 ipx = (struct ipxhdr *)framePtr;
958 unsigned char ipx_8022_type = 0xE0;
959 unsigned char snap_8022_type = 0xAA;
961 if(*framePtr == snap_8022_type)
963 unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID
964 unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID
965 unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID
967 framePtr += 3; // eliminate the 802.2 header
969 if(!memcmp(ipx_snap_id, framePtr, 5))
971 framePtr += 5; // eliminate the SNAP header
973 DBG_871X("NAT25: Protocol=IPX (Ethernet SNAP)\n");
974 ipx = (struct ipxhdr *)framePtr;
976 else if(!memcmp(aarp_snap_id, framePtr, 5))
978 framePtr += 5; // eliminate the SNAP header
980 ea = (struct elapaarp *)framePtr;
982 else if(!memcmp(ddp_snap_id, framePtr, 5))
984 framePtr += 5; // eliminate the SNAP header
986 ddp = (struct ddpehdr *)framePtr;
990 DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0],
991 framePtr[1], framePtr[2], framePtr[3], framePtr[4]);
995 else if(*framePtr == ipx_8022_type)
997 framePtr += 3; // eliminate the 802.2 header
999 if(!memcmp(ipx_header, framePtr, 2))
1001 DBG_871X("NAT25: Protocol=IPX (Ethernet 802.2)\n");
1002 ipx = (struct ipxhdr *)framePtr;
1016 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1018 DBG_871X("NAT25: Check IPX skb_copy\n");
1025 DBG_871X("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n",
1027 ipx->ipx_dest.node[0],
1028 ipx->ipx_dest.node[1],
1029 ipx->ipx_dest.node[2],
1030 ipx->ipx_dest.node[3],
1031 ipx->ipx_dest.node[4],
1032 ipx->ipx_dest.node[5],
1034 ipx->ipx_source.net,
1035 ipx->ipx_source.node[0],
1036 ipx->ipx_source.node[1],
1037 ipx->ipx_source.node[2],
1038 ipx->ipx_source.node[3],
1039 ipx->ipx_source.node[4],
1040 ipx->ipx_source.node[5],
1041 ipx->ipx_source.sock);
1043 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1045 DBG_871X("NAT25: Use IPX Net, and Socket as network addr\n");
1047 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
1049 // change IPX source node addr to wlan STA address
1050 memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
1054 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node);
1057 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1059 __nat25_db_print(priv);
1065 if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN))
1067 DBG_871X("NAT25: Lookup IPX, Modify Destination IPX Node addr\n");
1069 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock);
1071 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1073 // replace IPX destination node addr with Lookup destination MAC addr
1074 memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
1078 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node);
1080 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1093 /* Sanity check fields. */
1094 if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN)
1096 DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n");
1107 // change to AARP source mac address to wlan STA address
1108 memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
1110 DBG_871X("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
1116 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node);
1118 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1120 __nat25_db_print(priv);
1126 DBG_871X("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n",
1132 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node);
1134 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1136 // change to AARP destination mac address to Lookup result
1137 memcpy(ea->hw_dst, skb->data, ETH_ALEN);
1147 else if(ddp != NULL)
1156 DBG_871X("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n",
1162 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode);
1164 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1166 __nat25_db_print(priv);
1172 DBG_871X("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n",
1178 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode);
1180 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1192 /*---------------------------------------------------*/
1193 /* Handle PPPoE frame */
1194 /*---------------------------------------------------*/
1195 else if((protocol == __constant_htons(ETH_P_PPP_DISC)) ||
1196 (protocol == __constant_htons(ETH_P_PPP_SES)))
1198 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
1199 unsigned short *pMagic;
1209 if(ph->sid == 0) // Discovery phase according to tag
1211 if(ph->code == PADI_CODE || ph->code == PADR_CODE)
1213 if (priv->ethBrExtInfo.addPPPoETag) {
1214 struct pppoe_tag *tag, *pOldTag;
1215 unsigned char tag_buf[40];
1218 tag = (struct pppoe_tag *)tag_buf;
1219 pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
1220 if (pOldTag) { // if SID existed, copy old value and delete it
1221 old_tag_len = ntohs(pOldTag->tag_len);
1222 if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) {
1223 DEBUG_ERR("SID tag length too long!\n");
1227 memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN,
1228 pOldTag->tag_data, old_tag_len);
1230 if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) {
1231 DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n");
1234 ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len);
1237 tag->tag_type = PTT_RELAY_SID;
1238 tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len);
1240 // insert the magic_code+client mac in relay tag
1241 pMagic = (unsigned short *)tag->tag_data;
1242 *pMagic = htons(MAGIC_CODE);
1243 memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN);
1246 if(__nat25_add_pppoe_tag(skb, tag) < 0)
1249 DBG_871X("NAT25: Insert PPPoE, forward %s packet\n",
1250 (ph->code == PADI_CODE ? "PADI" : "PADR"));
1252 else { // not add relay tag
1253 if (priv->pppoe_connection_in_progress &&
1254 memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) {
1255 DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n");
1259 if (priv->pppoe_connection_in_progress == 0)
1260 memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN);
1262 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1268 else // session phase
1270 DBG_871X("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name);
1272 __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid));
1274 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1276 __nat25_db_print(priv);
1278 if (!priv->ethBrExtInfo.addPPPoETag &&
1279 priv->pppoe_connection_in_progress &&
1280 !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN))
1281 priv->pppoe_connection_in_progress = 0;
1286 if(ph->code == PADO_CODE || ph->code == PADS_CODE)
1288 if (priv->ethBrExtInfo.addPPPoETag) {
1289 struct pppoe_tag *tag;
1291 unsigned short tagType, tagLen;
1294 if((ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID))) == 0) {
1295 DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n");
1299 tag = (struct pppoe_tag *)ptr;
1300 tagType = (unsigned short)((ptr[0] << 8) + ptr[1]);
1301 tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]);
1303 if((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) {
1304 DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen);
1308 pMagic = (unsigned short *)tag->tag_data;
1309 if (ntohs(*pMagic) != MAGIC_CODE) {
1310 DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n",
1311 (ph->code == PADO_CODE ? "PADO" : "PADS"));
1315 memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN);
1317 if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN)
1318 offset = TAG_HDR_LEN;
1320 if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) {
1321 DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n");
1324 ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset));
1326 tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN);
1328 DBG_871X("NAT25: Lookup PPPoE, forward %s Packet from %s\n",
1329 (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name);
1331 else { // not add relay tag
1332 if (!priv->pppoe_connection_in_progress) {
1333 DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n");
1336 memcpy(skb->data, priv->pppoe_addr, ETH_ALEN);
1337 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1343 DBG_871X("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name);
1344 __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid));
1346 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1348 __nat25_db_print(priv);
1361 /*---------------------------------------------------*/
1362 /* Handle EAP frame */
1363 /*---------------------------------------------------*/
1364 else if(protocol == __constant_htons(0x888e))
1382 /*---------------------------------------------------*/
1383 /* Handle C-Media proprietary frame */
1384 /*---------------------------------------------------*/
1385 else if((protocol == __constant_htons(0xe2ae)) ||
1386 (protocol == __constant_htons(0xe2af)))
1404 /*---------------------------------------------------*/
1405 /* Handle IPV6 frame */
1406 /*---------------------------------------------------*/
1408 else if(protocol == __constant_htons(ETH_P_IPV6))
1410 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
1412 if (sizeof(*iph) >= (skb->len - ETH_HLEN))
1414 DEBUG_WARN("NAT25: malformed IPv6 packet !\n");
1421 if (skb->data[0] & 1)
1427 DBG_871X("NAT25: Insert IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1428 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1429 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1430 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1431 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1432 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1434 if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) {
1435 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr);
1436 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1437 __nat25_db_print(priv);
1439 if (iph->nexthdr == IPPROTO_ICMPV6 &&
1440 skb->len > (ETH_HLEN + sizeof(*iph) + 4)) {
1441 if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph),
1442 skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) {
1443 struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph));
1444 hdr->icmp6_cksum = 0;
1445 hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr,
1448 csum_partial((__u8 *)hdr, iph->payload_len, 0));
1456 DBG_871X("NAT25: Lookup IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1457 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1458 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1459 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1460 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1461 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1464 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr);
1465 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
1466 #ifdef SUPPORT_RX_UNI2MCAST
1467 if (iph->daddr.s6_addr[0] == 0xff)
1468 convert_ipv6_mac_to_mc(skb);
1477 #endif // CL_IPV6_PASS
1483 int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
1486 if((!priv->ethBrExtInfo.nat25_disable) && (!(skb->data[0] & 1)))
1488 panic_printk("NAT25: Input Frame: DA=%02x%02x%02x%02x%02x%02x SA=%02x%02x%02x%02x%02x%02x\n",
1504 if(!(skb->data[0] & 1))
1506 int is_vlan_tag=0, i, retval=0;
1507 unsigned short vlan_hdr=0;
1509 if (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_8021Q)) {
1511 vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2));
1513 *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2));
1517 if (!priv->ethBrExtInfo.nat25_disable)
1520 _enter_critical_bh(&priv->br_ext_lock, &irqL);
1522 * This function look up the destination network address from
1523 * the NAT2.5 database. Return value = -1 means that the
1524 * corresponding network protocol is NOT support.
1526 if (!priv->ethBrExtInfo.nat25sc_disable &&
1527 (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1528 !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
1529 memcpy(skb->data, priv->scdb_mac, ETH_ALEN);
1531 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1534 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1536 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1540 if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1541 !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
1542 ((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_ARP)) &&
1543 !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
1544 // for traffic to upper TCP/IP
1545 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1552 *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
1553 *((unsigned short *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q);
1554 *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr;
1558 //DEBUG_ERR("NAT25: Lookup fail!\n");
1567 void mac_clone(_adapter *priv, unsigned char *addr)
1571 memcpy(sa.sa_data, addr, ETH_ALEN);
1572 DBG_871X("MAC Clone: Addr=%02x%02x%02x%02x%02x%02x\n",
1573 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
1574 rtl8192cd_set_hwaddr(priv->dev, &sa);
1578 int mac_clone_handle_frame(_adapter *priv, struct sk_buff *skb)
1580 if(priv->ethBrExtInfo.macclone_enable && !priv->macclone_completed)
1582 if(!(skb->data[ETH_ALEN] & 1)) //// check any other particular MAC add
1584 if(memcmp(skb->data+ETH_ALEN, GET_MY_HWADDR(priv), ETH_ALEN) &&
1585 ((priv->dev->br_port) &&
1586 memcmp(skb->data+ETH_ALEN, priv->br_mac, ETH_ALEN)))
1588 mac_clone(priv, skb->data+ETH_ALEN);
1589 priv->macclone_completed = 1;
1598 #define SERVER_PORT 67
1599 #define CLIENT_PORT 68
1600 #define DHCP_MAGIC 0x63825363
1601 #define BROADCAST_FLAG 0x8000
1603 struct dhcpMessage {
1615 u_int8_t chaddr[16];
1619 u_int8_t options[308]; /* 312 - cookie */
1622 void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb)
1627 if(!priv->ethBrExtInfo.dhcp_bcst_disable)
1629 unsigned short protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
1631 if(protocol == __constant_htons(ETH_P_IP)) // IP
1633 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
1635 if(iph->protocol == IPPROTO_UDP) // UDP
1637 struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2));
1639 if((udph->source == __constant_htons(CLIENT_PORT))
1640 && (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request
1642 struct dhcpMessage *dhcph =
1643 (struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr));
1645 if(dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word
1647 if(!(dhcph->flags & htons(BROADCAST_FLAG))) // if not broadcast
1649 register int sum = 0;
1651 DBG_871X("DHCP: change flag of DHCP request to broadcast.\n");
1652 // or BROADCAST flag
1653 dhcph->flags |= htons(BROADCAST_FLAG);
1654 // recalculate checksum
1655 sum = ~(udph->check) & 0xffff;
1656 sum += dhcph->flags;
1658 sum = (sum & 0xffff) + (sum >> 16);
1669 void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
1670 unsigned char *ipAddr)
1672 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
1673 struct nat25_network_db_entry *db;
1676 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
1678 __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr);
1679 hash = __nat25_network_hash(networkAddr);
1680 db = priv->nethash[hash];
1683 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) {
1684 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1691 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1695 #endif // CONFIG_BR_EXT