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>
57 //#define BR_EXT_DEBUG
62 #define NAT25_APPLE 04
63 #define NAT25_PPPOE 05
65 #define RTL_RELAY_TAG_LEN (ETH_ALEN)
68 #define MAGIC_CODE 0x8186
69 #define MAGIC_CODE_LEN 2
70 #define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec
72 /*-----------------------------------------------------------------
73 How database records network address:
74 0 1 2 3 4 5 6 7 8 9 10
75 |----|----|----|----|----|----|----|----|----|----|----|
76 IPv4 |type| | IP addr |
77 IPX |type| Net addr | Node addr |
78 IPX |type| Net addr |Sckt addr|
79 Apple |type| Network |node|
80 PPPoE |type| SID | AC MAC |
81 -----------------------------------------------------------------*/
84 //Find a tag in pppoe frame and return the pointer
85 static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
87 unsigned char *cur_ptr, *start_ptr;
88 unsigned short tagLen, tagType;
90 start_ptr = cur_ptr = (unsigned char *)ph->tag;
91 while((cur_ptr - start_ptr) < ntohs(ph->length)) {
92 // prevent un-alignment access
93 tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
94 tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
97 cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen;
103 static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
105 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
108 data_len = tag->tag_len + TAG_HDR_LEN;
109 if (skb_tailroom(skb) < data_len) {
110 _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n");
114 skb_put(skb, data_len);
115 // have a room for new tag
116 memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
117 ph->length = htons(ntohs(ph->length) + data_len);
118 memcpy((unsigned char *)ph->tag, tag, data_len);
122 static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len)
125 unsigned long end, tail;
127 if ((src+len) > skb_tail_pointer(skb) || skb->len < len)
130 tail = (unsigned long)skb_tail_pointer(skb);
131 end = (unsigned long)src+len;
135 tail_len = (int)(tail-end);
137 memmove(src, src+len, tail_len);
139 skb_trim(skb, skb->len-len);
143 static __inline__ unsigned long __nat25_timeout(_adapter *priv)
145 unsigned long timeout;
147 timeout = jiffies - NAT25_AGEING_TIME*HZ;
153 static __inline__ int __nat25_has_expired(_adapter *priv,
154 struct nat25_network_db_entry *fdb)
156 if(time_before_eq(fdb->ageing_timer, __nat25_timeout(priv)))
163 static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr,
164 unsigned int *ipAddr)
166 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
168 networkAddr[0] = NAT25_IPV4;
169 memcpy(networkAddr+7, (unsigned char *)ipAddr, 4);
173 static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr,
174 unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr)
176 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
178 networkAddr[0] = NAT25_IPX;
179 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
180 memcpy(networkAddr+5, ipxNodeAddr, 6);
184 static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr,
185 unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr)
187 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
189 networkAddr[0] = NAT25_IPX;
190 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
191 memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2);
195 static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr,
196 unsigned short *network, unsigned char *node)
198 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
200 networkAddr[0] = NAT25_APPLE;
201 memcpy(networkAddr+1, (unsigned char *)network, 2);
202 networkAddr[3] = *node;
206 static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr,
207 unsigned char *ac_mac, unsigned short *sid)
209 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
211 networkAddr[0] = NAT25_PPPOE;
212 memcpy(networkAddr+1, (unsigned char *)sid, 2);
213 memcpy(networkAddr+3, (unsigned char *)ac_mac, 6);
218 static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr,
219 unsigned int *ipAddr)
221 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
223 networkAddr[0] = NAT25_IPV6;
224 memcpy(networkAddr+1, (unsigned char *)ipAddr, 16);
228 static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b)
231 if (*data == tag && *(data+1) == len8b && len >= len8b*8)
234 len -= (*(data+1))*8;
235 data += (*(data+1))*8;
241 static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac)
243 struct icmp6hdr *icmphdr = (struct icmp6hdr *)data;
246 if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) {
248 mac = scan_tlv(&data[8], len-8, 1, 1);
250 _DEBUG_INFO("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
251 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
252 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
253 memcpy(mac, replace_mac, 6);
258 else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) {
260 mac = scan_tlv(&data[16], len-16, 1, 1);
262 _DEBUG_INFO("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
263 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
264 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
265 memcpy(mac, replace_mac, 6);
270 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
272 mac = scan_tlv(&data[24], len-24, 1, 1);
274 _DEBUG_INFO("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
275 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
276 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
277 memcpy(mac, replace_mac, 6);
282 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
284 mac = scan_tlv(&data[24], len-24, 2, 1);
286 _DEBUG_INFO("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
287 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
288 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
289 memcpy(mac, replace_mac, 6);
294 else if (icmphdr->icmp6_type == NDISC_REDIRECT) {
296 mac = scan_tlv(&data[40], len-40, 2, 1);
298 _DEBUG_INFO("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
299 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
300 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
301 memcpy(mac, replace_mac, 6);
310 static void convert_ipv6_mac_to_mc(struct sk_buff *skb)
312 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
313 unsigned char *dst_mac = skb->data;
317 /*modified by qinjunjie,ipv6 multicast address ix 0x33-33-xx-xx-xx-xx*/
320 memcpy(&dst_mac[2], &iph->daddr.s6_addr32[3], 4);
321 #if defined(__LINUX_2_6__)
322 /*modified by qinjunjie,warning:should not remove next line*/
323 skb->pkt_type = PACKET_MULTICAST;
326 #endif /* CL_IPV6_PASS */
329 static __inline__ int __nat25_network_hash(unsigned char *networkAddr)
331 if(networkAddr[0] == NAT25_IPV4)
335 x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
337 return x & (NAT25_HASH_SIZE - 1);
339 else if(networkAddr[0] == NAT25_IPX)
343 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
344 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
346 return x & (NAT25_HASH_SIZE - 1);
348 else if(networkAddr[0] == NAT25_APPLE)
352 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3];
354 return x & (NAT25_HASH_SIZE - 1);
356 else if(networkAddr[0] == NAT25_PPPOE)
360 x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8];
362 return x & (NAT25_HASH_SIZE - 1);
365 else if(networkAddr[0] == NAT25_IPV6)
369 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
370 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^
371 networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^
374 return x & (NAT25_HASH_SIZE - 1);
382 for (i=0; i<MAX_NETWORK_ADDR_LEN; i++)
385 return x & (NAT25_HASH_SIZE - 1);
390 static __inline__ void __network_hash_link(_adapter *priv,
391 struct nat25_network_db_entry *ent, int hash)
393 // Caller must _enter_critical_bh already!
395 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
397 ent->next_hash = priv->nethash[hash];
398 if(ent->next_hash != NULL)
399 ent->next_hash->pprev_hash = &ent->next_hash;
400 priv->nethash[hash] = ent;
401 ent->pprev_hash = &priv->nethash[hash];
403 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
407 static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
409 // Caller must _enter_critical_bh already!
411 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
413 *(ent->pprev_hash) = ent->next_hash;
414 if(ent->next_hash != NULL)
415 ent->next_hash->pprev_hash = ent->pprev_hash;
416 ent->next_hash = NULL;
417 ent->pprev_hash = NULL;
419 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
423 static int __nat25_db_network_lookup_and_replace(_adapter *priv,
424 struct sk_buff *skb, unsigned char *networkAddr)
426 struct nat25_network_db_entry *db;
428 _enter_critical_bh(&priv->br_ext_lock, &irqL);
430 db = priv->nethash[__nat25_network_hash(networkAddr)];
433 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
435 if(!__nat25_has_expired(priv, db))
437 // replace the destination mac address
438 memcpy(skb->data, db->macAddr, ETH_ALEN);
439 atomic_inc(&db->use_count);
442 DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
443 "%02x%02x%02x%02x%02x%02x\n",
466 db->networkAddr[16]);
468 DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
485 db->networkAddr[10]);
488 _exit_critical_bh(&priv->br_ext_lock, &irqL);
495 _exit_critical_bh(&priv->br_ext_lock, &irqL);
500 static void __nat25_db_network_insert(_adapter *priv,
501 unsigned char *macAddr, unsigned char *networkAddr)
503 struct nat25_network_db_entry *db;
506 _enter_critical_bh(&priv->br_ext_lock, &irqL);
508 hash = __nat25_network_hash(networkAddr);
509 db = priv->nethash[hash];
512 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
514 memcpy(db->macAddr, macAddr, ETH_ALEN);
515 db->ageing_timer = jiffies;
516 _exit_critical_bh(&priv->br_ext_lock, &irqL);
523 db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db));
525 _exit_critical_bh(&priv->br_ext_lock, &irqL);
529 memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN);
530 memcpy(db->macAddr, macAddr, ETH_ALEN);
531 atomic_set(&db->use_count, 1);
532 db->ageing_timer = jiffies;
534 __network_hash_link(priv, db, hash);
536 _exit_critical_bh(&priv->br_ext_lock, &irqL);
540 static void __nat25_db_print(_adapter *priv)
543 _enter_critical_bh(&priv->br_ext_lock, &irqL);
546 static int counter = 0;
548 struct nat25_network_db_entry *db;
551 if((counter % 16) != 0)
554 for(i=0, j=0; i<NAT25_HASH_SIZE; i++)
556 db = priv->nethash[i];
561 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"
562 "%02x%02x%02x%02x%02x%02x\n",
565 atomic_read(&db->use_count),
588 db->networkAddr[16]);
590 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",
593 atomic_read(&db->use_count),
610 db->networkAddr[10]);
619 _exit_critical_bh(&priv->br_ext_lock, &irqL);
629 void nat25_db_cleanup(_adapter *priv)
633 _enter_critical_bh(&priv->br_ext_lock, &irqL);
635 for(i=0; i<NAT25_HASH_SIZE; i++)
637 struct nat25_network_db_entry *f;
638 f = priv->nethash[i];
640 struct nat25_network_db_entry *g;
643 if(priv->scdb_entry == f)
645 memset(priv->scdb_mac, 0, ETH_ALEN);
646 memset(priv->scdb_ip, 0, 4);
647 priv->scdb_entry = NULL;
649 __network_hash_unlink(f);
650 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
656 _exit_critical_bh(&priv->br_ext_lock, &irqL);
660 void nat25_db_expire(_adapter *priv)
664 _enter_critical_bh(&priv->br_ext_lock, &irqL);
666 //if(!priv->ethBrExtInfo.nat25_disable)
668 for (i=0; i<NAT25_HASH_SIZE; i++)
670 struct nat25_network_db_entry *f;
671 f = priv->nethash[i];
675 struct nat25_network_db_entry *g;
678 if(__nat25_has_expired(priv, f))
680 if(atomic_dec_and_test(&f->use_count))
684 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"
685 "%02x%02x%02x%02x%02x%02x\n",
712 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",
733 if(priv->scdb_entry == f)
735 memset(priv->scdb_mac, 0, ETH_ALEN);
736 memset(priv->scdb_ip, 0, 4);
737 priv->scdb_entry = NULL;
739 __network_hash_unlink(f);
740 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
749 _exit_critical_bh(&priv->br_ext_lock, &irqL);
753 #ifdef SUPPORT_TX_MCAST2UNI
754 static int checkIPMcAndReplace(_adapter *priv, struct sk_buff *skb, unsigned int *dst_ip)
756 struct stat_info *pstat;
757 struct list_head *phead, *plist;
760 phead = &priv->asoc_list;
763 while (plist != phead) {
764 pstat = list_entry(plist, struct stat_info, asoc_list);
767 if (pstat->ipmc_num == 0)
770 for (i=0; i<MAX_IP_MC_ENTRY; i++) {
771 if (pstat->ipmc[i].used && !memcmp(&pstat->ipmc[i].mcmac[3], ((unsigned char *)dst_ip)+1, 3)) {
772 memcpy(skb->data, pstat->ipmc[i].mcmac, ETH_ALEN);
781 int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
783 unsigned short protocol;
784 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
789 if((method <= NAT25_MIN) || (method >= NAT25_MAX))
792 protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
794 /*---------------------------------------------------*/
795 /* Handle IP frame */
796 /*---------------------------------------------------*/
797 if(protocol == __constant_htons(ETH_P_IP))
799 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
801 if(((unsigned char*)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len))
803 DEBUG_WARN("NAT25: malformed IP packet !\n");
814 //some muticast with source IP is all zero, maybe other case is illegal
815 //in class A, B, C, host address is all zero or all one is illegal
818 DEBUG_INFO("NAT25: Insert IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
819 __nat25_generate_ipv4_network_addr(networkAddr, &iph->saddr);
820 //record source IP address and , source mac address into db
821 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
823 __nat25_db_print(priv);
829 DEBUG_INFO("NAT25: Lookup IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
830 #ifdef SUPPORT_TX_MCAST2UNI
831 if (priv->pshare->rf_ft_var.mc2u_disable ||
832 ((((OPMODE & (WIFI_STATION_STATE|WIFI_ASOC_STATE))
833 == (WIFI_STATION_STATE|WIFI_ASOC_STATE)) &&
834 !checkIPMcAndReplace(priv, skb, &iph->daddr)) ||
835 (OPMODE & WIFI_ADHOC_STATE)))
838 __nat25_generate_ipv4_network_addr(networkAddr, &iph->daddr);
840 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
841 if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
842 // L2 is unicast but L3 is broadcast, make L2 bacome broadcast
843 DEBUG_INFO("NAT25: Set DA as boardcast\n");
844 memset(skb->data, 0xff, ETH_ALEN);
847 // forward unknow IP packet to upper TCP/IP
848 DEBUG_INFO("NAT25: Replace DA with BR's MAC\n");
849 if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) {
850 void netdev_br_init(struct net_device *netdev);
851 printk("Re-init netdev_br_init() due to br_mac==0!\n");
852 netdev_br_init(priv->pnetdev);
854 memcpy(skb->data, priv->br_mac, ETH_ALEN);
866 /*---------------------------------------------------*/
867 /* Handle ARP frame */
868 /*---------------------------------------------------*/
869 else if(protocol == __constant_htons(ETH_P_ARP))
871 struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
872 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
873 unsigned int *sender, *target;
875 if(arp->ar_pro != __constant_htons(ETH_P_IP))
877 DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", htons(arp->ar_pro));
884 return 0; // skb_copy for all ARP frame
888 DEBUG_INFO("NAT25: Insert ARP, MAC=%02x%02x%02x%02x%02x%02x\n", arp_ptr[0],
889 arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]);
891 // change to ARP sender mac address to wlan STA address
892 memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
894 arp_ptr += arp->ar_hln;
895 sender = (unsigned int *)arp_ptr;
897 __nat25_generate_ipv4_network_addr(networkAddr, sender);
899 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
901 __nat25_db_print(priv);
907 DEBUG_INFO("NAT25: Lookup ARP\n");
909 arp_ptr += arp->ar_hln;
910 sender = (unsigned int *)arp_ptr;
911 arp_ptr += (arp->ar_hln + arp->ar_pln);
912 target = (unsigned int *)arp_ptr;
914 __nat25_generate_ipv4_network_addr(networkAddr, target);
916 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
918 // change to ARP target mac address to Lookup result
919 arp_ptr = (unsigned char *)(arp + 1);
920 arp_ptr += (arp->ar_hln + arp->ar_pln);
921 memcpy(arp_ptr, skb->data, ETH_ALEN);
930 /*---------------------------------------------------*/
931 /* Handle IPX and Apple Talk frame */
932 /*---------------------------------------------------*/
933 else if((protocol == __constant_htons(ETH_P_IPX)) ||
934 (protocol <= __constant_htons(ETH_FRAME_LEN)))
936 unsigned char ipx_header[2] = {0xFF, 0xFF};
937 struct ipxhdr *ipx = NULL;
938 struct elapaarp *ea = NULL;
939 struct ddpehdr *ddp = NULL;
940 unsigned char *framePtr = skb->data + ETH_HLEN;
942 if(protocol == __constant_htons(ETH_P_IPX))
944 DEBUG_INFO("NAT25: Protocol=IPX (Ethernet II)\n");
945 ipx = (struct ipxhdr *)framePtr;
947 else if(protocol <= __constant_htons(ETH_FRAME_LEN))
949 if(!memcmp(ipx_header, framePtr, 2))
951 DEBUG_INFO("NAT25: Protocol=IPX (Ethernet 802.3)\n");
952 ipx = (struct ipxhdr *)framePtr;
956 unsigned char ipx_8022_type = 0xE0;
957 unsigned char snap_8022_type = 0xAA;
959 if(*framePtr == snap_8022_type)
961 unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID
962 unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID
963 unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID
965 framePtr += 3; // eliminate the 802.2 header
967 if(!memcmp(ipx_snap_id, framePtr, 5))
969 framePtr += 5; // eliminate the SNAP header
971 DEBUG_INFO("NAT25: Protocol=IPX (Ethernet SNAP)\n");
972 ipx = (struct ipxhdr *)framePtr;
974 else if(!memcmp(aarp_snap_id, framePtr, 5))
976 framePtr += 5; // eliminate the SNAP header
978 ea = (struct elapaarp *)framePtr;
980 else if(!memcmp(ddp_snap_id, framePtr, 5))
982 framePtr += 5; // eliminate the SNAP header
984 ddp = (struct ddpehdr *)framePtr;
988 DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0],
989 framePtr[1], framePtr[2], framePtr[3], framePtr[4]);
993 else if(*framePtr == ipx_8022_type)
995 framePtr += 3; // eliminate the 802.2 header
997 if(!memcmp(ipx_header, framePtr, 2))
999 DEBUG_INFO("NAT25: Protocol=IPX (Ethernet 802.2)\n");
1000 ipx = (struct ipxhdr *)framePtr;
1018 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1020 DEBUG_INFO("NAT25: Check IPX skb_copy\n");
1027 DEBUG_INFO("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n",
1029 ipx->ipx_dest.node[0],
1030 ipx->ipx_dest.node[1],
1031 ipx->ipx_dest.node[2],
1032 ipx->ipx_dest.node[3],
1033 ipx->ipx_dest.node[4],
1034 ipx->ipx_dest.node[5],
1036 ipx->ipx_source.net,
1037 ipx->ipx_source.node[0],
1038 ipx->ipx_source.node[1],
1039 ipx->ipx_source.node[2],
1040 ipx->ipx_source.node[3],
1041 ipx->ipx_source.node[4],
1042 ipx->ipx_source.node[5],
1043 ipx->ipx_source.sock);
1045 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1047 DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n");
1049 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
1051 // change IPX source node addr to wlan STA address
1052 memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
1056 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node);
1059 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1061 __nat25_db_print(priv);
1067 if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN))
1069 DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n");
1071 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock);
1073 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1075 // replace IPX destination node addr with Lookup destination MAC addr
1076 memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
1080 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node);
1082 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1095 /* Sanity check fields. */
1096 if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN)
1098 DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n");
1109 // change to AARP source mac address to wlan STA address
1110 memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
1112 DEBUG_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
1118 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node);
1120 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1122 __nat25_db_print(priv);
1128 DEBUG_INFO("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n",
1134 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node);
1136 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1138 // change to AARP destination mac address to Lookup result
1139 memcpy(ea->hw_dst, skb->data, ETH_ALEN);
1149 else if(ddp != NULL)
1158 DEBUG_INFO("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n",
1164 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode);
1166 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1168 __nat25_db_print(priv);
1174 DEBUG_INFO("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n",
1180 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode);
1182 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1194 /*---------------------------------------------------*/
1195 /* Handle PPPoE frame */
1196 /*---------------------------------------------------*/
1197 else if((protocol == __constant_htons(ETH_P_PPP_DISC)) ||
1198 (protocol == __constant_htons(ETH_P_PPP_SES)))
1200 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
1201 unsigned short *pMagic;
1211 if(ph->sid == 0) // Discovery phase according to tag
1213 if(ph->code == PADI_CODE || ph->code == PADR_CODE)
1215 if (priv->ethBrExtInfo.addPPPoETag) {
1216 struct pppoe_tag *tag, *pOldTag;
1217 unsigned char tag_buf[40];
1220 tag = (struct pppoe_tag *)tag_buf;
1221 pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
1222 if (pOldTag) { // if SID existed, copy old value and delete it
1223 old_tag_len = ntohs(pOldTag->tag_len);
1224 if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) {
1225 DEBUG_ERR("SID tag length too long!\n");
1229 memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN,
1230 pOldTag->tag_data, old_tag_len);
1232 if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) {
1233 DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n");
1236 ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len);
1239 tag->tag_type = PTT_RELAY_SID;
1240 tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len);
1242 // insert the magic_code+client mac in relay tag
1243 pMagic = (unsigned short *)tag->tag_data;
1244 *pMagic = htons(MAGIC_CODE);
1245 memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN);
1248 if(__nat25_add_pppoe_tag(skb, tag) < 0)
1251 DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n",
1252 (ph->code == PADI_CODE ? "PADI" : "PADR"));
1254 else { // not add relay tag
1255 if (priv->pppoe_connection_in_progress &&
1256 memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) {
1257 DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n");
1261 if (priv->pppoe_connection_in_progress == 0)
1262 memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN);
1264 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1270 else // session phase
1272 DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name);
1274 __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid));
1276 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1278 __nat25_db_print(priv);
1280 if (!priv->ethBrExtInfo.addPPPoETag &&
1281 priv->pppoe_connection_in_progress &&
1282 !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN))
1283 priv->pppoe_connection_in_progress = 0;
1288 if(ph->code == PADO_CODE || ph->code == PADS_CODE)
1290 if (priv->ethBrExtInfo.addPPPoETag) {
1291 struct pppoe_tag *tag;
1293 unsigned short tagType, tagLen;
1296 if((ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID))) == 0) {
1297 DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n");
1301 tag = (struct pppoe_tag *)ptr;
1302 tagType = (unsigned short)((ptr[0] << 8) + ptr[1]);
1303 tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]);
1305 if((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) {
1306 DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen);
1310 pMagic = (unsigned short *)tag->tag_data;
1311 if (ntohs(*pMagic) != MAGIC_CODE) {
1312 DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n",
1313 (ph->code == PADO_CODE ? "PADO" : "PADS"));
1317 memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN);
1319 if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN)
1320 offset = TAG_HDR_LEN;
1322 if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) {
1323 DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n");
1326 ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset));
1328 tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN);
1330 DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n",
1331 (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name);
1333 else { // not add relay tag
1334 if (!priv->pppoe_connection_in_progress) {
1335 DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n");
1338 memcpy(skb->data, priv->pppoe_addr, ETH_ALEN);
1339 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1345 DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name);
1346 __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid));
1348 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1350 __nat25_db_print(priv);
1363 /*---------------------------------------------------*/
1364 /* Handle EAP frame */
1365 /*---------------------------------------------------*/
1366 else if(protocol == __constant_htons(0x888e))
1384 /*---------------------------------------------------*/
1385 /* Handle C-Media proprietary frame */
1386 /*---------------------------------------------------*/
1387 else if((protocol == __constant_htons(0xe2ae)) ||
1388 (protocol == __constant_htons(0xe2af)))
1406 /*---------------------------------------------------*/
1407 /* Handle IPV6 frame */
1408 /*---------------------------------------------------*/
1410 else if(protocol == __constant_htons(ETH_P_IPV6))
1412 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
1414 if (sizeof(*iph) >= (skb->len - ETH_HLEN))
1416 DEBUG_WARN("NAT25: malformed IPv6 packet !\n");
1423 if (skb->data[0] & 1)
1429 DEBUG_INFO("NAT25: Insert IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1430 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1431 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1432 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1433 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1434 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1436 if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) {
1437 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr);
1438 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1439 __nat25_db_print(priv);
1441 if (iph->nexthdr == IPPROTO_ICMPV6 &&
1442 skb->len > (ETH_HLEN + sizeof(*iph) + 4)) {
1443 if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph),
1444 skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) {
1445 struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph));
1446 hdr->icmp6_cksum = 0;
1447 hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr,
1450 csum_partial((__u8 *)hdr, iph->payload_len, 0));
1458 DEBUG_INFO("NAT25: Lookup IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1459 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1460 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1461 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1462 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1463 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1466 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr);
1467 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
1468 #ifdef SUPPORT_RX_UNI2MCAST
1469 if (iph->daddr.s6_addr[0] == 0xff)
1470 convert_ipv6_mac_to_mc(skb);
1479 #endif // CL_IPV6_PASS
1485 int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
1488 if((!priv->ethBrExtInfo.nat25_disable) && (!(skb->data[0] & 1)))
1490 panic_printk("NAT25: Input Frame: DA=%02x%02x%02x%02x%02x%02x SA=%02x%02x%02x%02x%02x%02x\n",
1506 if(!(skb->data[0] & 1))
1508 int is_vlan_tag=0, i, retval=0;
1509 unsigned short vlan_hdr=0;
1511 if (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_8021Q)) {
1513 vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2));
1515 *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2));
1519 if (!priv->ethBrExtInfo.nat25_disable)
1522 _enter_critical_bh(&priv->br_ext_lock, &irqL);
1524 * This function look up the destination network address from
1525 * the NAT2.5 database. Return value = -1 means that the
1526 * corresponding network protocol is NOT support.
1528 if (!priv->ethBrExtInfo.nat25sc_disable &&
1529 (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1530 !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
1531 memcpy(skb->data, priv->scdb_mac, ETH_ALEN);
1533 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1536 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1538 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1542 if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1543 !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
1544 ((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_ARP)) &&
1545 !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
1546 // for traffic to upper TCP/IP
1547 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1554 *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
1555 *((unsigned short *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q);
1556 *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr;
1560 //DEBUG_ERR("NAT25: Lookup fail!\n");
1569 void mac_clone(_adapter *priv, unsigned char *addr)
1573 memcpy(sa.sa_data, addr, ETH_ALEN);
1574 DEBUG_INFO("MAC Clone: Addr=%02x%02x%02x%02x%02x%02x\n",
1575 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
1576 rtl8192cd_set_hwaddr(priv->dev, &sa);
1580 int mac_clone_handle_frame(_adapter *priv, struct sk_buff *skb)
1582 if(priv->ethBrExtInfo.macclone_enable && !priv->macclone_completed)
1584 if(!(skb->data[ETH_ALEN] & 1)) //// check any other particular MAC add
1586 if(memcmp(skb->data+ETH_ALEN, GET_MY_HWADDR(priv), ETH_ALEN) &&
1587 ((priv->dev->br_port) &&
1588 memcmp(skb->data+ETH_ALEN, priv->br_mac, ETH_ALEN)))
1590 mac_clone(priv, skb->data+ETH_ALEN);
1591 priv->macclone_completed = 1;
1600 #define SERVER_PORT 67
1601 #define CLIENT_PORT 68
1602 #define DHCP_MAGIC 0x63825363
1603 #define BROADCAST_FLAG 0x8000
1605 struct dhcpMessage {
1617 u_int8_t chaddr[16];
1621 u_int8_t options[308]; /* 312 - cookie */
1624 void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb)
1629 if(!priv->ethBrExtInfo.dhcp_bcst_disable)
1631 unsigned short protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
1633 if(protocol == __constant_htons(ETH_P_IP)) // IP
1635 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
1637 if(iph->protocol == IPPROTO_UDP) // UDP
1639 struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2));
1641 if((udph->source == __constant_htons(CLIENT_PORT))
1642 && (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request
1644 struct dhcpMessage *dhcph =
1645 (struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr));
1647 if(dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word
1649 if(!(dhcph->flags & htons(BROADCAST_FLAG))) // if not broadcast
1651 register int sum = 0;
1653 DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n");
1654 // or BROADCAST flag
1655 dhcph->flags |= htons(BROADCAST_FLAG);
1656 // recalculate checksum
1657 sum = ~(udph->check) & 0xffff;
1658 sum += dhcph->flags;
1660 sum = (sum & 0xffff) + (sum >> 16);
1671 void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
1672 unsigned char *ipAddr)
1674 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
1675 struct nat25_network_db_entry *db;
1678 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
1680 __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr);
1681 hash = __nat25_network_hash(networkAddr);
1682 db = priv->nethash[hash];
1685 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) {
1686 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1693 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1697 #endif // CONFIG_BR_EXT