FreeBSD/sys/netgraph/ng_mppc.c
/*
 * Receive incoming data on our hook.
 */
Receive incoming data on our hook.
Receive incoming data on our hook .
static int
ng_mppc_rcvdata(hook_p hook, item_p item)
{
	const node_p node = NG_HOOK_NODE(hook);
	const priv_p priv = NG_NODE_PRIVATE(node);
	int error;
	struct mbuf *m;
	NGI_GET_M(item, m);
	if (hook == priv->xmit.hook) {
		if (!priv->xmit.cfg.enable) {
			NG_FREE_M(m);
			NG_FREE_ITEM(item);
			return (ENXIO);
		}
		if ((error = ng_mppc_compress(node, &m)) != 0) {
			NG_FREE_ITEM(item);
			return(error);
		}
		NG_FWD_NEW_DATA(error, item, priv->xmit.hook, m);
		return (error);
	}
	if (hook == priv->recv.hook) {
		if (!priv->recv.cfg.enable) {
			NG_FREE_M(m);
			NG_FREE_ITEM(item);
			return (ENXIO);
		}
		if ((error = ng_mppc_decompress(node, &m)) != 0) {
			NG_FREE_ITEM(item);
			if (error == EINVAL && priv->ctrlnode != 0) {
				struct ng_mesg *msg;
				NG_MKMESSAGE(msg, NGM_MPPC_COOKIE,
				    NGM_MPPC_RESETREQ, 0, M_NOWAIT);
				if (msg == NULL)
					return (error);
				NG_SEND_MSG_ID(error, node, msg,
					priv->ctrlnode, 0); 
			}
			return (error);
		}
		NG_FWD_NEW_DATA(error, item, priv->recv.hook, m);
		return (error);
	}
	panic("%s: unknown hook", __func__);
}
static int ng_mppc_rcvdata ( hook_p hook , item_p item ) { const node_p node = NG_HOOK_NODE ( hook ) ; const priv_p priv = NG_NODE_PRIVATE ( node ) ; int error ; struct mbuf * m ; NGI_GET_M ( item , m ) ; if ( hook == priv -> xmit . hook ) { if ( ! priv -> xmit . cfg . enable ) { NG_FREE_M ( m ) ; NG_FREE_ITEM ( item ) ; return ( ENXIO ) ; } if ( ( error = ng_mppc_compress ( node , & m ) ) != 0 ) { NG_FREE_ITEM ( item ) ; return ( error ) ; } NG_FWD_NEW_DATA ( error , item , priv -> xmit . hook , m ) ; return ( error ) ; } if ( hook == priv -> recv . hook ) { if ( ! priv -> recv . cfg . enable ) { NG_FREE_M ( m ) ; NG_FREE_ITEM ( item ) ; return ( ENXIO ) ; } if ( ( error = ng_mppc_decompress ( node , & m ) ) != 0 ) { NG_FREE_ITEM ( item ) ; if ( error == EINVAL && priv -> ctrlnode != 0 ) { struct ng_mesg * msg ; NG_MKMESSAGE ( msg , NGM_MPPC_COOKIE , NGM_MPPC_RESETREQ , 0 , M_NOWAIT ) ; if ( msg == NULL ) return ( error ) ; NG_SEND_MSG_ID ( error , node , msg , priv -> ctrlnode , 0 ) ; } return ( error ) ; } NG_FWD_NEW_DATA ( error , item , priv -> recv . hook , m ) ; return ( error ) ; } panic ( " " , __func__ ) ; }
Receive incoming data on our hook.
Receive incoming data on our hook .
/* Compress and/or encrypt */ /* Decompress and/or decrypt */ /* Need to send a reset-request */ /* Oops */