Пример #1
0
/*
 * Update the info we have for a single bridge interface.
 * Return:
 * 1, if successful
 * 0, if the interface was deleted
 * -1, error occured while fetching the info from the kernel.
 */
static int
bridge_update_bif(struct bridge_if *bif)
{
	struct mibif *ifp;

	/* Walk through the mibII interface list. */
	for (ifp = mib_first_if(); ifp != NULL; ifp = mib_next_if(ifp))
		if (strcmp(ifp->name, bif->bif_name) == 0)
			break;

	if (ifp == NULL) {
		/* Ops, we do not exist anymore. */
		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;
	}

	/*
	 * The number of ports is accessible via SNMP -
	 * update the ports each time the bridge interface data
	 * is refreshed too.
	 */
	bif->num_ports = bridge_update_memif(bif);
	bif->entry_age = time(NULL);

	return (1);
}
Пример #2
0
struct bridge_if *
bridge_get_default(void)
{
	struct mibif *ifp;

	if (bif_default != NULL) {

		/* Walk through the mibII interface list. */
		for (ifp = mib_first_if(); ifp != NULL; ifp = mib_next_if(ifp))
			if (strcmp(ifp->name, bif_default->bif_name) == 0)
				break;

		if (ifp == NULL)
			bif_default = NULL;
	}

	return (bif_default);
}
Пример #3
0
/*
 * Update all addresses only.
 */
void
bridge_update_all_addrs(void)
{
	struct mibif *ifp;
	struct bridge_if *bif, *t_bif;

	for (bif = bridge_first_bif(); bif != NULL; bif = t_bif) {
		t_bif = bridge_next_bif(bif);

		for (ifp = mib_first_if(); ifp != NULL;
		    ifp = mib_next_if(ifp))
			if (strcmp(ifp->name, bif->bif_name) == 0)
				break;

		if (ifp != NULL)
			bif->num_addrs = bridge_update_addrs(bif);
		else  /* Ops, we don't exist anymore. */
			bridge_remove_bif(bif);
	}

	bridge_addrs_update_listage();
}