1 diff -Naur 88x2bu-fd0b735e2e30d32f4d91497242cf6af288bdd082.org/core/rtw_br_ext.c 88x2bu-fd0b735e2e30d32f4d91497242cf6af288bdd082/core/rtw_br_ext.c
2 --- 88x2bu-fd0b735e2e30d32f4d91497242cf6af288bdd082.org/core/rtw_br_ext.c 2021-09-30 20:27:33.000000000 +0200
3 +++ 88x2bu-fd0b735e2e30d32f4d91497242cf6af288bdd082/core/rtw_br_ext.c 2021-11-04 18:57:11.853953556 +0100
6 #include <linux/if_arp.h>
9 #include <linux/atalk.h>
10 #include <linux/udp.h>
11 #include <linux/if_pppox.h>
13 memcpy(networkAddr + 7, (unsigned char *)ipAddr, 4);
17 -static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr,
18 - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr)
20 - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
22 - networkAddr[0] = NAT25_IPX;
23 - memcpy(networkAddr + 1, (unsigned char *)ipxNetAddr, 4);
24 - memcpy(networkAddr + 5, ipxNodeAddr, 6);
28 -static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr,
29 - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr)
31 - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
33 - networkAddr[0] = NAT25_IPX;
34 - memcpy(networkAddr + 1, (unsigned char *)ipxNetAddr, 4);
35 - memcpy(networkAddr + 5, (unsigned char *)ipxSocketAddr, 2);
39 -static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr,
40 - unsigned short *network, unsigned char *node)
42 - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN);
44 - networkAddr[0] = NAT25_APPLE;
45 - memcpy(networkAddr + 1, (unsigned char *)network, 2);
46 - networkAddr[3] = *node;
50 static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr,
51 unsigned char *ac_mac, unsigned short *sid)
56 /*---------------------------------------------------*/
57 - /* Handle IPX and Apple Talk frame */
58 - /*---------------------------------------------------*/
59 - else if ((protocol == __constant_htons(ETH_P_IPX)) ||
60 - (protocol == __constant_htons(ETH_P_ATALK)) ||
61 - (protocol == __constant_htons(ETH_P_AARP))) {
62 - unsigned char ipx_header[2] = {0xFF, 0xFF};
63 - struct ipxhdr *ipx = NULL;
64 - struct elapaarp *ea = NULL;
65 - struct ddpehdr *ddp = NULL;
66 - unsigned char *framePtr = skb->data + ETH_HLEN;
68 - if (protocol == __constant_htons(ETH_P_IPX)) {
69 - RTW_INFO("NAT25: Protocol=IPX (Ethernet II)\n");
70 - ipx = (struct ipxhdr *)framePtr;
71 - } else { /* if(protocol <= __constant_htons(ETH_FRAME_LEN)) */
72 - if (!memcmp(ipx_header, framePtr, 2)) {
73 - RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.3)\n");
74 - ipx = (struct ipxhdr *)framePtr;
76 - unsigned char ipx_8022_type = 0xE0;
77 - unsigned char snap_8022_type = 0xAA;
79 - if (*framePtr == snap_8022_type) {
80 - unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */
81 - unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */
82 - unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */
84 - framePtr += 3; /* eliminate the 802.2 header */
86 - if (!memcmp(ipx_snap_id, framePtr, 5)) {
87 - framePtr += 5; /* eliminate the SNAP header */
89 - RTW_INFO("NAT25: Protocol=IPX (Ethernet SNAP)\n");
90 - ipx = (struct ipxhdr *)framePtr;
91 - } else if (!memcmp(aarp_snap_id, framePtr, 5)) {
92 - framePtr += 5; /* eliminate the SNAP header */
94 - ea = (struct elapaarp *)framePtr;
95 - } else if (!memcmp(ddp_snap_id, framePtr, 5)) {
96 - framePtr += 5; /* eliminate the SNAP header */
98 - ddp = (struct ddpehdr *)framePtr;
100 - DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0],
101 - framePtr[1], framePtr[2], framePtr[3], framePtr[4]);
104 - } else if (*framePtr == ipx_8022_type) {
105 - framePtr += 3; /* eliminate the 802.2 header */
107 - if (!memcmp(ipx_header, framePtr, 2)) {
108 - RTW_INFO("NAT25: Protocol=IPX (Ethernet 802.2)\n");
109 - ipx = (struct ipxhdr *)framePtr;
120 - if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) {
121 - RTW_INFO("NAT25: Check IPX skb_copy\n");
126 - case NAT25_INSERT: {
127 - RTW_INFO("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n",
129 - ipx->ipx_dest.node[0],
130 - ipx->ipx_dest.node[1],
131 - ipx->ipx_dest.node[2],
132 - ipx->ipx_dest.node[3],
133 - ipx->ipx_dest.node[4],
134 - ipx->ipx_dest.node[5],
135 - ipx->ipx_dest.sock,
136 - ipx->ipx_source.net,
137 - ipx->ipx_source.node[0],
138 - ipx->ipx_source.node[1],
139 - ipx->ipx_source.node[2],
140 - ipx->ipx_source.node[3],
141 - ipx->ipx_source.node[4],
142 - ipx->ipx_source.node[5],
143 - ipx->ipx_source.sock);
145 - if (!memcmp(skb->data + ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) {
146 - RTW_INFO("NAT25: Use IPX Net, and Socket as network addr\n");
148 - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock);
150 - /* change IPX source node addr to wlan STA address */
151 - memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN);
153 - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node);
155 - __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr);
157 - __nat25_db_print(priv);
161 - case NAT25_LOOKUP: {
162 - if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) {
163 - RTW_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n");
165 - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock);
167 - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
169 - /* replace IPX destination node addr with Lookup destination MAC addr */
170 - memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN);
172 - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node);
174 - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
185 - else if (ea != NULL) {
186 - /* Sanity check fields. */
187 - if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) {
188 - DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n");
196 - case NAT25_INSERT: {
197 - /* change to AARP source mac address to wlan STA address */
198 - memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN);
200 - RTW_INFO("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n",
206 - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node);
208 - __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr);
210 - __nat25_db_print(priv);
214 - case NAT25_LOOKUP: {
215 - RTW_INFO("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n",
221 - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node);
223 - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
225 - /* change to AARP destination mac address to Lookup result */
226 - memcpy(ea->hw_dst, skb->data, ETH_ALEN);
236 - else if (ddp != NULL) {
241 - case NAT25_INSERT: {
242 - RTW_INFO("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n",
248 - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode);
250 - __nat25_db_network_insert(priv, skb->data + ETH_ALEN, networkAddr);
252 - __nat25_db_print(priv);
256 - case NAT25_LOOKUP: {
257 - RTW_INFO("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n",
263 - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode);
265 - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr);
277 - /*---------------------------------------------------*/
278 /* Handle PPPoE frame */
279 /*---------------------------------------------------*/
280 else if ((protocol == __constant_htons(ETH_P_PPP_DISC)) ||