Deleted Added
sdiff udiff text old ( 69840 ) new ( 69922 )
full compact
1
2/*
3 * ng_ether.c
4 *
5 * Copyright (c) 1996-2000 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 23 unchanged lines hidden (view full) ---

32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Authors: Archie Cobbs <archie@freebsd.org>
38 * Julian Elischer <julian@freebsd.org>
39 *
40 * $FreeBSD: head/sys/netgraph/ng_ether.c 69840 2000-12-11 03:36:26Z archie $
41 */
42
43/*
44 * ng_ether(4) netgraph node type
45 */
46
47#include <sys/param.h>
48#include <sys/systm.h>

--- 46 unchanged lines hidden (view full) ---

95static int ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta);
96static int ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta);
97
98/* Netgraph node methods */
99static ng_constructor_t ng_ether_constructor;
100static ng_rcvmsg_t ng_ether_rcvmsg;
101static ng_shutdown_t ng_ether_rmnode;
102static ng_newhook_t ng_ether_newhook;
103static ng_rcvdata_t ng_ether_rcvdata;
104static ng_disconnect_t ng_ether_disconnect;
105static int ng_ether_mod_event(module_t mod, int event, void *data);
106
107/* Parse type for an Ethernet address */
108static ng_parse_t ng_enaddr_parse;
109static ng_unparse_t ng_enaddr_unparse;
110const struct ng_parse_type ng_ether_enaddr_type = {

--- 71 unchanged lines hidden (view full) ---

182 NG_VERSION,
183 NG_ETHER_NODE_TYPE,
184 ng_ether_mod_event,
185 ng_ether_constructor,
186 ng_ether_rcvmsg,
187 ng_ether_rmnode,
188 ng_ether_newhook,
189 NULL,
190 NULL,
191 ng_ether_rcvdata,
192 ng_ether_rcvdata,
193 ng_ether_disconnect,
194 ng_ether_cmdlist,
195};
196NETGRAPH_INIT(ether, &ng_ether_typestruct);
197
198/******************************************************************
199 ETHERNET FUNCTION HOOKS
200******************************************************************/

--- 36 unchanged lines hidden (view full) ---

237 return;
238 }
239 ng_ether_input2(node, &m, eh);
240 if (m != NULL)
241 m_freem(m);
242}
243
244/*
245 * Handle a packet that has come in on an interface.
246 * The Ethernet header has already been detached from the mbuf,
247 * so we have to put it back.
248 *
249 * NOTE: this function will get called at splimp()
250 */
251static void
252ng_ether_input2(node_p node, struct mbuf **mp, struct ether_header *eh)
253{
254 const priv_p priv = node->private;
255 meta_p meta = NULL;
256 int error;
257
258 /* Glue Ethernet header back on */
259 if ((error = ng_ether_glueback_header(mp, eh)) != 0)
260 return;
261
262 /* Send out lower/orphan hook */
263 (void)ng_queue_data(priv->lower, *mp, meta);
264 *mp = NULL;
265}
266
267/*
268 * Handle a packet that is going out on an interface.
269 * The Ethernet header is already attached to the mbuf.
270 */
271static int

--- 4 unchanged lines hidden (view full) ---

276 meta_p meta = NULL;
277 int error = 0;
278
279 /* If "upper" hook not connected, let packet continue */
280 if (priv->upper == NULL)
281 return (0);
282
283 /* Send it out "upper" hook */
284 NG_SEND_DATA_RET(error, priv->upper, *mp, meta);
285
286 /* If we got a reflected packet back, handle it */
287 if (error == 0 && *mp != NULL) {
288 error = ng_ether_rcv_upper(node, *mp, meta);
289 *mp = NULL;
290 }
291 return (error);
292}

--- 183 unchanged lines hidden (view full) ---

476
477 /* OK */
478 *hookptr = hook;
479 priv->lowerOrphan = orphan;
480 return (0);
481}
482
483/*
484 * Receive an incoming control message.
485 */
486static int
487ng_ether_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
488 struct ng_mesg **rptr, hook_p lasthook)
489{
490 const priv_p priv = node->private;
491 struct ng_mesg *resp = NULL;

--- 94 unchanged lines hidden (view full) ---

586 return (error);
587}
588
589/*
590 * Receive data on a hook.
591 */
592static int
593ng_ether_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
594 struct mbuf **ret_m, meta_p *ret_meta)
595{
596 const node_p node = hook->node;
597 const priv_p priv = node->private;
598
599 if (hook == priv->lower)
600 return ng_ether_rcv_lower(node, m, meta);
601 if (hook == priv->upper)
602 return ng_ether_rcv_upper(node, m, meta);

--- 206 unchanged lines hidden ---