FreeBSD/sys/netgraph/atm/ng_atm.c
/*
 * Produce a textual description of the current status
 */
Produce a textual description of the current status
Produce a textual description of the current status
static int
text_status(node_p node, char *arg, u_int len)
{
	const struct priv *priv = NG_NODE_PRIVATE(node);
	const struct ifatm_mib *mib;
	struct sbuf sbuf;
	u_int i;
	static const struct {
		const char	*name;
		const char	*vendor;
	} devices[] = {
		ATM_DEVICE_NAMES
	};
	mib = (const struct ifatm_mib *)(priv->ifp->if_linkmib);
	sbuf_new(&sbuf, arg, len, SBUF_FIXEDLEN);
	sbuf_printf(&sbuf, "interface: %s\n", priv->ifp->if_xname);
	if (mib->device >= nitems(devices))
		sbuf_printf(&sbuf, "device=unknown\nvendor=unknown\n");
	else
		sbuf_printf(&sbuf, "device=%s\nvendor=%s\n",
		    devices[mib->device].name, devices[mib->device].vendor);
	for (i = 0; atmmedia[i].name; i++)
		if(mib->media == atmmedia[i].media) {
			sbuf_printf(&sbuf, "media=%s\n", atmmedia[i].name);
			break;
		}
	if(atmmedia[i].name == NULL)
		sbuf_printf(&sbuf, "media=unknown\n");
	sbuf_printf(&sbuf, "serial=%u esi=%6D hardware=%u software=%u\n",
	    mib->serial, mib->esi, ":", mib->hw_version, mib->sw_version);
	sbuf_printf(&sbuf, "pcr=%u vpi_bits=%u vci_bits=%u max_vpcs=%u "
	    "max_vccs=%u\n", mib->pcr, mib->vpi_bits, mib->vci_bits,
	    mib->max_vpcs, mib->max_vccs);
	sbuf_printf(&sbuf, "ifflags=%b\n", priv->ifp->if_flags, IFFLAGS);
	sbuf_finish(&sbuf);
	return (sbuf_len(&sbuf));
}
static int text_status ( node_p node , char * arg , u_int len ) { const struct priv * priv = NG_NODE_PRIVATE ( node ) ; const struct ifatm_mib * mib ; struct sbuf sbuf ; u_int i ; static const struct { const char * name ; const char * vendor ; } devices [ ] = { ATM_DEVICE_NAMES } ; mib = ( const struct ifatm_mib * ) ( priv -> ifp -> if_linkmib ) ; sbuf_new ( & sbuf , arg , len , SBUF_FIXEDLEN ) ; sbuf_printf ( & sbuf , " \n " , priv -> ifp -> if_xname ) ; if ( mib -> device >= nitems ( devices ) ) sbuf_printf ( & sbuf , " \n \n " ) ; else sbuf_printf ( & sbuf , " \n \n " , devices [ mib -> device ] . name , devices [ mib -> device ] . vendor ) ; for ( i = 0 ; atmmedia [ i ] . name ; i ++ ) if ( mib -> media == atmmedia [ i ] . media ) { sbuf_printf ( & sbuf , " \n " , atmmedia [ i ] . name ) ; break ; } if ( atmmedia [ i ] . name == NULL ) sbuf_printf ( & sbuf , " \n " ) ; sbuf_printf ( & sbuf , " \n " , mib -> serial , mib -> esi , " " , mib -> hw_version , mib -> sw_version ) ; sbuf_printf ( & sbuf , " " " \n " , mib -> pcr , mib -> vpi_bits , mib -> vci_bits , mib -> max_vpcs , mib -> max_vccs ) ; sbuf_printf ( & sbuf , " \n " , priv -> ifp -> if_flags , IFFLAGS ) ; sbuf_finish ( & sbuf ) ; return ( sbuf_len ( & sbuf ) ) ; }
Produce a textual description of the current status
Produce a textual description of the current status