Пример #1
0
status_t
add_interface(const char* name, net_domain_private* domain,
	const ifaliasreq& request, net_device_interface* deviceInterface)
{
	RecursiveLocker locker(sLock);

	if (find_interface(name) != NULL)
		return B_NAME_IN_USE;

	Interface* interface
		= new(std::nothrow) Interface(name, deviceInterface);
	if (interface == NULL)
		return B_NO_MEMORY;

	sInterfaces.Add(interface);
	interface->AcquireReference();
		// We need another reference to be able to use the interface without
		// holding sLock.

	locker.Unlock();

	status_t status = add_interface_address(interface, domain, request);
	if (status == B_OK)
		notify_interface_added(interface);
	else {
		locker.Lock();
		sInterfaces.Remove(interface);
		locker.Unlock();
		interface->ReleaseReference();
	}

	interface->ReleaseReference();

	return status;
}
Пример #2
0
/*!	Removes the interface from the list, and puts the stack's reference to it.
*/
void
remove_interface(Interface* interface)
{
	interface->SetDown();
	interface->RemoveAddresses();

	RecursiveLocker locker(sLock);
	sInterfaces.Remove(interface);
	locker.Unlock();

	notify_interface_removed(interface);

	interface->ReleaseReference();
}