Add net_stack_cleanup()

Add a cleanup function net_stack_cleanup() that calls a new NetStack::ShutDown() method.
Make sure this method works even if the network stack was never initialized.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
Andreas Faerber 2010-06-13 16:55:53 +02:00 committed by Augustin Cavalier
parent 9037351c6c
commit 74077e46e1
2 changed files with 21 additions and 0 deletions

View File

@ -26,6 +26,7 @@ private:
public:
static status_t CreateDefault();
static NetStack *Default();
static status_t ShutDown();
status_t AddEthernetInterface(EthernetInterface *interface);
@ -53,6 +54,7 @@ private:
// afterwards, which is supposed to add network interfaces.
status_t net_stack_init();
status_t platform_net_stack_init();
status_t net_stack_cleanup();
#endif // _BOOT_NET_STACK_H

View File

@ -120,6 +120,19 @@ NetStack::Default()
return sNetStack;
}
status_t
NetStack::ShutDown()
{
if (sNetStack != NULL) {
delete sNetStack;
sNetStack = NULL;
}
return B_OK;
}
// AddEthernetInterface
status_t
NetStack::AddEthernetInterface(EthernetInterface *interface)
@ -155,3 +168,9 @@ net_stack_init()
return platform_net_stack_init();
}
status_t
net_stack_cleanup()
{
return NetStack::ShutDown();
}