native: net: Make _native_tap_fd static

One global variable less is always good.
This commit is contained in:
Benoît Canet 2015-07-19 11:21:26 +02:00
parent 88a81a3753
commit 800b057fac
3 changed files with 17 additions and 4 deletions

View File

@ -36,7 +36,11 @@ extern "C" {
*/
int tap_init(char *name);
extern int _native_tap_fd;
/**
* Close tap device
*/
void tap_cleanup(void);
extern unsigned char _native_tap_mac[ETHER_ADDR_LEN];
struct nativenet_header {

View File

@ -73,9 +73,7 @@ int reboot_arch(int mode)
/* TODO: close stdio fds */
#endif
#ifdef MODULE_NATIVENET
if (_native_tap_fd != -1) {
real_close(_native_tap_fd);
}
tap_cleanup();
#endif
if (real_execve(_native_argv[0], _native_argv, NULL) == -1) {

View File

@ -351,4 +351,15 @@ int tap_init(char *name)
DEBUG("RIOT native tap initialized.\n");
return _native_tap_fd;
}
void tap_cleanup(void)
{
if (_native_tap_fd == -1) {
return;
}
real_close(_native_tap_fd);
_native_tap_fd = -1;
}
/** @} */