diff options
Diffstat (limited to 'drivers/staging/rtl8188eu/core/rtw_br_ext.c')
-rw-r--r-- | drivers/staging/rtl8188eu/core/rtw_br_ext.c | 87 |
1 files changed, 39 insertions, 48 deletions
diff --git a/drivers/staging/rtl8188eu/core/rtw_br_ext.c b/drivers/staging/rtl8188eu/core/rtw_br_ext.c index 9f40742..75e38d4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_br_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_br_ext.c @@ -89,7 +89,7 @@ static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *t struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; - data_len = tag->tag_len + TAG_HDR_LEN; + data_len = be16_to_cpu(tag->tag_len) + TAG_HDR_LEN; if (skb_tailroom(skb) < data_len) { _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); return -1; @@ -155,7 +155,7 @@ static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) + __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -166,7 +166,7 @@ static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *ne static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) + __be32 *ipxNetAddr, __be16 *ipxSocketAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -177,7 +177,7 @@ static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char * static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - unsigned short *network, unsigned char *node) + __be16 *network, unsigned char *node) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -187,7 +187,7 @@ static inline void __nat25_generate_apple_network_addr(unsigned char *networkAdd } static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, - unsigned char *ac_mac, unsigned short *sid) + unsigned char *ac_mac, __be16 *sid) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -197,7 +197,7 @@ static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAdd } static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr, - unsigned int *ipAddr) + __be32 *ipAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -331,7 +331,7 @@ static inline int __nat25_network_hash(unsigned char *networkAddr) static inline void __network_hash_link(struct adapter *priv, struct nat25_network_db_entry *ent, int hash) { - /* Caller must _enter_critical_bh already! */ + /* Caller must spin_lock_bh already! */ ent->next_hash = priv->nethash[hash]; if (ent->next_hash != NULL) ent->next_hash->pprev_hash = &ent->next_hash; @@ -341,7 +341,7 @@ static inline void __network_hash_link(struct adapter *priv, static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) { - /* Caller must _enter_critical_bh already! */ + /* Caller must spin_lock_bh already! */ *(ent->pprev_hash) = ent->next_hash; if (ent->next_hash != NULL) ent->next_hash->pprev_hash = ent->pprev_hash; @@ -353,8 +353,7 @@ static int __nat25_db_network_lookup_and_replace(struct adapter *priv, struct sk_buff *skb, unsigned char *networkAddr) { struct nat25_network_db_entry *db; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); + spin_lock_bh(&priv->br_ext_lock); db = priv->nethash[__nat25_network_hash(networkAddr)]; while (db != NULL) { @@ -390,12 +389,12 @@ static int __nat25_db_network_lookup_and_replace(struct adapter *priv, db->networkAddr[15], db->networkAddr[16]); } - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); return 1; } db = db->next_hash; } - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); return 0; } @@ -404,23 +403,22 @@ static void __nat25_db_network_insert(struct adapter *priv, { struct nat25_network_db_entry *db; int hash; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); + spin_lock_bh(&priv->br_ext_lock); hash = __nat25_network_hash(networkAddr); db = priv->nethash[hash]; while (db != NULL) { if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { memcpy(db->macAddr, macAddr, ETH_ALEN); db->ageing_timer = jiffies; - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); return; } db = db->next_hash; } db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); if (db == NULL) { - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); return; } memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN); @@ -430,7 +428,7 @@ static void __nat25_db_network_insert(struct adapter *priv, __network_hash_link(priv, db, hash); - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); } static void __nat25_db_print(struct adapter *priv) @@ -444,8 +442,7 @@ static void __nat25_db_print(struct adapter *priv) void nat25_db_cleanup(struct adapter *priv) { int i; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); + spin_lock_bh(&priv->br_ext_lock); for (i = 0; i < NAT25_HASH_SIZE; i++) { struct nat25_network_db_entry *f; @@ -464,14 +461,13 @@ void nat25_db_cleanup(struct adapter *priv) f = g; } } - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); } void nat25_db_expire(struct adapter *priv) { int i; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); + spin_lock_bh(&priv->br_ext_lock); for (i = 0; i < NAT25_HASH_SIZE; i++) { struct nat25_network_db_entry *f; @@ -495,7 +491,7 @@ void nat25_db_expire(struct adapter *priv) f = g; } } - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); } int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) @@ -811,7 +807,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) /* Handle PPPoE frame */ /*---------------------------------------------------*/ struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); - unsigned short *pMagic; + __be16 *pMagic; switch (method) { case NAT25_CHECK: @@ -849,7 +845,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len); /* insert the magic_code+client mac in relay tag */ - pMagic = (unsigned short *)tag->tag_data; + pMagic = (__be16 *)tag->tag_data; *pMagic = htons(MAGIC_CODE); memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN); @@ -912,7 +908,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) return -1; } - pMagic = (unsigned short *)tag->tag_data; + pMagic = (__be16 *)tag->tag_data; if (ntohs(*pMagic) != MAGIC_CODE) { DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n", (ph->code == PADO_CODE ? "PADO" : "PADS")); @@ -1009,7 +1005,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) { - __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr); + __nat25_generate_ipv6_network_addr(networkAddr, (__be32 *)&iph->saddr); __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); __nat25_db_print(priv); @@ -1020,9 +1016,10 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph)); hdr->icmp6_cksum = 0; hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr, - iph->payload_len, + be16_to_cpu(iph->payload_len), IPPROTO_ICMPV6, - csum_partial((__u8 *)hdr, iph->payload_len, 0)); + csum_partial((__u8 *)hdr, + be16_to_cpu(iph->payload_len), 0)); } } } @@ -1033,7 +1030,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); - __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr); + __nat25_generate_ipv6_network_addr(networkAddr, (__be32 *)&iph->daddr); __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); return 0; default: @@ -1060,8 +1057,7 @@ int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) } if (!priv->ethBrExtInfo.nat25_disable) { - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); + spin_lock_bh(&priv->br_ext_lock); /* * This function look up the destination network address from * the NAT2.5 database. Return value = -1 means that the @@ -1072,9 +1068,9 @@ int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) !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); + spin_unlock_bh(&priv->br_ext_lock); } else { - _exit_critical_bh(&priv->br_ext_lock, &irqL); + spin_unlock_bh(&priv->br_ext_lock); retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); } @@ -1115,17 +1111,17 @@ struct dhcpMessage { u_int8_t htype; u_int8_t hlen; u_int8_t hops; - u_int32_t xid; - u_int16_t secs; - u_int16_t flags; - u_int32_t ciaddr; - u_int32_t yiaddr; - u_int32_t siaddr; - u_int32_t giaddr; + __be32 xid; + __be16 secs; + __be16 flags; + __be32 ciaddr; + __be32 yiaddr; + __be32 siaddr; + __be32 giaddr; u_int8_t chaddr[16]; u_int8_t sname[64]; u_int8_t file[128]; - u_int32_t cookie; + __be32 cookie; u_int8_t options[308]; /* 312 - cookie */ }; @@ -1178,21 +1174,16 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; struct nat25_network_db_entry *db; int hash; - /* unsigned long irqL; */ - /* _enter_critical_bh(&priv->br_ext_lock, &irqL); */ __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr); hash = __nat25_network_hash(networkAddr); db = priv->nethash[hash]; while (db != NULL) { - if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { - /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) return (void *)db; - } db = db->next_hash; } - /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ return NULL; } |