本文整理汇总了C++中NG_HOOK_NODE函数的典型用法代码示例。如果您正苦于以下问题:C++ NG_HOOK_NODE函数的具体用法?C++ NG_HOOK_NODE怎么用?C++ NG_HOOK_NODE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NG_HOOK_NODE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ngipi_disconnect
/*
* Hook disconnection
*/
static int
ngipi_disconnect(hook_p hook)
{
if (NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
ng_rmnode_self(NG_HOOK_NODE(hook));
return (0);
}
示例2: text_status
/*
* CONTROL MESSAGES
*/
static int
text_status(node_p node, struct priv *priv, char *arg, u_int len)
{
struct sbuf sbuf;
sbuf_new(&sbuf, arg, len, 0);
if (priv->upper)
sbuf_printf(&sbuf, "upper hook: %s connected to %s:%s\n",
NG_HOOK_NAME(priv->upper),
NG_NODE_NAME(NG_HOOK_NODE(NG_HOOK_PEER(priv->upper))),
NG_HOOK_NAME(NG_HOOK_PEER(priv->upper)));
else
sbuf_printf(&sbuf, "upper hook: <not connected>\n");
if (priv->lower)
sbuf_printf(&sbuf, "lower hook: %s connected to %s:%s\n",
NG_HOOK_NAME(priv->lower),
NG_NODE_NAME(NG_HOOK_NODE(NG_HOOK_PEER(priv->lower))),
NG_HOOK_NAME(NG_HOOK_PEER(priv->lower)));
else
sbuf_printf(&sbuf, "lower hook: <not connected>\n");
sbuf_printf(&sbuf, "sscf state: %s\n",
priv->enabled == NULL ? "<disabled>" :
sscfu_statename(sscfu_getstate(priv->sscf)));
sbuf_finish(&sbuf);
return (sbuf_len(&sbuf));
}
示例3: ngee_disconnect
/*
* Removal of the last link destroys the nodeo
*/
static int
ngee_disconnect(hook_p hook)
{
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);
}
示例4: ng_ksocket_disconnect
/*
* Hook disconnection
*/
static int
ng_ksocket_disconnect(hook_p hook)
{
KASSERT(NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0,
("%s: numhooks=%d?", __func__,
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);
}
示例5: ng_udbp_disconnect
/*
* Dook disconnection
*
* For this type, removal of the last link destroys the node
*/
Static int
ng_udbp_disconnect(hook_p hook)
{
const udbp_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
sc->hook = NULL;
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);
}
示例6: ngt_disconnect
/*
* Hook disconnection
*/
static int
ngt_disconnect(hook_p hook)
{
struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
KASSERT(hinfo != NULL, ("%s: null info", __func__));
hinfo->hook = NULL;
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);
}
示例7: ng_split_disconnect
/*
* Hook disconnection
*/
static int
ng_split_disconnect(hook_p hook)
{
hook_p *localhook = NG_HOOK_PRIVATE(hook);
KASSERT(localhook != NULL, ("%s: null info", __func__));
*localhook = NULL;
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);
}
示例8: ng_xxx_connect
/*
* This is called once we've already connected a new hook to the other node.
* It gives us a chance to balk at the last minute.
*/
static int
ng_xxx_connect(hook_p hook)
{
#if 0
/*
* If we were a driver running at other than splnet then
* we should set the QUEUE bit on the edge so that we
* will deliver by queing.
*/
if /*it is the upstream hook */
NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
#endif
#if 0
/*
* If for some reason we want incoming date to be queued
* by the NETISR system and delivered later we can set the same bit on
* OUR hook. (maybe to allow unwinding of the stack)
*/
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 *) NG_HOOK_PRIVATE(hook))->dlci;
if (dlci == 1023) {
NG_HOOK_FORCE_QUEUE(hook);
}
#endif
/* otherwise be really amiable and just say "YUP that's OK by me! " */
return (0);
}
/*
* Hook disconnection
*
* For this type, removal of the last link destroys the node
*/
static int
ng_xxx_disconnect(hook_p hook)
{
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);
}
示例9: ng_sscfu_disconnect
static int
ng_sscfu_disconnect(hook_p hook)
{
node_p node = NG_HOOK_NODE(hook);
struct priv *priv = NG_NODE_PRIVATE(node);
if (hook == priv->upper)
priv->upper = NULL;
else if (hook == priv->lower)
priv->lower = NULL;
else {
log(LOG_ERR, "bogus hook");
return (EINVAL);
}
if (NG_NODE_NUMHOOKS(node) == 0) {
if (NG_NODE_IS_VALID(node))
ng_rmnode_self(node);
} else {
/*
* Because there are no timeouts reset the protocol
* if the lower layer is disconnected.
*/
if (priv->lower == NULL &&
priv->enabled &&
sscfu_getstate(priv->sscf) != SSCFU_RELEASED)
sscfu_reset(priv->sscf);
}
return (0);
}
示例10: ng_sscop_disconnect
static int
ng_sscop_disconnect(hook_p hook)
{
node_p node = NG_HOOK_NODE(hook);
struct priv *priv = NG_NODE_PRIVATE(node);
if(hook == priv->upper)
priv->upper = NULL;
else if(hook == priv->lower)
priv->lower = NULL;
else if(hook == priv->manage)
priv->manage = NULL;
if(NG_NODE_NUMHOOKS(node) == 0) {
if(NG_NODE_IS_VALID(node))
ng_rmnode_self(node);
} else {
/*
* Imply a release request, if the upper layer is
* disconnected.
*/
if(priv->upper == NULL && priv->lower != NULL &&
priv->enabled &&
sscop_getstate(priv->sscop) != SSCOP_IDLE) {
sscop_aasig(priv->sscop, SSCOP_RELEASE_request,
NULL, 0);
}
}
return 0;
}
示例11: ng_ubt_disconnect
static int
ng_ubt_disconnect(hook_p hook)
{
struct ubt_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
UBT_NG_LOCK(sc);
if (hook != sc->sc_hook) {
UBT_NG_UNLOCK(sc);
return (EINVAL);
}
sc->sc_hook = NULL;
/* Kick off task to stop all USB xfers */
ubt_task_schedule(sc, UBT_FLAG_T_STOP_ALL);
/* Drain queues */
NG_BT_MBUFQ_DRAIN(&sc->sc_cmdq);
NG_BT_MBUFQ_DRAIN(&sc->sc_aclq);
NG_BT_MBUFQ_DRAIN(&sc->sc_scoq);
UBT_NG_UNLOCK(sc);
return (0);
} /* ng_ubt_disconnect */
示例12: ng_sscfu_rcvlower
static int
ng_sscfu_rcvlower(hook_p hook, item_p item)
{
node_p node = NG_HOOK_NODE(hook);
struct priv *priv = NG_NODE_PRIVATE(node);
struct mbuf *m;
struct sscop_arg a;
if (!priv->enabled || priv->upper == NULL) {
NG_FREE_ITEM(item);
return (0);
}
NGI_GET_M(item, m);
NG_FREE_ITEM(item);
if (!(m->m_flags & M_PKTHDR)) {
printf("no pkthdr\n");
m_freem(m);
return (EINVAL);
}
/*
* Strip of the SSCOP header.
*/
if (m->m_len < (int)sizeof(a) && (m = m_pullup(m, sizeof(a))) == NULL)
return (ENOMEM);
bcopy((caddr_t)mtod(m, struct sscop_arg *), &a, sizeof(a));
m_adj(m, sizeof(a));
sscfu_input(priv->sscf, a.sig, m, a.arg);
return (0);
}
示例13: ng_sscop_rcvlower
/*
* DATA
*/
static int
ng_sscop_rcvlower(hook_p hook, item_p item)
{
struct priv *priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
struct mbuf *m;
if (!priv->enabled) {
NG_FREE_ITEM(item);
return EINVAL;
}
/*
* If we are disconnected at the upper layer and in the IDLE
* state, drop any incoming packet.
*/
if (priv->upper != NULL || sscop_getstate(priv->sscop) != SSCOP_IDLE) {
NGI_GET_M(item, m);
priv->stats.in_packets++;
sscop_input(priv->sscop, m);
} else {
priv->stats.in_dropped++;
}
NG_FREE_ITEM(item);
return (0);
}
示例14: ng_ksocket_rcvdata
/*
* Receive incoming data on our hook. Send it out the socket.
*/
static int
ng_ksocket_rcvdata(hook_p hook, item_p item)
{
struct thread *td = curthread; /* XXX broken */
const node_p node = NG_HOOK_NODE(hook);
const priv_p priv = NG_NODE_PRIVATE(node);
struct socket *const so = priv->so;
struct sockaddr *sa = NULL;
int error;
struct mbuf *m;
struct sa_tag *stag;
/* Extract data */
NGI_GET_M(item, m);
NG_FREE_ITEM(item);
/*
* Look if socket address is stored in packet tags.
* If sockaddr is ours, or provided by a third party (zero id),
* then we accept it.
*/
if (((stag = (struct sa_tag *)m_tag_locate(m, NGM_KSOCKET_COOKIE,
NG_KSOCKET_TAG_SOCKADDR, NULL)) != NULL) &&
(stag->id == NG_NODE_ID(node) || stag->id == 0))
sa = &stag->sa;
/* Reset specific mbuf flags to prevent addressing problems. */
m->m_flags &= ~(M_BCAST|M_MCAST);
/* Send packet */
error = sosend(so, sa, 0, m, 0, 0, td);
return (error);
}
示例15: ng_sscop_rcvupper
static int
ng_sscop_rcvupper(hook_p hook, item_p item)
{
struct priv *priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
struct sscop_arg a;
struct mbuf *m;
if (!priv->enabled) {
NG_FREE_ITEM(item);
return (EINVAL);
}
/*
* If the lower layer is not connected allow to proceed.
* The lower layer sending function will drop outgoing frames,
* and the sscop will timeout any establish requests.
*/
NGI_GET_M(item, m);
NG_FREE_ITEM(item);
if (!(m->m_flags & M_PKTHDR)) {
printf("no pkthdr\n");
m_freem(m);
return (EINVAL);
}
if (m->m_len < (int)sizeof(a) && (m = m_pullup(m, sizeof(a))) == NULL)
return (ENOBUFS);
bcopy((caddr_t)mtod(m, struct sscop_arg *), &a, sizeof(a));
m_adj(m, sizeof(a));
return (sscop_aasig(priv->sscop, a.sig, m, a.arg));
}