void FUN_00402080(int *param_1,int param_2)

{
  short sVar1;
  bool bVar2;
  bool bVar3;
  bool bVar4;
  time_t tVar5;
  FILE *__stream;
  int iVar6;
  int iVar7;
  int *piVar8;
  char *pcVar9;
  undefined4 uVar10;
  char *pcVar11;
  int local_178;
  undefined4 local_174;
  char *local_170;
  undefined4 local_16c;
  undefined4 local_168;
  undefined4 local_164;
  undefined4 local_160;
  undefined4 local_15c;
  char acStack_158 [16];
  undefined1 auStack_148 [16];
  int local_138;
  char acStack_128 [256];
  
  iVar6 = DAT_0041a424;
  local_178 = 0;
  tVar5 = time((time_t *)0x0);
  if (iVar6 + 299 < tVar5) {
    DAT_0041a424 = time((time_t *)0x0);
    dolog(7,"Updating Interfaces --> \n");
    __stream = fopen("/proc/net/if_inet6","r")   //possible issue identified - semgrep
    if (__stream != (FILE *)0x0) {
      piVar8 = param_1;
LAB_0040252c:
      bVar4 = false;
      bVar2 = false;
      bVar3 = false;
LAB_00402678:
      do {
        do {
          while( true ) {
            pcVar9 = fgets(acStack_128,0x100,__stream)   //possible issue identified - semgrep
            if (pcVar9 == (char *)0x0) goto LAB_0040269c;
            iVar6 = sscanf(acStack_128,
                           "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx %x %x %x %x %8s"
                           ,&local_168,(int)&local_168 + 1,(int)&local_168 + 2,(int)&local_168 + 3,
                           &local_164,(int)&local_164 + 1,(int)&local_164 + 2,(int)&local_164 + 3,
                           &local_160,(int)&local_160 + 1,(int)&local_160 + 2,(int)&local_160 + 3,
                           &local_15c,(int)&local_15c + 1,(int)&local_15c + 2,(int)&local_15c + 3,
                           &local_178,&local_174,&local_170,&local_16c,acStack_158)   //possible issue identified - semgrep
            if (iVar6 == 0x15) break;
            dolog(4,"/proc/net/if_inet6 has a broken line, ignoring");
          }
        } while ((((*(char **)(g_conf + 0x10) != (char *)0x0) &&
                  (pcVar9 = *(char **)(g_conf + 0x14), pcVar9 != (char *)0x0)) &&
                 (iVar6 = strcasecmp(acStack_158,*(char **)(g_conf + 0x10)), iVar6 != 0)) &&
                (iVar6 = strcasecmp(acStack_158,pcVar9), iVar6 != 0));
        pcVar11 = acStack_158;
        pcVar9 = local_170;
        uVar10 = local_16c;
        dolog(7,
              "Updating Interfaces, checking: ifindex:%x, prefixlen:%x, scope:%x, flags:%x, devname:%8s\n"
              ,local_178,local_174,local_170,local_16c,pcVar11);
      } while (((local_168 & 0xc0ff) != 0x80fe) &&
              ((((local_168 == 0 && (local_164 == 0)) &&
                ((local_160 == 0 && ((local_15c == 0 || (local_15c == 0x1000000)))))) ||
               ((char)local_168 == -1))));
      if (param_1 == (int *)0x0) {
        bVar4 = false;
        piVar8 = (int *)int_find();
        if (piVar8 == (int *)0x0) {
          piVar8 = (int *)int_create(local_178);
          if (piVar8 == (int *)0x0) goto LAB_0040252c;
          bVar4 = true;
        }
        bVar2 = false;
        bVar3 = false;
      }
      else {
        dolog(7,"Updating Interfaces for specific, intn->ifindex:%d, ifindex:%d\n",*piVar8,local_178
              ,pcVar9,uVar10,pcVar11);
        if (param_2 == 0) {
          piVar8 = param_1;
          if (*param_1 == local_178) goto LAB_00402678;
        }
        else {
          dolog(7,"Force updateing interfaces mtu for specific, OLD intn->ifindex:%d, mtu:%d\n",
                *param_1,param_1[6],pcVar9,uVar10,pcVar11);
          memset(auStack_148,0,0x20)   //possible issue identified - semgrep
          memcpy(auStack_148,param_1 + 1,0x10)   //possible issue identified - semgrep
          iVar6 = socket(2,1,0);
          if (iVar6 < 0) {
            dolog(3,"Couldn\'t create tempory socket for ioctl\'s (called by update_interfaces())\n"
                 );
            piVar8 = param_1;
          }
          else {
            iVar7 = ioctl(iVar6,0x8921,auStack_148);
            if (iVar7 == 0) {
              param_1[6] = local_138;
            }
            else {
              iVar7 = *param_1;
              piVar8 = __errno_location();
              pcVar9 = strerror(*piVar8);
              dolog(3,"Couldn\'t determine MTU size for %s, link %d : %s\n",param_1 + 1,iVar7,pcVar9
                   );
              perror("Error");
            }
            close(iVar6);
            dolog(7,"Force updateing interfaces mtu for specific, NEW intn->ifindex:%d, mtu:%d\n",
                  *param_1,param_1[6],pcVar9);
            piVar8 = param_1;
          }
        }
      }
      if ((local_168 & 0xc0ff) == 0x80fe) {
        memcpy(piVar8 + 0xd,&local_168,0x10)   //possible issue identified - semgrep
        bVar2 = true;
      }
      else {
        dolog(7,"Updating global IPv6 address for %s\n",piVar8 + 1);
        memcpy(piVar8 + 0x11,&local_168,0x10)   //possible issue identified - semgrep
        bVar3 = true;
      }
      if (param_1 == (int *)0x0) {
        if (bVar4) {
          if ((bool)(bVar2 | bVar3)) {
            sVar1 = (short)piVar8[9]   //possible issue identified - semgrep
            pcVar9 = "Ethernet";
            if ((sVar1 != 1) && (pcVar9 = "Unknown", sVar1 == 0x308)) {
              pcVar9 = "sit";
            }
            dolog(7,"Added %s, link %u, hw %s/%u with an MTU of %d\n",piVar8 + 1,*piVar8,pcVar9,
                  sVar1,piVar8[6]);
          }
          else {
            dolog(7,"[%-5s] Didn\'t get a linklocal or global address, interface destroying %u\n",
                  piVar8 + 1,*piVar8);
            bVar2 = false;
            bVar3 = false;
            int_destroy(piVar8);
          }
        }
      }
      else if ((bVar2) && (bVar3)) {
LAB_0040269c:
        dolog(7,"Updating Interfaces <--, highest ifindex: %u\n",*(undefined4 *)(g_conf + 4));
        fclose(__stream);
        return;
      }
      goto LAB_00402678;
    }
    dolog(4,"Couldn\'t open /proc/net/if_inet6 for figuring out local interfaces\n");
  }
  return;
}