-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbr_ftph.c
194 lines (154 loc) · 5.14 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
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2010, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#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:
UINT32 (*RALINK_FP_Handle)(PNDIS_PACKET pPacket);
EXPORT_SYMBOL(RALINK_FP_Handle);
packet_forward()
{
UINT32 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);
}
}
*/
UINT32 BG_FTPH_PacketFromApHandle(
IN PNDIS_PACKET pPacket);
#ifdef BG_FT_OPEN_SUPPORT
extern UINT32 (*RALINK_FP_Handle)(PNDIS_PACKET pPacket);
#else
UINT32 (*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:
========================================================================
*/
UINT32 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 */