Part 2 of the netgraph rewrite.
This is mostly cosmetic changes, (though I caught a bug or two while makeing them) Reviewed by: archie@freebsd.org
This commit is contained in:
parent
6b827cac3b
commit
ff86256bf7
@ -602,43 +602,139 @@ and
|
||||
.Pa sys/netgraph/ng_message.h
|
||||
(for message definitions also of interest to user programs).
|
||||
|
||||
The following structures exist and have the following access
|
||||
fields of interest to the node writers. If applicable I show the
|
||||
access method for that information.
|
||||
for their fields:
|
||||
The two basic object types that are of interest to node authors are
|
||||
.Em nodes
|
||||
and
|
||||
.Em hooks .
|
||||
These two objects have the following
|
||||
properties that are also of interest to the node writers.
|
||||
.Bl -tag -width xxx
|
||||
./.Bl -bullet -compact -offset 2n
|
||||
.It struct ng_node
|
||||
Node authors should always use the following typedef to declare
|
||||
their pointers, and should never actually declare the structure.
|
||||
.Pp
|
||||
typedef struct ng_node *node_p;
|
||||
.Bl -tag -width xxx
|
||||
.It char name[NG_NODELEN+1]
|
||||
.Pp
|
||||
The following properties are associated with a node, and can be
|
||||
accessed in the following manner:
|
||||
.Bl -bullet -compact -offset 2n
|
||||
./.Bl -tag -width xxx
|
||||
.Pp
|
||||
.It
|
||||
Validity
|
||||
.Pp
|
||||
A driver or interrupt routine may want to check whether
|
||||
the node is still valid. It is assumed that the caller holds a reference
|
||||
on the node so it will not have been freed, however it may have been
|
||||
disabled or otherwise shut down. Using the
|
||||
.Fn NG_NODE_IS_VALID "node"
|
||||
macro will return this state. Eventually it should be almost impossible
|
||||
for code to run in an invalid node but at this time that work has not been
|
||||
completed.
|
||||
.Pp
|
||||
.It
|
||||
node ID
|
||||
.Pp
|
||||
Of type
|
||||
.Em ng_ID_t ,
|
||||
This property can be retrieved using the macro
|
||||
.Fn NG_NODE_ID "node".
|
||||
.Pp
|
||||
.It
|
||||
node name
|
||||
.Pp
|
||||
Optional globally unique name, null terminated string. If there
|
||||
is a value in here, it is the name of the node.
|
||||
.Pp
|
||||
if (node->name[0]) ....
|
||||
if (
|
||||
.Fn NG_NODE_NAME "node"
|
||||
[0]) ....
|
||||
.Pp
|
||||
.It void *private
|
||||
Node implementation private info.
|
||||
You may place anything you wish here.
|
||||
.It int numhooks
|
||||
Number of connected hooks.
|
||||
.It hook_p hooks
|
||||
Linked list of (connected) hooks.
|
||||
if (strncmp(
|
||||
.Fn NG_NODE_NAME "node"
|
||||
, "fred", NG_NODELEN)) ...
|
||||
.Pp
|
||||
.It
|
||||
A node dependent opaque cookie
|
||||
.Pp
|
||||
You may place anything of type
|
||||
.Em pointer
|
||||
here.
|
||||
Use the macros
|
||||
.Fn NG_NODE_SET_PRIVATE "node, value"
|
||||
and
|
||||
.Fn NG_NODE_PRIVATE "node"
|
||||
to set and retrieve this property.
|
||||
.Pp
|
||||
.It
|
||||
number of hooks
|
||||
.Pp
|
||||
Use
|
||||
.Fn NG_NODE_NUMHOOKS "node"
|
||||
to retrieve this value.
|
||||
.Pp
|
||||
.It
|
||||
hooks
|
||||
.Pp
|
||||
The node may have a number of hooks.
|
||||
A traversal method is provided to allow all the hooks to be
|
||||
tested for some condition.
|
||||
.Fn NG_NODE_FOREACH_HOOK "node, fn, arg, rethook"
|
||||
where fn is a function that will be called for each hook
|
||||
with the form
|
||||
.Fn fn "hook, arg"
|
||||
and returning 0 to terminate the search. If the search is terminated, then
|
||||
.Em rethook
|
||||
will be set to the hook at which the search was terminated.
|
||||
.El
|
||||
.It struct ng_hook
|
||||
Node authors should always use the following typedef to declare
|
||||
their hook pointers.
|
||||
.Pp
|
||||
typedef struct ng_hook *hook_p;
|
||||
.Bl -tag -width xxx
|
||||
.It void *private;
|
||||
Node implementation private info.
|
||||
You may place anything you wish in this field.
|
||||
.It struct ng_node *node;
|
||||
The node this hook is attached to.
|
||||
.It struct ng_hook *peer;
|
||||
The other hook in this connected pair.
|
||||
.It struct ng_hook *next;
|
||||
Next in list of hooks for this node.
|
||||
A hook list traversal method will be supplied so use of this field
|
||||
directly will go away.
|
||||
.Pp
|
||||
The following properties are associated with a hook, and can be
|
||||
accessed in the following manner:
|
||||
.Bl -bullet -compact -offset 2n
|
||||
./.Bl -tag -width xxx
|
||||
.Pp
|
||||
.It
|
||||
A node dependent opaque cookie.
|
||||
.Pp
|
||||
You may place anything of type
|
||||
.Em pointer
|
||||
here.
|
||||
Use the macros
|
||||
.Fn NG_HOOK_SET_PRIVATE "hook, value"
|
||||
and
|
||||
.Fn NG_HOOK_PRIVATE "hook"
|
||||
to set and retrieve this property.
|
||||
.Pp
|
||||
.It
|
||||
An associate node.
|
||||
.Pp
|
||||
You may use the macro
|
||||
.Fn NG_HOOK_NODE "hook"
|
||||
to find the associated node.
|
||||
.Pp
|
||||
.It
|
||||
A peer hook
|
||||
.Pp
|
||||
The other hook in this connected pair. Of type hook_p. You can
|
||||
use
|
||||
.Fn NG_HOOK_PEER "hook"
|
||||
to find the peer.
|
||||
.Pp
|
||||
.It
|
||||
references
|
||||
.Pp
|
||||
.Fn NG_HOOK_REF "hook"
|
||||
and
|
||||
.Fn NG_HOOK_UNREF "hook"
|
||||
increment and decrement the hook reference count accordingly.
|
||||
After decrement you should always sume the hook has been freed.
|
||||
In fact the macro may set it to NULL.
|
||||
.El
|
||||
.Pp
|
||||
The maintenance of the names, reference counts, and linked list
|
||||
@ -650,11 +746,11 @@ structure, which counts as a new reference that must be included
|
||||
in the reference count for the node. When the node constructor is called
|
||||
there is already a reference for this calculated in, so that
|
||||
when the node is destroyed, it should remember to do a
|
||||
.Fn ng_unref
|
||||
.Fn NG_NODE_UNREF
|
||||
on the node.
|
||||
.Pp
|
||||
From a hook you can obtain the corresponding node, and from
|
||||
a node, the list of all active hooks.
|
||||
a node, it is possible to traverse all the active hooks.
|
||||
.Pp
|
||||
A current example of how to define a node can always be seen in
|
||||
.Em sys/netgraph/ng_sample.c
|
||||
|
@ -511,10 +511,10 @@ arattach(struct ar_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -2186,13 +2186,13 @@ ngar_constructor(node_p node)
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
@ -2223,7 +2223,7 @@ ngar_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -2281,7 +2281,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -2292,7 +2292,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -2338,10 +2338,10 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngar_shutdown(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
ar_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX need to drain the output queues! */
|
||||
|
||||
/* The node is dead, long live the node! */
|
||||
@ -2352,10 +2352,10 @@ ngar_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
sc->node = NULL;
|
||||
printf("node naming failed\n");
|
||||
ng_unref(sc->node); /* node dissappears */
|
||||
NG_NODE_UNREF(sc->node); /* node dissappears */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
}
|
||||
@ -2365,7 +2365,7 @@ static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -2384,12 +2384,12 @@ ngar_connect(hook_p hook)
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -511,10 +511,10 @@ arattach(struct ar_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -2186,13 +2186,13 @@ ngar_constructor(node_p node)
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
@ -2223,7 +2223,7 @@ ngar_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -2281,7 +2281,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -2292,7 +2292,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -2338,10 +2338,10 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngar_shutdown(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
ar_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX need to drain the output queues! */
|
||||
|
||||
/* The node is dead, long live the node! */
|
||||
@ -2352,10 +2352,10 @@ ngar_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
sc->node = NULL;
|
||||
printf("node naming failed\n");
|
||||
ng_unref(sc->node); /* node dissappears */
|
||||
NG_NODE_UNREF(sc->node); /* node dissappears */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
}
|
||||
@ -2365,7 +2365,7 @@ static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -2384,12 +2384,12 @@ ngar_connect(hook_p hook)
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -1132,10 +1132,10 @@ lmc_attach(lmc_softc_t * const sc)
|
||||
return (0);
|
||||
sprintf(sc->lmc_nodename, "%s%d", NG_LMC_NODE_TYPE, sc->lmc_unit);
|
||||
if (ng_name_node(sc->lmc_node, sc->lmc_nodename)) {
|
||||
ng_unref(sc->lmc_node); /* make it go away again */
|
||||
NG_NODE_UNREF(sc->lmc_node); /* make it go away again */
|
||||
return (0);
|
||||
}
|
||||
sc->lmc_node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->lmc_node, sc);
|
||||
callout_handle_init(&sc->lmc_handle);
|
||||
sc->lmc_xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->lmc_xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -1265,13 +1265,13 @@ ng_lmc_constructor(node_p node)
|
||||
static int
|
||||
ng_lmc_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
lmc_softc_t * sc = (lmc_softc_t *) node->private;
|
||||
lmc_softc_t * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_LMC_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->lmc_debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ ng_lmc_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_LMC_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->lmc_hook = hook;
|
||||
sc->lmc_datahooks++;
|
||||
lmc_ifup(sc);
|
||||
@ -1296,7 +1296,7 @@ ng_lmc_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_lmc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
lmc_softc_t *sc = (lmc_softc_t *) node->private;
|
||||
lmc_softc_t *sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -1390,7 +1390,7 @@ ng_lmc_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
lmc_softc_t * sc = (lmc_softc_t *) hook->node->private;
|
||||
lmc_softc_t * sc = (lmc_softc_t *) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -1403,7 +1403,7 @@ ng_lmc_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -1449,16 +1449,15 @@ ng_lmc_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_lmc_rmnode(node_p node)
|
||||
{
|
||||
lmc_softc_t * sc = (lmc_softc_t *) node->private;
|
||||
lmc_softc_t * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
lmc_ifdown(sc);
|
||||
|
||||
/*
|
||||
* Get rid of the old node.
|
||||
*/
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
|
||||
/*
|
||||
* Create a new node. This is basically what a device
|
||||
@ -1470,10 +1469,10 @@ ng_lmc_rmnode(node_p node)
|
||||
sprintf(sc->lmc_nodename, "%s%d", NG_LMC_NODE_TYPE, sc->lmc_unit);
|
||||
if (ng_name_node(sc->lmc_node, sc->lmc_nodename)) {
|
||||
sc->lmc_node = NULL; /* to be sure */
|
||||
ng_unref(sc->lmc_node); /* make it go away */
|
||||
NG_NODE_UNREF(sc->lmc_node); /* make it go away */
|
||||
return (0);
|
||||
}
|
||||
sc->lmc_node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->lmc_node, sc);
|
||||
callout_handle_init(&sc->lmc_handle);
|
||||
sc->lmc_running = 0;
|
||||
/*
|
||||
@ -1488,7 +1487,7 @@ static int
|
||||
ng_lmc_connect(hook_p hook)
|
||||
{
|
||||
/* We are probably not at splnet.. force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -1506,12 +1505,12 @@ ng_lmc_connect(hook_p hook)
|
||||
static int
|
||||
ng_lmc_disconnect(hook_p hook)
|
||||
{
|
||||
lmc_softc_t * sc = (lmc_softc_t *) hook->node->private;
|
||||
lmc_softc_t * sc = (lmc_softc_t *) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->lmc_datahooks--;
|
||||
if (sc->lmc_datahooks == 0)
|
||||
|
@ -855,7 +855,7 @@ musycc_config(node_p node, char *set, char *ret)
|
||||
enum framing wframing;
|
||||
int i;
|
||||
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
csc = sc->csc;
|
||||
if (csc->state == C_IDLE)
|
||||
init_card(csc);
|
||||
@ -941,7 +941,7 @@ musycc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
if (msg->header.typecookie != NGM_GENERIC_COOKIE)
|
||||
goto out;
|
||||
|
||||
@ -995,7 +995,7 @@ musycc_newhook(node_p node, hook_p hook, const char *name)
|
||||
u_int32_t ts, chan;
|
||||
int nbit;
|
||||
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
csc = sc->csc;
|
||||
|
||||
while (csc->state != C_RUNNING)
|
||||
@ -1033,7 +1033,7 @@ musycc_newhook(node_p node, hook_p hook, const char *name)
|
||||
sch->ts = ts;
|
||||
sch->hook = hook;
|
||||
sch->tx_limit = nbit * 8;
|
||||
hook->private = sch;
|
||||
NG_HOOK_SET_PRIVATE(hook, sch);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -1049,7 +1049,7 @@ musycc_rcvdata(hook_p hook, item_p item)
|
||||
struct mbuf *m2;
|
||||
struct mbuf *m;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
sc = sch->sc;
|
||||
csc = sc->csc;
|
||||
ch = sch->chan;
|
||||
@ -1116,7 +1116,7 @@ musycc_connect(hook_p hook)
|
||||
int nts, nbuf, i, nmd, ch;
|
||||
struct mbuf *m;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
sc = sch->sc;
|
||||
csc = sc->csc;
|
||||
ch = sch->chan;
|
||||
@ -1231,7 +1231,7 @@ musycc_connect(hook_p hook)
|
||||
tsleep(&sc->last, PZERO + PCATCH, "con4", hz);
|
||||
sc->reg->srd = sc->last = 0x0820 + ch;
|
||||
tsleep(&sc->last, PZERO + PCATCH, "con3", hz);
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
|
||||
return (0);
|
||||
|
||||
@ -1254,7 +1254,7 @@ musycc_disconnect(hook_p hook)
|
||||
struct schan *sch;
|
||||
int i, ch;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
sc = sch->sc;
|
||||
csc = sc->csc;
|
||||
ch = sch->chan;
|
||||
@ -1452,12 +1452,13 @@ musycc_attach(device_t self)
|
||||
printf("ng_make_node_common() failed %d\n", error);
|
||||
continue;
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sprintf(sc->nodename, "sync-%d-%d-%d",
|
||||
csc->bus,
|
||||
csc->slot,
|
||||
i);
|
||||
error = ng_name_node(sc->node, sc->nodename);
|
||||
/* XXX Apparently failure isn't a problem */
|
||||
}
|
||||
csc->ram = (struct globalr *)&csc->serial[0].mycg->cg;
|
||||
sc = &csc->serial[0];
|
||||
|
@ -936,10 +936,10 @@ srattach(struct sr_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* make it go away again */
|
||||
NG_NODE_UNREF(sc->node); /* make it go away again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -3139,13 +3139,13 @@ ngsr_constructor(node_p node)
|
||||
static int
|
||||
ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -3156,7 +3156,7 @@ ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_SR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
sr_up(sc);
|
||||
@ -3176,7 +3176,7 @@ ngsr_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item,msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_SR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -3236,7 +3236,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -3247,7 +3247,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -3293,10 +3293,10 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngsr_shutdown(node_p node)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
sr_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX should drain queues! */
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
@ -3304,10 +3304,10 @@ ngsr_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
printf("node naming failed\n");
|
||||
sc->node = NULL;
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle); /* should kill timeout */
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
@ -3318,7 +3318,7 @@ static int
|
||||
ngsr_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -3337,12 +3337,12 @@ ngsr_connect(hook_p hook)
|
||||
static int
|
||||
ngsr_disconnect(hook_p hook)
|
||||
{
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -936,10 +936,10 @@ srattach(struct sr_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* make it go away again */
|
||||
NG_NODE_UNREF(sc->node); /* make it go away again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -3139,13 +3139,13 @@ ngsr_constructor(node_p node)
|
||||
static int
|
||||
ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -3156,7 +3156,7 @@ ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_SR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
sr_up(sc);
|
||||
@ -3176,7 +3176,7 @@ ngsr_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item,msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_SR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -3236,7 +3236,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -3247,7 +3247,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -3293,10 +3293,10 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngsr_shutdown(node_p node)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
sr_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX should drain queues! */
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
@ -3304,10 +3304,10 @@ ngsr_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
printf("node naming failed\n");
|
||||
sc->node = NULL;
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle); /* should kill timeout */
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
@ -3318,7 +3318,7 @@ static int
|
||||
ngsr_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -3337,12 +3337,12 @@ ngsr_connect(hook_p hook)
|
||||
static int
|
||||
ngsr_disconnect(hook_p hook)
|
||||
{
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -357,11 +357,11 @@ USB_ATTACH(udbp)
|
||||
char nodename[128];
|
||||
sprintf(nodename, "%s", USBDEVNAME(sc->sc_dev));
|
||||
if ((err = ng_name_node(sc->node, nodename))) {
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
sc->node = NULL;
|
||||
goto bad;
|
||||
} else {
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
mtx_init(&sc->xmitq.ifq_mtx, "usb_xmitq", MTX_DEF);
|
||||
@ -420,10 +420,9 @@ USB_DETACH(udbp)
|
||||
}
|
||||
|
||||
if (sc->flags & NETGRAPH_INITIALISED) {
|
||||
ng_unname(sc->node);
|
||||
ng_udbp_rmnode(sc->node);
|
||||
sc->node->private = NULL;
|
||||
ng_unref(sc->node);
|
||||
ng_rmnode_self(sc->node);
|
||||
NG_NODE_SET_PRIVATE(sc->node, NULL);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
sc->node = NULL; /* Paranoid */
|
||||
}
|
||||
|
||||
@ -629,7 +628,7 @@ ng_udbp_constructor(node_p node)
|
||||
Static int
|
||||
ng_udbp_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const udbp_p sc = node->private;
|
||||
const udbp_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
#if 0
|
||||
/* Possibly start up the device if it's not already going */
|
||||
@ -640,7 +639,7 @@ ng_udbp_newhook(node_p node, hook_p hook, const char *name)
|
||||
|
||||
if (strcmp(name, NG_UDBP_HOOK_NAME) == 0) {
|
||||
sc->hook = hook;
|
||||
hook->private = NULL;
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
} else {
|
||||
return (EINVAL); /* not a hook we know about */
|
||||
}
|
||||
@ -661,7 +660,7 @@ ng_udbp_newhook(node_p node, hook_p hook, const char *name)
|
||||
Static int
|
||||
ng_udbp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const udbp_p sc = node->private;
|
||||
const udbp_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -714,7 +713,7 @@ ng_udbp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
Static int
|
||||
ng_udbp_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const udbp_p sc = hook->node->private;
|
||||
const udbp_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int error;
|
||||
struct ifqueue *xmitq_p;
|
||||
int s;
|
||||
@ -765,29 +764,37 @@ ng_udbp_rcvdata(hook_p hook, item_p item)
|
||||
Static int
|
||||
ng_udbp_rmnode(node_p node)
|
||||
{
|
||||
const udbp_p sc = node->private;
|
||||
const udbp_p sc = NG_NODE_PRIVATE(node);
|
||||
int err;
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
if (sc->flags & DISCONNECTED) {
|
||||
/*
|
||||
* WE are really going away.. hardware must have gone.
|
||||
* Assume that the hardware drive part will clear up the
|
||||
* sc, in fact it may already have done so..
|
||||
* In which case we may have just segfaulted..XXX
|
||||
*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* stolen from attach routine */
|
||||
/* Drain the queues */
|
||||
IF_DRAIN(&sc->xmitq_hipri);
|
||||
IF_DRAIN(&sc->xmitq);
|
||||
|
||||
sc->packets_in = 0; /* reset stats */
|
||||
sc->packets_out = 0;
|
||||
ng_unref(node); /* forget it ever existed */
|
||||
NG_NODE_UNREF(node); /* forget it ever existed */
|
||||
|
||||
/* stolen from attach routine */
|
||||
if ((err = ng_make_node_common(&ng_udbp_typestruct, &sc->node)) == 0) {
|
||||
char nodename[128];
|
||||
sprintf(nodename, "%s", USBDEVNAME(sc->sc_dev));
|
||||
if ((err = ng_name_node(sc->node, nodename))) {
|
||||
ng_unref(sc->node); /* out damned spot! */
|
||||
NG_NODE_UNREF(sc->node); /* out damned spot! */
|
||||
sc->flags &= ~NETGRAPH_INITIALISED;
|
||||
sc->node = NULL;
|
||||
} else {
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
}
|
||||
}
|
||||
return (err);
|
||||
@ -801,7 +808,7 @@ Static int
|
||||
ng_udbp_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -814,12 +821,12 @@ ng_udbp_connect(hook_p hook)
|
||||
Static int
|
||||
ng_udbp_disconnect(hook_p hook)
|
||||
{
|
||||
const udbp_p sc = hook->node->private;
|
||||
const udbp_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
sc->hook = NULL;
|
||||
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -511,10 +511,10 @@ arattach(struct ar_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -2186,13 +2186,13 @@ ngar_constructor(node_p node)
|
||||
static int
|
||||
ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ ngar_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
ar_up(sc);
|
||||
@ -2223,7 +2223,7 @@ ngar_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_AR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -2281,7 +2281,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -2292,7 +2292,7 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -2338,10 +2338,10 @@ ngar_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngar_shutdown(node_p node)
|
||||
{
|
||||
struct ar_softc * sc = node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
ar_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX need to drain the output queues! */
|
||||
|
||||
/* The node is dead, long live the node! */
|
||||
@ -2352,10 +2352,10 @@ ngar_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
sc->node = NULL;
|
||||
printf("node naming failed\n");
|
||||
ng_unref(sc->node); /* node dissappears */
|
||||
NG_NODE_UNREF(sc->node); /* node dissappears */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
}
|
||||
@ -2365,7 +2365,7 @@ static int
|
||||
ngar_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -2384,12 +2384,12 @@ ngar_connect(hook_p hook)
|
||||
static int
|
||||
ngar_disconnect(hook_p hook)
|
||||
{
|
||||
struct ar_softc * sc = hook->node->private;
|
||||
struct ar_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -936,10 +936,10 @@ srattach(struct sr_hardc *hc)
|
||||
return (0);
|
||||
sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node); /* make it go away again */
|
||||
NG_NODE_UNREF(sc->node); /* make it go away again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle);
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -3139,13 +3139,13 @@ ngsr_constructor(node_p node)
|
||||
static int
|
||||
ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debug_hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -3156,7 +3156,7 @@ ngsr_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (strcmp(name, NG_SR_HOOK_RAW) != 0) {
|
||||
return (EINVAL);
|
||||
}
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
sc->datahooks++;
|
||||
sr_up(sc);
|
||||
@ -3176,7 +3176,7 @@ ngsr_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item,msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
switch (msg->header.typecookie) {
|
||||
case NG_SR_COOKIE:
|
||||
error = EINVAL;
|
||||
@ -3236,7 +3236,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int s;
|
||||
int error = 0;
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
@ -3247,7 +3247,7 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
/*
|
||||
* data doesn't come in from just anywhere (e.g control hook)
|
||||
*/
|
||||
if ( hook->private == NULL) {
|
||||
if ( NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
error = ENETDOWN;
|
||||
goto bad;
|
||||
}
|
||||
@ -3293,10 +3293,10 @@ ngsr_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngsr_shutdown(node_p node)
|
||||
{
|
||||
struct sr_softc * sc = node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
sr_down(sc);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
/* XXX should drain queues! */
|
||||
if (ng_make_node_common(&typestruct, &sc->node) != 0)
|
||||
return (0);
|
||||
@ -3304,10 +3304,10 @@ ngsr_shutdown(node_p node)
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
printf("node naming failed\n");
|
||||
sc->node = NULL;
|
||||
ng_unref(sc->node); /* drop it again */
|
||||
NG_NODE_UNREF(sc->node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
callout_handle_init(&sc->handle); /* should kill timeout */
|
||||
sc->running = 0;
|
||||
return (0);
|
||||
@ -3318,7 +3318,7 @@ static int
|
||||
ngsr_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
/* be really amiable and just say "YUP that's OK by me! " */
|
||||
return (0);
|
||||
}
|
||||
@ -3337,12 +3337,12 @@ ngsr_connect(hook_p hook)
|
||||
static int
|
||||
ngsr_disconnect(hook_p hook)
|
||||
{
|
||||
struct sr_softc * sc = hook->node->private;
|
||||
struct sr_softc * sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
/*
|
||||
* If it's the data hook, then free resources etc.
|
||||
*/
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
s = splimp();
|
||||
sc->datahooks--;
|
||||
if (sc->datahooks == 0)
|
||||
|
@ -280,11 +280,11 @@ i4bingattach(void *dummy)
|
||||
if((ret = ng_name_node(sc->node, sc->nodename)))
|
||||
{
|
||||
printf("ing: ng_name node, ret = %d\n!", ret);
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
break;
|
||||
}
|
||||
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
|
||||
sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
|
||||
@ -587,14 +587,14 @@ ng_ing_constructor(node_p node)
|
||||
static int
|
||||
ng_ing_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
struct ing_softc *sc = node->private;
|
||||
struct ing_softc *sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
/*
|
||||
* check if it's our friend the debug hook
|
||||
*/
|
||||
if(strcmp(name, NG_ING_HOOK_DEBUG) == 0)
|
||||
{
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
sc->debughook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -603,7 +603,7 @@ ng_ing_newhook(node_p node, hook_p hook, const char *name)
|
||||
*/
|
||||
if(strcmp(name, NG_ING_HOOK_RAW) == 0)
|
||||
{
|
||||
hook->private = sc;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc);
|
||||
sc->hook = hook;
|
||||
return (0);
|
||||
}
|
||||
@ -628,7 +628,7 @@ ng_ing_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
|
||||
struct ng_mesg **rptr)
|
||||
#endif
|
||||
{
|
||||
struct ing_softc *sc = node->private;
|
||||
struct ing_softc *sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
@ -746,7 +746,7 @@ static int
|
||||
ng_ing_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
#endif
|
||||
{
|
||||
struct ing_softc *sc = hook->node->private;
|
||||
struct ing_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ifqueue *xmitq_p;
|
||||
int s;
|
||||
#if defined(__FreeBSD_version) && __FreeBSD_version >= 500000
|
||||
@ -757,7 +757,7 @@ ng_ing_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
NGI_GET_META(item, meta);
|
||||
NG_FREE_ITEM(item);
|
||||
#endif
|
||||
if(hook->private == NULL)
|
||||
if(NG_HOOK_PRIVATE(hook) == NULL)
|
||||
{
|
||||
NG_FREE_M(m);
|
||||
NG_FREE_META(meta);
|
||||
@ -815,11 +815,10 @@ ng_ing_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
|
||||
static int
|
||||
ng_ing_shutdown(node_p node)
|
||||
{
|
||||
struct ing_softc *sc = node->private;
|
||||
struct ing_softc *sc = NG_NODE_PRIVATE(node);
|
||||
int ret;
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
|
||||
sc->packets_in = 0; /* reset stats */
|
||||
sc->packets_out = 0;
|
||||
@ -834,11 +833,11 @@ ng_ing_shutdown(node_p node)
|
||||
if((ret = ng_name_node(sc->node, sc->nodename)))
|
||||
{
|
||||
printf("ing: ng_name node, ret = %d\n!", ret);
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -850,7 +849,7 @@ static int
|
||||
ng_ing_connect(hook_p hook)
|
||||
{
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -862,10 +861,10 @@ ng_ing_connect(hook_p hook)
|
||||
static int
|
||||
ng_ing_disconnect(hook_p hook)
|
||||
{
|
||||
struct ing_softc *sc = hook->node->private;
|
||||
struct ing_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
|
||||
if(hook->private)
|
||||
if(NG_HOOK_PRIVATE(hook))
|
||||
{
|
||||
s = splimp();
|
||||
splx(s);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -101,7 +101,7 @@ NETGRAPH_INIT(UI, &typestruct);
|
||||
*/
|
||||
|
||||
static int
|
||||
ng_UI_constructor(node_p nodep)
|
||||
ng_UI_constructor(node_p node)
|
||||
{
|
||||
priv_p priv;
|
||||
|
||||
@ -110,7 +110,7 @@ ng_UI_constructor(node_p nodep)
|
||||
if (priv == NULL) {
|
||||
return (ENOMEM);
|
||||
}
|
||||
nodep->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ ng_UI_constructor(node_p nodep)
|
||||
static int
|
||||
ng_UI_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (!strcmp(name, NG_UI_HOOK_DOWNSTREAM)) {
|
||||
if (priv->downlink)
|
||||
@ -142,27 +142,25 @@ static int
|
||||
ng_UI_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
int error;
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *msg;
|
||||
|
||||
msg = NGI_MSG(item); /* only peeking */
|
||||
if ((msg->header.typecookie == NGM_FLOW_COOKIE) && lasthook) {
|
||||
if (lasthook == priv->downlink) {
|
||||
if (priv->uplink) {
|
||||
NG_FWD_MSG_HOOK(error, node, item,
|
||||
priv->uplink, 0);
|
||||
NG_FWD_ITEM_HOOK(error, item, priv->uplink);
|
||||
return (error);
|
||||
}
|
||||
} else {
|
||||
if (priv->downlink) {
|
||||
NG_FWD_MSG_HOOK(error, node, item,
|
||||
priv->downlink, 0);
|
||||
NG_FWD_ITEM_HOOK(error, item, priv->downlink);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NG_FREE_MSG(msg);
|
||||
NG_FREE_ITEM(item);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -175,8 +173,8 @@ ng_UI_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_UI_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct mbuf *m;
|
||||
int error = 0;
|
||||
|
||||
@ -217,12 +215,12 @@ ng_UI_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_UI_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Take down netgraph node */
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -232,7 +230,7 @@ ng_UI_shutdown(node_p node)
|
||||
static int
|
||||
ng_UI_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
if (hook == priv->downlink)
|
||||
priv->downlink = NULL;
|
||||
@ -244,9 +242,9 @@ ng_UI_disconnect(hook_p hook)
|
||||
* If we are not already shutting down,
|
||||
* and we have no more hooks, then DO shut down.
|
||||
*/
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0)) {
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ nga_constructor(node_p node)
|
||||
FREE(sc, M_NETGRAPH);
|
||||
return (ENOMEM);
|
||||
}
|
||||
node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(node, sc);
|
||||
sc->node = node;
|
||||
return (0);
|
||||
}
|
||||
@ -208,7 +208,7 @@ nga_constructor(node_p node)
|
||||
static int
|
||||
nga_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
hook_p *hookp;
|
||||
|
||||
if (!strcmp(name, NG_ASYNC_HOOK_ASYNC)) {
|
||||
@ -217,7 +217,7 @@ nga_newhook(node_p node, hook_p hook, const char *name)
|
||||
* at a time can be allowed to travel in this direction.
|
||||
* Force Writer semantics.
|
||||
*/
|
||||
hook->flags |= HK_FORCE_WRITER;
|
||||
NG_HOOK_FORCE_WRITER(hook);
|
||||
hookp = &sc->async;
|
||||
} else if (!strcmp(name, NG_ASYNC_HOOK_SYNC)) {
|
||||
/*
|
||||
@ -228,8 +228,7 @@ nga_newhook(node_p node, hook_p hook, const char *name)
|
||||
* we might as well set it for the whole node
|
||||
* bit I haven;t done that (yet).
|
||||
*/
|
||||
hook->flags |= HK_FORCE_WRITER;
|
||||
hookp = &sc->async;
|
||||
NG_HOOK_FORCE_WRITER(hook);
|
||||
hookp = &sc->sync;
|
||||
} else {
|
||||
return (EINVAL);
|
||||
@ -246,10 +245,7 @@ nga_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
nga_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
#ifdef ITEM_DEBUG
|
||||
meta_p meta = NGI_META(item);
|
||||
#endif
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
if (hook == sc->sync)
|
||||
return (nga_rcv_sync(sc, item));
|
||||
@ -264,12 +260,11 @@ nga_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
nga_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const sc_p sc = (sc_p) node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
switch (msg->header.typecookie) {
|
||||
case NGM_ASYNC_COOKIE:
|
||||
@ -347,14 +342,14 @@ nga_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
nga_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
FREE(sc->abuf, M_NETGRAPH);
|
||||
FREE(sc->sbuf, M_NETGRAPH);
|
||||
bzero(sc, sizeof(*sc));
|
||||
FREE(sc, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -364,7 +359,7 @@ nga_shutdown(node_p node)
|
||||
static int
|
||||
nga_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
hook_p *hookp;
|
||||
|
||||
if (hook == sc->async)
|
||||
@ -378,9 +373,9 @@ nga_disconnect(hook_p hook)
|
||||
*hookp = NULL;
|
||||
bzero(&sc->stats, sizeof(sc->stats));
|
||||
sc->lasttime = 0;
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -422,7 +417,7 @@ nga_rcv_sync(const sc_p sc, item_p item)
|
||||
|
||||
/* Check for bypass mode */
|
||||
if (!sc->cfg.enabled) {
|
||||
NG_FWD_DATA(error, item, sc->async );
|
||||
NG_FWD_ITEM_HOOK(error, item, sc->async );
|
||||
return (error);
|
||||
}
|
||||
NGI_GET_M(item, m);
|
||||
@ -510,7 +505,7 @@ nga_rcv_async(const sc_p sc, item_p item)
|
||||
struct mbuf *m;
|
||||
|
||||
if (!sc->cfg.enabled) {
|
||||
NG_FWD_DATA(error, item, sc->sync);
|
||||
NG_FWD_ITEM_HOOK(error, item, sc->sync);
|
||||
return (error);
|
||||
}
|
||||
NGI_GET_M(item, m);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -219,7 +219,7 @@ static const struct ng_bpf_hookprog ng_bpf_default_prog = {
|
||||
static int
|
||||
ng_bpf_constructor(node_p node)
|
||||
{
|
||||
node->private = NULL;
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -237,13 +237,13 @@ ng_bpf_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (hip == NULL)
|
||||
return (ENOMEM);
|
||||
hip->hook = hook;
|
||||
hook->private = hip;
|
||||
NG_HOOK_SET_PRIVATE(hook, hip);
|
||||
hip->node = node;
|
||||
|
||||
/* Attach the default BPF program */
|
||||
if ((error = ng_bpf_setprog(hook, &ng_bpf_default_prog)) != 0) {
|
||||
FREE(hip, M_NETGRAPH);
|
||||
hook->private = NULL;
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ ng_bpf_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
ERROUT(ENOENT);
|
||||
|
||||
/* Build response */
|
||||
hp = ((hinfo_p)hook->private)->prog;
|
||||
hp = ((hinfo_p)NG_HOOK_PRIVATE(hook))->prog;
|
||||
NG_MKRESPONSE(resp, msg,
|
||||
NG_BPF_HOOKPROG_SIZE(hp->bpf_prog_len), M_NOWAIT);
|
||||
if (resp == NULL)
|
||||
@ -329,7 +329,7 @@ ng_bpf_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
/* Find hook */
|
||||
if ((hook = ng_findhook(node, msg->data)) == NULL)
|
||||
ERROUT(ENOENT);
|
||||
stats = &((hinfo_p)hook->private)->stats;
|
||||
stats = &((hinfo_p)NG_HOOK_PRIVATE(hook))->stats;
|
||||
|
||||
/* Build response (if desired) */
|
||||
if (msg->header.cmd != NGM_BPF_CLR_STATS) {
|
||||
@ -371,7 +371,7 @@ ng_bpf_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_bpf_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const hinfo_p hip = hook->private;
|
||||
const hinfo_p hip = NG_HOOK_PRIVATE(hook);
|
||||
int totlen;
|
||||
int needfree = 0, error = 0;
|
||||
u_char *data, buf[256];
|
||||
@ -431,10 +431,10 @@ ng_bpf_rcvdata(hook_p hook, item_p item)
|
||||
}
|
||||
|
||||
/* Deliver frame out destination hook */
|
||||
dhip = (hinfo_p)dest->private;
|
||||
dhip = NG_HOOK_PRIVATE(dest);
|
||||
dhip->stats.xmitOctets += totlen;
|
||||
dhip->stats.xmitFrames++;
|
||||
NG_FWD_DATA(error, item, dest);
|
||||
NG_FWD_ITEM_HOOK(error, item, dest);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -444,8 +444,7 @@ ng_bpf_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_bpf_shutdown(node_p node)
|
||||
{
|
||||
node->flags |= NG_INVALID;
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -455,16 +454,16 @@ ng_bpf_shutdown(node_p node)
|
||||
static int
|
||||
ng_bpf_disconnect(hook_p hook)
|
||||
{
|
||||
const hinfo_p hip = hook->private;
|
||||
const hinfo_p hip = NG_HOOK_PRIVATE(hook);
|
||||
|
||||
KASSERT(hip != NULL, ("%s: null info", __FUNCTION__));
|
||||
FREE(hip->prog, M_NETGRAPH);
|
||||
bzero(hip, sizeof(*hip));
|
||||
FREE(hip, M_NETGRAPH);
|
||||
hook->private = NULL; /* for good measure */
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags && NG_INVALID) == 0)) {
|
||||
ng_rmnode_self(hook->node);
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* for good measure */
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@ -479,7 +478,7 @@ ng_bpf_disconnect(hook_p hook)
|
||||
static int
|
||||
ng_bpf_setprog(hook_p hook, const struct ng_bpf_hookprog *hp0)
|
||||
{
|
||||
const hinfo_p hip = hook->private;
|
||||
const hinfo_p hip = NG_HOOK_PRIVATE(hook);
|
||||
struct ng_bpf_hookprog *hp;
|
||||
int size;
|
||||
|
||||
|
@ -324,12 +324,12 @@ ng_bridge_constructor(node_p node)
|
||||
* When it's fixed the process SHOULD NOT SLEEP, spinlocks please!
|
||||
* (and atomic ops )
|
||||
*/
|
||||
node->flags |= NG_FORCE_WRITER;
|
||||
node->private = priv;
|
||||
NG_NODE_FORCE_WRITER(node);
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
priv->node = node;
|
||||
|
||||
/* Start timer by faking a timeout event */
|
||||
node->refs++; /* XXX ???? because of the timeout?*/
|
||||
NG_NODE_REF(node); /* because the timeout will drop a reference */
|
||||
ng_bridge_timeout(node);
|
||||
return (0);
|
||||
}
|
||||
@ -340,7 +340,7 @@ ng_bridge_constructor(node_p node)
|
||||
static int
|
||||
ng_bridge_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Check for a link hook */
|
||||
if (strncmp(name, NG_BRIDGE_HOOK_LINK_PREFIX,
|
||||
@ -362,7 +362,7 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name)
|
||||
if (priv->links[linkNum] == NULL)
|
||||
return (ENOMEM);
|
||||
priv->links[linkNum]->hook = hook;
|
||||
LINK_NUM(hook) = linkNum;
|
||||
NG_HOOK_SET_PRIVATE(hook, (void *)linkNum);
|
||||
priv->numLinks++;
|
||||
return (0);
|
||||
}
|
||||
@ -377,7 +377,7 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -512,8 +512,8 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_bridge_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_bridge_host *host;
|
||||
struct ng_bridge_link *link;
|
||||
struct ether_header *eh;
|
||||
@ -525,7 +525,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
|
||||
|
||||
NGI_GET_M(item, m);
|
||||
/* Get link number */
|
||||
linkNum = LINK_NUM(hook);
|
||||
linkNum = (int)NG_HOOK_PRIVATE(hook);
|
||||
KASSERT(linkNum >= 0 && linkNum < NG_BRIDGE_MAX_LINKS,
|
||||
("%s: linkNum=%u", __FUNCTION__, linkNum));
|
||||
link = priv->links[linkNum];
|
||||
@ -600,7 +600,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
|
||||
log(LOG_WARNING, "ng_bridge: %s:"
|
||||
" loopback detected on %s%s\n",
|
||||
ng_bridge_nodename(node),
|
||||
hook->name, suffix);
|
||||
NG_HOOK_NAME(hook), suffix);
|
||||
}
|
||||
|
||||
/* Mark link as linka non grata */
|
||||
@ -758,15 +758,15 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_bridge_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
KASSERT(priv->numLinks == 0 && priv->numHosts == 0,
|
||||
("%s: numLinks=%d numHosts=%d",
|
||||
__FUNCTION__, priv->numLinks, priv->numHosts));
|
||||
FREE(priv->tab, M_NETGRAPH);
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -776,11 +776,11 @@ ng_bridge_shutdown(node_p node)
|
||||
static int
|
||||
ng_bridge_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int linkNum;
|
||||
|
||||
/* Get link number */
|
||||
linkNum = LINK_NUM(hook);
|
||||
linkNum = (int)NG_HOOK_PRIVATE(hook);
|
||||
KASSERT(linkNum >= 0 && linkNum < NG_BRIDGE_MAX_LINKS,
|
||||
("%s: linkNum=%u", __FUNCTION__, linkNum));
|
||||
|
||||
@ -794,9 +794,10 @@ ng_bridge_disconnect(hook_p hook)
|
||||
priv->numLinks--;
|
||||
|
||||
/* If no more hooks, go away */
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& (( hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -965,15 +966,15 @@ static void
|
||||
ng_bridge_timeout(void *arg)
|
||||
{
|
||||
const node_p node = arg;
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int s, bucket;
|
||||
int counter = 0;
|
||||
int linkNum;
|
||||
|
||||
/* Avoid race condition with ng_bridge_shutdown() */
|
||||
s = splnet();
|
||||
if ((node->flags & NG_INVALID) != 0 || priv == NULL) {
|
||||
ng_unref(node);
|
||||
if ((NG_NODE_NOT_VALID(node)) || priv == NULL) {
|
||||
NG_NODE_UNREF(node);
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
@ -1045,8 +1046,8 @@ ng_bridge_nodename(node_p node)
|
||||
{
|
||||
static char name[NG_NODELEN+1];
|
||||
|
||||
if (node->name != NULL)
|
||||
snprintf(name, sizeof(name), "%s", node->name);
|
||||
if (NG_NODE_NAME(node) != NULL)
|
||||
snprintf(name, sizeof(name), "%s", NG_NODE_NAME(node));
|
||||
else
|
||||
snprintf(name, sizeof(name), "[%x]", ng_node2ID(node));
|
||||
return name;
|
||||
|
@ -199,7 +199,7 @@ cisco_constructor(node_p node)
|
||||
return (ENOMEM);
|
||||
|
||||
callout_handle_init(&sc->handle);
|
||||
node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(node, sc);
|
||||
sc->node = node;
|
||||
|
||||
/* Initialise the varous protocol hook holders */
|
||||
@ -217,25 +217,25 @@ cisco_constructor(node_p node)
|
||||
static int
|
||||
cisco_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (strcmp(name, NG_CISCO_HOOK_DOWNSTREAM) == 0) {
|
||||
sc->downstream.hook = hook;
|
||||
hook->private = &sc->downstream;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->downstream);
|
||||
|
||||
/* Start keepalives */
|
||||
sc->handle = timeout(cisco_keepalive, sc, hz * KEEPALIVE_SECS);
|
||||
} else if (strcmp(name, NG_CISCO_HOOK_INET) == 0) {
|
||||
sc->inet.hook = hook;
|
||||
hook->private = &sc->inet;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->inet);
|
||||
} else if (strcmp(name, NG_CISCO_HOOK_APPLETALK) == 0) {
|
||||
sc->atalk.hook = hook;
|
||||
hook->private = &sc->atalk;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->atalk);
|
||||
} else if (strcmp(name, NG_CISCO_HOOK_IPX) == 0) {
|
||||
sc->ipx.hook = hook;
|
||||
hook->private = &sc->ipx;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->ipx);
|
||||
} else if (strcmp(name, NG_CISCO_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* unimplemented */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* unimplemented */
|
||||
} else
|
||||
return (EINVAL);
|
||||
return 0;
|
||||
@ -248,7 +248,7 @@ static int
|
||||
cisco_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
struct ng_mesg *msg;
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
|
||||
@ -344,13 +344,13 @@ cisco_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
cisco_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct protoent *pep;
|
||||
struct cisco_header *h;
|
||||
int error = 0;
|
||||
struct mbuf *m;
|
||||
|
||||
if ((pep = hook->private) == NULL)
|
||||
if ((pep = NG_HOOK_PRIVATE(hook)) == NULL)
|
||||
goto out;
|
||||
|
||||
/* If it came from our downlink, deal with it separately */
|
||||
@ -402,11 +402,10 @@ cisco_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
cisco_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
FREE(sc, M_NETGRAPH);
|
||||
return (0);
|
||||
}
|
||||
@ -419,11 +418,11 @@ cisco_shutdown(node_p node)
|
||||
static int
|
||||
cisco_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct protoent *pep;
|
||||
|
||||
/* Check it's not the debug hook */
|
||||
if ((pep = hook->private)) {
|
||||
if ((pep = NG_HOOK_PRIVATE(hook))) {
|
||||
pep->hook = NULL;
|
||||
if (pep->af == 0xffff) {
|
||||
/* If it is the downstream hook, stop the timers */
|
||||
@ -432,9 +431,9 @@ cisco_disconnect(hook_p hook)
|
||||
}
|
||||
|
||||
/* If no more hooks, remove the node */
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -106,7 +107,7 @@ nge_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
NG_FWD_DATA(error, item, hook);
|
||||
NG_FWD_ITEM_HOOK(error, item, hook);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -116,9 +117,9 @@ nge_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
nge_disconnect(hook_p hook)
|
||||
{
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0)) {
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ ng_ether_input(struct ifnet *ifp,
|
||||
struct mbuf **mp, struct ether_header *eh)
|
||||
{
|
||||
const node_p node = IFP2NG(ifp);
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* If "lower" hook not connected, let packet continue */
|
||||
if (priv->lower == NULL || priv->lowerOrphan)
|
||||
@ -229,7 +229,7 @@ ng_ether_input_orphan(struct ifnet *ifp,
|
||||
struct mbuf *m, struct ether_header *eh)
|
||||
{
|
||||
const node_p node = IFP2NG(ifp);
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* If "orphan" hook not connected, let packet continue */
|
||||
if (priv->lower == NULL || !priv->lowerOrphan) {
|
||||
@ -251,7 +251,7 @@ ng_ether_input_orphan(struct ifnet *ifp,
|
||||
static void
|
||||
ng_ether_input2(node_p node, struct mbuf **mp, struct ether_header *eh)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int error;
|
||||
|
||||
/* Glue Ethernet header back on */
|
||||
@ -271,7 +271,7 @@ static int
|
||||
ng_ether_output(struct ifnet *ifp, struct mbuf **mp)
|
||||
{
|
||||
const node_p node = IFP2NG(ifp);
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int error = 0;
|
||||
|
||||
/* If "upper" hook not connected, let packet continue */
|
||||
@ -308,10 +308,10 @@ ng_ether_attach(struct ifnet *ifp)
|
||||
if (priv == NULL) {
|
||||
log(LOG_ERR, "%s: can't %s for %s\n",
|
||||
__FUNCTION__, "allocate memory", name);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
return;
|
||||
}
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
priv->ifp = ifp;
|
||||
IFP2NG(ifp) = node;
|
||||
priv->autoSrcAddr = 1;
|
||||
@ -336,13 +336,12 @@ ng_ether_detach(struct ifnet *ifp)
|
||||
if (node == NULL) /* no node (why not?), ignore */
|
||||
return;
|
||||
ng_rmnode_self(node); /* break all links to other nodes */
|
||||
node->flags |= NG_INVALID;
|
||||
IFP2NG(ifp) = NULL; /* detach node from interface */
|
||||
priv = node->private; /* free node private info */
|
||||
priv = NG_NODE_PRIVATE(node); /* free node private info */
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node); /* free node itself */
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node); /* free node itself */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -441,7 +440,7 @@ ng_ether_constructor(node_p node)
|
||||
static int
|
||||
ng_ether_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
u_char orphan = priv->lowerOrphan;
|
||||
hook_p *hookptr;
|
||||
|
||||
@ -479,7 +478,7 @@ ng_ether_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_ether_connect(hook_p hook)
|
||||
{
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -489,7 +488,7 @@ ng_ether_connect(hook_p hook)
|
||||
static int
|
||||
ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -593,8 +592,8 @@ ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_ether_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
|
||||
@ -614,7 +613,7 @@ ng_ether_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Make sure header is fully pulled up */
|
||||
if (m->m_pkthdr.len < sizeof(struct ether_header)) {
|
||||
@ -646,7 +645,7 @@ ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta)
|
||||
static int
|
||||
ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ether_header *eh;
|
||||
|
||||
/* Check length and pull off header */
|
||||
@ -681,13 +680,13 @@ static int
|
||||
ng_ether_shutdown(node_p node)
|
||||
{
|
||||
char name[IFNAMSIZ + 1];
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (priv->promisc) { /* disable promiscuous mode */
|
||||
(void)ifpromisc(priv->ifp, 0);
|
||||
priv->promisc = 0;
|
||||
}
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
snprintf(name, sizeof(name), "%s%d", priv->ifp->if_name, priv->ifp->if_unit);
|
||||
if (ng_make_node_common(&ng_ether_typestruct, &node) != 0) {
|
||||
log(LOG_ERR, "%s: can't %s for %s\n",
|
||||
@ -696,7 +695,7 @@ ng_ether_shutdown(node_p node)
|
||||
}
|
||||
|
||||
/* Allocate private data */
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
IFP2NG(priv->ifp) = node;
|
||||
priv->autoSrcAddr = 1; /* reset auto-src-addr flag */
|
||||
|
||||
@ -714,7 +713,7 @@ ng_ether_shutdown(node_p node)
|
||||
static int
|
||||
ng_ether_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
if (hook == priv->upper)
|
||||
priv->upper = NULL;
|
||||
@ -723,9 +722,9 @@ ng_ether_disconnect(hook_p hook)
|
||||
priv->lowerOrphan = 0;
|
||||
} else
|
||||
panic("%s: weird hook", __FUNCTION__);
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node); /* reset node */
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook)); /* reset node */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ ngfrm_constructor(node_p node)
|
||||
sc->addrlen = 2; /* default */
|
||||
|
||||
/* Link the node and our private info */
|
||||
node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(node, sc);
|
||||
sc->node = node;
|
||||
return (0);
|
||||
}
|
||||
@ -237,7 +237,7 @@ ngfrm_constructor(node_p node)
|
||||
static int
|
||||
ngfrm_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
const char *cp;
|
||||
char *eptr;
|
||||
int dlci = 0;
|
||||
@ -245,7 +245,7 @@ ngfrm_newhook(node_p node, hook_p hook, const char *name)
|
||||
|
||||
/* Check if it's our friend the control hook */
|
||||
if (strcmp(name, NG_FRAMERELAY_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL; /* paranoid */
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL); /* paranoid */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ ngfrm_newhook(node_p node, hook_p hook, const char *name)
|
||||
return (EADDRINUSE);
|
||||
|
||||
/* OK add it */
|
||||
hook->private = &sc->downstream;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->downstream);
|
||||
sc->downstream.hook = hook;
|
||||
sc->downstream.dlci = -1;
|
||||
sc->downstream.flags |= CHAN_ACTIVE;
|
||||
@ -303,7 +303,7 @@ ngfrm_newhook(node_p node, hook_p hook, const char *name)
|
||||
* Put our hooks into it (pun not intended)
|
||||
*/
|
||||
sc->channel[ctxnum].flags |= CHAN_ACTIVE;
|
||||
hook->private = sc->channel + ctxnum;
|
||||
NG_HOOK_SET_PRIVATE(hook, sc->channel + ctxnum);
|
||||
sc->channel[ctxnum].hook = hook;
|
||||
sc->datahooks++;
|
||||
return (0);
|
||||
@ -332,7 +332,7 @@ ngfrm_addrlen(char *hdr)
|
||||
static int
|
||||
ngfrm_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
struct ctxinfo *const ctxp = hook->private;
|
||||
struct ctxinfo *const ctxp = NG_HOOK_PRIVATE(hook);
|
||||
int error = 0;
|
||||
int dlci;
|
||||
sc_p sc;
|
||||
@ -349,11 +349,11 @@ ngfrm_rcvdata(hook_p hook, item_p item)
|
||||
/* If coming from downstream, decode it to a channel */
|
||||
dlci = ctxp->dlci;
|
||||
if (dlci == -1)
|
||||
return (ngfrm_decode(hook->node, item));
|
||||
return (ngfrm_decode(NG_HOOK_NODE(hook), item));
|
||||
|
||||
NGI_GET_M(item, m);
|
||||
/* Derive the softc we will need */
|
||||
sc = hook->node->private;
|
||||
sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
/* If there is no live channel, throw it away */
|
||||
if ((sc->downstream.hook == NULL)
|
||||
@ -419,7 +419,7 @@ ngfrm_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngfrm_decode(node_p node, item_p item)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
char *data;
|
||||
int alen;
|
||||
u_int dlci = 0;
|
||||
@ -482,12 +482,11 @@ ngfrm_decode(node_p node, item_p item)
|
||||
static int
|
||||
ngfrm_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
FREE(sc, M_NETGRAPH);
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -500,8 +499,8 @@ ngfrm_shutdown(node_p node)
|
||||
static int
|
||||
ngfrm_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
struct ctxinfo *const cp = hook->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ctxinfo *const cp = NG_HOOK_PRIVATE(hook);
|
||||
int dlci;
|
||||
|
||||
/* If it's a regular dlci hook, then free resources etc.. */
|
||||
@ -513,8 +512,8 @@ ngfrm_disconnect(hook_p hook)
|
||||
cp->flags = 0;
|
||||
sc->datahooks--;
|
||||
}
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -98,7 +99,7 @@ ngh_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngh_disconnect(hook_p hook)
|
||||
{
|
||||
if (hook->node->numhooks == 0)
|
||||
ng_rmnode_self(hook->node);
|
||||
if (NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ ng_iface_constructor(node_p node)
|
||||
}
|
||||
|
||||
/* Link together node and private info */
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
priv->node = node;
|
||||
|
||||
/* Initialize interface structure */
|
||||
@ -594,7 +594,7 @@ ng_iface_newhook(node_p node, hook_p hook, const char *name)
|
||||
|
||||
if (iffam == NULL)
|
||||
return (EPFNOSUPPORT);
|
||||
hookptr = get_hook_from_iffam((priv_p) node->private, iffam);
|
||||
hookptr = get_hook_from_iffam(NG_NODE_PRIVATE(node), iffam);
|
||||
if (*hookptr != NULL)
|
||||
return (EISCONN);
|
||||
*hookptr = hook;
|
||||
@ -607,7 +607,7 @@ ng_iface_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ifnet *const ifp = priv->ifp;
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
@ -709,7 +709,7 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_iface_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
const iffam_p iffam = get_iffam_from_hook(priv, hook);
|
||||
struct ifnet *const ifp = priv->ifp;
|
||||
struct mbuf *m;
|
||||
@ -746,15 +746,15 @@ ng_iface_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_iface_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
bpfdetach(priv->ifp);
|
||||
if_detach(priv->ifp);
|
||||
priv->ifp = NULL;
|
||||
ng_iface_free_unit(priv->unit);
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ ng_iface_shutdown(node_p node)
|
||||
static int
|
||||
ng_iface_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
const iffam_p iffam = get_iffam_from_hook(priv, hook);
|
||||
|
||||
if (iffam == NULL)
|
||||
|
@ -493,7 +493,7 @@ ng_ksocket_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
@ -511,7 +511,7 @@ static int
|
||||
ng_ksocket_newhook(node_p node, hook_p hook, const char *name0)
|
||||
{
|
||||
struct proc *p = curproc ? curproc : &proc0; /* XXX broken */
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
char *s1, *s2, name[NG_HOOKLEN+1];
|
||||
int family, type, protocol, error;
|
||||
|
||||
@ -560,7 +560,7 @@ static int
|
||||
ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
struct proc *p = curproc ? curproc : &proc0; /* XXX broken */
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct socket *const so = priv->so;
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
@ -774,8 +774,8 @@ static int
|
||||
ng_ksocket_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
struct proc *p = curproc ? curproc : &proc0; /* XXX broken */
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct socket *const so = priv->so;
|
||||
int error;
|
||||
struct mbuf *m;
|
||||
@ -792,7 +792,7 @@ ng_ksocket_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_ksocket_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Close our socket (if any) */
|
||||
if (priv->so != NULL) {
|
||||
@ -804,11 +804,10 @@ ng_ksocket_shutdown(node_p node)
|
||||
}
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node); /* let the node escape */
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node); /* let the node escape */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -818,10 +817,10 @@ ng_ksocket_shutdown(node_p node)
|
||||
static int
|
||||
ng_ksocket_disconnect(hook_p hook)
|
||||
{
|
||||
KASSERT(hook->node->numhooks == 0,
|
||||
("%s: numhooks=%d?", __FUNCTION__, hook->node->numhooks));
|
||||
if ((hook->node->flags & NG_INVALID) == 0)
|
||||
ng_rmnode_self(hook->node);
|
||||
KASSERT(NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0,
|
||||
("%s: numhooks=%d?", __FUNCTION__, NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook))));
|
||||
if (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -836,7 +835,7 @@ static void
|
||||
ng_ksocket_incoming(struct socket *so, void *arg, int waitflag)
|
||||
{
|
||||
const node_p node = arg;
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct mbuf *m;
|
||||
struct uio auio;
|
||||
int s, flags, error;
|
||||
@ -844,7 +843,7 @@ ng_ksocket_incoming(struct socket *so, void *arg, int waitflag)
|
||||
s = splnet();
|
||||
|
||||
/* Sanity check */
|
||||
if ((node->flags & NG_INVALID) != 0) {
|
||||
if (NG_NODE_NOT_VALID(node)) {
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ nglmi_constructor(node_p node)
|
||||
if (sc == NULL)
|
||||
return (ENOMEM);
|
||||
callout_handle_init(&sc->handle);
|
||||
node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(node, sc);
|
||||
sc->protoname = NAME_NONE;
|
||||
sc->node = node;
|
||||
sc->liv_per_full = NG_LMI_SEQ_PER_FULL; /* make this dynamic */
|
||||
@ -207,10 +207,10 @@ nglmi_constructor(node_p node)
|
||||
static int
|
||||
nglmi_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
sc_p sc = node->private;
|
||||
sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (strcmp(name, NG_LMI_HOOK_DEBUG) == 0) {
|
||||
hook->private = NULL;
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
return (0);
|
||||
}
|
||||
if (sc->flags & SCF_CONNECTED) {
|
||||
@ -219,21 +219,21 @@ nglmi_newhook(node_p node, hook_p hook, const char *name)
|
||||
}
|
||||
if (strcmp(name, NG_LMI_HOOK_ANNEXA) == 0) {
|
||||
sc->lmi_annexA = hook;
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
sc->protoID = 8;
|
||||
SETLMITYPE(sc, SCF_ANNEX_A);
|
||||
sc->protoname = NAME_ANNEXA;
|
||||
nglmi_startup_fixed(sc, hook);
|
||||
} else if (strcmp(name, NG_LMI_HOOK_ANNEXD) == 0) {
|
||||
sc->lmi_annexD = hook;
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
sc->protoID = 8;
|
||||
SETLMITYPE(sc, SCF_ANNEX_D);
|
||||
sc->protoname = NAME_ANNEXD;
|
||||
nglmi_startup_fixed(sc, hook);
|
||||
} else if (strcmp(name, NG_LMI_HOOK_GROUPOF4) == 0) {
|
||||
sc->lmi_group4 = hook;
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
sc->protoID = 9;
|
||||
SETLMITYPE(sc, SCF_GROUP4);
|
||||
sc->protoname = NAME_GROUP4;
|
||||
@ -242,14 +242,14 @@ nglmi_newhook(node_p node, hook_p hook, const char *name)
|
||||
/* Note this, and if B is already installed, we're complete */
|
||||
sc->lmi_channel0 = hook;
|
||||
sc->protoname = NAME_NONE;
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
if (sc->lmi_channel1023)
|
||||
nglmi_startup_auto(sc);
|
||||
} else if (strcmp(name, NG_LMI_HOOK_AUTO1023) == 0) {
|
||||
/* Note this, and if A is already installed, we're complete */
|
||||
sc->lmi_channel1023 = hook;
|
||||
sc->protoname = NAME_NONE;
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
if (sc->lmi_channel0)
|
||||
nglmi_startup_auto(sc);
|
||||
} else
|
||||
@ -445,7 +445,7 @@ ngauto_state_machine(sc_p sc)
|
||||
static int
|
||||
nglmi_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
sc_p sc = node->private;
|
||||
sc_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -557,7 +557,7 @@ nglmi_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
nglmi_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
sc_p sc = hook->node->private;
|
||||
sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
u_char *data;
|
||||
unsigned short dlci;
|
||||
u_short packetlen;
|
||||
@ -567,7 +567,7 @@ nglmi_rcvdata(hook_p hook, item_p item)
|
||||
|
||||
NGI_GET_M(item, m);
|
||||
NG_FREE_ITEM(item);
|
||||
if (hook->private == NULL) {
|
||||
if (NG_HOOK_PRIVATE(hook) == NULL) {
|
||||
goto drop;
|
||||
}
|
||||
packetlen = m->m_hdr.mh_len;
|
||||
@ -742,7 +742,7 @@ nglmi_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
nglmi_checkdata(hook_p hook, struct mbuf *m)
|
||||
{
|
||||
sc_p sc = hook->node->private;
|
||||
sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
u_char *data;
|
||||
u_short packetlen;
|
||||
unsigned short dlci;
|
||||
@ -1055,11 +1055,10 @@ nglmi_checkdata(hook_p hook, struct mbuf *m)
|
||||
static int
|
||||
nglmi_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
FREE(sc, M_NETGRAPH);
|
||||
return (0);
|
||||
}
|
||||
@ -1071,10 +1070,10 @@ nglmi_shutdown(node_p node)
|
||||
static int
|
||||
nglmi_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
/* OK to remove debug hook(s) */
|
||||
if (hook->private == NULL)
|
||||
if (NG_HOOK_PRIVATE(hook) == NULL)
|
||||
return (0);
|
||||
|
||||
/* Stop timer if it's currently active */
|
||||
@ -1082,8 +1081,8 @@ nglmi_disconnect(hook_p hook)
|
||||
untimeout(LMI_ticker, sc, sc->handle);
|
||||
|
||||
/* Self-destruct */
|
||||
if ((hook->node->flags & NG_INVALID) == 0)
|
||||
ng_rmnode_self(hook->node);
|
||||
if (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ ng_mppc_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
@ -192,7 +192,7 @@ ng_mppc_constructor(node_p node)
|
||||
static int
|
||||
ng_mppc_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
hook_p *hookPtr;
|
||||
|
||||
/* Check hook name */
|
||||
@ -218,7 +218,7 @@ ng_mppc_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_mppc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -328,8 +328,8 @@ ng_mppc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_mppc_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct mbuf *out;
|
||||
int error;
|
||||
struct mbuf *m;
|
||||
@ -390,10 +390,9 @@ ng_mppc_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_mppc_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
#ifdef NETGRAPH_MPPC_COMPRESSION
|
||||
if (priv->xmit.history != NULL)
|
||||
FREE(priv->xmit.history, M_NETGRAPH);
|
||||
@ -402,8 +401,8 @@ ng_mppc_shutdown(node_p node)
|
||||
#endif
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node); /* let the node escape */
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node); /* let the node escape */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -413,8 +412,8 @@ ng_mppc_shutdown(node_p node)
|
||||
static int
|
||||
ng_mppc_disconnect(hook_p hook)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Zero out hook pointer */
|
||||
if (hook == priv->xmit.hook)
|
||||
@ -423,8 +422,8 @@ ng_mppc_disconnect(hook_p hook)
|
||||
priv->recv.hook = NULL;
|
||||
|
||||
/* Go away if no longer connected */
|
||||
if ((node->numhooks == 0)
|
||||
&& ((node->flags & NG_INVALID) == 0))
|
||||
if ((NG_NODE_NUMHOOKS(node) == 0)
|
||||
&& NG_NODE_IS_VALID(node))
|
||||
ng_rmnode_self(node);
|
||||
return (0);
|
||||
}
|
||||
@ -440,7 +439,7 @@ ng_mppc_disconnect(hook_p hook)
|
||||
static int
|
||||
ng_mppc_compress(node_p node, struct mbuf *m, struct mbuf **resultp)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mppc_dir *const d = &priv->xmit;
|
||||
u_char *inbuf, *outbuf;
|
||||
int outlen, inlen;
|
||||
@ -556,7 +555,7 @@ ng_mppc_compress(node_p node, struct mbuf *m, struct mbuf **resultp)
|
||||
static int
|
||||
ng_mppc_decompress(node_p node, struct mbuf *m, struct mbuf **resultp)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mppc_dir *const d = &priv->recv;
|
||||
u_int16_t header, cc, numLost;
|
||||
u_char *buf;
|
||||
@ -719,7 +718,7 @@ ng_mppc_decompress(node_p node, struct mbuf *m, struct mbuf **resultp)
|
||||
static void
|
||||
ng_mppc_reset_req(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mppc_dir *const d = &priv->xmit;
|
||||
|
||||
#ifdef NETGRAPH_MPPC_COMPRESSION
|
||||
|
@ -196,7 +196,7 @@ ng_one2many_constructor(node_p node)
|
||||
priv->conf.xmitAlg = NG_ONE2MANY_XMIT_ROUNDROBIN;
|
||||
priv->conf.failAlg = NG_ONE2MANY_FAIL_MANUAL;
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
@ -208,7 +208,7 @@ ng_one2many_constructor(node_p node)
|
||||
static int
|
||||
ng_one2many_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_one2many_link *link;
|
||||
int linkNum;
|
||||
u_long i;
|
||||
@ -238,7 +238,7 @@ ng_one2many_newhook(node_p node, hook_p hook, const char *name)
|
||||
return (EISCONN);
|
||||
|
||||
/* Setup private info for this link */
|
||||
LINK_NUM(hook) = linkNum;
|
||||
NG_HOOK_SET_PRIVATE(hook, (void *)linkNum);
|
||||
link->hook = hook;
|
||||
bzero(&link->stats, sizeof(link->stats));
|
||||
if (linkNum != NG_ONE2MANY_ONE_LINKNUM) {
|
||||
@ -256,7 +256,7 @@ ng_one2many_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_one2many_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -375,8 +375,8 @@ ng_one2many_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_one2many_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_one2many_link *src;
|
||||
struct ng_one2many_link *dst;
|
||||
int error = 0;
|
||||
@ -385,7 +385,7 @@ ng_one2many_rcvdata(hook_p hook, item_p item)
|
||||
|
||||
m = NGI_M(item); /* just peaking, mbuf still owned by item */
|
||||
/* Get link number */
|
||||
linkNum = LINK_NUM(hook);
|
||||
linkNum = (int)NG_HOOK_PRIVATE(hook);
|
||||
KASSERT(linkNum == NG_ONE2MANY_ONE_LINKNUM
|
||||
|| (linkNum >= 0 && linkNum < NG_ONE2MANY_MAX_LINKS),
|
||||
("%s: linkNum=%d", __FUNCTION__, linkNum));
|
||||
@ -415,7 +415,7 @@ ng_one2many_rcvdata(hook_p hook, item_p item)
|
||||
dst->stats.xmitOctets += m->m_pkthdr.len;
|
||||
|
||||
/* Deliver packet */
|
||||
NG_FWD_DATA(error, item, dst->hook);
|
||||
NG_FWD_ITEM_HOOK(error, item, dst->hook);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -425,13 +425,13 @@ ng_one2many_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_one2many_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
KASSERT(priv->numActiveMany == 0,
|
||||
("%s: numActiveMany=%d", __FUNCTION__, priv->numActiveMany));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -441,11 +441,11 @@ ng_one2many_shutdown(node_p node)
|
||||
static int
|
||||
ng_one2many_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int linkNum;
|
||||
|
||||
/* Get link number */
|
||||
linkNum = LINK_NUM(hook);
|
||||
linkNum = (int)NG_HOOK_PRIVATE(hook);
|
||||
KASSERT(linkNum == NG_ONE2MANY_ONE_LINKNUM
|
||||
|| (linkNum >= 0 && linkNum < NG_ONE2MANY_MAX_LINKS),
|
||||
("%s: linkNum=%d", __FUNCTION__, linkNum));
|
||||
@ -460,9 +460,9 @@ ng_one2many_disconnect(hook_p hook)
|
||||
}
|
||||
|
||||
/* If no hooks left, go away */
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,10 @@ static const char *const ng_ppp_hook_names[] = {
|
||||
|
||||
/* We store index numbers in the hook private pointer. The HOOK_INDEX()
|
||||
for a hook is either the index (above) for normal hooks, or the ones
|
||||
complement of the link number for link hooks. */
|
||||
complement of the link number for link hooks.
|
||||
XXX Not any more.. (what a hack)
|
||||
#define HOOK_INDEX(hook) (*((int16_t *) &(hook)->private))
|
||||
*/
|
||||
|
||||
/* Per-link private information */
|
||||
struct ng_ppp_link {
|
||||
@ -384,7 +386,7 @@ ng_ppp_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Initialize state */
|
||||
TAILQ_INIT(&priv->frags);
|
||||
@ -402,7 +404,7 @@ ng_ppp_constructor(node_p node)
|
||||
static int
|
||||
ng_ppp_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int linkNum = -1;
|
||||
hook_p *hookPtr = NULL;
|
||||
int hookIndex = -1;
|
||||
@ -446,7 +448,7 @@ ng_ppp_newhook(node_p node, hook_p hook, const char *name)
|
||||
|
||||
/* OK */
|
||||
*hookPtr = hook;
|
||||
HOOK_INDEX(hook) = hookIndex;
|
||||
NG_HOOK_SET_PRIVATE(hook, (void *)hookIndex);
|
||||
ng_ppp_update(node, 0);
|
||||
return (0);
|
||||
}
|
||||
@ -457,7 +459,7 @@ ng_ppp_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -553,11 +555,16 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
/*
|
||||
* Forward it to the vjc node. leave the
|
||||
* old return address alone.
|
||||
* If we have no hook, let NG_RESPOND_MSG
|
||||
* clean up any remaining resources.
|
||||
* Because we have no resp, the item will be freed
|
||||
* along with anything it references. Don't
|
||||
* let msg be freed twice.
|
||||
*/
|
||||
NGI_MSG(item) = msg; /* put it back in the item */
|
||||
if (priv->links[HOOK_INDEX_VJC_IP].hook) {
|
||||
NG_FWD_MSG_HOOK(error, NULL, item,
|
||||
priv->links[HOOK_INDEX_VJC_IP].hook, NULL);
|
||||
msg = NULL;
|
||||
if ((lasthook = priv->links[HOOK_INDEX_VJC_IP].hook)) {
|
||||
NG_FWD_ITEM_HOOK(error, item, lasthook);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
@ -577,9 +584,9 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_ppp_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const int index = HOOK_INDEX(hook);
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
const int index = (int)NG_HOOK_PRIVATE(hook);
|
||||
u_int16_t linkNum = NG_PPP_BUNDLE_LINKNUM;
|
||||
hook_p outHook = NULL;
|
||||
int proto = 0, error;
|
||||
@ -780,13 +787,7 @@ ng_ppp_rcvdata(hook_p hook, item_p item)
|
||||
}
|
||||
|
||||
/* Send packet out hook */
|
||||
NG_FWD_DATA(error, item, outHook);
|
||||
#if 0
|
||||
/* help archie... what's going on? */
|
||||
/* Looks like you were acrually USING the stub functions
|
||||
(now gone again) */
|
||||
return ng_ppp_rcvdata(outHook, item);
|
||||
#endif
|
||||
NG_FWD_ITEM_HOOK(error, item, outHook);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -796,18 +797,17 @@ ng_ppp_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_ppp_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Stop fragment queue timer */
|
||||
ng_ppp_stop_frag_timer(node);
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
ng_ppp_frag_reset(node);
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node); /* let the node escape */
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node); /* let the node escape */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -817,9 +817,9 @@ ng_ppp_shutdown(node_p node)
|
||||
static int
|
||||
ng_ppp_disconnect(hook_p hook)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const int index = HOOK_INDEX(hook);
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
const int index = (int)NG_HOOK_PRIVATE(hook);
|
||||
|
||||
/* Zero out hook pointer */
|
||||
if (index < 0)
|
||||
@ -828,10 +828,10 @@ ng_ppp_disconnect(hook_p hook)
|
||||
priv->hooks[index] = NULL;
|
||||
|
||||
/* Update derived info (or go away if no hooks left) */
|
||||
if (node->numhooks > 0) {
|
||||
if (NG_NODE_NUMHOOKS(node) > 0) {
|
||||
ng_ppp_update(node, 0);
|
||||
} else {
|
||||
if ((node->flags & NG_INVALID) == 0) {
|
||||
if (NG_NODE_IS_VALID(node)) {
|
||||
ng_rmnode_self(node);
|
||||
}
|
||||
}
|
||||
@ -849,7 +849,7 @@ ng_ppp_disconnect(hook_p hook)
|
||||
static int
|
||||
ng_ppp_input(node_p node, int bypass, int linkNum, item_p item)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
hook_p outHook = NULL;
|
||||
int proto, error;
|
||||
struct mbuf *m;
|
||||
@ -947,7 +947,7 @@ static int
|
||||
ng_ppp_output(node_p node, int bypass,
|
||||
int proto, int linkNum, item_p item)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_link *link;
|
||||
int len, error;
|
||||
struct mbuf *m;
|
||||
@ -1070,7 +1070,7 @@ ng_ppp_output(node_p node, int bypass,
|
||||
static int
|
||||
ng_ppp_mp_input(node_p node, int linkNum, item_p item)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_link *const link = &priv->links[linkNum];
|
||||
struct ng_ppp_frag frag0, *frag = &frag0;
|
||||
struct ng_ppp_frag *qent;
|
||||
@ -1190,7 +1190,7 @@ ng_ppp_mp_input(node_p node, int linkNum, item_p item)
|
||||
static int
|
||||
ng_ppp_check_packet(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_frag *qent, *qnext;
|
||||
|
||||
/* Check for empty queue */
|
||||
@ -1223,7 +1223,7 @@ ng_ppp_check_packet(node_p node)
|
||||
static void
|
||||
ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_frag *qent, *qnext;
|
||||
struct mbuf *m = NULL, *tail;
|
||||
|
||||
@ -1261,7 +1261,7 @@ ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap)
|
||||
static int
|
||||
ng_ppp_frag_trim(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_frag *qent, *qnext = NULL;
|
||||
int removed = 0;
|
||||
|
||||
@ -1311,7 +1311,7 @@ ng_ppp_frag_trim(node_p node)
|
||||
static int
|
||||
ng_ppp_frag_process(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct mbuf *m;
|
||||
meta_p meta;
|
||||
item_p item;
|
||||
@ -1389,7 +1389,7 @@ ng_ppp_frag_process(node_p node)
|
||||
static void
|
||||
ng_ppp_frag_checkstale(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_frag *qent, *beg, *end;
|
||||
struct timeval now, age;
|
||||
struct mbuf *m;
|
||||
@ -1474,12 +1474,12 @@ static void
|
||||
ng_ppp_frag_timeout(void *arg)
|
||||
{
|
||||
const node_p node = arg;
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int s = splnet();
|
||||
|
||||
/* Handle the race where shutdown happens just before splnet() above */
|
||||
if ((node->flags & NG_INVALID) != 0) {
|
||||
ng_unref(node);
|
||||
if (NG_NODE_NOT_VALID(node)) {
|
||||
NG_NODE_UNREF(node);
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
@ -1487,8 +1487,8 @@ ng_ppp_frag_timeout(void *arg)
|
||||
/* Reset timer state after timeout */
|
||||
KASSERT(priv->timerActive, ("%s: !timerActive", __FUNCTION__));
|
||||
priv->timerActive = 0;
|
||||
KASSERT(node->refs > 1, ("%s: refs=%d", __FUNCTION__, node->refs));
|
||||
ng_unref(node);
|
||||
KASSERT(node->nd_refs > 1, ("%s: nd_refs=%d", __FUNCTION__, node->nd_refs));
|
||||
NG_NODE_UNREF(node);
|
||||
|
||||
/* Start timer again */
|
||||
ng_ppp_start_frag_timer(node);
|
||||
@ -1505,7 +1505,7 @@ ng_ppp_frag_timeout(void *arg)
|
||||
static int
|
||||
ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int distrib[NG_PPP_MAX_LINKS];
|
||||
int firstFragment;
|
||||
int activeLinkNum;
|
||||
@ -1720,7 +1720,7 @@ ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta)
|
||||
static void
|
||||
ng_ppp_mp_strategy(node_p node, int len, int *distrib)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int latency[NG_PPP_MAX_LINKS];
|
||||
int sortByLatency[NG_PPP_MAX_LINKS];
|
||||
int activeLinkNum;
|
||||
@ -1906,7 +1906,7 @@ ng_ppp_prepend(struct mbuf *m, const void *buf, int len)
|
||||
static void
|
||||
ng_ppp_update(node_p node, int newConf)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int i;
|
||||
|
||||
/* Update active status for VJ Compression */
|
||||
@ -1983,7 +1983,7 @@ ng_ppp_update(node_p node, int newConf)
|
||||
static int
|
||||
ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int i, newNumLinksActive;
|
||||
|
||||
/* Check per-link config and count how many links would be active */
|
||||
@ -2029,7 +2029,7 @@ ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf)
|
||||
static void
|
||||
ng_ppp_frag_reset(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_ppp_frag *qent, *qnext;
|
||||
|
||||
for (qent = TAILQ_FIRST(&priv->frags); qent; qent = qnext) {
|
||||
@ -2048,13 +2048,13 @@ ng_ppp_frag_reset(node_p node)
|
||||
static void
|
||||
ng_ppp_start_frag_timer(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (!priv->timerActive) {
|
||||
priv->fragTimer = timeout(ng_ppp_frag_timeout,
|
||||
node, MP_FRAGTIMER_INTERVAL);
|
||||
priv->timerActive = 1;
|
||||
node->refs++;
|
||||
NG_NODE_REF(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2064,14 +2064,14 @@ ng_ppp_start_frag_timer(node_p node)
|
||||
static void
|
||||
ng_ppp_stop_frag_timer(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (priv->timerActive) {
|
||||
untimeout(ng_ppp_frag_timeout, node, priv->fragTimer);
|
||||
priv->timerActive = 0;
|
||||
KASSERT(node->refs > 1,
|
||||
("%s: refs=%d", __FUNCTION__, node->refs));
|
||||
ng_unref(node);
|
||||
KASSERT(node->nd_refs > 1,
|
||||
("%s: nd_refs=%d", __FUNCTION__, node->nd_refs));
|
||||
NG_NODE_UNREF(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ get_new_sid(node_p node)
|
||||
sessp sp;
|
||||
hook_p hook;
|
||||
u_int16_t val;
|
||||
priv_p privp = node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
|
||||
AAA
|
||||
restart:
|
||||
@ -278,12 +278,12 @@ AAA
|
||||
}
|
||||
|
||||
/* Check it isn't already in use */
|
||||
LIST_FOREACH(hook, &node->hooks, hooks) {
|
||||
LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
|
||||
/* don't check special hooks */
|
||||
if ((hook->private == &privp->debug_hook)
|
||||
|| (hook->private == &privp->ethernet_hook))
|
||||
if ((NG_HOOK_PRIVATE(hook) == &privp->debug_hook)
|
||||
|| (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook))
|
||||
continue;
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
if (sp->Session_ID == val)
|
||||
goto restart;
|
||||
}
|
||||
@ -423,17 +423,17 @@ pppoe_match_svc(node_p node, char *svc_name, int svc_len)
|
||||
{
|
||||
sessp sp = NULL;
|
||||
negp neg = NULL;
|
||||
priv_p privp = node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
hook_p hook;
|
||||
|
||||
AAA
|
||||
LIST_FOREACH(hook, &node->hooks, hooks) {
|
||||
LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
|
||||
|
||||
/* skip any hook that is debug or ethernet */
|
||||
if ((hook->private == &privp->debug_hook)
|
||||
|| (hook->private == &privp->ethernet_hook))
|
||||
if ((NG_HOOK_PRIVATE(hook) == &privp->debug_hook)
|
||||
|| (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook))
|
||||
continue;
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
|
||||
/* Skip any sessions which are not in LISTEN mode. */
|
||||
if ( sp->state != PPPOE_LISTENING)
|
||||
@ -471,20 +471,20 @@ pppoe_findsession(node_p node, struct pppoe_full_hdr *wh)
|
||||
{
|
||||
sessp sp = NULL;
|
||||
hook_p hook = NULL;
|
||||
priv_p privp = node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
u_int16_t session = ntohs(wh->ph.sid);
|
||||
|
||||
/*
|
||||
* find matching peer/session combination.
|
||||
*/
|
||||
AAA
|
||||
LIST_FOREACH(hook, &node->hooks, hooks) {
|
||||
LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
|
||||
/* don't check special hooks */
|
||||
if ((hook->private == &privp->debug_hook)
|
||||
|| (hook->private == &privp->ethernet_hook)) {
|
||||
if ((NG_HOOK_PRIVATE(hook) == &privp->debug_hook)
|
||||
|| (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook)) {
|
||||
continue;
|
||||
}
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
if ( ( (sp->state == PPPOE_CONNECTED)
|
||||
|| (sp->state == PPPOE_NEWCONNECTED) )
|
||||
&& (sp->Session_ID == session)
|
||||
@ -501,18 +501,18 @@ static hook_p
|
||||
pppoe_finduniq(node_p node, struct pppoe_tag *tag)
|
||||
{
|
||||
hook_p hook = NULL;
|
||||
priv_p privp = node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
union uniq uniq;
|
||||
|
||||
AAA
|
||||
bcopy(tag->tag_data, uniq.bytes, sizeof(void *));
|
||||
/* cycle through all known hooks */
|
||||
LIST_FOREACH(hook, &node->hooks, hooks) {
|
||||
LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
|
||||
/* don't check special hooks */
|
||||
if ((hook->private == &privp->debug_hook)
|
||||
|| (hook->private == &privp->ethernet_hook))
|
||||
if ((NG_HOOK_PRIVATE(hook) == &privp->debug_hook)
|
||||
|| (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook))
|
||||
continue;
|
||||
if (uniq.pointer == hook->private)
|
||||
if (uniq.pointer == NG_HOOK_PRIVATE(hook))
|
||||
break;
|
||||
}
|
||||
return (hook);
|
||||
@ -544,7 +544,7 @@ AAA
|
||||
return (ENOMEM);
|
||||
|
||||
/* Link structs together; this counts as our one reference to *nodep */
|
||||
node->private = privdata;
|
||||
NG_NODE_SET_PRIVATE(node, privdata);
|
||||
privdata->node = node;
|
||||
return (0);
|
||||
}
|
||||
@ -561,16 +561,16 @@ AAA
|
||||
static int
|
||||
ng_pppoe_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p privp = node->private;
|
||||
const priv_p privp = NG_NODE_PRIVATE(node);
|
||||
sessp sp;
|
||||
|
||||
AAA
|
||||
if (strcmp(name, NG_PPPOE_HOOK_ETHERNET) == 0) {
|
||||
privp->ethernet_hook = hook;
|
||||
hook->private = &privp->ethernet_hook;
|
||||
NG_HOOK_SET_PRIVATE(hook, &privp->ethernet_hook);
|
||||
} else if (strcmp(name, NG_PPPOE_HOOK_DEBUG) == 0) {
|
||||
privp->debug_hook = hook;
|
||||
hook->private = &privp->debug_hook;
|
||||
NG_HOOK_SET_PRIVATE(hook, &privp->debug_hook);
|
||||
} else {
|
||||
/*
|
||||
* Any other unique name is OK.
|
||||
@ -582,7 +582,7 @@ AAA
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
hook->private = sp;
|
||||
NG_HOOK_SET_PRIVATE(hook, sp);
|
||||
sp->hook = hook;
|
||||
}
|
||||
return(0);
|
||||
@ -597,7 +597,7 @@ AAA
|
||||
static int
|
||||
ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
priv_p privp = node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
struct ngpppoe_init_data *ourmsg = NULL;
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
@ -638,19 +638,19 @@ AAA
|
||||
ourmsg->hook[sizeof(ourmsg->hook) - 1] = '\0';
|
||||
|
||||
/* cycle through all known hooks */
|
||||
LIST_FOREACH(hook, &node->hooks, hooks) {
|
||||
if (hook->name
|
||||
&& strcmp(hook->name, ourmsg->hook) == 0)
|
||||
LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) {
|
||||
if (NG_HOOK_NAME(hook)
|
||||
&& strcmp(NG_HOOK_NAME(hook), ourmsg->hook) == 0)
|
||||
break;
|
||||
}
|
||||
if (hook == NULL) {
|
||||
LEAVE(ENOENT);
|
||||
}
|
||||
if ((hook->private == &privp->debug_hook)
|
||||
|| (hook->private == &privp->ethernet_hook)) {
|
||||
if ((NG_HOOK_PRIVATE(hook) == &privp->debug_hook)
|
||||
|| (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook)) {
|
||||
LEAVE(EINVAL);
|
||||
}
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
|
||||
/*
|
||||
* PPPOE_SERVICE advertisments are set up
|
||||
@ -848,9 +848,9 @@ AAA
|
||||
static int
|
||||
ng_pppoe_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
node_p node = hook->node;
|
||||
const priv_p privp = node->private;
|
||||
sessp sp = hook->private;
|
||||
node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p privp = NG_NODE_PRIVATE(node);
|
||||
sessp sp = NG_HOOK_PRIVATE(hook);
|
||||
struct pppoe_full_hdr *wh;
|
||||
struct pppoe_hdr *ph;
|
||||
int error = 0;
|
||||
@ -868,14 +868,14 @@ ng_pppoe_rcvdata(hook_p hook, item_p item)
|
||||
|
||||
AAA
|
||||
NGI_GET_M(item, m);
|
||||
if (hook->private == &privp->debug_hook) {
|
||||
if (NG_HOOK_PRIVATE(hook) == &privp->debug_hook) {
|
||||
/*
|
||||
* Data from the debug hook gets sent without modification
|
||||
* straight to the ethernet.
|
||||
*/
|
||||
NG_FWD_DATA( error, item, privp->ethernet_hook);
|
||||
NG_FWD_ITEM_HOOK( error, item, privp->ethernet_hook);
|
||||
privp->packets_out++;
|
||||
} else if (hook->private == &privp->ethernet_hook) {
|
||||
} else if (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook) {
|
||||
/*
|
||||
* Incoming data.
|
||||
* Dig out various fields from the packet.
|
||||
@ -952,7 +952,7 @@ AAA
|
||||
printf("no service tag\n");
|
||||
LEAVE(ENETUNREACH);
|
||||
}
|
||||
sendhook = pppoe_match_svc(hook->node,
|
||||
sendhook = pppoe_match_svc(NG_HOOK_NODE(hook),
|
||||
tag->tag_data, ntohs(tag->tag_len));
|
||||
if (sendhook) {
|
||||
NG_FWD_NEW_DATA(error, item,
|
||||
@ -987,7 +987,7 @@ AAA
|
||||
* Check the session is in the right state.
|
||||
* It needs to be in PPPOE_SINIT.
|
||||
*/
|
||||
sp = sendhook->private;
|
||||
sp = NG_HOOK_PRIVATE(sendhook);
|
||||
if (sp->state != PPPOE_SINIT) {
|
||||
printf("session in wrong state\n");
|
||||
LEAVE(ENETUNREACH);
|
||||
@ -1044,7 +1044,7 @@ AAA
|
||||
* then this is a retry by the client.
|
||||
* so be nice, and resend.
|
||||
*/
|
||||
sp = sendhook->private;
|
||||
sp = NG_HOOK_PRIVATE(sendhook);
|
||||
if (sp->state == PPPOE_NEWCONNECTED) {
|
||||
/*
|
||||
* Whoa! drop back to resend that
|
||||
@ -1119,7 +1119,7 @@ AAA
|
||||
* Check the session is in the right state.
|
||||
* It needs to be in PPPOE_SREQ.
|
||||
*/
|
||||
sp = sendhook->private;
|
||||
sp = NG_HOOK_PRIVATE(sendhook);
|
||||
if (sp->state != PPPOE_SREQ) {
|
||||
LEAVE(ENETUNREACH);
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ AAA
|
||||
LEAVE (ENETUNREACH);
|
||||
break;
|
||||
}
|
||||
sp = sendhook->private;
|
||||
sp = NG_HOOK_PRIVATE(sendhook);
|
||||
m_adj(m, sizeof(*wh));
|
||||
if (m->m_pkthdr.len < length) {
|
||||
/* Packet too short, dump it */
|
||||
@ -1220,7 +1220,7 @@ AAA
|
||||
* So we can decide how to handle it.
|
||||
* Check the hook's state.
|
||||
*/
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
switch (sp->state) {
|
||||
case PPPOE_NEWCONNECTED:
|
||||
case PPPOE_CONNECTED: {
|
||||
@ -1349,12 +1349,11 @@ AAA
|
||||
static int
|
||||
ng_pppoe_shutdown(node_p node)
|
||||
{
|
||||
const priv_p privdata = node->private;
|
||||
const priv_p privdata = NG_NODE_PRIVATE(node);
|
||||
|
||||
AAA
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
ng_unref(privdata->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(privdata->node);
|
||||
FREE(privdata, M_NETGRAPH);
|
||||
return (0);
|
||||
}
|
||||
@ -1379,21 +1378,21 @@ ng_pppoe_connect(hook_p hook)
|
||||
static int
|
||||
ng_pppoe_disconnect(hook_p hook)
|
||||
{
|
||||
node_p node = hook->node;
|
||||
priv_p privp = node->private;
|
||||
node_p node = NG_HOOK_NODE(hook);
|
||||
priv_p privp = NG_NODE_PRIVATE(node);
|
||||
sessp sp;
|
||||
int hooks;
|
||||
|
||||
AAA
|
||||
hooks = node->numhooks; /* this one already not counted */
|
||||
if (hook->private == &privp->debug_hook) {
|
||||
hooks = NG_NODE_NUMHOOKS(node); /* this one already not counted */
|
||||
if (NG_HOOK_PRIVATE(hook) == &privp->debug_hook) {
|
||||
privp->debug_hook = NULL;
|
||||
} else if (hook->private == &privp->ethernet_hook) {
|
||||
} else if (NG_HOOK_PRIVATE(hook) == &privp->ethernet_hook) {
|
||||
privp->ethernet_hook = NULL;
|
||||
if ((node->flags & NG_INVALID) == 0)
|
||||
if (NG_NODE_IS_VALID(node))
|
||||
ng_rmnode_self(node);
|
||||
} else {
|
||||
sp = hook->private;
|
||||
sp = NG_HOOK_PRIVATE(hook);
|
||||
if (sp->state != PPPOE_SNONE ) {
|
||||
pppoe_send_event(sp, NGM_PPPOE_CLOSE);
|
||||
}
|
||||
@ -1452,14 +1451,14 @@ AAA
|
||||
FREE(sp->neg, M_NETGRAPH);
|
||||
}
|
||||
FREE(sp, M_NETGRAPH);
|
||||
hook->private = NULL;
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
/* work out how many session hooks there are */
|
||||
/* Node goes away on last session hook removal */
|
||||
if (privp->ethernet_hook) hooks -= 1;
|
||||
if (privp->debug_hook) hooks -= 1;
|
||||
}
|
||||
if ((node->numhooks == 0)
|
||||
&& ((node->flags & NG_INVALID) == 0))
|
||||
if ((NG_NODE_NUMHOOKS(node) == 0)
|
||||
&& (NG_NODE_IS_VALID(node)))
|
||||
ng_rmnode_self(node);
|
||||
return (0);
|
||||
}
|
||||
@ -1472,11 +1471,11 @@ pppoe_ticker(void *arg)
|
||||
{
|
||||
int s = splnet();
|
||||
hook_p hook = arg;
|
||||
sessp sp = hook->private;
|
||||
sessp sp = NG_HOOK_PRIVATE(hook);
|
||||
negp neg = sp->neg;
|
||||
int error = 0;
|
||||
struct mbuf *m0 = NULL;
|
||||
priv_p privp = hook->node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
AAA
|
||||
switch(sp->state) {
|
||||
@ -1521,7 +1520,7 @@ sendpacket(sessp sp)
|
||||
struct mbuf *m0 = NULL;
|
||||
hook_p hook = sp->hook;
|
||||
negp neg = sp->neg;
|
||||
priv_p privp = hook->node->private;
|
||||
priv_p privp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
AAA
|
||||
switch(sp->state) {
|
||||
@ -1628,7 +1627,7 @@ AAA
|
||||
if (msg == NULL)
|
||||
return (ENOMEM);
|
||||
sts = (struct ngpppoe_sts *)msg->data;
|
||||
strncpy(sts->hook, sp->hook->name, NG_HOOKLEN + 1);
|
||||
NG_SEND_MSG_ID(error, sp->hook->node, msg, sp->creator, NULL);
|
||||
strncpy(sts->hook, NG_HOOK_NAME(sp->hook), NG_HOOKLEN + 1);
|
||||
NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, NULL);
|
||||
return (error);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ ng_pptpgre_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Initialize state */
|
||||
callout_handle_init(&priv->ackp.sackTimer);
|
||||
@ -295,7 +295,7 @@ ng_pptpgre_constructor(node_p node)
|
||||
static int
|
||||
ng_pptpgre_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
hook_p *hookPtr;
|
||||
|
||||
/* Check hook name */
|
||||
@ -321,7 +321,7 @@ ng_pptpgre_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_pptpgre_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -385,8 +385,8 @@ ng_pptpgre_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_pptpgre_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* If not configured, reject */
|
||||
if (!priv->conf.enabled) {
|
||||
@ -408,17 +408,16 @@ ng_pptpgre_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_pptpgre_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Reset node */
|
||||
ng_pptpgre_reset(node);
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -428,8 +427,8 @@ ng_pptpgre_shutdown(node_p node)
|
||||
static int
|
||||
ng_pptpgre_disconnect(hook_p hook)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Zero out hook pointer */
|
||||
if (hook == priv->upper)
|
||||
@ -440,8 +439,8 @@ ng_pptpgre_disconnect(hook_p hook)
|
||||
panic("%s: unknown hook", __FUNCTION__);
|
||||
|
||||
/* Go away if no longer connected to anything */
|
||||
if ((node->numhooks == 0)
|
||||
&& ((node->flags & NG_INVALID) == 0))
|
||||
if ((NG_NODE_NUMHOOKS(node) == 0)
|
||||
&& (NG_NODE_IS_VALID(node)))
|
||||
ng_rmnode_self(node);
|
||||
return (0);
|
||||
}
|
||||
@ -456,7 +455,7 @@ ng_pptpgre_disconnect(hook_p hook)
|
||||
static int
|
||||
ng_pptpgre_xmit(node_p node, item_p item)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
u_char buf[sizeof(struct greheader) + 2 * sizeof(u_int32_t)];
|
||||
struct greheader *const gre = (struct greheader *)buf;
|
||||
@ -561,7 +560,7 @@ ng_pptpgre_xmit(node_p node, item_p item)
|
||||
static int
|
||||
ng_pptpgre_recv(node_p node, item_p item)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int iphlen, grelen, extralen;
|
||||
struct greheader *gre;
|
||||
struct ip *ip;
|
||||
@ -739,7 +738,7 @@ ng_pptpgre_recv(node_p node, item_p item)
|
||||
static void
|
||||
ng_pptpgre_start_recv_ack_timer(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
int remain, ticks;
|
||||
|
||||
@ -761,7 +760,7 @@ ng_pptpgre_start_recv_ack_timer(node_p node)
|
||||
return; /* XXX potential hang here */
|
||||
}
|
||||
*a->rackTimerPtr = node; /* insures the correct timeout event */
|
||||
node->refs++;
|
||||
NG_NODE_REF(node);
|
||||
|
||||
/* Be conservative: timeout() can return up to 1 tick early */
|
||||
ticks = (((remain * hz) + PPTP_TIME_SCALE - 1) / PPTP_TIME_SCALE) + 1;
|
||||
@ -779,18 +778,18 @@ ng_pptpgre_recv_ack_timeout(void *arg)
|
||||
{
|
||||
int s = splnet();
|
||||
const node_p node = *((node_p *)arg);
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
|
||||
/* This complicated stuff is needed to avoid race conditions */
|
||||
FREE(arg, M_NETGRAPH);
|
||||
KASSERT(node->refs > 0, ("%s: no refs", __FUNCTION__));
|
||||
if ((node->flags & NG_INVALID) != 0) { /* shutdown race condition */
|
||||
ng_unref(node);
|
||||
KASSERT(node->nd_refs > 0, ("%s: no nd_refs", __FUNCTION__));
|
||||
if (NG_NODE_NOT_VALID(node)) { /* shutdown race condition */
|
||||
NG_NODE_UNREF(node);
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
if (arg != a->rackTimerPtr) { /* timer stopped race condition */
|
||||
splx(s);
|
||||
return;
|
||||
@ -827,7 +826,7 @@ ng_pptpgre_recv_ack_timeout(void *arg)
|
||||
static void
|
||||
ng_pptpgre_start_send_ack_timer(node_p node, int ackTimeout)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
int ticks;
|
||||
|
||||
@ -839,7 +838,7 @@ ng_pptpgre_start_send_ack_timer(node_p node, int ackTimeout)
|
||||
return; /* XXX potential hang here */
|
||||
}
|
||||
*a->sackTimerPtr = node;
|
||||
node->refs++;
|
||||
NG_NODE_REF(node);
|
||||
|
||||
/* Be conservative: timeout() can return up to 1 tick early */
|
||||
ticks = (((ackTimeout * hz) + PPTP_TIME_SCALE - 1) / PPTP_TIME_SCALE);
|
||||
@ -858,18 +857,18 @@ ng_pptpgre_send_ack_timeout(void *arg)
|
||||
{
|
||||
int s = splnet();
|
||||
const node_p node = *((node_p *)arg);
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
|
||||
/* This complicated stuff is needed to avoid race conditions */
|
||||
FREE(arg, M_NETGRAPH);
|
||||
KASSERT(node->refs > 0, ("%s: no refs", __FUNCTION__));
|
||||
if ((node->flags & NG_INVALID) != 0) { /* shutdown race condition */
|
||||
ng_unref(node);
|
||||
KASSERT(node->nd_refs > 0, ("%s: no nd_refs", __FUNCTION__));
|
||||
if (NG_NODE_NOT_VALID(node)) { /* shutdown race condition */
|
||||
NG_NODE_UNREF(node);
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
ng_unref(node);
|
||||
NG_NODE_UNREF(node);
|
||||
if (a->sackTimerPtr != arg) { /* timer stopped race condition */
|
||||
splx(s);
|
||||
return;
|
||||
@ -891,7 +890,7 @@ ng_pptpgre_send_ack_timeout(void *arg)
|
||||
static void
|
||||
ng_pptpgre_reset(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_pptpgre_ackp *const a = &priv->ackp;
|
||||
|
||||
/* Reset adaptive timeout state */
|
||||
@ -930,7 +929,7 @@ ng_pptpgre_reset(node_p node)
|
||||
static pptptime_t
|
||||
ng_pptpgre_time(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct timeval tv;
|
||||
pptptime_t t;
|
||||
|
||||
|
@ -128,7 +128,7 @@ ng_rfc1490_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
@ -140,7 +140,7 @@ ng_rfc1490_constructor(node_p node)
|
||||
static int
|
||||
ng_rfc1490_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (!strcmp(name, NG_RFC1490_HOOK_DOWNSTREAM)) {
|
||||
if (priv->downlink)
|
||||
@ -208,8 +208,8 @@ ng_rfc1490_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_rfc1490_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int error = 0;
|
||||
struct mbuf *m;
|
||||
|
||||
@ -306,13 +306,12 @@ ng_rfc1490_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_rfc1490_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Take down netgraph node */
|
||||
node->flags |= NG_INVALID;
|
||||
bzero(priv, sizeof(*priv));
|
||||
node->private = NULL;
|
||||
ng_unref(node); /* let the node escape */
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node); /* let the node escape */
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -322,11 +321,11 @@ ng_rfc1490_shutdown(node_p node)
|
||||
static int
|
||||
ng_rfc1490_disconnect(hook_p hook)
|
||||
{
|
||||
const priv_p priv = hook->node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
else if (hook == priv->downlink)
|
||||
priv->downlink = NULL;
|
||||
else if (hook == priv->inet)
|
||||
|
@ -140,7 +140,7 @@ typedef struct XXX *xxx_p;
|
||||
* to creatednodes that depend on hardware (unless you can add the hardware :)
|
||||
*/
|
||||
static int
|
||||
ng_xxx_constructor(node_p nodep)
|
||||
ng_xxx_constructor(node_p node)
|
||||
{
|
||||
xxx_p privdata;
|
||||
int i, error;
|
||||
@ -156,8 +156,8 @@ ng_xxx_constructor(node_p nodep)
|
||||
}
|
||||
|
||||
/* Link structs together; this counts as our one reference to *nodep */
|
||||
(*nodep)->private = privdata;
|
||||
privdata->node = *nodep;
|
||||
NG_NODE_PRIVATE(node) = privdata;
|
||||
privdata->node = node;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ ng_xxx_constructor(node_p nodep)
|
||||
static int
|
||||
ng_xxx_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const xxx_p xxxp = node->private;
|
||||
const xxx_p xxxp = NG_NODE_PRIVATE(node);
|
||||
const char *cp;
|
||||
int dlci = 0;
|
||||
int chan;
|
||||
@ -216,18 +216,18 @@ ng_xxx_newhook(node_p node, hook_p hook, const char *name)
|
||||
}
|
||||
if (xxxp->channel[chan].hook != NULL)
|
||||
return (EADDRINUSE);
|
||||
hook->private = xxxp->channel + chan;
|
||||
NG_HOOK_SET_PRIVATE(hook, xxxp->channel + chan);
|
||||
xxxp->channel[chan].hook = hook;
|
||||
return (0);
|
||||
} else if (strcmp(name, NG_XXX_HOOK_DOWNSTREAM) == 0) {
|
||||
/* Example of simple predefined hooks. */
|
||||
/* do something specific to the downstream connection */
|
||||
xxxp->downstream_hook.hook = hook;
|
||||
hook->private = &xxxp->downstream_hook;
|
||||
NG_HOOK_SET_PRIVATE(hook, &xxxp->downstream_hook);
|
||||
} else if (strcmp(name, NG_XXX_HOOK_DEBUG) == 0) {
|
||||
/* do something specific to a debug connection */
|
||||
xxxp->debughook = hook;
|
||||
hook->private = NULL;
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
} else
|
||||
return (EINVAL); /* not a hook we know about */
|
||||
return(0);
|
||||
@ -252,7 +252,7 @@ ng_xxx_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_xxx_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const xxx_p xxxp = node->private;
|
||||
const xxx_p xxxp = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -318,7 +318,7 @@ ng_xxx_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_xxx_rcvdata(hook_p hook, item_p item )
|
||||
{
|
||||
const xxx_p xxxp = hook->node->private;
|
||||
const xxx_p xxxp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int chan = -2;
|
||||
int dlci = -2;
|
||||
int error;
|
||||
@ -327,9 +327,9 @@ ng_xxx_rcvdata(hook_p hook, item_p item )
|
||||
|
||||
|
||||
NGI_GET_M(item, m);
|
||||
if (hook->private) {
|
||||
dlci = ((struct XXX_hookinfo *) hook->private)->dlci;
|
||||
chan = ((struct XXX_hookinfo *) hook->private)->channel;
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
dlci = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->dlci;
|
||||
chan = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->channel;
|
||||
if (dlci != -1) {
|
||||
/* If received on a DLCI hook process for this
|
||||
* channel and pass it to the downstream module.
|
||||
@ -406,12 +406,11 @@ devintr()
|
||||
static int
|
||||
ng_xxx_shutdown(node_p node)
|
||||
{
|
||||
const xxx_p privdata = node->private;
|
||||
const xxx_p privdata = NG_NODE_PRIVATE(node);
|
||||
int error;
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
node->private = NULL;
|
||||
ng_unref(privdata->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(privdata->node);
|
||||
#ifndef PERSISTANT_NODE
|
||||
FREE(privdata, M_NETGRAPH);
|
||||
#else
|
||||
@ -426,7 +425,7 @@ ng_xxx_shutdown(node_p node)
|
||||
}
|
||||
if ( ng_name_node(node, "name")) { /* whatever name is needed */
|
||||
printf("something informative");
|
||||
ng_unref(node); /* drop it again */
|
||||
NG_NODE_UNREF(node); /* drop it again */
|
||||
return (0);
|
||||
}
|
||||
privdata->packets_in = 0; /* reset stats */
|
||||
@ -438,8 +437,8 @@ ng_xxx_shutdown(node_p node)
|
||||
|
||||
/* Link structs together; this counts as our one reference to node */
|
||||
privdata->node = node;
|
||||
node->private = privdata;
|
||||
node->flags &= ~NG_INVALID; /* reset invalid flag */
|
||||
NG_NODE_SET_PRIVATE(node, privdata);
|
||||
node->nd_flags &= ~NG_INVALID; /* reset invalid flag */
|
||||
#endif /* PERSISTANT_NODE */
|
||||
return (0);
|
||||
}
|
||||
@ -458,7 +457,7 @@ ng_xxx_connect(hook_p hook)
|
||||
* will deliver by queing.
|
||||
*/
|
||||
if /*it is the upstream hook */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
#endif
|
||||
#if 0
|
||||
/*
|
||||
@ -467,16 +466,16 @@ ng_xxx_connect(hook_p hook)
|
||||
* OUR hook. (maybe to allow unwinding of the stack)
|
||||
*/
|
||||
|
||||
if (hook->private) {
|
||||
if (NG_HOOK_PRIVATE(hook)) {
|
||||
int dlci;
|
||||
/*
|
||||
* If it's dlci 1023, requeue it so that it's handled
|
||||
* at a lower priority. This is how a node decides to
|
||||
* defer a data message.
|
||||
*/
|
||||
dlci = ((struct XXX_hookinfo *) hook->private)->dlci;
|
||||
dlci = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->dlci;
|
||||
if (dlci == 1023) {
|
||||
hook->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(hook);
|
||||
}
|
||||
#endif
|
||||
/* otherwise be really amiable and just say "YUP that's OK by me! " */
|
||||
@ -491,11 +490,11 @@ ng_xxx_connect(hook_p hook)
|
||||
static int
|
||||
ng_xxx_disconnect(hook_p hook)
|
||||
{
|
||||
if (hook->private)
|
||||
((struct XXX_hookinfo *) (hook->private))->hook = NULL;
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0)) /* already shutting down? */
|
||||
ng_rmnode_self(hook->node);
|
||||
if (NG_HOOK_PRIVATE(hook))
|
||||
((struct XXX_hookinfo *) (NG_HOOK_PRIVATE(hook)))->hook = NULL;
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) /* already shutting down? */
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Subject to the following obligations and disclaimer of warranty, use and
|
||||
* redistribution of this software, in source or object code forms, with or
|
||||
* without modifications are expressly permitted by Whistle Communications;
|
||||
@ -15,7 +15,7 @@
|
||||
* Communications, Inc. trademarks, including the mark "WHISTLE
|
||||
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
||||
* such appears in the above copyright notice or in the software.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
||||
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
||||
@ -235,9 +235,38 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
}
|
||||
m_copydata(m, 0, len, (char *)msg);
|
||||
|
||||
#ifdef TRACE_MESSAGES
|
||||
do {
|
||||
item_p item;
|
||||
if ((item = ng_package_msg(msg)) == NULL) {
|
||||
(msg) = NULL;
|
||||
(error) = ENOMEM;
|
||||
printf("err=%d\n",error);
|
||||
break;
|
||||
}
|
||||
if (((error) = ng_address_path((pcbp->sockdata->node), (item),
|
||||
(path), (NULL))) == 0) {
|
||||
printf("[%x]:<---------[socket]: c=<%d>cmd=%x(%s) f=%x #%d (%s)\n",
|
||||
item->el_dest->nd_ID,
|
||||
msg->header.typecookie,
|
||||
msg->header.cmd,
|
||||
msg->header.cmdstr,
|
||||
msg->header.flags,
|
||||
msg->header.token,
|
||||
item->el_dest->nd_type->name);
|
||||
SAVE_LINE(item);
|
||||
(error) = ng_snd_item((item), 0);
|
||||
}
|
||||
else {
|
||||
printf("errx=%d\n",error);
|
||||
}
|
||||
(msg) = NULL;
|
||||
} while (0);
|
||||
|
||||
#else
|
||||
/* The callee will free the msg when done. The path is our business. */
|
||||
NG_SEND_MSG_PATH(error, pcbp->sockdata->node, msg, path, NULL);
|
||||
|
||||
#endif
|
||||
release:
|
||||
if (path != NULL)
|
||||
FREE(path, M_NETGRAPH);
|
||||
@ -261,8 +290,9 @@ ngc_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
|
||||
static int
|
||||
ngc_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
|
||||
{
|
||||
printf(" program tried to connect control socket to remote node\n ");
|
||||
/*
|
||||
* At this time refuse to do this.. it used to
|
||||
* At this time refuse to do this.. it used to
|
||||
* do something but it was undocumented and not used.
|
||||
*/
|
||||
return (EINVAL);
|
||||
@ -318,7 +348,7 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
if ((sap == NULL)
|
||||
|| ((len = sap->sg_len) <= 2)
|
||||
|| (*sap->sg_data == '\0')) {
|
||||
if (pcbp->sockdata->node->numhooks != 1) {
|
||||
if (NG_NODE_NUMHOOKS(pcbp->sockdata->node) != 1) {
|
||||
error = EDESTADDRREQ;
|
||||
goto release;
|
||||
}
|
||||
@ -326,7 +356,7 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
* if exactly one hook exists, just use it.
|
||||
* Special case to allow write(2) to work on an ng_socket.
|
||||
*/
|
||||
hook = LIST_FIRST(&pcbp->sockdata->node->hooks);
|
||||
hook = LIST_FIRST(&pcbp->sockdata->node->nd_hooks);
|
||||
} else {
|
||||
if (len > NG_HOOKLEN) {
|
||||
error = EINVAL;
|
||||
@ -341,8 +371,8 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
||||
hookname[len] = '\0';
|
||||
|
||||
/* Find the correct hook from 'hookname' */
|
||||
LIST_FOREACH(hook, &pcbp->sockdata->node->hooks, hooks) {
|
||||
if (strcmp(hookname, hook->name) == 0)
|
||||
LIST_FOREACH(hook, &pcbp->sockdata->node->nd_hooks, hk_hooks) {
|
||||
if (strcmp(hookname, NG_HOOK_NAME(hook)) == 0)
|
||||
break;
|
||||
}
|
||||
if (hook == NULL)
|
||||
@ -391,14 +421,13 @@ ng_setsockaddr(struct socket *so, struct sockaddr **addr)
|
||||
}
|
||||
|
||||
namelen = 0; /* silence compiler ! */
|
||||
|
||||
if (pcbp->sockdata->node->name != NULL)
|
||||
sg_len += namelen = strlen(pcbp->sockdata->node->name);
|
||||
if ( NG_NODE_HAS_NAME(pcbp->sockdata->node))
|
||||
sg_len += namelen = strlen(NG_NODE_NAME(pcbp->sockdata->node));
|
||||
|
||||
MALLOC(sg, struct sockaddr_ng *, sg_len, M_SONAME, M_WAITOK | M_ZERO);
|
||||
|
||||
if (pcbp->sockdata->node->name != NULL)
|
||||
bcopy(pcbp->sockdata->node->name, sg->sg_data, namelen);
|
||||
if (NG_NODE_HAS_NAME(pcbp->sockdata->node))
|
||||
bcopy(NG_NODE_NAME(pcbp->sockdata->node), sg->sg_data, namelen);
|
||||
splx(s);
|
||||
|
||||
sg->sg_len = sg_len;
|
||||
@ -440,7 +469,7 @@ ng_attach_cntl(struct socket *so)
|
||||
ng_detach_common(pcbp, NG_CONTROL);
|
||||
return (error);
|
||||
}
|
||||
privdata->node->private = privdata;
|
||||
NG_NODE_SET_PRIVATE(privdata->node, privdata);
|
||||
|
||||
/* Link the pcb and the node private data */
|
||||
privdata->ctlsock = pcbp;
|
||||
@ -612,16 +641,16 @@ ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp)
|
||||
return (error); /* item is freed on failure */
|
||||
|
||||
/*
|
||||
* Extract node from item and free item. Remember we now have
|
||||
* Extract node from item and free item. Remember we now have
|
||||
* a reference on the node. The item holds it for us.
|
||||
* when we free the item we release the reference.
|
||||
*/
|
||||
farnode = item->el_dest; /* shortcut */
|
||||
if (strcmp(farnode->type->name, NG_SOCKET_NODE_TYPE) != 0) {
|
||||
if (strcmp(farnode->nd_type->name, NG_SOCKET_NODE_TYPE) != 0) {
|
||||
NG_FREE_ITEM(item); /* drop the reference to the node */
|
||||
return (EINVAL);
|
||||
}
|
||||
sockdata = farnode->private;
|
||||
sockdata = NG_NODE_PRIVATE(farnode);
|
||||
if (sockdata->datasock != NULL) {
|
||||
NG_FREE_ITEM(item); /* drop the reference to the node */
|
||||
return (EADDRINUSE);
|
||||
@ -712,7 +741,7 @@ ngs_constructor(node_p nodep)
|
||||
static int
|
||||
ngs_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
hook->private = node->private;
|
||||
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -723,7 +752,7 @@ ngs_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ngs_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
struct ngsock *const sockdata = node->private;
|
||||
struct ngsock *const sockdata = NG_NODE_PRIVATE(node);
|
||||
struct ngpcb *const pcbp = sockdata->ctlsock;
|
||||
struct sockaddr_ng *addr;
|
||||
int addrlen;
|
||||
@ -741,6 +770,16 @@ ngs_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
TRAP_ERROR;
|
||||
return (EINVAL);
|
||||
}
|
||||
#ifdef TRACE_MESSAGES
|
||||
printf("[%x]:---------->[socket]: c=<%d>cmd=%x(%s) f=%x #%d\n",
|
||||
retaddr,
|
||||
msg->header.typecookie,
|
||||
msg->header.cmd,
|
||||
msg->header.cmdstr,
|
||||
msg->header.flags,
|
||||
msg->header.token);
|
||||
|
||||
#endif
|
||||
|
||||
if (msg->header.typecookie == NGM_SOCKET_COOKIE) {
|
||||
switch (msg->header.cmd) {
|
||||
@ -783,7 +822,7 @@ ngs_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ngs_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
struct ngsock *const sockdata = hook->node->private;
|
||||
struct ngsock *const sockdata = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct ngpcb *const pcbp = sockdata->datasock;
|
||||
struct socket *so;
|
||||
struct sockaddr_ng *addr;
|
||||
@ -801,11 +840,11 @@ ngs_rcvdata(hook_p hook, item_p item)
|
||||
so = pcbp->ng_socket;
|
||||
|
||||
/* Get the return address into a sockaddr. */
|
||||
addrlen = strlen(hook->name); /* <= NG_HOOKLEN */
|
||||
addrlen = strlen(NG_HOOK_NAME(hook)); /* <= NG_HOOKLEN */
|
||||
addr = (struct sockaddr_ng *) addrbuf;
|
||||
addr->sg_len = addrlen + 3;
|
||||
addr->sg_family = AF_NETGRAPH;
|
||||
bcopy(hook->name, addr->sg_data, addrlen);
|
||||
bcopy(NG_HOOK_NAME(hook), addr->sg_data, addrlen);
|
||||
addr->sg_data[addrlen] = '\0';
|
||||
|
||||
/* Try to tell the socket which hook it came in on */
|
||||
@ -827,12 +866,12 @@ ngs_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngs_disconnect(hook_p hook)
|
||||
{
|
||||
struct ngsock *const sockdata = hook->node->private;
|
||||
struct ngsock *const sockdata = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
|
||||
if ((sockdata->flags & NGS_FLAG_NOLINGER )
|
||||
&& (hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0)) {
|
||||
ng_rmnode_self(hook->node);
|
||||
&& (NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) {
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@ -845,7 +884,7 @@ ngs_disconnect(hook_p hook)
|
||||
static int
|
||||
ngs_shutdown(node_p node)
|
||||
{
|
||||
struct ngsock *const sockdata = node->private;
|
||||
struct ngsock *const sockdata = NG_NODE_PRIVATE(node);
|
||||
struct ngpcb *const dpcbp = sockdata->datasock;
|
||||
struct ngpcb *const pcbp = sockdata->ctlsock;
|
||||
|
||||
@ -861,8 +900,8 @@ ngs_shutdown(node_p node)
|
||||
sockdata->ctlsock = NULL;
|
||||
sockdata->refs--;
|
||||
}
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
FREE(sockdata, M_NETGRAPH);
|
||||
return (0);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ ngt_constructor(node_p node)
|
||||
if (privdata == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = privdata;
|
||||
NG_NODE_SET_PRIVATE(node, privdata);
|
||||
privdata->node = node;
|
||||
return (0);
|
||||
}
|
||||
@ -166,24 +166,24 @@ ngt_constructor(node_p node)
|
||||
static int
|
||||
ngt_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (strcmp(name, NG_TEE_HOOK_RIGHT) == 0) {
|
||||
sc->right.hook = hook;
|
||||
bzero(&sc->right.stats, sizeof(sc->right.stats));
|
||||
hook->private = &sc->right;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->right);
|
||||
} else if (strcmp(name, NG_TEE_HOOK_LEFT) == 0) {
|
||||
sc->left.hook = hook;
|
||||
bzero(&sc->left.stats, sizeof(sc->left.stats));
|
||||
hook->private = &sc->left;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->left);
|
||||
} else if (strcmp(name, NG_TEE_HOOK_RIGHT2LEFT) == 0) {
|
||||
sc->right2left.hook = hook;
|
||||
bzero(&sc->right2left.stats, sizeof(sc->right2left.stats));
|
||||
hook->private = &sc->right2left;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->right2left);
|
||||
} else if (strcmp(name, NG_TEE_HOOK_LEFT2RIGHT) == 0) {
|
||||
sc->left2right.hook = hook;
|
||||
bzero(&sc->left2right.stats, sizeof(sc->left2right.stats));
|
||||
hook->private = &sc->left2right;
|
||||
NG_HOOK_SET_PRIVATE(hook, &sc->left2right);
|
||||
} else
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
@ -195,7 +195,7 @@ ngt_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ngt_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -249,15 +249,15 @@ ngt_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
if (lasthook == sc->left.hook) {
|
||||
if (sc->right.hook) {
|
||||
NGI_MSG(item) = msg;
|
||||
NG_FWD_MSG_HOOK(error, node, item,
|
||||
sc->right.hook, 0);
|
||||
NG_FWD_ITEM_HOOK(error, item,
|
||||
sc->right.hook);
|
||||
return (error);
|
||||
}
|
||||
} else {
|
||||
if (sc->left.hook) {
|
||||
NGI_MSG(item) = msg;
|
||||
NG_FWD_MSG_HOOK(error, node, item,
|
||||
sc->left.hook, 0);
|
||||
NG_FWD_ITEM_HOOK(error, item,
|
||||
sc->left.hook);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
@ -286,8 +286,8 @@ ngt_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ngt_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
struct hookinfo *const hinfo = (struct hookinfo *) hook->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
|
||||
struct hookinfo *dest;
|
||||
struct hookinfo *dup;
|
||||
int error = 0;
|
||||
@ -350,7 +350,7 @@ ngt_rcvdata(hook_p hook, item_p item)
|
||||
dest->stats.outOctets += m->m_pkthdr.len;
|
||||
dest->stats.outFrames++;
|
||||
if (dest->hook)
|
||||
NG_FWD_DATA(error, item, dest->hook);
|
||||
NG_FWD_ITEM_HOOK(error, item, dest->hook);
|
||||
else
|
||||
NG_FREE_ITEM(item);
|
||||
return (0);
|
||||
@ -370,15 +370,14 @@ ngt_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngt_shutdown(node_p node)
|
||||
{
|
||||
const sc_p privdata = node->private;
|
||||
const sc_p privdata = NG_NODE_PRIVATE(node);
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
#if 0 /* can never happen as cutlinks is already called */
|
||||
if (privdata->left.hook && privdata->right.hook)
|
||||
ng_bypass(privdata->left.hook, privdata->right.hook);
|
||||
#endif
|
||||
node->private = NULL;
|
||||
ng_unref(privdata->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(privdata->node);
|
||||
FREE(privdata, M_NETGRAPH);
|
||||
return (0);
|
||||
}
|
||||
@ -389,13 +388,13 @@ ngt_shutdown(node_p node)
|
||||
static int
|
||||
ngt_disconnect(hook_p hook)
|
||||
{
|
||||
struct hookinfo *const hinfo = (struct hookinfo *) hook->private;
|
||||
struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
|
||||
|
||||
KASSERT(hinfo != NULL, ("%s: null info", __FUNCTION__));
|
||||
hinfo->hook = NULL;
|
||||
if ((hook->node->numhooks == 0)
|
||||
&& ((hook->node->flags & NG_INVALID) == 0))
|
||||
ng_rmnode_self(hook->node);
|
||||
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
|
||||
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
|
||||
ng_rmnode_self(NG_HOOK_NODE(hook));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -233,13 +233,13 @@ ngt_open(dev_t dev, struct tty *tp)
|
||||
if ((error = ng_name_node(sc->node, name))) {
|
||||
log(LOG_ERR, "%s: node name exists?\n", name);
|
||||
ngt_nodeop_ok = 1;
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
ngt_nodeop_ok = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set back pointers */
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
tp->t_sc = (caddr_t) sc;
|
||||
|
||||
/*
|
||||
@ -322,11 +322,11 @@ ngt_tioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
|
||||
const node_p node = sc->node;
|
||||
|
||||
bzero(ni, sizeof(*ni));
|
||||
if (node->name)
|
||||
strncpy(ni->name, node->name, sizeof(ni->name) - 1);
|
||||
strncpy(ni->type, node->type->name, sizeof(ni->type) - 1);
|
||||
ni->id = (u_int32_t) node;
|
||||
ni->hooks = node->numhooks;
|
||||
if (NG_NODE_HAS_NAME(node))
|
||||
strncpy(ni->name, NG_NODE_NAME(node), sizeof(ni->name) - 1);
|
||||
strncpy(ni->type, node->nd_type->name, sizeof(ni->type) - 1);
|
||||
ni->id = (u_int32_t) ng_node2ID(node);
|
||||
ni->hooks = NG_NODE_NUMHOOKS(node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -359,14 +359,14 @@ ngt_input(int c, struct tty *tp)
|
||||
/* Check for error conditions */
|
||||
if ((tp->t_state & TS_CONNECTED) == 0) {
|
||||
if (sc->flags & FLG_DEBUG)
|
||||
log(LOG_DEBUG, "%s: no carrier\n", node->name);
|
||||
log(LOG_DEBUG, "%s: no carrier\n", NG_NODE_NAME(node));
|
||||
ERROUT(0);
|
||||
}
|
||||
if (c & TTY_ERRORMASK) {
|
||||
/* framing error or overrun on this char */
|
||||
if (sc->flags & FLG_DEBUG)
|
||||
log(LOG_DEBUG, "%s: line error %x\n",
|
||||
node->name, c & TTY_ERRORMASK);
|
||||
NG_NODE_NAME(node), c & TTY_ERRORMASK);
|
||||
ERROUT(0);
|
||||
}
|
||||
c &= TTY_CHARMASK;
|
||||
@ -377,7 +377,7 @@ ngt_input(int c, struct tty *tp)
|
||||
if (!m) {
|
||||
if (sc->flags & FLG_DEBUG)
|
||||
log(LOG_ERR,
|
||||
"%s: can't get mbuf\n", node->name);
|
||||
"%s: can't get mbuf\n", NG_NODE_NAME(node));
|
||||
ERROUT(ENOBUFS);
|
||||
}
|
||||
m->m_len = m->m_pkthdr.len = 0;
|
||||
@ -504,7 +504,7 @@ ngt_constructor(node_p node)
|
||||
static int
|
||||
ngt_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
int s, error = 0;
|
||||
|
||||
if (strcmp(name, NG_TTY_HOOK))
|
||||
@ -525,7 +525,8 @@ ngt_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ngt_connect(hook_p hook)
|
||||
{
|
||||
hook->peer->flags |= HK_QUEUE|HK_FORCE_WRITER;
|
||||
/*NG_HOOK_FORCE_WRITER(hook);
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -535,7 +536,7 @@ ngt_connect(hook_p hook)
|
||||
static int
|
||||
ngt_disconnect(hook_p hook)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
@ -555,12 +556,12 @@ ngt_disconnect(hook_p hook)
|
||||
static int
|
||||
ngt_shutdown(node_p node)
|
||||
{
|
||||
const sc_p sc = node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (!ngt_nodeop_ok)
|
||||
return (EOPNOTSUPP);
|
||||
node->private = NULL;
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
m_freem(sc->qhead);
|
||||
m_freem(sc->m);
|
||||
bzero(sc, sizeof(*sc));
|
||||
@ -575,7 +576,7 @@ ngt_shutdown(node_p node)
|
||||
static int
|
||||
ngt_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const sc_p sc = hook->node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
|
||||
int s, error = 0;
|
||||
struct mbuf *m;
|
||||
|
||||
@ -608,7 +609,7 @@ ngt_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ngt_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const sc_p sc = (sc_p) node->private;
|
||||
const sc_p sc = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
|
@ -254,7 +254,7 @@ ng_vjc_constructor(node_p node)
|
||||
if (priv == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
node->private = priv;
|
||||
NG_NODE_SET_PRIVATE(node, priv);
|
||||
|
||||
/* Done */
|
||||
return (0);
|
||||
@ -266,7 +266,7 @@ ng_vjc_constructor(node_p node)
|
||||
static int
|
||||
ng_vjc_newhook(node_p node, hook_p hook, const char *name)
|
||||
{
|
||||
const priv_p priv = (priv_p) node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
hook_p *hookp;
|
||||
|
||||
/* Get hook */
|
||||
@ -296,7 +296,7 @@ ng_vjc_newhook(node_p node, hook_p hook, const char *name)
|
||||
static int
|
||||
ng_vjc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
{
|
||||
const priv_p priv = (priv_p) node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
@ -403,8 +403,8 @@ ng_vjc_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
static int
|
||||
ng_vjc_rcvdata(hook_p hook, item_p item)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = (priv_p) node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
int error = 0;
|
||||
struct mbuf *m;
|
||||
|
||||
@ -549,13 +549,12 @@ ng_vjc_rcvdata(hook_p hook, item_p item)
|
||||
static int
|
||||
ng_vjc_shutdown(node_p node)
|
||||
{
|
||||
const priv_p priv = (priv_p) node->private;
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
node->flags |= NG_INVALID;
|
||||
bzero(priv, sizeof(*priv));
|
||||
FREE(priv, M_NETGRAPH);
|
||||
node->private = NULL;
|
||||
ng_unref(node);
|
||||
NG_NODE_SET_PRIVATE(node, NULL);
|
||||
NG_NODE_UNREF(node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -565,8 +564,8 @@ ng_vjc_shutdown(node_p node)
|
||||
static int
|
||||
ng_vjc_disconnect(hook_p hook)
|
||||
{
|
||||
const node_p node = hook->node;
|
||||
const priv_p priv = node->private;
|
||||
const node_p node = NG_HOOK_NODE(hook);
|
||||
const priv_p priv = NG_NODE_PRIVATE(node);
|
||||
|
||||
/* Zero out hook pointer */
|
||||
if (hook == priv->ip)
|
||||
@ -581,8 +580,8 @@ ng_vjc_disconnect(hook_p hook)
|
||||
panic("%s: unknown hook", __FUNCTION__);
|
||||
|
||||
/* Go away if no hooks left */
|
||||
if ((node->numhooks == 0)
|
||||
&& ((node->flags & NG_INVALID) == 0))
|
||||
if ((NG_NODE_NUMHOOKS(node) == 0)
|
||||
&& (NG_NODE_IS_VALID(node)))
|
||||
ng_rmnode_self(node);
|
||||
return (0);
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ ngmn_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
struct ng_mesg *msg;
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (msg->header.typecookie != NGM_GENERIC_COOKIE ||
|
||||
msg->header.cmd != NGM_TEXT_STATUS) {
|
||||
@ -340,7 +340,7 @@ ngmn_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
sch = sc->ch[i];
|
||||
|
||||
pos += sprintf(arg + pos, " Chan %d <%s> ",
|
||||
i, sch->hook->name);
|
||||
i, NG_HOOK_NAME(sch->hook));
|
||||
|
||||
pos += sprintf(arg + pos, " Last Rx: ");
|
||||
if (sch->last_recv)
|
||||
@ -389,7 +389,7 @@ ngmn_newhook(node_p node, hook_p hook, const char *name)
|
||||
struct softc *sc;
|
||||
int nbit;
|
||||
|
||||
sc = node->private;
|
||||
sc = NG_NODE_PRIVATE(node);
|
||||
|
||||
if (name[0] != 't' || name[1] != 's')
|
||||
return (EINVAL);
|
||||
@ -405,7 +405,7 @@ ngmn_newhook(node_p node, hook_p hook, const char *name)
|
||||
sc->ch[chan]->ts = ts;
|
||||
sc->ch[chan]->hook = hook;
|
||||
sc->ch[chan]->tx_limit = nbit * 8;
|
||||
hook->private = sc->ch[chan];
|
||||
NG_HOOK_SET_PRIVATE(hook, sc->ch[chan]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -510,7 +510,7 @@ ngmn_rcvdata(hook_p hook, item_p item)
|
||||
int chan, pitch, len;
|
||||
struct mbuf *m;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
sc = sch->sc;
|
||||
chan = sch->chan;
|
||||
|
||||
@ -589,7 +589,7 @@ ngmn_connect(hook_p hook)
|
||||
struct schan *sch;
|
||||
u_int32_t u;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
chan = sch->chan;
|
||||
sc = sch->sc;
|
||||
|
||||
@ -684,7 +684,7 @@ ngmn_connect(hook_p hook)
|
||||
printf("%s: init chan %d stat %08x\n", sc->name, chan, u);
|
||||
sc->m32x->stat = 1;
|
||||
/* probably not at splnet, force outward queueing */
|
||||
hook->peer->flags |= HK_QUEUE;
|
||||
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -701,7 +701,7 @@ ngmn_disconnect(hook_p hook)
|
||||
struct trxd *dp, *dp2;
|
||||
u_int32_t u;
|
||||
|
||||
sch = hook->private;
|
||||
sch = NG_HOOK_PRIVATE(hook);
|
||||
chan = sch->chan;
|
||||
sc = sch->sc;
|
||||
|
||||
@ -1345,10 +1345,10 @@ mn_attach (device_t self)
|
||||
printf("ng_make_node_common failed\n");
|
||||
return (0);
|
||||
}
|
||||
sc->node->private = sc;
|
||||
NG_NODE_SET_PRIVATE(sc->node, sc);
|
||||
sprintf(sc->nodename, "%s%d", NG_MN_NODE_TYPE, sc->unit);
|
||||
if (ng_name_node(sc->node, sc->nodename)) {
|
||||
ng_unref(sc->node);
|
||||
NG_NODE_UNREF(sc->node);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user