mirror of
https://github.com/lwfinger/rtl8188eu.git
synced 2025-05-09 06:43:06 +00:00
rtl8188eu: Change C90 comments to kernel form for files in core/
This commit also includes some sparse fixes for endian issues. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
parent
fb786d0283
commit
d2c90ee304
24 changed files with 4667 additions and 5077 deletions
|
@ -49,7 +49,7 @@
|
|||
|
||||
#ifdef CONFIG_BR_EXT
|
||||
|
||||
//#define BR_EXT_DEBUG
|
||||
/* define BR_EXT_DEBUG */
|
||||
|
||||
#define NAT25_IPV4 01
|
||||
#define NAT25_IPV6 02
|
||||
|
@ -62,7 +62,7 @@
|
|||
|
||||
#define MAGIC_CODE 0x8186
|
||||
#define MAGIC_CODE_LEN 2
|
||||
#define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec
|
||||
#define WAIT_TIME_PPPOE 5 /* waiting time for pppoe server in sec */
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
How database records network address:
|
||||
|
@ -76,7 +76,7 @@
|
|||
-----------------------------------------------------------------*/
|
||||
|
||||
|
||||
//Find a tag in pppoe frame and return the pointer
|
||||
/* Find a tag in pppoe frame and return the pointer */
|
||||
static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type)
|
||||
{
|
||||
unsigned char *cur_ptr, *start_ptr;
|
||||
|
@ -84,7 +84,7 @@ static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, un
|
|||
|
||||
start_ptr = cur_ptr = (unsigned char *)ph->tag;
|
||||
while ((cur_ptr - start_ptr) < ntohs(ph->length)) {
|
||||
// prevent un-alignment access
|
||||
/* prevent un-alignment access */
|
||||
tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]);
|
||||
tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]);
|
||||
if (tagType == type)
|
||||
|
@ -107,7 +107,7 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta
|
|||
}
|
||||
|
||||
skb_put(skb, data_len);
|
||||
// have a room for new tag
|
||||
/* have a room for new tag */
|
||||
memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length));
|
||||
ph->length = htons(ntohs(ph->length) + data_len);
|
||||
memcpy((unsigned char *)ph->tag, tag, data_len);
|
||||
|
@ -307,8 +307,8 @@ static void convert_ipv6_mac_to_mc(struct sk_buff *skb)
|
|||
struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
|
||||
unsigned char *dst_mac = skb->data;
|
||||
|
||||
//dst_mac[0] = 0xff;
|
||||
//dst_mac[1] = 0xff;
|
||||
/* dst_mac[0] = 0xff; */
|
||||
/* dst_mac[1] = 0xff; */
|
||||
/*modified by qinjunjie,ipv6 multicast address ix 0x33-33-xx-xx-xx-xx*/
|
||||
dst_mac[0] = 0x33;
|
||||
dst_mac[1] = 0x33;
|
||||
|
@ -385,9 +385,9 @@ static __inline__ int __nat25_network_hash(unsigned char *networkAddr)
|
|||
static __inline__ void __network_hash_link(_adapter *priv,
|
||||
struct nat25_network_db_entry *ent, int hash)
|
||||
{
|
||||
// Caller must _enter_critical_bh already!
|
||||
//_irqL irqL;
|
||||
//_enter_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* Caller must _enter_critical_bh already! */
|
||||
/* _irqL irqL; */
|
||||
/* _enter_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
|
||||
ent->next_hash = priv->nethash[hash];
|
||||
if (ent->next_hash != NULL)
|
||||
|
@ -395,15 +395,15 @@ static __inline__ void __network_hash_link(_adapter *priv,
|
|||
priv->nethash[hash] = ent;
|
||||
ent->pprev_hash = &priv->nethash[hash];
|
||||
|
||||
//_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* _exit_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
}
|
||||
|
||||
|
||||
static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
|
||||
{
|
||||
// Caller must _enter_critical_bh already!
|
||||
//_irqL irqL;
|
||||
//_enter_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* Caller must _enter_critical_bh already! */
|
||||
/* _irqL irqL; */
|
||||
/* _enter_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
|
||||
*(ent->pprev_hash) = ent->next_hash;
|
||||
if (ent->next_hash != NULL)
|
||||
|
@ -411,7 +411,7 @@ static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent)
|
|||
ent->next_hash = NULL;
|
||||
ent->pprev_hash = NULL;
|
||||
|
||||
//_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* _exit_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
}
|
||||
|
||||
|
||||
|
@ -429,7 +429,7 @@ static int __nat25_db_network_lookup_and_replace(_adapter *priv,
|
|||
{
|
||||
if (!__nat25_has_expired(priv, db))
|
||||
{
|
||||
// replace the destination mac address
|
||||
/* replace the destination mac address */
|
||||
memcpy(skb->data, db->macAddr, ETH_ALEN);
|
||||
atomic_inc(&db->use_count);
|
||||
|
||||
|
@ -658,7 +658,7 @@ void nat25_db_expire(_adapter *priv)
|
|||
_irqL irqL;
|
||||
_enter_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
|
||||
//if (!priv->ethBrExtInfo.nat25_disable)
|
||||
/* if (!priv->ethBrExtInfo.nat25_disable) */
|
||||
{
|
||||
for (i=0; i<NAT25_HASH_SIZE; i++)
|
||||
{
|
||||
|
@ -777,6 +777,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
{
|
||||
unsigned short protocol;
|
||||
unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
|
||||
unsigned int tmp;
|
||||
|
||||
if (skb == NULL)
|
||||
return -1;
|
||||
|
@ -784,12 +785,12 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
if ((method <= NAT25_MIN) || (method >= NAT25_MAX))
|
||||
return -1;
|
||||
|
||||
protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
|
||||
protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN)));
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/* Handle IP frame */
|
||||
/*---------------------------------------------------*/
|
||||
if (protocol == __constant_htons(ETH_P_IP))
|
||||
if (protocol == ETH_P_IP)
|
||||
{
|
||||
struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
|
||||
|
||||
|
@ -806,13 +807,14 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
case NAT25_INSERT:
|
||||
{
|
||||
//some muticast with source IP is all zero, maybe other case is illegal
|
||||
//in class A, B, C, host address is all zero or all one is illegal
|
||||
/* some muticast with source IP is all zero, maybe other case is illegal */
|
||||
/* in class A, B, C, host address is all zero or all one is illegal */
|
||||
if (iph->saddr == 0)
|
||||
return 0;
|
||||
DEBUG_INFO("NAT25: Insert IP, SA=%08x, DA=%08x\n", iph->saddr, iph->daddr);
|
||||
__nat25_generate_ipv4_network_addr(networkAddr, &iph->saddr);
|
||||
//record source IP address and , source mac address into db
|
||||
tmp = be32_to_cpu(iph->saddr);
|
||||
DEBUG_INFO("NAT25: Insert IP, SA=%08x, DA=%08x\n", tmp, iph->daddr);
|
||||
__nat25_generate_ipv4_network_addr(networkAddr, &tmp);
|
||||
/* record source IP address and , source mac address into db */
|
||||
__nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr);
|
||||
|
||||
__nat25_db_print(priv);
|
||||
|
@ -830,16 +832,17 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
(OPMODE & WIFI_ADHOC_STATE)))
|
||||
#endif
|
||||
{
|
||||
__nat25_generate_ipv4_network_addr(networkAddr, &iph->daddr);
|
||||
tmp = be32_to_cpu(iph->daddr);
|
||||
__nat25_generate_ipv4_network_addr(networkAddr, &tmp);
|
||||
|
||||
if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) {
|
||||
if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
|
||||
// L2 is unicast but L3 is broadcast, make L2 bacome broadcast
|
||||
/* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */
|
||||
DEBUG_INFO("NAT25: Set DA as boardcast\n");
|
||||
memset(skb->data, 0xff, ETH_ALEN);
|
||||
}
|
||||
else {
|
||||
// forward unknow IP packet to upper TCP/IP
|
||||
/* forward unknow IP packet to upper TCP/IP */
|
||||
DEBUG_INFO("NAT25: Replace DA with BR's MAC\n");
|
||||
if ( (*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0 ) {
|
||||
printk("Re-init netdev_br_init() due to br_mac==0!\n");
|
||||
|
@ -860,7 +863,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/*---------------------------------------------------*/
|
||||
/* Handle ARP frame */
|
||||
/*---------------------------------------------------*/
|
||||
else if (protocol == __constant_htons(ETH_P_ARP))
|
||||
else if (protocol == ETH_P_ARP)
|
||||
{
|
||||
struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN);
|
||||
unsigned char *arp_ptr = (unsigned char *)(arp + 1);
|
||||
|
@ -868,21 +871,21 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
if (arp->ar_pro != __constant_htons(ETH_P_IP))
|
||||
{
|
||||
DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", htons(arp->ar_pro));
|
||||
DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", be16_to_cpu(arp->ar_pro));
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case NAT25_CHECK:
|
||||
return 0; // skb_copy for all ARP frame
|
||||
return 0; /* skb_copy for all ARP frame */
|
||||
|
||||
case NAT25_INSERT:
|
||||
{
|
||||
DEBUG_INFO("NAT25: Insert ARP, MAC=%02x%02x%02x%02x%02x%02x\n", arp_ptr[0],
|
||||
arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]);
|
||||
|
||||
// change to ARP sender mac address to wlan STA address
|
||||
/* change to ARP sender mac address to wlan STA address */
|
||||
memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN);
|
||||
|
||||
arp_ptr += arp->ar_hln;
|
||||
|
@ -909,7 +912,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
__nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
|
||||
|
||||
// change to ARP target mac address to Lookup result
|
||||
/* change to ARP target mac address to Lookup result */
|
||||
arp_ptr = (unsigned char *)(arp + 1);
|
||||
arp_ptr += (arp->ar_hln + arp->ar_pln);
|
||||
memcpy(arp_ptr, skb->data, ETH_ALEN);
|
||||
|
@ -924,8 +927,8 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/*---------------------------------------------------*/
|
||||
/* Handle IPX and Apple Talk frame */
|
||||
/*---------------------------------------------------*/
|
||||
else if ((protocol == __constant_htons(ETH_P_IPX)) ||
|
||||
(protocol <= __constant_htons(ETH_FRAME_LEN)))
|
||||
else if ((protocol == ETH_P_IPX) ||
|
||||
(protocol <= ETH_FRAME_LEN))
|
||||
{
|
||||
unsigned char ipx_header[2] = {0xFF, 0xFF};
|
||||
struct ipxhdr *ipx = NULL;
|
||||
|
@ -933,12 +936,12 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
struct ddpehdr *ddp = NULL;
|
||||
unsigned char *framePtr = skb->data + ETH_HLEN;
|
||||
|
||||
if (protocol == __constant_htons(ETH_P_IPX))
|
||||
if (protocol == ETH_P_IPX)
|
||||
{
|
||||
DEBUG_INFO("NAT25: Protocol=IPX (Ethernet II)\n");
|
||||
ipx = (struct ipxhdr *)framePtr;
|
||||
}
|
||||
else if (protocol <= __constant_htons(ETH_FRAME_LEN))
|
||||
else if (protocol <= ETH_FRAME_LEN)
|
||||
{
|
||||
if (!memcmp(ipx_header, framePtr, 2))
|
||||
{
|
||||
|
@ -952,28 +955,28 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
if (*framePtr == snap_8022_type)
|
||||
{
|
||||
unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID
|
||||
unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID
|
||||
unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID
|
||||
unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */
|
||||
unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */
|
||||
unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */
|
||||
|
||||
framePtr += 3; // eliminate the 802.2 header
|
||||
framePtr += 3; /* eliminate the 802.2 header */
|
||||
|
||||
if (!memcmp(ipx_snap_id, framePtr, 5))
|
||||
{
|
||||
framePtr += 5; // eliminate the SNAP header
|
||||
framePtr += 5; /* eliminate the SNAP header */
|
||||
|
||||
DEBUG_INFO("NAT25: Protocol=IPX (Ethernet SNAP)\n");
|
||||
ipx = (struct ipxhdr *)framePtr;
|
||||
}
|
||||
else if (!memcmp(aarp_snap_id, framePtr, 5))
|
||||
{
|
||||
framePtr += 5; // eliminate the SNAP header
|
||||
framePtr += 5; /* eliminate the SNAP header */
|
||||
|
||||
ea = (struct elapaarp *)framePtr;
|
||||
}
|
||||
else if (!memcmp(ddp_snap_id, framePtr, 5))
|
||||
{
|
||||
framePtr += 5; // eliminate the SNAP header
|
||||
framePtr += 5; /* eliminate the SNAP header */
|
||||
|
||||
ddp = (struct ddpehdr *)framePtr;
|
||||
}
|
||||
|
@ -986,7 +989,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
}
|
||||
else if (*framePtr == ipx_8022_type)
|
||||
{
|
||||
framePtr += 3; // eliminate the 802.2 header
|
||||
framePtr += 3; /* eliminate the 802.2 header */
|
||||
|
||||
if (!memcmp(ipx_header, framePtr, 2))
|
||||
{
|
||||
|
@ -1042,7 +1045,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
__nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
|
||||
|
||||
// change IPX source node addr to wlan STA address
|
||||
/* change IPX source node addr to wlan STA address */
|
||||
memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
|
||||
}
|
||||
else
|
||||
|
@ -1066,7 +1069,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
__nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
|
||||
|
||||
// replace IPX destination node addr with Lookup destination MAC addr
|
||||
/* replace IPX destination node addr with Lookup destination MAC addr */
|
||||
memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
|
||||
}
|
||||
else
|
||||
|
@ -1100,7 +1103,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
case NAT25_INSERT:
|
||||
{
|
||||
// change to AARP source mac address to wlan STA address
|
||||
/* change to AARP source mac address to wlan STA address */
|
||||
memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
|
||||
|
||||
DEBUG_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
|
||||
|
@ -1129,7 +1132,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
__nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
|
||||
|
||||
// change to AARP destination mac address to Lookup result
|
||||
/* change to AARP destination mac address to Lookup result */
|
||||
memcpy(ea->hw_dst, skb->data, ETH_ALEN);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1188,8 +1191,8 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/*---------------------------------------------------*/
|
||||
/* Handle PPPoE frame */
|
||||
/*---------------------------------------------------*/
|
||||
else if ((protocol == __constant_htons(ETH_P_PPP_DISC)) ||
|
||||
(protocol == __constant_htons(ETH_P_PPP_SES)))
|
||||
else if ((protocol == ETH_P_PPP_DISC) ||
|
||||
(protocol == ETH_P_PPP_SES))
|
||||
{
|
||||
struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN);
|
||||
unsigned short *pMagic;
|
||||
|
@ -1202,7 +1205,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
return 1;
|
||||
|
||||
case NAT25_INSERT:
|
||||
if (ph->sid == 0) // Discovery phase according to tag
|
||||
if (ph->sid == 0) /* Discovery phase according to tag */
|
||||
{
|
||||
if (ph->code == PADI_CODE || ph->code == PADR_CODE)
|
||||
{
|
||||
|
@ -1213,7 +1216,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
|
||||
tag = (struct pppoe_tag *)tag_buf;
|
||||
pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID));
|
||||
if (pOldTag) { // if SID existed, copy old value and delete it
|
||||
if (pOldTag) { /* if SID existed, copy old value and delete it */
|
||||
old_tag_len = ntohs(pOldTag->tag_len);
|
||||
if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) {
|
||||
DEBUG_ERR("SID tag length too long!\n");
|
||||
|
@ -1233,19 +1236,19 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
tag->tag_type = PTT_RELAY_SID;
|
||||
tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len);
|
||||
|
||||
// insert the magic_code+client mac in relay tag
|
||||
/* insert the magic_code+client mac in relay tag */
|
||||
pMagic = (unsigned short *)tag->tag_data;
|
||||
*pMagic = htons(MAGIC_CODE);
|
||||
memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN);
|
||||
|
||||
//Add relay tag
|
||||
/* Add relay tag */
|
||||
if (__nat25_add_pppoe_tag(skb, tag) < 0)
|
||||
return -1;
|
||||
|
||||
DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n",
|
||||
(ph->code == PADI_CODE ? "PADI" : "PADR"));
|
||||
}
|
||||
else { // not add relay tag
|
||||
else { /* not add relay tag */
|
||||
if (priv->pppoe_connection_in_progress &&
|
||||
memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) {
|
||||
DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n");
|
||||
|
@ -1261,7 +1264,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
else
|
||||
return -1;
|
||||
}
|
||||
else // session phase
|
||||
else /* session phase */
|
||||
{
|
||||
DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name);
|
||||
|
||||
|
@ -1324,7 +1327,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n",
|
||||
(ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name);
|
||||
}
|
||||
else { // not add relay tag
|
||||
else { /* not add relay tag */
|
||||
if (!priv->pppoe_connection_in_progress) {
|
||||
DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n");
|
||||
return -1;
|
||||
|
@ -1357,7 +1360,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/*---------------------------------------------------*/
|
||||
/* Handle EAP frame */
|
||||
/*---------------------------------------------------*/
|
||||
else if (protocol == __constant_htons(0x888e))
|
||||
else if (protocol == 0x888e)
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
|
@ -1378,8 +1381,8 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/*---------------------------------------------------*/
|
||||
/* Handle C-Media proprietary frame */
|
||||
/*---------------------------------------------------*/
|
||||
else if ((protocol == __constant_htons(0xe2ae)) ||
|
||||
(protocol == __constant_htons(0xe2af)))
|
||||
else if ((protocol == 0xe2ae) ||
|
||||
(protocol == 0xe2af))
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
|
@ -1401,7 +1404,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
/* Handle IPV6 frame */
|
||||
/*---------------------------------------------------*/
|
||||
#ifdef CL_IPV6_PASS
|
||||
else if (protocol == __constant_htons(ETH_P_IPV6))
|
||||
else if (protocol == ETH_P_IPV6)
|
||||
{
|
||||
struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN);
|
||||
|
||||
|
@ -1470,7 +1473,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
#endif // CL_IPV6_PASS
|
||||
#endif /* CL_IPV6_PASS */
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -1501,8 +1504,10 @@ int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
|
|||
{
|
||||
int is_vlan_tag=0, i, retval=0;
|
||||
unsigned short vlan_hdr=0;
|
||||
unsigned short protocol;
|
||||
|
||||
if (*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_8021Q)) {
|
||||
protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN)));
|
||||
if (protocol == ETH_P_8021Q) {
|
||||
is_vlan_tag = 1;
|
||||
vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2));
|
||||
for (i=0; i<6; i++)
|
||||
|
@ -1520,24 +1525,22 @@ int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
|
|||
* corresponding network protocol is NOT support.
|
||||
*/
|
||||
if (!priv->ethBrExtInfo.nat25sc_disable &&
|
||||
(*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
|
||||
!memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
|
||||
(be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) &&
|
||||
!memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) {
|
||||
memcpy(skb->data, priv->scdb_mac, ETH_ALEN);
|
||||
|
||||
_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
|
||||
retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_IP)) &&
|
||||
!memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
|
||||
((*((unsigned short *)(skb->data+ETH_ALEN*2)) == __constant_htons(ETH_P_ARP)) &&
|
||||
!memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
|
||||
// for traffic to upper TCP/IP
|
||||
} else {
|
||||
if (((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) &&
|
||||
!memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) ||
|
||||
((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_ARP) &&
|
||||
!memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) {
|
||||
/* for traffic to upper TCP/IP */
|
||||
retval = nat25_db_handle(priv, skb, NAT25_LOOKUP);
|
||||
}
|
||||
}
|
||||
|
@ -1551,7 +1554,7 @@ int nat25_handle_frame(_adapter *priv, struct sk_buff *skb)
|
|||
}
|
||||
|
||||
if (retval == -1) {
|
||||
//DEBUG_ERR("NAT25: Lookup fail!\n");
|
||||
/* DEBUG_ERR("NAT25: Lookup fail!\n"); */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1590,34 +1593,33 @@ void dhcp_flag_bcast(_adapter *priv, struct sk_buff *skb)
|
|||
|
||||
if (!priv->ethBrExtInfo.dhcp_bcst_disable)
|
||||
{
|
||||
unsigned short protocol = *((unsigned short *)(skb->data + 2 * ETH_ALEN));
|
||||
__be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN));
|
||||
|
||||
if (protocol == __constant_htons(ETH_P_IP)) // IP
|
||||
if (protocol == __constant_htons(ETH_P_IP)) /* IP */
|
||||
{
|
||||
struct iphdr* iph = (struct iphdr *)(skb->data + ETH_HLEN);
|
||||
|
||||
if (iph->protocol == IPPROTO_UDP) // UDP
|
||||
if (iph->protocol == IPPROTO_UDP) /* UDP */
|
||||
{
|
||||
struct udphdr *udph = (struct udphdr *)((SIZE_PTR)iph + (iph->ihl << 2));
|
||||
|
||||
if ((udph->source == __constant_htons(CLIENT_PORT))
|
||||
&& (udph->dest == __constant_htons(SERVER_PORT))) // DHCP request
|
||||
{
|
||||
if ((udph->source == __constant_htons(CLIENT_PORT)) &&
|
||||
(udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */
|
||||
struct dhcpMessage *dhcph =
|
||||
(struct dhcpMessage *)((SIZE_PTR)udph + sizeof(struct udphdr));
|
||||
u32 cookie = be32_to_cpu((__be32)dhcph->cookie);
|
||||
|
||||
if (dhcph->cookie == __constant_htonl(DHCP_MAGIC)) // match magic word
|
||||
{
|
||||
if (!(dhcph->flags & htons(BROADCAST_FLAG))) // if not broadcast
|
||||
if (cookie == DHCP_MAGIC) { /* match magic word */
|
||||
if (!(dhcph->flags & htons(BROADCAST_FLAG))) /* if not broadcast */
|
||||
{
|
||||
register int sum = 0;
|
||||
|
||||
DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n");
|
||||
// or BROADCAST flag
|
||||
/* or BROADCAST flag */
|
||||
dhcph->flags |= htons(BROADCAST_FLAG);
|
||||
// recalculate checksum
|
||||
/* recalculate checksum */
|
||||
sum = ~(udph->check) & 0xffff;
|
||||
sum += dhcph->flags;
|
||||
sum += be16_to_cpu(dhcph->flags);
|
||||
while (sum >> 16)
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
udph->check = ~sum;
|
||||
|
@ -1636,8 +1638,8 @@ void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
|
|||
unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
|
||||
struct nat25_network_db_entry *db;
|
||||
int hash;
|
||||
//_irqL irqL;
|
||||
//_enter_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* _irqL irqL; */
|
||||
/* _enter_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
|
||||
__nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr);
|
||||
hash = __nat25_network_hash(networkAddr);
|
||||
|
@ -1645,15 +1647,15 @@ void *scdb_findEntry(_adapter *priv, unsigned char *macAddr,
|
|||
while (db != NULL)
|
||||
{
|
||||
if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) {
|
||||
//_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* _exit_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
return (void *)db;
|
||||
}
|
||||
|
||||
db = db->next_hash;
|
||||
}
|
||||
|
||||
//_exit_critical_bh(&priv->br_ext_lock, &irqL);
|
||||
/* _exit_critical_bh(&priv->br_ext_lock, &irqL); */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BR_EXT
|
||||
#endif /* CONFIG_BR_EXT */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue