forked from Anthony96922/mt7601u-ap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbr_ftph.c
195 lines (152 loc) · 4.77 KB
/
br_ftph.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/****************************************************************************
* Ralink Tech Inc.
* 4F, No. 2 Technology 5th Rd.
* Science-based Industrial Park
* Hsin-chu, Taiwan, R.O.C.
* (c) Copyright 2002, Ralink Technology, Inc.
*
* All rights reserved. Ralink's source code is an unpublished work and the
* use of a copyright notice does not imply otherwise. This source code
* contains confidential trade secret material of Ralink Tech. Any attemp
* or participation in deciphering, decoding, reverse engineering or in any
* way altering the source code is stricitly prohibited, unless the prior
* written consent of Ralink Technology, Inc. is obtained.
****************************************************************************
Module Name:
bg_ftph.c
Abstract:
Provide fast path between LAN and WLAN.
Revision History:
Who When What
-------- ---------- ----------------------------------------------
Sample Lin 01-22-2008 Created
*/
#include "rt_config.h"
#ifdef BG_FT_SUPPORT
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
#include <linux/netfilter_bridge.h>
#include "../net/bridge/br_private.h"
/* extern export symbol in other drivers */
/*
Example in other drivers:
unsigned int (*RALINK_FP_Handle)(PNDIS_PACKET pPacket);
EXPORT_SYMBOL(RALINK_FP_Handle);
packet_forward()
{
unsigned int HandRst = 1;
......
if (RALINK_FP_Handle != NULL)
HandRst = RALINK_FP_Handle(skb);
if (HandRst != 0)
{
/* pass the packet to upper layer */
skb->protocol = eth_type_trans(skb, skb->dev);
netif_rx(skb);
}
}
*/
unsigned int BG_FTPH_PacketFromApHandle(
IN PNDIS_PACKET pPacket);
#ifdef BG_FT_OPEN_SUPPORT
extern unsigned int (*RALINK_FP_Handle)(PNDIS_PACKET pPacket);
#else
unsigned int (*RALINK_FP_Handle)(PNDIS_PACKET pPacket);
#endif /* BG_FT_OPEN_SUPPORT */
/* --------------------------------- Public -------------------------------- */
/*
========================================================================
Routine Description:
Init bridge fast path module.
Arguments:
None
Return Value:
None
Note:
Used in module init.
========================================================================
*/
VOID BG_FTPH_Init(VOID)
{
RALINK_FP_Handle = BG_FTPH_PacketFromApHandle;
}
/*
========================================================================
Routine Description:
Remove bridge fast path module.
Arguments:
None
Return Value:
None
Note:
Used in module remove.
========================================================================
*/
VOID BG_FTPH_Remove(VOID)
{
RALINK_FP_Handle = NULL;
} /* End of BG_FTPH_Init */
/*
========================================================================
Routine Description:
Forward the received packet.
Arguments:
pPacket - the received packet
Return Value:
None
Note:
========================================================================
*/
unsigned int BG_FTPH_PacketFromApHandle(
IN PNDIS_PACKET pPacket)
{
struct net_device *pNetDev;
struct sk_buff *pRxPkt;
struct net_bridge_fdb_entry *pSrcFdbEntry, *pDstFdbEntry;
/* init */
pRxPkt = RTPKT_TO_OSPKT(pPacket);
pNetDev = pRxPkt->dev;
/* if pNetDev is promisc mode ??? */
DBGPRINT(RT_DEBUG_INFO, ("ft bg> BG_FTPH_PacketFromApHandle\n"));
if (pNetDev != NULL)
{
if (pNetDev->br_port != NULL)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
pDstFdbEntry = br_fdb_get_hook(pNetDev->br_port->br, pRxPkt->data);
pSrcFdbEntry = br_fdb_get_hook(pNetDev->br_port->br, pRxPkt->data + 6);
#else
/* br_fdb_get is not exported symbol, need exported in net/bridge/br.c */
pDstFdbEntry = br_fdb_get(pNetDev->br_port->br, pRxPkt->data);
pSrcFdbEntry = br_fdb_get(pNetDev->br_port->br, pRxPkt->data + 6);
#endif
/* check destination address in bridge forwarding table */
if ((pSrcFdbEntry == NULL) ||
(pDstFdbEntry == NULL) ||
(pDstFdbEntry->is_local) ||
(pDstFdbEntry->dst == NULL) ||
(pDstFdbEntry->dst->dev == NULL) ||
(pDstFdbEntry->dst->dev == pNetDev) ||
(pNetDev->br_port->state != BR_STATE_FORWARDING) ||
((pSrcFdbEntry->dst != NULL) &&
(pSrcFdbEntry->dst->dev != NULL) &&
(pSrcFdbEntry->dst->dev != pNetDev)))
{
goto LabelPassToUpperLayer;
} /* End of if */
if ((!pDstFdbEntry->is_local) &&
(pDstFdbEntry->dst != NULL) &&
(pDstFdbEntry->dst->dev != NULL))
{
pRxPkt->dev = pDstFdbEntry->dst->dev;
pDstFdbEntry->dst->dev->hard_start_xmit(pRxPkt, pDstFdbEntry->dst->dev);
return 0;
} /* End of if */
} /* End of if */
} /* End of if */
LabelPassToUpperLayer:
DBGPRINT(RT_DEBUG_TRACE, ("ft bg> Pass packet to bridge module.\n"));
return 1;
} /* End of BG_FTPH_PacketFromApHandle */
#endif /* CONFIG_BRIDGE || CONFIG_BRIDGE_MODULE */
#endif /* BG_FT_SUPPORT */
/* End of bg_ftph.c */