1
2/*
3 * ng_ether.c
4 */
5
6/*-
7 * Copyright (c) 1996-2000 Whistle Communications, Inc.
8 * All rights reserved.
--- 25 unchanged lines hidden (view full) ---
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
37 * OF SUCH DAMAGE.
38 *
39 * Authors: Archie Cobbs <archie@freebsd.org>
40 * Julian Elischer <julian@freebsd.org>
41 *
42 * $FreeBSD: head/sys/netgraph/ng_ether.c 238844 2012-07-27 13:57:28Z emaste $
43 */
44
45/*
46 * ng_ether(4) netgraph node type
47 */
48
49#include <sys/param.h>
50#include <sys/systm.h>
--- 164 unchanged lines hidden (view full) ---
215
216/******************************************************************
217 ETHERNET FUNCTION HOOKS
218******************************************************************/
219
220/*
221 * Handle a packet that has come in on an interface. We get to
222 * look at it here before any upper layer protocols do.
223 *
224 * NOTE: this function will get called at splimp()
225 */
226static void
227ng_ether_input(struct ifnet *ifp, struct mbuf **mp)
228{
229 const node_p node = IFP2NG(ifp);
230 const priv_p priv = NG_NODE_PRIVATE(node);
231 int error;
232
233 /* If "lower" hook not connected, let packet continue */
234 if (priv->lower == NULL)
235 return;
236 NG_SEND_DATA_ONLY(error, priv->lower, *mp); /* sets *mp = NULL */
237}
238
239/*
240 * Handle a packet that has come in on an interface, and which
241 * does not match any of our known protocols (an ``orphan'').
242 *
243 * NOTE: this function will get called at splimp()
244 */
245static void
246ng_ether_input_orphan(struct ifnet *ifp, struct mbuf *m)
247{
248 const node_p node = IFP2NG(ifp);
249 const priv_p priv = NG_NODE_PRIVATE(node);
250 int error;
251
--- 502 unchanged lines hidden (view full) ---
754
755/*
756 * Handle loading and unloading for this node type.
757 */
758static int
759ng_ether_mod_event(module_t mod, int event, void *data)
760{
761 int error = 0;
762 int s;
763
764 s = splnet();
765 switch (event) {
766 case MOD_LOAD:
767
768 /* Register function hooks */
769 if (ng_ether_attach_p != NULL) {
770 error = EEXIST;
771 break;
772 }
--- 24 unchanged lines hidden (view full) ---
797 ng_ether_input_orphan_p = NULL;
798 ng_ether_link_state_p = NULL;
799 break;
800
801 default:
802 error = EOPNOTSUPP;
803 break;
804 }
805 splx(s);
806 return (error);
807}
808
809static void
810vnet_ng_ether_init(const void *unused)
811{
812 struct ifnet *ifp;
813
--- 15 unchanged lines hidden ---
2/*
3 * ng_ether.c
4 */
5
6/*-
7 * Copyright (c) 1996-2000 Whistle Communications, Inc.
8 * All rights reserved.
--- 25 unchanged lines hidden (view full) ---
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
37 * OF SUCH DAMAGE.
38 *
39 * Authors: Archie Cobbs <archie@freebsd.org>
40 * Julian Elischer <julian@freebsd.org>
41 *
42 * $FreeBSD: head/sys/netgraph/ng_ether.c 238844 2012-07-27 13:57:28Z emaste $
43 */
44
45/*
46 * ng_ether(4) netgraph node type
47 */
48
49#include <sys/param.h>
50#include <sys/systm.h>
--- 164 unchanged lines hidden (view full) ---
215
216/******************************************************************
217 ETHERNET FUNCTION HOOKS
218******************************************************************/
219
220/*
221 * Handle a packet that has come in on an interface. We get to
222 * look at it here before any upper layer protocols do.
223 *
224 * NOTE: this function will get called at splimp()
225 */
226static void
227ng_ether_input(struct ifnet *ifp, struct mbuf **mp)
228{
229 const node_p node = IFP2NG(ifp);
230 const priv_p priv = NG_NODE_PRIVATE(node);
231 int error;
232
233 /* If "lower" hook not connected, let packet continue */
234 if (priv->lower == NULL)
235 return;
236 NG_SEND_DATA_ONLY(error, priv->lower, *mp); /* sets *mp = NULL */
237}
238
239/*
240 * Handle a packet that has come in on an interface, and which
241 * does not match any of our known protocols (an ``orphan'').
242 *
243 * NOTE: this function will get called at splimp()
244 */
245static void
246ng_ether_input_orphan(struct ifnet *ifp, struct mbuf *m)
247{
248 const node_p node = IFP2NG(ifp);
249 const priv_p priv = NG_NODE_PRIVATE(node);
250 int error;
251
--- 502 unchanged lines hidden (view full) ---
754
755/*
756 * Handle loading and unloading for this node type.
757 */
758static int
759ng_ether_mod_event(module_t mod, int event, void *data)
760{
761 int error = 0;
762 int s;
763
764 s = splnet();
765 switch (event) {
766 case MOD_LOAD:
767
768 /* Register function hooks */
769 if (ng_ether_attach_p != NULL) {
770 error = EEXIST;
771 break;
772 }
--- 24 unchanged lines hidden (view full) ---
797 ng_ether_input_orphan_p = NULL;
798 ng_ether_link_state_p = NULL;
799 break;
800
801 default:
802 error = EOPNOTSUPP;
803 break;
804 }
805 splx(s);
806 return (error);
807}
808
809static void
810vnet_ng_ether_init(const void *unused)
811{
812 struct ifnet *ifp;
813
--- 15 unchanged lines hidden ---