More tuntap refactoring

This commit is contained in:
Monsterovich 2024-03-25 03:59:45 +02:00
parent 4c2393d36a
commit 6967b8f80b
2 changed files with 4 additions and 3 deletions

View file

@ -103,7 +103,7 @@ JFUNC(jint, openTun) {
}
#endif
if (ioctl(fd, TAPGIFNAME, (void*)&ifr) < 0) {
if (ioctl(fd, TAPGIFNAME, &ifr) < 0) {
close(fd);
printf("error: ioctl(TAPGIFNAME)\n");
return 1;
@ -113,7 +113,7 @@ JFUNC(jint, openTun) {
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (ioctl(fd, TUNSETIFF, (void*)&ifr) < 0) {
if (ioctl(fd, TUNSETIFF, &ifr) < 0) {
close(fd);
printf("error: ioctl(TUNSETIFF)\n");
return 1;
@ -136,6 +136,7 @@ JFUNC(void, write, jbyteArray jb, jint len) {
fd = getFd(env, this);
b = (*env)->GetByteArrayElements(env, jb, NULL);
#pragma GCC diagnostic ignored "-Wunused-result"
write(fd, b, len);
(*env)->ReleaseByteArrayElements(env, jb, b, JNI_ABORT);

View file

@ -91,7 +91,7 @@ int findTapDevice(char *deviceID, int deviceIDLen, char *deviceName, int deviceN
status = RegQueryValueEx(key, "ComponentId", NULL, NULL, componentId, &len);
if (status == ERROR_SUCCESS &&
strncmp(componentId, TAP_COMPONENT_ID_PREFIX, strlen(TAP_COMPONENT_ID_PREFIX)) == 0) {
if (skip<1) {
if (skip < 1) {
len = deviceIDLen;
RegQueryValueEx(key, "NetCfgInstanceId", NULL, NULL, deviceID, &len);
} else {