Beispiel #1
0
/*
 * Find the address entry for the SNMP index from the default bridge only.
 */
static struct tp_entry *
bridge_addrs_get(const struct asn_oid *oid, uint sub,
	struct bridge_if *bif)
{
	int i;
	uint8_t tp_addr[ETHER_ADDR_LEN];

	if (oid->len - sub != ETHER_ADDR_LEN + 1 ||
	    oid->subs[sub] != ETHER_ADDR_LEN)
		return (NULL);

	for (i = 0; i < ETHER_ADDR_LEN; i++)
		tp_addr[i] = oid->subs[sub + i + 1];

	return (bridge_addrs_find(tp_addr, bif));
}
Beispiel #2
0
/*
 * Update the addresses for the bridge interface.
 */
int
bridge_update_addrs(struct bridge_if *bif)
{
	int added, updated;
	uint32_t i;
	int32_t buf_len;
	struct tp_entry *te, *te_next;
	struct ifbareq *addr_req_buf, *addr_req;

	if ((buf_len = bridge_addrs_getinfo_ifalist(bif, &addr_req_buf)) < 0)
		return (-1);

	added = updated = 0;

#define	BA_FOUND	0x01
	for (i = 0; i < buf_len / sizeof(struct ifbareq); i++) {
		addr_req = addr_req_buf + i;

		if ((te = bridge_addrs_find(addr_req->ifba_dst, bif)) == NULL) {
			added++;

			if ((te = bridge_new_addrs(addr_req->ifba_dst, bif))
			    == NULL)
				continue;
		} else
			updated++;

		bridge_addrs_info_ifaddrlist(addr_req, te);
		te-> flags |= BA_FOUND;
	}
	free(addr_req_buf);

	for (te = bridge_addrs_bif_first(bif); te != NULL; te = te_next) {
		te_next = bridge_addrs_bif_next(te);

		if ((te-> flags & BA_FOUND) == 0)
			bridge_addrs_remove(te, bif);
		else
			te-> flags &= ~BA_FOUND;
	}
#undef	BA_FOUND

	bif->addrs_age = time(NULL);
	return (updated + added);
}