FreeBSD/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
/**************************************************************
 * BridgeId
 **************************************************************
 * BRIDGE-MIB, REVISION		"200509190000Z"
 * BridgeId ::= TEXTUAL-CONVENTION
 *    STATUS	current
 *    DESCRIPTION
 *	"The Bridge-Identifier, as used in the Spanning Tree
 *	Protocol, to uniquely identify a bridge.  Its first two
 *	octets (in network byte order) contain a priority value,
 *	and its last 6 octets contain the MAC address used to
 *	refer to a bridge in a unique fashion (typically, the
 *	numerically smallest MAC address of all ports on the
 *	bridge)."
 *    SYNTAX	OCTET STRING (SIZE (8))
 */
BridgeId
BRIDGE-MIB, REVISION         "200509190000Z"
BridgeId ::= TEXTUAL-CONVENTION
STATUS    current
DESCRIPTION
"The Bridge-Identifier, as used in the Spanning Tree
Protocol, to uniquely identify a bridge.  Its first two
octets (in network byte order) contain a priority value,
and its last 6 octets contain the MAC address used to
refer to a bridge in a unique fashion (typically, the
numerically smallest MAC address of all ports on the
bridge)."
SYNTAX    OCTET STRING (SIZE (8))
BridgeId BRIDGE - MIB REVISION " 200509190000Z " BridgeId :: = TEXTUAL - CONVENTION STATUS current DESCRIPTION " The Bridge - Identifier as used in the Spanning Tree Protocol to uniquely identify a bridge . Its first two octets ( in network byte order ) contain a priority value and its last 6 octets contain the MAC address used to refer to a bridge in a unique fashion ( typically the numerically smallest MAC address of all ports on the bridge ) . " SYNTAX OCTET STRING ( SIZE ( 8 ))
static char *
snmp_oct2bridgeid(uint32_t len, char *octets, char *buf)
{
	char *ptr;
	uint32_t i, priority;
	if (len != SNMP_BRIDGEID_OCTETS || octets == NULL || buf == NULL)
		return (NULL);
	buf[0]= '\0';
	ptr = buf;
	priority = octets[0] << 8;
	priority += octets[1];
	if (priority > SNMP_MAX_BRIDGE_PRIORITY) {
		warnx("Invalid bridge priority %d", priority);
		return (NULL);
	} else
		ptr += sprintf(ptr, "%d.", octets[0]);
	ptr += sprintf(ptr, "%2.2x", octets[2]);
	for (i = 1; i < 6; i++)
		ptr += sprintf(ptr, ":%2.2x", octets[i + 2]);
	return (buf);
}
static char * snmp_oct2bridgeid ( uint32_t len , char * octets , char * buf ) { char * ptr ; uint32_t i , priority ; if ( len != SNMP_BRIDGEID_OCTETS || octets == NULL || buf == NULL ) return ( NULL ) ; buf [ 0 ] = ' \0 ' ; ptr = buf ; priority = octets [ 0 ] << 8 ; priority += octets [ 1 ] ; if ( priority > SNMP_MAX_BRIDGE_PRIORITY ) { warnx ( " " , priority ) ; return ( NULL ) ; } else ptr += sprintf ( ptr , " " , octets [ 0 ] ) ; ptr += sprintf ( ptr , " " , octets [ 2 ] ) ; for ( i = 1 ; i < 6 ; i ++ ) ptr += sprintf ( ptr , " " , octets [ i + 2 ] ) ; return ( buf ) ; }
BridgeId
 BRIDGE-MIB, REVISION         "200509190000Z"
 BridgeId ::= TEXTUAL-CONVENTION
    STATUS    current
    DESCRIPTION
      "The Bridge-Identifier, as used in the Spanning Tree
      Protocol, to uniquely identify a bridge.
BridgeId BRIDGE - MIB REVISION " 200509190000Z " BridgeId :: = TEXTUAL - CONVENTION STATUS current DESCRIPTION " The Bridge - Identifier as used in the Spanning Tree Protocol to uniquely identify a bridge .