summaryrefslogtreecommitdiff
path: root/module_test
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-05-08 20:31:19 +0800
committer杨威 <[email protected]>2023-05-16 17:47:35 +0800
commite725f5c8e14359c6e2d63fff833fc548e7523fd4 (patch)
treecbd8cec7a658d8a5d1097b9ec88e2c904dbbeaa4 /module_test
parent7aee7340527eaba27c9f2c770900efe406de0c88 (diff)
🧪 test(inline test): 增加ioctl输出时的打印信息
Diffstat (limited to 'module_test')
-rw-r--r--module_test/src/gtest_sapp_comm.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/module_test/src/gtest_sapp_comm.cpp b/module_test/src/gtest_sapp_comm.cpp
index d76649e..e5bec76 100644
--- a/module_test/src/gtest_sapp_comm.cpp
+++ b/module_test/src/gtest_sapp_comm.cpp
@@ -976,7 +976,7 @@ int ifconfig_device_up(const char *interface_name)
sprintf(ifr.ifr_name, "%s", interface_name);
/* 获得接口的标�?*/
if (ioctl(socket_fd, SIOCGIFFLAGS, (void *)&ifr) < 0) {
- perror("ioctl SIOCGIFADDR");
+ fprintf(stderr, "ifconfig_device_up(%s), ioctl SIOCGIFFLAGS: %s\n", interface_name, strerror(errno));
close(socket_fd);
return -3;
}
@@ -984,7 +984,7 @@ int ifconfig_device_up(const char *interface_name)
ret = ioctl(socket_fd, SIOCSIFFLAGS, &ifr);
if (ret != 0)
{
- printf("Up Device %s Failed.\n", interface_name);
+ fprintf(stderr, "ifconfig_device_up(%s), ioctl SIOCSIFFLAGS: %s\n", interface_name, strerror(errno));
close(socket_fd);
return -3;
}
@@ -1014,7 +1014,7 @@ int ifconfig_device_mtu(const char *interface_name, int mtu_val)
sprintf(ifr.ifr_name, "%s", interface_name);
/* 获得接口的标�?*/
if (ioctl(socket_fd, SIOCGIFMTU, (void *)&ifr) < 0) {
- perror("ioctl SIOCGIFMTU");
+ fprintf(stderr, "ifconfig_device_mtu(%s), ioctl SIOCGIFMTU: %s\n", interface_name, strerror(errno));
close(socket_fd);
return -3;
}
@@ -1022,7 +1022,7 @@ int ifconfig_device_mtu(const char *interface_name, int mtu_val)
ret = ioctl(socket_fd, SIOCSIFMTU, &ifr);
if (ret != 0)
{
- perror("ioctl SIOCSIFMTU");
+ fprintf(stderr, "ifconfig_device_mtu(%s), ioctl SIOCSIFMTU: %s\n", interface_name, strerror(errno));
close(socket_fd);
return -3;
}
@@ -1053,14 +1053,14 @@ int tuntap_dev_create(char *dev, int flags)
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
}
if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) {
- perror ("Error: ");
+ fprintf(stderr, "tuntap_dev_create(%s), ioctl TUNSETIFF: %s\n", dev, strerror(errno));
close(fd);
return err;
}
ifconfig_device_up(dev);
- ifconfig_device_mtu(dev, 2000); /* 某些pcap包可能开启了offload, 或者vlan, vxlan�? 增加MTU */
+ ifconfig_device_mtu(dev, 2000); /* 某些pcap包可能开启了offload, 或者vlan, vxlan 增加MTU */
return fd;
}