FreeBSD/usr.sbin/bsnmpd/modules/snmp_bridge/bridge_if.c
/*
 * Callback for handling new bridge interface creation.
 */
Callback for handling new bridge interface creation.
Callback for handling new bridge interface creation .
int
bridge_attach_newif(struct mibif *ifp)
{
	u_char mac[ETHER_ADDR_LEN];
	struct bridge_if *bif;
	if (ifp->mib.ifmd_data.ifi_type != IFT_BRIDGE)
		return (0);
	TAILQ_FOREACH(bif, &bridge_ifs, b_if)
		if(strcmp(bif->bif_name, ifp->name) == 0) {
			syslog(LOG_ERR, "bridge interface %s already "
			    "in list", bif->bif_name);
			return (-1);
		}
	if (ifp->physaddr == NULL) {
		if (bridge_get_basemac(ifp->name, mac, sizeof(mac)) == NULL) {
			syslog(LOG_ERR, "bridge attach new %s failed - "
			    "no bridge mac address", ifp->name);
			return (-1);
		}
	} else
		bcopy(ifp->physaddr, &mac, sizeof(mac));
	if ((bif = bridge_new_bif(ifp->name, ifp->sysindex, mac)) == NULL)
		return (-1);
	if (ifp->mib.ifmd_flags & IFF_RUNNING)
		bif->if_status = RowStatus_active;
	else
		bif->if_status = RowStatus_notInService;
	if (bridge_getinfo_bif(bif) < 0 ||
	    (bif->num_ports = bridge_getinfo_bif_ports(bif)) < 0 ||
	    (bif->num_addrs = bridge_getinfo_bif_addrs(bif)) < 0) {
		bridge_remove_bif(bif);
		return (-1);
	}
	if (strcmp(ifp->name, bridge_get_default_name()) == 0)
		bridge_set_default(bif);
	return (0);
}
int bridge_attach_newif ( struct mibif * ifp ) { u_char mac [ ETHER_ADDR_LEN ] ; struct bridge_if * bif ; if ( ifp -> mib . ifmd_data . ifi_type != IFT_BRIDGE ) return ( 0 ) ; TAILQ_FOREACH ( bif , & bridge_ifs , b_if ) if ( strcmp ( bif -> bif_name , ifp -> name ) == 0 ) { syslog ( LOG_ERR , " " " " , bif -> bif_name ) ; return ( -1 ) ; } if ( ifp -> physaddr == NULL ) { if ( bridge_get_basemac ( ifp -> name , mac , sizeof ( mac ) ) == NULL ) { syslog ( LOG_ERR , " " " " , ifp -> name ) ; return ( -1 ) ; } } else bcopy ( ifp -> physaddr , & mac , sizeof ( mac ) ) ; if ( ( bif = bridge_new_bif ( ifp -> name , ifp -> sysindex , mac ) ) == NULL ) return ( -1 ) ; if ( ifp -> mib . ifmd_flags & IFF_RUNNING ) bif -> if_status = RowStatus_active ; else bif -> if_status = RowStatus_notInService ; if ( bridge_getinfo_bif ( bif ) < 0 || ( bif -> num_ports = bridge_getinfo_bif_ports ( bif ) ) < 0 || ( bif -> num_addrs = bridge_getinfo_bif_addrs ( bif ) ) < 0 ) { bridge_remove_bif ( bif ) ; return ( -1 ) ; } if ( strcmp ( ifp -> name , bridge_get_default_name ( ) ) == 0 ) bridge_set_default ( bif ) ; return ( 0 ) ; }
Callback for handling new bridge interface creation.
Callback for handling new bridge interface creation .
/* Make sure it does not exist in our list. */ /* Skip sending notifications if the interface was just created. */ /* Check whether we are the default bridge interface. */