FreeBSD/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
/*
 * Update the info we have for a single bridge interface.
 * Return:
 * 1, if successful
 * 0, if the interface was deleted
 * -1, error occurred while fetching the info from the kernel.
 */
Update the info we have for a single bridge interface.
Return:
1, if successful
0, if the interface was deleted
-1, error occurred while fetching the info from the kernel.
Update the info we have for a single bridge interface . Return : 1 if successful 0 if the interface was deleted - 1 error occurred while fetching the info from the kernel .
static int
bridge_update_bif(struct bridge_if *bif)
{
	struct mibif *ifp;
	for (ifp = mib_first_if(); ifp != NULL; ifp = mib_next_if(ifp))
		if (strcmp(ifp->name, bif->bif_name) == 0)
			break;
	if (ifp == NULL) {
		bridge_remove_bif(bif);
		return (0);
	}
	if (ifp->physaddr != NULL )
		bcopy(ifp->physaddr, bif->br_addr.octet, ETHER_ADDR_LEN);
	else
		bridge_get_basemac(bif->bif_name, bif->br_addr.octet,
		    ETHER_ADDR_LEN);
	if (ifp->mib.ifmd_flags & IFF_RUNNING)
		bif->if_status = RowStatus_active;
	else
		bif->if_status = RowStatus_notInService;
	switch (bridge_getinfo_bif(bif)) {
		case 2:
			bridge_new_root(bif);
			break;
		case 1:
			bridge_top_change(bif);
			break;
		case -1:
			bridge_remove_bif(bif);
			return (-1);
		default:
			break;
	}
	bif->num_ports = bridge_update_memif(bif);
	bif->entry_age = time(NULL);
	return (1);
}
static int bridge_update_bif ( struct bridge_if * bif ) { struct mibif * ifp ; for ( ifp = mib_first_if ( ) ; ifp != NULL ; ifp = mib_next_if ( ifp ) ) if ( strcmp ( ifp -> name , bif -> bif_name ) == 0 ) break ; if ( ifp == NULL ) { bridge_remove_bif ( bif ) ; return ( 0 ) ; } if ( ifp -> physaddr != NULL ) bcopy ( ifp -> physaddr , bif -> br_addr . octet , ETHER_ADDR_LEN ) ; else bridge_get_basemac ( bif -> bif_name , bif -> br_addr . octet , ETHER_ADDR_LEN ) ; if ( ifp -> mib . ifmd_flags & IFF_RUNNING ) bif -> if_status = RowStatus_active ; else bif -> if_status = RowStatus_notInService ; switch ( bridge_getinfo_bif ( bif ) ) { case 2 : bridge_new_root ( bif ) ; break ; case 1 : bridge_top_change ( bif ) ; break ; case -1 : bridge_remove_bif ( bif ) ; return ( -1 ) ; default : break ; } bif -> num_ports = bridge_update_memif ( bif ) ; bif -> entry_age = time ( NULL ) ; return ( 1 ) ; }
Update the info we have for a single bridge interface.
Update the info we have for a single bridge interface .
/* Walk through the mibII interface list. */ /* Ops, we do not exist anymore. */ /*
	 * The number of ports is accessible via SNMP -
	 * update the ports each time the bridge interface data
	 * is refreshed too.
	 */