mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
read device name in FreeBSD
This commit is contained in:
15
src/tun.c
15
src/tun.c
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
@@ -414,6 +415,20 @@ int open_tun(main_server_st* s, struct lease_st** l)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* find device name */
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
ret = fstat(tunfd, &st);
|
||||
if (ret < 0) {
|
||||
e = errno;
|
||||
mslog(s, NULL, LOG_ERR, "%s: stat: %s\n", strerror(e));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
snprintf(lease->name, sizeof(lease->name), "%s", devname(st.st_rdev, S_IFCHR));
|
||||
}
|
||||
|
||||
set_cloexec_flag (tunfd, 1);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user