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
33 #include <drv_types.h>
34 #include "rtw_br_ext.h"
35 #else // rtw_wifi_driver
36 #include "./8192cd_cfg.h"
39 #include "./sys-support.h"
43 #include "./8192cd_headers.h"
44 #include "./8192cd_br_ext.h"
45 #include "./8192cd_debug.h"
46 #endif // rtw_wifi_driver
50 #include <linux/ipv6.h>
51 #include <linux/icmpv6.h>
52 #include <net/ndisc.h>
53 #include <net/checksum.h>
59 //#define BR_EXT_DEBUG
64 #define NAT25_APPLE 04
65 #define NAT25_PPPOE 05
67 #define RTL_RELAY_TAG_LEN (ETH_ALEN)
70 #define MAGIC_CODE 0x8186
71 #define MAGIC_CODE_LEN 2
72 #define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec
74 /*-----------------------------------------------------------------
75 How database records network address:
76 0 1 2 3 4 5 6 7 8 9 10
77 |----|----|----|----|----|----|----|----|----|----|----|
78 IPv4 |type| | IP addr |
79 IPX |type| Net addr | Node addr |
80 IPX |type| Net addr |Sckt addr|
81 Apple |type| Network |node|
82 PPPoE |type| SID | AC MAC |
83 -----------------------------------------------------------------*/
86 //Find a tag in pppoe frame and return the pointer
87 static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
89 unsigned char *cur_ptr, *start_ptr;
90 unsigned short tagLen, tagType;
92 start_ptr = cur_ptr = (unsigned char *)ph->tag;
93 while((cur_ptr - start_ptr) < ntohs(ph->length)) {
94 // prevent un-alignment access
95 tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
96 tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
99 cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen;
105 static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag)
107 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
110 data_len = tag->tag_len + TAG_HDR_LEN;
111 if (skb_tailroom(skb) < data_len) {
112 _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n");
116 skb_put(skb, data_len);
117 // have a room for new tag
118 memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
119 ph->length = htons(ntohs(ph->length) + data_len);
120 memcpy((unsigned char *)ph->tag, tag, data_len);
124 static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len)
127 unsigned long end, tail;
129 if ((src+len) > skb_tail_pointer(skb) || skb->len < len)
132 tail = (unsigned long)skb_tail_pointer(skb);
133 end = (unsigned long)src+len;
137 tail_len = (int)(tail-end);
139 memmove(src, src+len, tail_len);
141 skb_trim(skb, skb->len-len);
145 static __inline__ unsigned long __nat25_timeout(_adapter *priv)
147 unsigned long timeout;
149 timeout = jiffies - NAT25_AGEING_TIME*HZ;
155 static __inline__ int __nat25_has_expired(_adapter *priv,
156 struct nat25_network_db_entry *fdb)
158 if(time_before_eq(fdb->ageing_timer, __nat25_timeout(priv)))
165 static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr,
166 unsigned int *ipAddr)
168 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
170 networkAddr[0] = NAT25_IPV4;
171 memcpy(networkAddr+7, (unsigned char *)ipAddr, 4);
175 static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr,
176 unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr)
178 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
180 networkAddr[0] = NAT25_IPX;
181 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
182 memcpy(networkAddr+5, ipxNodeAddr, 6);
186 static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr,
187 unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr)
189 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
191 networkAddr[0] = NAT25_IPX;
192 memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4);
193 memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2);
197 static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr,
198 unsigned short *network, unsigned char *node)
200 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
202 networkAddr[0] = NAT25_APPLE;
203 memcpy(networkAddr+1, (unsigned char *)network, 2);
204 networkAddr[3] = *node;
208 static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr,
209 unsigned char *ac_mac, unsigned short *sid)
211 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
213 networkAddr[0] = NAT25_PPPOE;
214 memcpy(networkAddr+1, (unsigned char *)sid, 2);
215 memcpy(networkAddr+3, (unsigned char *)ac_mac, 6);
220 static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr,
221 unsigned int *ipAddr)
223 memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
225 networkAddr[0] = NAT25_IPV6;
226 memcpy(networkAddr+1, (unsigned char *)ipAddr, 16);
230 static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b)
233 if (*data == tag && *(data+1) == len8b && len >= len8b*8)
236 len -= (*(data+1))*8;
237 data += (*(data+1))*8;
243 static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac)
245 struct icmp6hdr *icmphdr = (struct icmp6hdr *)data;
248 if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) {
250 mac = scan_tlv(&data[8], len-8, 1, 1);
252 _DEBUG_INFO("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
253 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
254 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
255 memcpy(mac, replace_mac, 6);
260 else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) {
262 mac = scan_tlv(&data[16], len-16, 1, 1);
264 _DEBUG_INFO("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
265 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
266 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
267 memcpy(mac, replace_mac, 6);
272 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
274 mac = scan_tlv(&data[24], len-24, 1, 1);
276 _DEBUG_INFO("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
277 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
278 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
279 memcpy(mac, replace_mac, 6);
284 else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
286 mac = scan_tlv(&data[24], len-24, 2, 1);
288 _DEBUG_INFO("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
289 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
290 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
291 memcpy(mac, replace_mac, 6);
296 else if (icmphdr->icmp6_type == NDISC_REDIRECT) {
298 mac = scan_tlv(&data[40], len-40, 2, 1);
300 _DEBUG_INFO("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n",
301 mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],
302 replace_mac[0],replace_mac[1],replace_mac[2],replace_mac[3],replace_mac[4],replace_mac[5]);
303 memcpy(mac, replace_mac, 6);
312 static void convert_ipv6_mac_to_mc(struct sk_buff *skb)
314 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
315 unsigned char *dst_mac = skb->data;
319 /*modified by qinjunjie,ipv6 multicast address ix 0x33-33-xx-xx-xx-xx*/
322 memcpy(&dst_mac[2], &iph->daddr.s6_addr32[3], 4);
323 #if defined(__LINUX_2_6__)
324 /*modified by qinjunjie,warning:should not remove next line*/
325 skb->pkt_type = PACKET_MULTICAST;
328 #endif /* CL_IPV6_PASS */
331 static __inline__ int __nat25_network_hash(unsigned char *networkAddr)
333 if(networkAddr[0] == NAT25_IPV4)
337 x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
339 return x & (NAT25_HASH_SIZE - 1);
341 else if(networkAddr[0] == NAT25_IPX)
345 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
346 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10];
348 return x & (NAT25_HASH_SIZE - 1);
350 else if(networkAddr[0] == NAT25_APPLE)
354 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3];
356 return x & (NAT25_HASH_SIZE - 1);
358 else if(networkAddr[0] == NAT25_PPPOE)
362 x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8];
364 return x & (NAT25_HASH_SIZE - 1);
367 else if(networkAddr[0] == NAT25_IPV6)
371 x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^
372 networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^
373 networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^
376 return x & (NAT25_HASH_SIZE - 1);
384 for (i=0; i<MAX_NETWORK_ADDR_LEN; i++)
387 return x & (NAT25_HASH_SIZE - 1);
392 static __inline__ void __network_hash_link(_adapter *priv,
393 struct nat25_network_db_entry *ent, int hash)
395 // Caller must _enter_critical_bh already!
397 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
399 ent->next_hash = priv->nethash[hash];
400 if(ent->next_hash != NULL)
401 ent->next_hash->pprev_hash = &ent->next_hash;
402 priv->nethash[hash] = ent;
403 ent->pprev_hash = &priv->nethash[hash];
405 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
409 static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
411 // Caller must _enter_critical_bh already!
413 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
415 *(ent->pprev_hash) = ent->next_hash;
416 if(ent->next_hash != NULL)
417 ent->next_hash->pprev_hash = ent->pprev_hash;
418 ent->next_hash = NULL;
419 ent->pprev_hash = NULL;
421 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
425 static int __nat25_db_network_lookup_and_replace(_adapter *priv,
426 struct sk_buff *skb, unsigned char *networkAddr)
428 struct nat25_network_db_entry *db;
430 _enter_critical_bh(&priv->br_ext_lock, &irqL);
432 db = priv->nethash[__nat25_network_hash(networkAddr)];
435 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
437 if(!__nat25_has_expired(priv, db))
439 // replace the destination mac address
440 memcpy(skb->data, db->macAddr, ETH_ALEN);
441 atomic_inc(&db->use_count);
444 DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
445 "%02x%02x%02x%02x%02x%02x\n",
468 db->networkAddr[16]);
470 DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
487 db->networkAddr[10]);
490 _exit_critical_bh(&priv->br_ext_lock, &irqL);
497 _exit_critical_bh(&priv->br_ext_lock, &irqL);
502 static void __nat25_db_network_insert(_adapter *priv,
503 unsigned char *macAddr, unsigned char *networkAddr)
505 struct nat25_network_db_entry *db;
508 _enter_critical_bh(&priv->br_ext_lock, &irqL);
510 hash = __nat25_network_hash(networkAddr);
511 db = priv->nethash[hash];
514 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN))
516 memcpy(db->macAddr, macAddr, ETH_ALEN);
517 db->ageing_timer = jiffies;
518 _exit_critical_bh(&priv->br_ext_lock, &irqL);
525 db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db));
527 _exit_critical_bh(&priv->br_ext_lock, &irqL);
531 memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN);
532 memcpy(db->macAddr, macAddr, ETH_ALEN);
533 atomic_set(&db->use_count, 1);
534 db->ageing_timer = jiffies;
536 __network_hash_link(priv, db, hash);
538 _exit_critical_bh(&priv->br_ext_lock, &irqL);
542 static void __nat25_db_print(_adapter *priv)
545 _enter_critical_bh(&priv->br_ext_lock, &irqL);
548 static int counter = 0;
550 struct nat25_network_db_entry *db;
553 if((counter % 16) != 0)
556 for(i=0, j=0; i<NAT25_HASH_SIZE; i++)
558 db = priv->nethash[i];
563 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"
564 "%02x%02x%02x%02x%02x%02x\n",
567 atomic_read(&db->use_count),
590 db->networkAddr[16]);
592 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",
595 atomic_read(&db->use_count),
612 db->networkAddr[10]);
621 _exit_critical_bh(&priv->br_ext_lock, &irqL);
631 void nat25_db_cleanup(_adapter *priv)
635 _enter_critical_bh(&priv->br_ext_lock, &irqL);
637 for(i=0; i<NAT25_HASH_SIZE; i++)
639 struct nat25_network_db_entry *f;
640 f = priv->nethash[i];
642 struct nat25_network_db_entry *g;
645 if(priv->scdb_entry == f)
647 memset(priv->scdb_mac, 0, ETH_ALEN);
648 memset(priv->scdb_ip, 0, 4);
649 priv->scdb_entry = NULL;
651 __network_hash_unlink(f);
652 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
658 _exit_critical_bh(&priv->br_ext_lock, &irqL);
662 void nat25_db_expire(_adapter *priv)
666 _enter_critical_bh(&priv->br_ext_lock, &irqL);
668 //if(!priv->ethBrExtInfo.nat25_disable)
670 for (i=0; i<NAT25_HASH_SIZE; i++)
672 struct nat25_network_db_entry *f;
673 f = priv->nethash[i];
677 struct nat25_network_db_entry *g;
680 if(__nat25_has_expired(priv, f))
682 if(atomic_dec_and_test(&f->use_count))
686 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"
687 "%02x%02x%02x%02x%02x%02x\n",
714 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",
735 if(priv->scdb_entry == f)
737 memset(priv->scdb_mac, 0, ETH_ALEN);
738 memset(priv->scdb_ip, 0, 4);
739 priv->scdb_entry = NULL;
741 __network_hash_unlink(f);
742 rtw_mfree((u8 *) f, sizeof(struct nat25_network_db_entry));
751 _exit_critical_bh(&priv->br_ext_lock, &irqL);
755 #ifdef SUPPORT_TX_MCAST2UNI
756 static int checkIPMcAndReplace(_adapter *priv, struct sk_buff *skb, unsigned int *dst_ip)
758 struct stat_info *pstat;
759 struct list_head *phead, *plist;
762 phead = &priv->asoc_list;
765 while (plist != phead) {
766 pstat = list_entry(plist, struct stat_info, asoc_list);
769 if (pstat->ipmc_num == 0)
772 for (i=0; i<MAX_IP_MC_ENTRY; i++) {
773 if (pstat->ipmc[i].used && !memcmp(&pstat->ipmc[i].mcmac[3], ((unsigned char *)dst_ip)+1, 3)) {
774 memcpy(skb->data, pstat->ipmc[i].mcmac, ETH_ALEN);
783 int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
785 unsigned short protocol;
786 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
791 if((method <= NAT25_MIN) || (method >= NAT25_MAX))
794 protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
796 /*---------------------------------------------------*/
797 /* Handle IP frame */
798 /*---------------------------------------------------*/
799 if(protocol == __constant_htons(ETH_P_IP))
801 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
803 if(((unsigned char*)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len))
805 DEBUG_WARN("NAT25: malformed IP packet !\n");
816 //some muticast with source IP is all zero, maybe other case is illegal
817 //in class A, B, C, host address is all zero or all one is illegal
820 DEBUG_INFO("NAT25: Insert IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
821 __nat25_generate_ipv4_network_addr(networkAddr, &iph->saddr);
822 //record source IP address and , source mac address into db
823 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
825 __nat25_db_print(priv);
831 DEBUG_INFO("NAT25: Lookup IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
832 #ifdef SUPPORT_TX_MCAST2UNI
833 if (priv->pshare->rf_ft_var.mc2u_disable ||
834 ((((OPMODE & (WIFI_STATION_STATE|WIFI_ASOC_STATE))
835 == (WIFI_STATION_STATE|WIFI_ASOC_STATE)) &&
836 !checkIPMcAndReplace(priv, skb, &iph->daddr)) ||
837 (OPMODE & WIFI_ADHOC_STATE)))
840 __nat25_generate_ipv4_network_addr(networkAddr, &iph->daddr);
842 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
843 if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
844 // L2 is unicast but L3 is broadcast, make L2 bacome broadcast
845 DEBUG_INFO("NAT25: Set DA as boardcast\n");
846 memset(skb->data, 0xff, ETH_ALEN);
849 // forward unknow IP packet to upper TCP/IP
850 DEBUG_INFO("NAT25: Replace DA with BR's MAC\n");
851 if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) {
852 void netdev_br_init(struct net_device *netdev);
853 printk("Re-init netdev_br_init() due to br_mac==0!\n");
854 netdev_br_init(priv->pnetdev);
856 memcpy(skb->data, priv->br_mac, ETH_ALEN);
868 /*---------------------------------------------------*/
869 /* Handle ARP frame */
870 /*---------------------------------------------------*/
871 else if(protocol == __constant_htons(ETH_P_ARP))
873 struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
874 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
875 unsigned int *sender, *target;
877 if(arp->ar_pro != __constant_htons(ETH_P_IP))
879 DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", htons(arp->ar_pro));
886 return 0; // skb_copy for all ARP frame
890 DEBUG_INFO("NAT25: Insert ARP, MAC=%02x%02x%02x%02x%02x%02x\n", arp_ptr[0],
891 arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]);
893 // change to ARP sender mac address to wlan STA address
894 memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
896 arp_ptr += arp->ar_hln;
897 sender = (unsigned int *)arp_ptr;
899 __nat25_generate_ipv4_network_addr(networkAddr, sender);
901 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
903 __nat25_db_print(priv);
909 DEBUG_INFO("NAT25: Lookup ARP\n");
911 arp_ptr += arp->ar_hln;
912 sender = (unsigned int *)arp_ptr;
913 arp_ptr += (arp->ar_hln + arp->ar_pln);
914 target = (unsigned int *)arp_ptr;
916 __nat25_generate_ipv4_network_addr(networkAddr, target);
918 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
920 // change to ARP target mac address to Lookup result
921 arp_ptr = (unsigned char *)(arp + 1);
922 arp_ptr += (arp->ar_hln + arp->ar_pln);
923 memcpy(arp_ptr, skb->data, ETH_ALEN);
932 /*---------------------------------------------------*/
933 /* Handle IPX and Apple Talk frame */
934 /*---------------------------------------------------*/
935 else if((protocol == __constant_htons(ETH_P_IPX)) ||
936 (protocol <= __constant_htons(ETH_FRAME_LEN)))
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 DEBUG_INFO("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 DEBUG_INFO("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 DEBUG_INFO("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 DEBUG_INFO("NAT25: Protocol=IPX (Ethernet 802.2)\n");
1002 ipx = (struct ipxhdr *)framePtr;
1020 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1022 DEBUG_INFO("NAT25: Check IPX skb_copy\n");
1029 DEBUG_INFO("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n",
1031 ipx->ipx_dest.node[0],
1032 ipx->ipx_dest.node[1],
1033 ipx->ipx_dest.node[2],
1034 ipx->ipx_dest.node[3],
1035 ipx->ipx_dest.node[4],
1036 ipx->ipx_dest.node[5],
1038 ipx->ipx_source.net,
1039 ipx->ipx_source.node[0],
1040 ipx->ipx_source.node[1],
1041 ipx->ipx_source.node[2],
1042 ipx->ipx_source.node[3],
1043 ipx->ipx_source.node[4],
1044 ipx->ipx_source.node[5],
1045 ipx->ipx_source.sock);
1047 if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN))
1049 DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n");
1051 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
1053 // change IPX source node addr to wlan STA address
1054 memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
1058 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node);
1061 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1063 __nat25_db_print(priv);
1069 if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN))
1071 DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n");
1073 __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock);
1075 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1077 // replace IPX destination node addr with Lookup destination MAC addr
1078 memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
1082 __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node);
1084 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1097 /* Sanity check fields. */
1098 if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN)
1100 DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n");
1111 // change to AARP source mac address to wlan STA address
1112 memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
1114 DEBUG_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
1120 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node);
1122 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1124 __nat25_db_print(priv);
1130 DEBUG_INFO("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n",
1136 __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node);
1138 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1140 // change to AARP destination mac address to Lookup result
1141 memcpy(ea->hw_dst, skb->data, ETH_ALEN);
1151 else if(ddp != NULL)
1160 DEBUG_INFO("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n",
1166 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode);
1168 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1170 __nat25_db_print(priv);
1176 DEBUG_INFO("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n",
1182 __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode);
1184 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1196 /*---------------------------------------------------*/
1197 /* Handle PPPoE frame */
1198 /*---------------------------------------------------*/
1199 else if((protocol == __constant_htons(ETH_P_PPP_DISC)) ||
1200 (protocol == __constant_htons(ETH_P_PPP_SES)))
1202 struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
1203 unsigned short *pMagic;
1213 if(ph->sid == 0) // Discovery phase according to tag
1215 if(ph->code == PADI_CODE || ph->code == PADR_CODE)
1217 if (priv->ethBrExtInfo.addPPPoETag) {
1218 struct pppoe_tag *tag, *pOldTag;
1219 unsigned char tag_buf[40];
1222 tag = (struct pppoe_tag *)tag_buf;
1223 pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
1224 if (pOldTag) { // if SID existed, copy old value and delete it
1225 old_tag_len = ntohs(pOldTag->tag_len);
1226 if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) {
1227 DEBUG_ERR("SID tag length too long!\n");
1231 memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN,
1232 pOldTag->tag_data, old_tag_len);
1234 if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) {
1235 DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n");
1238 ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len);
1241 tag->tag_type = PTT_RELAY_SID;
1242 tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len);
1244 // insert the magic_code+client mac in relay tag
1245 pMagic = (unsigned short *)tag->tag_data;
1246 *pMagic = htons(MAGIC_CODE);
1247 memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN);
1250 if(__nat25_add_pppoe_tag(skb, tag) < 0)
1253 DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n",
1254 (ph->code == PADI_CODE ? "PADI" : "PADR"));
1256 else { // not add relay tag
1257 if (priv->pppoe_connection_in_progress &&
1258 memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) {
1259 DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n");
1263 if (priv->pppoe_connection_in_progress == 0)
1264 memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN);
1266 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1272 else // session phase
1274 DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name);
1276 __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid));
1278 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1280 __nat25_db_print(priv);
1282 if (!priv->ethBrExtInfo.addPPPoETag &&
1283 priv->pppoe_connection_in_progress &&
1284 !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN))
1285 priv->pppoe_connection_in_progress = 0;
1290 if(ph->code == PADO_CODE || ph->code == PADS_CODE)
1292 if (priv->ethBrExtInfo.addPPPoETag) {
1293 struct pppoe_tag *tag;
1295 unsigned short tagType, tagLen;
1298 if((ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID))) == 0) {
1299 DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n");
1303 tag = (struct pppoe_tag *)ptr;
1304 tagType = (unsigned short)((ptr[0] << 8) + ptr[1]);
1305 tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]);
1307 if((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) {
1308 DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen);
1312 pMagic = (unsigned short *)tag->tag_data;
1313 if (ntohs(*pMagic) != MAGIC_CODE) {
1314 DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n",
1315 (ph->code == PADO_CODE ? "PADO" : "PADS"));
1319 memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN);
1321 if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN)
1322 offset = TAG_HDR_LEN;
1324 if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) {
1325 DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n");
1328 ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset));
1330 tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN);
1332 DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n",
1333 (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name);
1335 else { // not add relay tag
1336 if (!priv->pppoe_connection_in_progress) {
1337 DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n");
1340 memcpy(skb->data, priv->pppoe_addr, ETH_ALEN);
1341 priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE;
1347 DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name);
1348 __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid));
1350 __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
1352 __nat25_db_print(priv);
1365 /*---------------------------------------------------*/
1366 /* Handle EAP frame */
1367 /*---------------------------------------------------*/
1368 else if(protocol == __constant_htons(0x888e))
1386 /*---------------------------------------------------*/
1387 /* Handle C-Media proprietary frame */
1388 /*---------------------------------------------------*/
1389 else if((protocol == __constant_htons(0xe2ae)) ||
1390 (protocol == __constant_htons(0xe2af)))
1408 /*---------------------------------------------------*/
1409 /* Handle IPV6 frame */
1410 /*---------------------------------------------------*/
1412 else if(protocol == __constant_htons(ETH_P_IPV6))
1414 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
1416 if (sizeof(*iph) >= (skb->len - ETH_HLEN))
1418 DEBUG_WARN("NAT25: malformed IPv6 packet !\n");
1425 if (skb->data[0] & 1)
1431 DEBUG_INFO("NAT25: Insert IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1432 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1433 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1434 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1435 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1436 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1438 if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) {
1439 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr);
1440 __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
1441 __nat25_db_print(priv);
1443 if (iph->nexthdr == IPPROTO_ICMPV6 &&
1444 skb->len > (ETH_HLEN + sizeof(*iph) + 4)) {
1445 if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph),
1446 skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) {
1447 struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph));
1448 hdr->icmp6_cksum = 0;
1449 hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr,
1452 csum_partial((__u8 *)hdr, iph->payload_len, 0));
1460 DEBUG_INFO("NAT25: Lookup IP, SA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x,"
1461 " DA=%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n",
1462 iph->saddr.s6_addr16[0],iph->saddr.s6_addr16[1],iph->saddr.s6_addr16[2],iph->saddr.s6_addr16[3],
1463 iph->saddr.s6_addr16[4],iph->saddr.s6_addr16[5],iph->saddr.s6_addr16[6],iph->saddr.s6_addr16[7],
1464 iph->daddr.s6_addr16[0],iph->daddr.s6_addr16[1],iph->daddr.s6_addr16[2],iph->daddr.s6_addr16[3],
1465 iph->daddr.s6_addr16[4],iph->daddr.s6_addr16[5],iph->daddr.s6_addr16[6],iph->daddr.s6_addr16[7]);
1468 __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr);
1469 if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
1470 #ifdef SUPPORT_RX_UNI2MCAST
1471 if (iph->daddr.s6_addr[0] == 0xff)
1472 convert_ipv6_mac_to_mc(skb);
1481 #endif // CL_IPV6_PASS
1487 int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
1490 if((!priv->ethBrExtInfo.nat25_disable) && (!(skb->data[0] & 1)))
1492 panic_printk("NAT25: Input Frame: DA=%02x%02x%02x%02x%02x%02x SA=%02x%02x%02x%02x%02x%02x\n",
1508 if(!(skb->data[0] & 1))
1510 int is_vlan_tag=0, i, retval=0;
1511 unsigned short vlan_hdr=0;
1513 if (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_8021Q)) {
1515 vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2));
1517 *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2));
1521 if (!priv->ethBrExtInfo.nat25_disable)
1524 _enter_critical_bh(&priv->br_ext_lock, &irqL);
1526 * This function look up the destination network address from
1527 * the NAT2.5 database. Return value = -1 means that the
1528 * corresponding network protocol is NOT support.
1530 if (!priv->ethBrExtInfo.nat25sc_disable &&
1531 (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1532 !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
1533 memcpy(skb->data, priv->scdb_mac, ETH_ALEN);
1535 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1538 _exit_critical_bh(&priv->br_ext_lock, &irqL);
1540 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1544 if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
1545 !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
1546 ((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_ARP)) &&
1547 !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
1548 // for traffic to upper TCP/IP
1549 retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
1556 *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
1557 *((unsigned short *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q);
1558 *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr;
1562 //DEBUG_ERR("NAT25: Lookup fail!\n");
1571 void mac_clone(_adapter *priv, unsigned char *addr)
1575 memcpy(sa.sa_data, addr, ETH_ALEN);
1576 DEBUG_INFO("MAC Clone: Addr=%02x%02x%02x%02x%02x%02x\n",
1577 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
1578 rtl8192cd_set_hwaddr(priv->dev, &sa);
1582 int mac_clone_handle_frame(_adapter *priv, struct sk_buff *skb)
1584 if(priv->ethBrExtInfo.macclone_enable && !priv->macclone_completed)
1586 if(!(skb->data[ETH_ALEN] & 1)) //// check any other particular MAC add
1588 if(memcmp(skb->data+ETH_ALEN, GET_MY_HWADDR(priv), ETH_ALEN) &&
1589 ((priv->dev->br_port) &&
1590 memcmp(skb->data+ETH_ALEN, priv->br_mac, ETH_ALEN)))
1592 mac_clone(priv, skb->data+ETH_ALEN);
1593 priv->macclone_completed = 1;
1602 #define SERVER_PORT 67
1603 #define CLIENT_PORT 68
1604 #define DHCP_MAGIC 0x63825363
1605 #define BROADCAST_FLAG 0x8000
1607 struct dhcpMessage {
1619 u_int8_t chaddr[16];
1623 u_int8_t options[308]; /* 312 - cookie */
1626 void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb)
1631 if(!priv->ethBrExtInfo.dhcp_bcst_disable)
1633 unsigned short protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
1635 if(protocol == __constant_htons(ETH_P_IP)) // IP
1637 struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
1639 if(iph->protocol == IPPROTO_UDP) // UDP
1641 struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2));
1643 if((udph->source == __constant_htons(CLIENT_PORT))
1644 && (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request
1646 struct dhcpMessage *dhcph =
1647 (struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr));
1649 if(dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word
1651 if(!(dhcph->flags & htons(BROADCAST_FLAG))) // if not broadcast
1653 register int sum = 0;
1655 DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n");
1656 // or BROADCAST flag
1657 dhcph->flags |= htons(BROADCAST_FLAG);
1658 // recalculate checksum
1659 sum = ~(udph->check) & 0xffff;
1660 sum += dhcph->flags;
1662 sum = (sum & 0xffff) + (sum >> 16);
1673 void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
1674 unsigned char *ipAddr)
1676 unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
1677 struct nat25_network_db_entry *db;
1680 //_enter_critical_bh(&priv->br_ext_lock, &irqL);
1682 __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr);
1683 hash = __nat25_network_hash(networkAddr);
1684 db = priv->nethash[hash];
1687 if(!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) {
1688 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1695 //_exit_critical_bh(&priv->br_ext_lock, &irqL);
1699 #endif // CONFIG_BR_EXT