Show device name in INITIALIZED state
This commit is contained in:
@@ -1157,7 +1157,9 @@ int main (int argc, char **argv)
|
|||||||
struct fdbuf tun = { .fd = -1 };
|
struct fdbuf tun = { .fd = -1 };
|
||||||
struct fdbuf sock = { .fd = -1 };
|
struct fdbuf sock = { .fd = -1 };
|
||||||
|
|
||||||
tun.fd = tun_create(dev, option_is_set(opts, "multiqueue"));
|
char *tun_name = NULL;
|
||||||
|
|
||||||
|
tun.fd = tun_create(dev, &tun_name, option_is_set(opts, "multiqueue"));
|
||||||
|
|
||||||
if (tun.fd==-1) {
|
if (tun.fd==-1) {
|
||||||
gt_log("couldn't create tun device\n");
|
gt_log("couldn't create tun device\n");
|
||||||
@@ -1189,7 +1191,7 @@ int main (int argc, char **argv)
|
|||||||
long retry = 0;
|
long retry = 0;
|
||||||
uint8_t *db = NULL;
|
uint8_t *db = NULL;
|
||||||
|
|
||||||
state("INITIALIZED", NULL);
|
state("INITIALIZED", tun_name);
|
||||||
|
|
||||||
while (!gt_close) {
|
while (!gt_close) {
|
||||||
if (retry_count>=0 && retry>=retry_count+1) {
|
if (retry_count>=0 && retry>=retry_count+1) {
|
||||||
|
|||||||
@@ -131,9 +131,9 @@ static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int tun_create (char *dev_name, int mq)
|
int tun_create (char *dev_name, char **ret_name, int mq)
|
||||||
{
|
{
|
||||||
char name[64];
|
char name[64] = {0};
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
#ifndef IFF_MULTI_QUEUE
|
#ifndef IFF_MULTI_QUEUE
|
||||||
@@ -148,8 +148,8 @@ int tun_create (char *dev_name, int mq)
|
|||||||
fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
|
fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd!=-1)
|
if (fd!=-1 && ret_name)
|
||||||
gt_print("tun name: %s\n", name);
|
*ret_name = strdup(name);
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int tun_create (char *, int);
|
int tun_create (char *, char **, int);
|
||||||
ssize_t tun_read (int, void *, size_t);
|
ssize_t tun_read (int, void *, size_t);
|
||||||
ssize_t tun_write (int, const void *, size_t);
|
ssize_t tun_write (int, const void *, size_t);
|
||||||
|
|||||||
Reference in New Issue
Block a user