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:
parent
9037351c6c
commit
74077e46e1
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user