Deleted Added
full compact
ng_eiface.c (171595) ng_eiface.c (181803)
1/*-
2 *
3 * Copyright (c) 1999-2001, Vitaly V Belekhov
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 *
3 * Copyright (c) 1999-2001, Vitaly V Belekhov
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/netgraph/ng_eiface.c 171595 2007-07-26 10:54:33Z glebius $
28 * $FreeBSD: head/sys/netgraph/ng_eiface.c 181803 2008-08-17 23:27:27Z bz $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/errno.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/mbuf.h>
37#include <sys/errno.h>
38#include <sys/sockio.h>
39#include <sys/socket.h>
40#include <sys/syslog.h>
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/errno.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/mbuf.h>
37#include <sys/errno.h>
38#include <sys/sockio.h>
39#include <sys/socket.h>
40#include <sys/syslog.h>
41#include <sys/vimage.h>
41
42#include <net/if.h>
43#include <net/if_types.h>
44#include <net/netisr.h>
45
46#include <netgraph/ng_message.h>
47#include <netgraph/netgraph.h>
48#include <netgraph/ng_parse.h>

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

346 free(priv, M_NETGRAPH);
347 return (ENOSPC);
348 }
349
350 /* Link them together */
351 ifp->if_softc = priv;
352
353 /* Get an interface unit number */
42
43#include <net/if.h>
44#include <net/if_types.h>
45#include <net/netisr.h>
46
47#include <netgraph/ng_message.h>
48#include <netgraph/netgraph.h>
49#include <netgraph/ng_parse.h>

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

347 free(priv, M_NETGRAPH);
348 return (ENOSPC);
349 }
350
351 /* Link them together */
352 ifp->if_softc = priv;
353
354 /* Get an interface unit number */
354 priv->unit = alloc_unr(ng_eiface_unit);
355 priv->unit = alloc_unr(V_ng_eiface_unit);
355
356 /* Link together node and private info */
357 NG_NODE_SET_PRIVATE(node, priv);
358 priv->node = node;
359
360 /* Initialize interface structure */
361 if_initname(ifp, NG_EIFACE_EIFACE_NAME, priv->unit);
362 ifp->if_init = ng_eiface_init;

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

544static int
545ng_eiface_rmnode(node_p node)
546{
547 const priv_p priv = NG_NODE_PRIVATE(node);
548 struct ifnet *const ifp = priv->ifp;
549
550 ether_ifdetach(ifp);
551 if_free(ifp);
356
357 /* Link together node and private info */
358 NG_NODE_SET_PRIVATE(node, priv);
359 priv->node = node;
360
361 /* Initialize interface structure */
362 if_initname(ifp, NG_EIFACE_EIFACE_NAME, priv->unit);
363 ifp->if_init = ng_eiface_init;

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

545static int
546ng_eiface_rmnode(node_p node)
547{
548 const priv_p priv = NG_NODE_PRIVATE(node);
549 struct ifnet *const ifp = priv->ifp;
550
551 ether_ifdetach(ifp);
552 if_free(ifp);
552 free_unr(ng_eiface_unit, priv->unit);
553 free_unr(V_ng_eiface_unit, priv->unit);
553 FREE(priv, M_NETGRAPH);
554 NG_NODE_SET_PRIVATE(node, NULL);
555 NG_NODE_UNREF(node);
556 return (0);
557}
558
559/*
560 * Hook disconnection

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

573 */
574static int
575ng_eiface_mod_event(module_t mod, int event, void *data)
576{
577 int error = 0;
578
579 switch (event) {
580 case MOD_LOAD:
554 FREE(priv, M_NETGRAPH);
555 NG_NODE_SET_PRIVATE(node, NULL);
556 NG_NODE_UNREF(node);
557 return (0);
558}
559
560/*
561 * Hook disconnection

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

574 */
575static int
576ng_eiface_mod_event(module_t mod, int event, void *data)
577{
578 int error = 0;
579
580 switch (event) {
581 case MOD_LOAD:
581 ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
582 V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
582 break;
583 case MOD_UNLOAD:
583 break;
584 case MOD_UNLOAD:
584 delete_unrhdr(ng_eiface_unit);
585 delete_unrhdr(V_ng_eiface_unit);
585 break;
586 default:
587 error = EOPNOTSUPP;
588 break;
589 }
590 return (error);
591}
586 break;
587 default:
588 error = EOPNOTSUPP;
589 break;
590 }
591 return (error);
592}