uint * int_create(uint param_1)
{
void *pvVar1;
int iVar2;
char *pcVar3;
int *piVar4;
int iVar5;
char *pcVar6;
uint uVar7;
uint *__s;
uint *__ifname;
undefined1 auStack_60 [16];
uint local_50 [4];
char acStack_40 [16];
ushort local_30;
iVar2 = g_conf;
uVar7 = param_1 + 1;
if (*(uint *)(g_conf + 4) < uVar7) {
pvVar1 = realloc(*(void **)(g_conf + 8),uVar7 * 0x90) //possible issue identified - semgrep
iVar5 = g_conf;
*(void **)(iVar2 + 8) = pvVar1;
iVar2 = *(int *)(iVar5 + 8);
if (iVar2 == 0) {
dolog(3,"Couldn\'t init() - no memory for interface array.\n");
/* WARNING: Subroutine does not return */
exit(-1);
}
iVar5 = *(int *)(iVar5 + 4);
memset((void *)(iVar2 + iVar5 * 0x90),0,((param_1 - iVar5) + 1) * 0x90);
*(uint *)(g_conf + 4) = uVar7;
}
iVar5 = *(int *)(g_conf + 8);
dolog(7,"Creating new interface %u\n",param_1);
iVar2 = socket(2,1,0);
if (iVar2 < 0) {
dolog(3,"Couldn\'t create tempory socket for ioctl\'s\n");
return (uint *)0x0;
}
__s = (uint *)(iVar5 + param_1 * 0x90);
memset(__s,0,0x90) //possible issue identified - semgrep
*__s = param_1;
__s[7] = 0;
memset(auStack_60,0,0x20) //possible issue identified - semgrep
__ifname = __s + 1;
pcVar3 = if_indextoname(param_1,(char *)__ifname);
if (pcVar3 == (char *)0x0) {
uVar7 = *__s;
piVar4 = __errno_location();
pcVar3 = strerror(*piVar4);
dolog(3,"Couldn\'t determine interfacename of link %d : %s\n",uVar7,pcVar3);
goto LAB_00406cfc;
}
memcpy(auStack_60,__ifname,0x10) //possible issue identified - semgrep
iVar5 = ioctl(iVar2,0x8921,auStack_60);
if (iVar5 == 0) {
__s[6] = local_50[0];
iVar5 = ioctl(iVar2,0x8927,auStack_60);
if (iVar5 == 0) {
memcpy(__s + 9,local_50,0x10) //possible issue identified - semgrep
if ((short)__s[9] == 0x304) goto LAB_00406cfc;
if (*(int *)(g_conf + 0x34) != 0) {
memset(acStack_40,0,0x20) //possible issue identified - semgrep
strncpy(acStack_40,(char *)__ifname,0x10) //possible issue identified - semgrep
iVar5 = ioctl(iVar2,0x8913,acStack_40);
if (iVar5 == 0) {
local_30 = local_30 | 0x100;
iVar5 = ioctl(iVar2,0x8914,acStack_40);
if (iVar5 == 0) goto LAB_00406e00;
}
uVar7 = *__s;
piVar4 = __errno_location();
pcVar3 = strerror(*piVar4);
dolog(4,"Couldn\'t get interface flags of %u/%s: %s\n",uVar7,__ifname,pcVar3);
}
LAB_00406e00:
close(iVar2);
iVar2 = g_conf;
if ((*(char **)(g_conf + 0x10) != (char *)0x0) &&
(pcVar3 = *(char **)(g_conf + 0x14), pcVar3 != (char *)0x0)) {
iVar5 = strcasecmp((char *)__ifname,*(char **)(g_conf + 0x10));
if (iVar5 == 0) {
__s[0x22] = 1;
*(uint *)(iVar2 + 0x18) = *__s;
}
else {
iVar2 = strcasecmp((char *)__ifname,pcVar3);
if (iVar2 != 0) {
dolog(7,"Neither upstream nor downstream interface of %u/%s\n",*__s,__ifname);
goto LAB_00406f0c;
}
__s[0x22] = 0;
}
iVar2 = g_conf;
iVar5 = strcasecmp((char *)__ifname,*(char **)(g_conf + 0x14));
if (iVar5 != 0) {
__s[0x23] = 0;
return __s;
}
__s[0x23] = 1;
*(uint *)(iVar2 + 0x1c) = *__s;
return __s;
}
dolog(3,"\n!!! Need specify upstream and downstream (should\'t happen)!!!\n");
LAB_00406f0c:
__s[6] = 0;
return (uint *)0x0;
}
uVar7 = *__s;
piVar4 = __errno_location();
pcVar3 = strerror(*piVar4);
pcVar6 = "Couldn\'t determine hardware address for %s, link %d : %s\n";
}
else {
uVar7 = *__s;
piVar4 = __errno_location();
pcVar3 = strerror(*piVar4);
pcVar6 = "Couldn\'t determine MTU size for %s, link %d : %s\n";
}
dolog(3,pcVar6,__ifname,uVar7,pcVar3);
perror("Error");
LAB_00406cfc:
__s[6] = 0;
close(iVar2);
return (uint *)0x0;
}