ng_ether.c (69840) | ng_ether.c (69922) |
---|---|
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 * | 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 $ | 40 * $FreeBSD: head/sys/netgraph/ng_ether.c 69922 2000-12-12 18:52:14Z julian $ |
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; | 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_connect_t ng_ether_connect; |
|
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, | 104static ng_rcvdata_t ng_ether_rcvdata; 105static ng_disconnect_t ng_ether_disconnect; 106static int ng_ether_mod_event(module_t mod, int event, void *data); 107 108/* Parse type for an Ethernet address */ 109static ng_parse_t ng_enaddr_parse; 110static ng_unparse_t ng_enaddr_unparse; 111const struct ng_parse_type ng_ether_enaddr_type = { --- 71 unchanged lines hidden (view full) --- 183 NG_VERSION, 184 NG_ETHER_NODE_TYPE, 185 ng_ether_mod_event, 186 ng_ether_constructor, 187 ng_ether_rcvmsg, 188 ng_ether_rmnode, 189 ng_ether_newhook, 190 NULL, |
190 NULL, | 191 ng_ether_connect, |
191 ng_ether_rcvdata, | 192 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/* | 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. | 245 * Handle a packet that has come in on an ethernet 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; | 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 */ | 255 int error; 256 257 /* Glue Ethernet header back on */ 258 if ((error = ng_ether_glueback_header(mp, eh)) != 0) 259 return; 260 261 /* Send out lower/orphan hook */ |
263 (void)ng_queue_data(priv->lower, *mp, meta); | 262 NG_SEND_DATA_ONLY(error, priv->lower, *mp); |
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 */ | 263 *mp = NULL; 264} 265 266/* 267 * Handle a packet that is going out on an interface. 268 * The Ethernet header is already attached to the mbuf. 269 */ 270static int --- 4 unchanged lines hidden (view full) --- 275 meta_p meta = NULL; 276 int error = 0; 277 278 /* If "upper" hook not connected, let packet continue */ 279 if (priv->upper == NULL) 280 return (0); 281 282 /* Send it out "upper" hook */ |
284 NG_SEND_DATA_RET(error, priv->upper, *mp, meta); | 283 NG_SEND_DATA_RET(error, priv->upper, *mp, meta, NULL); |
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/* | 284 285 /* If we got a reflected packet back, handle it */ 286 if (error == 0 && *mp != NULL) { 287 error = ng_ether_rcv_upper(node, *mp, meta); 288 *mp = NULL; 289 } 290 return (error); 291} --- 183 unchanged lines hidden (view full) --- 475 476 /* OK */ 477 *hookptr = hook; 478 priv->lowerOrphan = orphan; 479 return (0); 480} 481 482/* |
483 * Hooks are attached, adjust to force queueing. 484 * We don't really care which hook it is. 485 * they should all be queuing for outgoing data. 486 */ 487static int 488ng_ether_connect(hook_p hook) 489{ 490 hook->peer->flags |= HK_QUEUE; 491 return (0); 492} 493 494/* |
|
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, | 495 * Receive an incoming control message. 496 */ 497static int 498ng_ether_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, 499 struct ng_mesg **rptr, hook_p lasthook) 500{ 501 const priv_p priv = node->private; 502 struct ng_mesg *resp = NULL; --- 94 unchanged lines hidden (view full) --- 597 return (error); 598} 599 600/* 601 * Receive data on a hook. 602 */ 603static int 604ng_ether_rcvdata(hook_p hook, struct mbuf *m, meta_p meta, |
594 struct mbuf **ret_m, meta_p *ret_meta) | 605 struct mbuf **ret_m, meta_p *ret_meta, struct ng_mesg **resp) |
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 --- | 606{ 607 const node_p node = hook->node; 608 const priv_p priv = node->private; 609 610 if (hook == priv->lower) 611 return ng_ether_rcv_lower(node, m, meta); 612 if (hook == priv->upper) 613 return ng_ether_rcv_upper(node, m, meta); --- 206 unchanged lines hidden --- |