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 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
52 #include <net/ip6_checksum.h>
54 #include <net/checksum.h>
61 //#define BR_EXT_DEBUG
66 #define NAT25_APPLE 04
67 #define NAT25_PPPOE 05
69 #define RTL_RELAY_TAG_LEN (ETH_ALEN)
72 #define MAGIC_CODE 0x8186
73 #define MAGIC_CODE_LEN 2
74 #define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec
76 /*-----------------------------------------------------------------
77 How database records network address:
78 0 1 2 3 4 5 6 7 8 9 10
79 |----|----|----|----|----|----|----|----|----|----|----|
80 IPv4 |type| | IP addr |
81 IPX |type| Net addr | Node addr |
82 IPX |type| Net addr |Sckt addr|
83 Apple |type| Network |node|
84 PPPoE |type| SID | AC MAC |
85 -----------------------------------------------------------------*/
88 //Find a tag in pppoe frame and return the pointer
89 static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
91 unsigned char *cur_ptr, *start_ptr;
92 unsigned short tagLen, tagType;
94 start_ptr = cur_ptr = (unsigned char *)ph->tag;
95 while((cur_ptr - start_ptr) < ntohs(ph->length)) {
96 // prevent un-alignment access
97 tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
98 tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
101 cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen;
107 static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
109 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
112 data_len = tag->tag_len + TAG_HDR_LEN;
113 if (skb_tailroom(skb) < data_len) {
114 _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n");
118 skb_put(skb, data_len);
119 // have a room for new tag
120 memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
121 ph->length = htons(ntohs(ph->length) + data_len);
122 memcpy((unsigned char *)ph->tag, tag, data_len);
126 static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len)
129 unsigned long end, tail;
131 if ((src+len) > skb_tail_pointer(skb) || skb->len < len)
134 tail = (unsigned long)skb_tail_pointer(skb);
135 end = (unsigned long)src+len;
139 tail_len = (int)(tail-end);
141 memmove(src, src+len, tail_len);
143 skb_trim(skb, skb->len-len);
147 static __inline__ unsigned long __nat25_timeout(_adapter *priv)
149 unsigned long timeout;
151 timeout = jiffies - NAT25_AGEING_TIME*HZ;
157 static __inline__ int __nat25_has_expired(_adapter *priv,
158 struct nat25_network_db_entry *fdb)
160 if(time_before_eq(fdb->ageing_timer, __nat25_timeout(priv)))
167 static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr,
168 unsigned int *ipAddr)
170 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
172 networkAddr[0] = NAT25_IPV4;
173 memcpy(networkAddr+7, (unsigned char *)ipAddr, 4);
177 static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr,
178 unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr)
180 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
182 networkAddr[0] = NAT25_IPX;
183 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
184 memcpy(networkAddr+5, ipxNodeAddr, 6);
188 static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr,
189 unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr)
191 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
193 networkAddr[0] = NAT25_IPX;
194 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
195 memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2);
199 static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr,
200 unsigned short *network, unsigned char *node)
202 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
204 networkAddr[0] = NAT25_APPLE;
205 memcpy(networkAddr+1, (unsigned char *)network, 2);
206 networkAddr[3] = *node;
210 static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr,
211 unsigned char *ac_mac, unsigned short *sid)
213 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
215 networkAddr[0] = NAT25_PPPOE;
216 memcpy(networkAddr+1, (unsigned char *)sid, 2);
217 memcpy(networkAddr+3, (unsigned char *)ac_mac, 6);
222 static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr,
223 unsigned int *ipAddr)
225 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
227 networkAddr[0] = NAT25_IPV6;
228 memcpy(networkAddr+1, (unsigned char *)ipAddr, 16);
232 static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b)
235 if (*data == tag && *(data+1) == len8b && len >= len8b*8)
238 len -= (*(data+1))*8;
239 data += (*(data+1))*8;
245 static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac)
247 struct icmp6hdr *icmphdr = (struct icmp6hdr *)data;
250 if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) {
252 mac = scan_tlv(&data[8], len-8, 1, 1);
254 DBG_871X("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
255 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
256 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
257 memcpy(mac, replace_mac, 6);
262 else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) {
264 mac = scan_tlv(&data[16], len-16, 1, 1);
266 DBG_871X("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
267 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
268 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
269 memcpy(mac, replace_mac, 6);
274 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
276 mac = scan_tlv(&data[24], len-24, 1, 1);
278 DBG_871X("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
279 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
280 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
281 memcpy(mac, replace_mac, 6);
286 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
288 mac = scan_tlv(&data[24], len-24, 2, 1);
290 DBG_871X("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
291 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
292 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
293 memcpy(mac, replace_mac, 6);
298 else if (icmphdr->icmp6_type == NDISC_REDIRECT) {
300 mac = scan_tlv(&data[40], len-40, 2, 1);
302 DBG_871X("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
303 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
304 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
305 memcpy(mac, replace_mac, 6);
314 static void convert_ipv6_mac_to_mc(struct sk_buff *skb)
316 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
317 unsigned char *dst_mac = skb->data;
321 /*modified by qinjunjie,ipv6 multicast address ix 0x33-33-xx-xx-xx-xx*/
324 memcpy(&dst_mac[2], &iph->daddr.s6_addr32[3], 4);
325 #if defined(__LINUX_2_6__)
326 /*modified by qinjunjie,warning:should not remove next line*/
327 skb->pkt_type = PACKET_MULTICAST;
330 #endif /* CL_IPV6_PASS */
333 static __inline__ int __nat25_network_hash(unsigned char *networkAddr)
335 if(networkAddr[0] == NAT25_IPV4)
339 x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
341 return x & (NAT25_HASH_SIZE - 1);
343 else if(networkAddr[0] == NAT25_IPX)
347 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
348 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
350 return x & (NAT25_HASH_SIZE - 1);
352 else if(networkAddr[0] == NAT25_APPLE)
356 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3];
358 return x & (NAT25_HASH_SIZE - 1);
360 else if(networkAddr[0] == NAT25_PPPOE)
364 x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8];
366 return x & (NAT25_HASH_SIZE - 1);
369 else if(networkAddr[0] == NAT25_IPV6)
373 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
374 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^
375 networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^
378 return x & (NAT25_HASH_SIZE - 1);
386 for (i=0; i<MAX_NETWORK_ADDR_LEN; i++)
389 return x & (NAT25_HASH_SIZE - 1);
394 static __inline__ void __network_hash_link(_adapter *priv,
395 struct nat25_network_db_entry *ent, int hash)
397 // Caller must _enter_critical_bh already!
399 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
401 ent->next_hash = priv->nethash[hash];
402 if(ent->next_hash != NULL)
403 ent->next_hash->pprev_hash = &ent->next_hash;
404 priv->nethash[hash] = ent;
405 ent->pprev_hash = &priv->nethash[hash];
407 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
411 static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
413 // Caller must _enter_critical_bh already!
415 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
417 *(ent->pprev_hash) = ent->next_hash;
418 if(ent->next_hash != NULL)
419 ent->next_hash->pprev_hash = ent->pprev_hash;
420 ent->next_hash = NULL;
421 ent->pprev_hash = NULL;
423 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
427 static int __nat25_db_network_lookup_and_replace(_adapter *priv,
428 struct sk_buff *skb, unsigned char *networkAddr)
430 struct nat25_network_db_entry *db;
432 _enter_critical_bh(&priv->br_ext_lock, &irqL);
434 db = priv->nethash[__nat25_network_hash(networkAddr)];
437 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
439 if(!__nat25_has_expired(priv, db))
441 // replace the destination mac address
442 memcpy(skb->data, db->macAddr, ETH_ALEN);
443 atomic_inc(&db->use_count);
446 DBG_871X("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
447 "%02x%02x%02x%02x%02x%02x\n",
470 db->networkAddr[16]);
472 DBG_871X("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
489 db->networkAddr[10]);
492 _exit_critical_bh(&priv->br_ext_lock, &irqL);
499 _exit_critical_bh(&priv->br_ext_lock, &irqL);
504 static void __nat25_db_network_insert(_adapter *priv,
505 unsigned char *macAddr, unsigned char *networkAddr)
507 struct nat25_network_db_entry *db;
510 _enter_critical_bh(&priv->br_ext_lock, &irqL);
512 hash = __nat25_network_hash(networkAddr);
513 db = priv->nethash[hash];
516 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
518 memcpy(db->macAddr, macAddr, ETH_ALEN);
519 db->ageing_timer = jiffies;
520 _exit_critical_bh(&priv->br_ext_lock, &irqL);
527 db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db));
529 _exit_critical_bh(&priv->br_ext_lock, &irqL);
533 memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN);
534 memcpy(db->macAddr, macAddr, ETH_ALEN);
535 atomic_set(&db->use_count, 1);
536 db->ageing_timer = jiffies;
538 __network_hash_link(priv, db, hash);
540 _exit_critical_bh(&priv->br_ext_lock, &irqL);
544 static void __nat25_db_print(_adapter *priv)
547 _enter_critical_bh(&priv->br_ext_lock, &irqL);
550 static int counter = 0;
552 struct nat25_network_db_entry *db;
555 if((counter % 16) != 0)
558 for(i=0, j=0; i<NAT25_HASH_SIZE; i++)
560 db = priv->nethash[i];
565 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"
566 "%02x%02x%02x%02x%02x%02x\n",
569 atomic_read(&db->use_count),
592 db->networkAddr[16]);
594 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",
597 atomic_read(&db->use_count),
614 db->networkAddr[10]);
623 _exit_critical_bh(&priv->br_ext_lock, &irqL);
633 void nat25_db_cleanup(_adapter *priv)
637 _enter_critical_bh(&priv->br_ext_lock, &irqL);
639 for(i=0; i<NAT25_HASH_SIZE; i++)
641 struct nat25_network_db_entry *f;
642 f = priv->nethash[i];
644 struct nat25_network_db_entry *g;
647 if(priv->scdb_entry == f)
649 memset(priv->scdb_mac, 0, ETH_ALEN);
650 memset(priv->scdb_ip, 0, 4);
651 priv->scdb_entry = NULL;
653 __network_hash_unlink(f);
654 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
660 _exit_critical_bh(&priv->br_ext_lock, &irqL);
664 void nat25_db_expire(_adapter *priv)
668 _enter_critical_bh(&priv->br_ext_lock, &irqL);
670 //if(!priv->ethBrExtInfo.nat25_disable)
672 for (i=0; i<NAT25_HASH_SIZE; i++)
674 struct nat25_network_db_entry *f;
675 f = priv->nethash[i];
679 struct nat25_network_db_entry *g;
682 if(__nat25_has_expired(priv, f))
684 if(atomic_dec_and_test(&f->use_count))
688 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"
689 "%02x%02x%02x%02x%02x%02x\n",
716 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",
737 if(priv->scdb_entry == f)
739 memset(priv->scdb_mac, 0, ETH_ALEN);
740 memset(priv->scdb_ip, 0, 4);
741 priv->scdb_entry = NULL;
743 __network_hash_unlink(f);
744 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
753 _exit_critical_bh(&priv->br_ext_lock, &irqL);
757 #ifdef SUPPORT_TX_MCAST2UNI
758 static int checkIPMcAndReplace(_adapter *priv, struct sk_buff *skb, unsigned int *dst_ip)
760 struct stat_info *pstat;
761 struct list_head *phead, *plist;
764 phead = &priv->asoc_list;
767 while (plist != phead) {
768 pstat = list_entry(plist, struct stat_info, asoc_list);
771 if (pstat->ipmc_num == 0)
774 for (i=0; i<MAX_IP_MC_ENTRY; i++) {
775 if (pstat->ipmc[i].used && !memcmp(&pstat->ipmc[i].mcmac[3], ((unsigned char *)dst_ip)+1, 3)) {
776 memcpy(skb->data, pstat->ipmc[i].mcmac, ETH_ALEN);
785 int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
787 unsigned short protocol;
788 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
793 if((method <= NAT25_MIN) || (method >= NAT25_MAX))
796 protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
798 /*---------------------------------------------------*/
799 /* Handle IP frame */
800 /*---------------------------------------------------*/
801 if(protocol == __constant_htons(ETH_P_IP))
803 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
805 if(((unsigned char*)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len))
807 DEBUG_WARN("NAT25: malformed IP packet !\n");
818 //some muticast with source IP is all zero, maybe other case is illegal
819 //in class A, B, C, host address is all zero or all one is illegal
822 DBG_871X("NAT25: Insert IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
823 __nat25_generate_ipv4_network_addr(networkAddr, &iph->saddr);
824 //record source IP address and , source mac address into db
825 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
827 __nat25_db_print(priv);
833 DBG_871X("NAT25: Lookup IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
834 #ifdef SUPPORT_TX_MCAST2UNI
835 if (priv->pshare->rf_ft_var.mc2u_disable ||
836 ((((OPMODE & (WIFI_STATION_STATE|WIFI_ASOC_STATE))
837 == (WIFI_STATION_STATE|WIFI_ASOC_STATE)) &&
838 !checkIPMcAndReplace(priv, skb, &iph->daddr)) ||
839 (OPMODE & WIFI_ADHOC_STATE)))
842 __nat25_generate_ipv4_network_addr(networkAddr, &iph->daddr);
844 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
845 if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
846 // L2 is unicast but L3 is broadcast, make L2 bacome broadcast
847 DBG_871X("NAT25: Set DA as boardcast\n");
848 memset(skb->data, 0xff, ETH_ALEN);
851 // forward unknow IP packet to upper TCP/IP
852 DBG_871X("NAT25: Replace DA with BR's MAC\n");
853 if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) {
854 void netdev_br_init(struct net_device *netdev);
855 printk("Re-init netdev_br_init() due to br_mac==0!\n");
856 netdev_br_init(priv->pnetdev);
858 memcpy(skb->data, priv->br_mac, ETH_ALEN);
870 /*---------------------------------------------------*/
871 /* Handle ARP frame */
872 /*---------------------------------------------------*/
873 else if(protocol == __constant_htons(ETH_P_ARP))
875 struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
876 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
877 unsigned int *sender, *target;
879 if(arp->ar_pro != __constant_htons(ETH_P_IP))
881 DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", htons(arp->ar_pro));
888 return 0; // skb_copy for all ARP frame
892 DBG_871X("NAT25: Insert ARP, MAC=%02x%02x%02x%02x%02x%02x\n", arp_ptr[0],
893 arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]);
895 // change to ARP sender mac address to wlan STA address
896 memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
898 arp_ptr += arp->ar_hln;
899 sender = (unsigned int *)arp_ptr;
901 __nat25_generate_ipv4_network_addr(networkAddr, sender);
903 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
905 __nat25_db_print(priv);
911 DBG_871X("NAT25: Lookup ARP\n");
913 arp_ptr += arp->ar_hln;
914 sender = (unsigned int *)arp_ptr;
915 arp_ptr += (arp->ar_hln + arp->ar_pln);
916 target = (unsigned int *)arp_ptr;
918 __nat25_generate_ipv4_network_addr(networkAddr, target);
920 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
922 // change to ARP target mac address to Lookup result
923 arp_ptr = (unsigned char *)(arp + 1);
924 arp_ptr += (arp->ar_hln + arp->ar_pln);
925 memcpy(arp_ptr, skb->data, ETH_ALEN);
934 /*---------------------------------------------------*/
935 /* Handle IPX and Apple Talk frame */
936 /*---------------------------------------------------*/
937 else if((protocol == __constant_htons(ETH_P_IPX)) ||
938 (protocol == __constant_htons(ETH_P_ATALK)) ||
939 (protocol == __constant_htons(ETH_P_AARP)))
941 unsigned char ipx_header[2] = {0xFF, 0xFF};
942 struct ipxhdr *ipx = NULL;
943 struct elapaarp *ea = NULL;
944 struct ddpehdr *ddp = NULL;
945 unsigned char *framePtr = skb->data + ETH_HLEN;
947 if(protocol == __constant_htons(ETH_P_IPX))
949 DBG_871X("NAT25: Protocol=IPX (Ethernet II)\n");
950 ipx = (struct ipxhdr *)framePtr;
952 else //if(protocol <= __constant_htons(ETH_FRAME_LEN))
954 if(!memcmp(ipx_header, framePtr, 2))
956 DBG_871X("NAT25: Protocol=IPX (Ethernet 802.3)\n");
957 ipx = (struct ipxhdr *)framePtr;
961 unsigned char ipx_8022_type = 0xE0;
962 unsigned char snap_8022_type = 0xAA;
964 if(*framePtr == snap_8022_type)
966 unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID
967 unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID
968 unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID
970 framePtr += 3; // eliminate the 802.2 header
972 if(!memcmp(ipx_snap_id, framePtr, 5))
974 framePtr += 5; // eliminate the SNAP header
976 DBG_871X("NAT25: Protocol=IPX (Ethernet SNAP)\n");
977 ipx = (struct ipxhdr *)framePtr;
979 else if(!memcmp(aarp_snap_id, framePtr, 5))
981 framePtr += 5; // eliminate the SNAP header
983 ea = (struct elapaarp *)framePtr;
985 else if(!memcmp(ddp_snap_id, framePtr, 5))
987 framePtr += 5; // eliminate the SNAP header
989 ddp = (struct ddpehdr *)framePtr;
993 DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0],
994 framePtr[1], framePtr[2], framePtr[3], framePtr[4]);
998 else if(*framePtr == ipx_8022_type)
1000 framePtr += 3; // eliminate the 802.2 header
1002 if(!memcmp(ipx_header, framePtr, 2))
1004 DBG_871X("NAT25: Protocol=IPX (Ethernet 802.2)\n");
1005 ipx = (struct ipxhdr *)framePtr;
1019 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1021 DBG_871X("NAT25: Check IPX skb_copy\n");
1028 DBG_871X("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n",
1030 ipx->ipx_dest.node[0],
1031 ipx->ipx_dest.node[1],
1032 ipx->ipx_dest.node[2],
1033 ipx->ipx_dest.node[3],
1034 ipx->ipx_dest.node[4],
1035 ipx->ipx_dest.node[5],
1037 ipx->ipx_source.net,
1038 ipx->ipx_source.node[0],
1039 ipx->ipx_source.node[1],
1040 ipx->ipx_source.node[2],
1041 ipx->ipx_source.node[3],
1042 ipx->ipx_source.node[4],
1043 ipx->ipx_source.node[5],
1044 ipx->ipx_source.sock);
1046 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1048 DBG_871X("NAT25: Use IPX Net, and Socket as network addr\n");
1050 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
1052 // change IPX source node addr to wlan STA address
1053 memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
1057 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node);
1060 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1062 __nat25_db_print(priv);
1068 if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN))
1070 DBG_871X("NAT25: Lookup IPX, Modify Destination IPX Node addr\n");
1072 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock);
1074 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1076 // replace IPX destination node addr with Lookup destination MAC addr
1077 memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
1081 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node);
1083 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1096 /* Sanity check fields. */
1097 if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN)
1099 DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n");
1110 // change to AARP source mac address to wlan STA address
1111 memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
1113 DBG_871X("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
1119 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node);
1121 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1123 __nat25_db_print(priv);
1129 DBG_871X("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n",
1135 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node);
1137 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1139 // change to AARP destination mac address to Lookup result
1140 memcpy(ea->hw_dst, skb->data, ETH_ALEN);
1150 else if(ddp != NULL)
1159 DBG_871X("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n",
1165 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode);
1167 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1169 __nat25_db_print(priv);
1175 DBG_871X("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n",
1181 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode);
1183 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1195 /*---------------------------------------------------*/
1196 /* Handle PPPoE frame */
1197 /*---------------------------------------------------*/
1198 else if((protocol == __constant_htons(ETH_P_PPP_DISC)) ||
1199 (protocol == __constant_htons(ETH_P_PPP_SES)))
1201 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
1202 unsigned short *pMagic;
1212 if(ph->sid == 0) // Discovery phase according to tag
1214 if(ph->code == PADI_CODE || ph->code == PADR_CODE)
1216 if (priv->ethBrExtInfo.addPPPoETag) {
1217 struct pppoe_tag *tag, *pOldTag;
1218 unsigned char tag_buf[40];
1221 tag = (struct pppoe_tag *)tag_buf;
1222 pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
1223 if (pOldTag) { // if SID existed, copy old value and delete it
1224 old_tag_len = ntohs(pOldTag->tag_len);
1225 if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) {
1226 DEBUG_ERR("SID tag length too long!\n");
1230 memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN,
1231 pOldTag->tag_data, old_tag_len);
1233 if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) {
1234 DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n");
1237 ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len);
1240 tag->tag_type = PTT_RELAY_SID;
1241 tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len);
1243 // insert the magic_code+client mac in relay tag
1244 pMagic = (unsigned short *)tag->tag_data;
1245 *pMagic = htons(MAGIC_CODE);
1246 memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN);
1249 if(__nat25_add_pppoe_tag(skb, tag) < 0)
1252 DBG_871X("NAT25: Insert PPPoE, forward %s packet\n",
1253 (ph->code == PADI_CODE ? "PADI" : "PADR"));
1255 else { // not add relay tag
1256 if (priv->pppoe_connection_in_progress &&
1257 memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) {
1258 DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n");
1262 if (priv->pppoe_connection_in_progress == 0)
1263 memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN);
1265 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1271 else // session phase
1273 DBG_871X("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name);
1275 __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid));
1277 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1279 __nat25_db_print(priv);
1281 if (!priv->ethBrExtInfo.addPPPoETag &&
1282 priv->pppoe_connection_in_progress &&
1283 !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN))
1284 priv->pppoe_connection_in_progress = 0;
1289 if(ph->code == PADO_CODE || ph->code == PADS_CODE)
1291 if (priv->ethBrExtInfo.addPPPoETag) {
1292 struct pppoe_tag *tag;
1294 unsigned short tagType, tagLen;
1297 if((ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID))) == 0) {
1298 DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n");
1302 tag = (struct pppoe_tag *)ptr;
1303 tagType = (unsigned short)((ptr[0] << 8) + ptr[1]);
1304 tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]);
1306 if((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) {
1307 DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen);
1311 pMagic = (unsigned short *)tag->tag_data;
1312 if (ntohs(*pMagic) != MAGIC_CODE) {
1313 DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n",
1314 (ph->code == PADO_CODE ? "PADO" : "PADS"));
1318 memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN);
1320 if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN)
1321 offset = TAG_HDR_LEN;
1323 if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) {
1324 DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n");
1327 ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset));
1329 tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN);
1331 DBG_871X("NAT25: Lookup PPPoE, forward %s Packet from %s\n",
1332 (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name);
1334 else { // not add relay tag
1335 if (!priv->pppoe_connection_in_progress) {
1336 DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n");
1339 memcpy(skb->data, priv->pppoe_addr, ETH_ALEN);
1340 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1346 DBG_871X("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name);
1347 __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid));
1349 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1351 __nat25_db_print(priv);
1364 /*---------------------------------------------------*/
1365 /* Handle EAP frame */
1366 /*---------------------------------------------------*/
1367 else if(protocol == __constant_htons(0x888e))
1385 /*---------------------------------------------------*/
1386 /* Handle C-Media proprietary frame */
1387 /*---------------------------------------------------*/
1388 else if((protocol == __constant_htons(0xe2ae)) ||
1389 (protocol == __constant_htons(0xe2af)))
1407 /*---------------------------------------------------*/
1408 /* Handle IPV6 frame */
1409 /*---------------------------------------------------*/
1411 else if(protocol == __constant_htons(ETH_P_IPV6))
1413 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
1415 if (sizeof(*iph) >= (skb->len - ETH_HLEN))
1417 DEBUG_WARN("NAT25: malformed IPv6 packet !\n");
1424 if (skb->data[0] & 1)
1430 DBG_871X("NAT25: Insert IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1431 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1432 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1433 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1434 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1435 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1437 if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) {
1438 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr);
1439 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1440 __nat25_db_print(priv);
1442 if (iph->nexthdr == IPPROTO_ICMPV6 &&
1443 skb->len > (ETH_HLEN + sizeof(*iph) + 4)) {
1444 if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph),
1445 skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) {
1446 struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph));
1447 hdr->icmp6_cksum = 0;
1448 hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr,
1451 csum_partial((__u8 *)hdr, iph->payload_len, 0));
1459 DBG_871X("NAT25: Lookup IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1460 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1461 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1462 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1463 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1464 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1467 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr);
1468 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
1469 #ifdef SUPPORT_RX_UNI2MCAST
1470 if (iph->daddr.s6_addr[0] == 0xff)
1471 convert_ipv6_mac_to_mc(skb);
1480 #endif // CL_IPV6_PASS
1486 int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
1489 if((!priv->ethBrExtInfo.nat25_disable) && (!(skb->data[0] & 1)))
1491 panic_printk("NAT25: Input Frame: DA=%02x%02x%02x%02x%02x%02x SA=%02x%02x%02x%02x%02x%02x\n",
1507 if(!(skb->data[0] & 1))
1509 int is_vlan_tag=0, i, retval=0;
1510 unsigned short vlan_hdr=0;
1512 if (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_8021Q)) {
1514 vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2));
1516 *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2));
1520 if (!priv->ethBrExtInfo.nat25_disable)
1523 _enter_critical_bh(&priv->br_ext_lock, &irqL);
1525 * This function look up the destination network address from
1526 * the NAT2.5 database. Return value = -1 means that the
1527 * corresponding network protocol is NOT support.
1529 if (!priv->ethBrExtInfo.nat25sc_disable &&
1530 (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1531 !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
1532 memcpy(skb->data, priv->scdb_mac, ETH_ALEN);
1534 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1537 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1539 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1543 if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1544 !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
1545 ((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_ARP)) &&
1546 !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
1547 // for traffic to upper TCP/IP
1548 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1555 *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
1556 *((unsigned short *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q);
1557 *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr;
1561 //DEBUG_ERR("NAT25: Lookup fail!\n");
1570 void mac_clone(_adapter *priv, unsigned char *addr)
1574 memcpy(sa.sa_data, addr, ETH_ALEN);
1575 DBG_871X("MAC Clone: Addr=%02x%02x%02x%02x%02x%02x\n",
1576 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
1577 rtl8192cd_set_hwaddr(priv->dev, &sa);
1581 int mac_clone_handle_frame(_adapter *priv, struct sk_buff *skb)
1583 if(priv->ethBrExtInfo.macclone_enable && !priv->macclone_completed)
1585 if(!(skb->data[ETH_ALEN] & 1)) //// check any other particular MAC add
1587 if(memcmp(skb->data+ETH_ALEN, GET_MY_HWADDR(priv), ETH_ALEN) &&
1588 ((priv->dev->br_port) &&
1589 memcmp(skb->data+ETH_ALEN, priv->br_mac, ETH_ALEN)))
1591 mac_clone(priv, skb->data+ETH_ALEN);
1592 priv->macclone_completed = 1;
1601 #define SERVER_PORT 67
1602 #define CLIENT_PORT 68
1603 #define DHCP_MAGIC 0x63825363
1604 #define BROADCAST_FLAG 0x8000
1606 struct dhcpMessage {
1618 u_int8_t chaddr[16];
1622 u_int8_t options[308]; /* 312 - cookie */
1625 void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb)
1630 if(!priv->ethBrExtInfo.dhcp_bcst_disable)
1632 unsigned short protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
1634 if(protocol == __constant_htons(ETH_P_IP)) // IP
1636 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
1638 if(iph->protocol == IPPROTO_UDP) // UDP
1640 struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2));
1642 if((udph->source == __constant_htons(CLIENT_PORT))
1643 && (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request
1645 struct dhcpMessage *dhcph =
1646 (struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr));
1648 if(dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word
1650 if(!(dhcph->flags & htons(BROADCAST_FLAG))) // if not broadcast
1652 register int sum = 0;
1654 DBG_871X("DHCP: change flag of DHCP request to broadcast.\n");
1655 // or BROADCAST flag
1656 dhcph->flags |= htons(BROADCAST_FLAG);
1657 // recalculate checksum
1658 sum = ~(udph->check) & 0xffff;
1659 sum += dhcph->flags;
1661 sum = (sum & 0xffff) + (sum >> 16);
1672 void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
1673 unsigned char *ipAddr)
1675 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
1676 struct nat25_network_db_entry *db;
1679 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
1681 __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr);
1682 hash = __nat25_network_hash(networkAddr);
1683 db = priv->nethash[hash];
1686 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) {
1687 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1694 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1698 #endif // CONFIG_BR_EXT