// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/nd6.c
// Function: nd6_tmr
void
nd6_tmr(void)
{
  s8_t i;
  struct netif *netif;

  /* Process neighbor entries. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    switch (neighbor_cache[i].state) {
    case ND6_INCOMPLETE:
      if ((neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) &&
          (!neighbor_cache[i].isrouter)) {
        /* Retries exceeded. */
        nd6_free_neighbor_cache_entry(i);
      } else {
        /* Send a NS for this entry. */
        neighbor_cache[i].counter.probes_sent++;
        nd6_send_neighbor_cache_probe(&neighbor_cache[i], ND6_SEND_FLAG_MULTICAST_DEST);
      }
      break;
    case ND6_REACHABLE:
      /* Send queued packets, if any are left. Should have been sent already. */
      if (neighbor_cache[i].q != NULL) {
        nd6_send_q(i);
      }
      if (neighbor_cache[i].counter.reachable_time <= ND6_TMR_INTERVAL) {
        /* Change to stale state. */
        neighbor_cache[i].state = ND6_STALE;
        neighbor_cache[i].counter.stale_time = 0;
      } else {
        neighbor_cache[i].counter.reachable_time -= ND6_TMR_INTERVAL;
      }
      break;
    case ND6_STALE:
      neighbor_cache[i].counter.stale_time++;
      break;
    case ND6_DELAY:
      if (neighbor_cache[i].counter.delay_time <= 1) {
        /* Change to PROBE state. */
        neighbor_cache[i].state = ND6_PROBE;
        neighbor_cache[i].counter.probes_sent = 0;
      } else {
        neighbor_cache[i].counter.delay_time--;
      }
      break;
    case ND6_PROBE:
      if ((neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) &&
          (!neighbor_cache[i].isrouter)) {
        /* Retries exceeded. */
        nd6_free_neighbor_cache_entry(i);
      } else {
        /* Send a NS for this entry. */
        neighbor_cache[i].counter.probes_sent++;
        nd6_send_neighbor_cache_probe(&neighbor_cache[i], 0);
      }
      break;
    case ND6_NO_ENTRY:
    default:
      /* Do nothing. */
      break;
    }
  }

  /* Process destination entries. */
  for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) {
    destination_cache[i].age++;
  }

  /* Process router entries. */
  for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) {
    if (default_router_list[i].neighbor_entry != NULL) {
      /* Active entry. */
      if (default_router_list[i].invalidation_timer <= ND6_TMR_INTERVAL / 1000) {
        /* No more than 1 second remaining. Clear this entry. Also clear any of
         * its destination cache entries, as per RFC 4861 Sec. 5.3 and 6.3.5. */
        s8_t j;
        for (j = 0; j < LWIP_ND6_NUM_DESTINATIONS; j++) {
          if (ip6_addr_cmp(&destination_cache[j].next_hop_addr,
               &default_router_list[i].neighbor_entry->next_hop_address)) {
             ip6_addr_set_any(&destination_cache[j].destination_addr);
          }
        }
        default_router_list[i].neighbor_entry->isrouter = 0;
        default_router_list[i].neighbor_entry = NULL;
        default_router_list[i].invalidation_timer = 0;
        default_router_list[i].flags = 0;
      } else {
        default_router_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
      }
    }
  }

  /* Process prefix entries. */
  for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) {
    if (prefix_list[i].netif != NULL) {
      if (prefix_list[i].invalidation_timer <= ND6_TMR_INTERVAL / 1000) {
        /* Entry timed out, remove it */
        prefix_list[i].invalidation_timer = 0;
        prefix_list[i].netif = NULL;
      } else {
        prefix_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
      }
    }
  }

  /* Process our own addresses, updating address lifetimes and/or DAD state. */
  NETIF_FOREACH(netif) {
    for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) {
      u8_t addr_state;
#if LWIP_IPV6_ADDRESS_LIFETIMES
      /* Step 1: update address lifetimes (valid and preferred). */
      addr_state = netif_ip6_addr_state(netif, i);
      /* RFC 4862 is not entirely clear as to whether address lifetimes affect
       * tentative addresses, and is even less clear as to what should happen
       * with duplicate addresses. We choose to track and update lifetimes for
       * both those types, although for different reasons:
       * - for tentative addresses, the line of thought of Sec. 5.7 combined
       *   with the potentially long period that an address may be in tentative
       *   state (due to the interface being down) suggests that lifetimes
       *   should be independent of external factors which would include DAD;
       * - for duplicate addresses, retiring them early could result in a new
       *   but unwanted attempt at marking them as valid, while retiring them
       *   late/never could clog up address slots on the netif.
       * As a result, we may end up expiring addresses of either type here.
       */
      if (!ip6_addr_isinvalid(addr_state) &&
          !netif_ip6_addr_isstatic(netif, i)) {
        u32_t life = netif_ip6_addr_valid_life(netif, i);
        if (life <= ND6_TMR_INTERVAL / 1000) {
          /* The address has expired. */
          netif_ip6_addr_set_valid_life(netif, i, 0);
          netif_ip6_addr_set_pref_life(netif, i, 0);
          netif_ip6_addr_set_state(netif, i, IP6_ADDR_INVALID);
        } else {
          if (!ip6_addr_life_isinfinite(life)) {
            life -= ND6_TMR_INTERVAL / 1000;
            LWIP_ASSERT("bad valid lifetime", life != IP6_ADDR_LIFE_STATIC);
            netif_ip6_addr_set_valid_life(netif, i, life);
          }
          /* The address is still here. Update the preferred lifetime too. */
          life = netif_ip6_addr_pref_life(netif, i);
          if (life <= ND6_TMR_INTERVAL / 1000) {
            /* This case must also trigger if 'life' was already zero, so as to
             * deal correctly with advertised preferred-lifetime reductions. */
            netif_ip6_addr_set_pref_life(netif, i, 0);
            if (addr_state == IP6_ADDR_PREFERRED)
              netif_ip6_addr_set_state(netif, i, IP6_ADDR_DEPRECATED);
          } else if (!ip6_addr_life_isinfinite(life)) {
            life -= ND6_TMR_INTERVAL / 1000;
            netif_ip6_addr_set_pref_life(netif, i, life);
          }
        }
      }
      /* The address state may now have changed, so reobtain it next. */
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
      /* Step 2: update DAD state. */
      addr_state = netif_ip6_addr_state(netif, i);
      if (ip6_addr_istentative(addr_state)) {
        if ((addr_state & IP6_ADDR_TENTATIVE_COUNT_MASK) >= LWIP_IPV6_DUP_DETECT_ATTEMPTS) {
          /* No NA received in response. Mark address as valid. For dynamic
           * addresses with an expired preferred lifetime, the state is set to
           * deprecated right away. That should almost never happen, though. */
          addr_state = IP6_ADDR_PREFERRED;
#if LWIP_IPV6_ADDRESS_LIFETIMES
          if (!netif_ip6_addr_isstatic(netif, i) &&
              netif_ip6_addr_pref_life(netif, i) == 0) {
            addr_state = IP6_ADDR_DEPRECATED;
          }
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
          netif_ip6_addr_set_state(netif, i, addr_state);
        } else if (netif_is_up(netif) && netif_is_link_up(netif)) {
          /* tentative: set next state by increasing by one */
          netif_ip6_addr_set_state(netif, i, addr_state + 1);
          /* Send a NS for this address. Use the unspecified address as source
           * address in all cases (RFC 4862 Sec. 5.4.2), not in the least
           * because as it is, we only consider multicast replies for DAD. */
          nd6_send_ns(netif, netif_ip6_addr(netif, i),
            ND6_SEND_FLAG_MULTICAST_DEST | ND6_SEND_FLAG_ANY_SRC);
        }
      }
    }
  }

#if LWIP_IPV6_SEND_ROUTER_SOLICIT
  /* Send router solicitation messages, if necessary. */
  if (!nd6_tmr_rs_reduction) {
    nd6_tmr_rs_reduction = (ND6_RTR_SOLICITATION_INTERVAL / ND6_TMR_INTERVAL) - 1;
    NETIF_FOREACH(netif) {
      if ((netif->rs_count > 0) && netif_is_up(netif) &&
          netif_is_link_up(netif) &&
          !ip6_addr_isinvalid(netif_ip6_addr_state(netif, 0)) &&
          !ip6_addr_isduplicated(netif_ip6_addr_state(netif, 0))) {
        if (nd6_send_rs(netif) == ERR_OK) {
          netif->rs_count--;
        }
      }
    }
  } else {
    nd6_tmr_rs_reduction--;
  }
#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0xb960(%rip), %rbx      # 0x1da20
xorl %r14d, %r14d
leaq 0x4712(%rip), %r15      # 0x167dc
pushq $0x1
popq %rbp
cmpq $0xa, %r14
je 0x12182
movzbl 0x30(%rbx), %eax
decl %eax
cmpl $0x4, %eax
ja 0x12176
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x120fd
cmpb $0x0, 0x31(%rbx)
je 0x1216d
incl %eax
movl %eax, 0x34(%rbx)
movq %rbx, %rdi
movl %ebp, %esi
jmp 0x12121
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x12117
cmpb $0x0, 0x31(%rbx)
je 0x1216d
incl %eax
movl %eax, 0x34(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x12456
jmp 0x12176
incl 0x34(%rbx)
jmp 0x12176
movl 0x34(%rbx), %eax
cmpl $0x1, %eax
ja 0x1215f
movb $0x5, 0x30(%rbx)
jmp 0x12159
cmpq $0x0, 0x28(%rbx)
je 0x1214b
movsbl %r14b, %edi
callq 0x11b97
movl 0x34(%rbx), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
ja 0x12163
movb $0x3, 0x30(%rbx)
andl $0x0, 0x34(%rbx)
jmp 0x12176
decl %eax
jmp 0x12168
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
movl %eax, 0x34(%rbx)
jmp 0x12176
movsbl %r14b, %edi
callq 0x12409
incq %r14
addq $0x38, %rbx
jmp 0x120cd
xorl %ecx, %ecx
leaq 0xbbe5(%rip), %rax      # 0x1dd70
cmpq $0x1e0, %rcx            # imm = 0x1E0
je 0x1219e
incl 0x2c(%rcx,%rax)
addq $0x30, %rcx
jmp 0x1218b
xorl %ecx, %ecx
leaq 0xbaa9(%rip), %rdx      # 0x1dc50
xorps %xmm0, %xmm0
xorl %esi, %esi
cmpq $0x3, %rsi
je 0x12248
movq %rsi, %rdi
shlq $0x4, %rdi
movq (%rdi,%rdx), %r8
testq %r8, %r8
je 0x12240
addq %rdx, %rdi
movl 0x8(%rdi), %r9d
cmpl $0x1, %r9d
ja 0x12228
xorl %r9d, %r9d
cmpq $0x1e0, %r9             # imm = 0x1E0
je 0x12231
movl 0x14(%r9,%rax), %r10d
cmpl (%r8), %r10d
jne 0x12222
movl 0x18(%r9,%rax), %r10d
cmpl 0x4(%r8), %r10d
jne 0x12222
movl 0x1c(%r9,%rax), %r10d
cmpl 0x8(%r8), %r10d
jne 0x12222
movl 0x20(%r9,%rax), %r10d
cmpl 0xc(%r8), %r10d
jne 0x12222
movb 0x24(%r9,%rax), %r10b
cmpb 0x10(%r8), %r10b
jne 0x12222
leaq (%rax,%r9), %r10
movaps %xmm0, (%r10)
movb $0x0, 0x10(%r10)
addq $0x30, %r9
jmp 0x121d6
decl %r9d
movl %r9d, 0x8(%rdi)
jmp 0x12240
movb %cl, 0x31(%r8)
andq $0x0, (%rdi)
andl $0x0, 0x8(%rdi)
movb %cl, 0xc(%rdi)
incq %rsi
jmp 0x121ac
pushq $0x20
popq %rax
leaq 0xba4e(%rip), %rcx      # 0x1dca0
cmpq $0xe8, %rax
je 0x12281
cmpq $0x0, -0x8(%rax,%rcx)
je 0x1227b
movl (%rax,%rcx), %edx
cmpl $0x1, %edx
ja 0x12276
andl $0x0, (%rax,%rcx)
andq $0x0, -0x8(%rax,%rcx)
jmp 0x1227b
decl %edx
movl %edx, (%rax,%rcx)
addq $0x28, %rax
jmp 0x12252
leaq 0xb650(%rip), %rbx      # 0x1d8d8
pushq $0x5
popq %rbp
pushq $0x10
popq %r14
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x123a4
leaq 0x50(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0x1228f
movb 0x98(%rbx,%r12), %al
testb %al, %al
je 0x1232b
movl 0x9c(%rbx,%r12,4), %ecx
cmpl $-0x1, %ecx
je 0x122f1
testl %ecx, %ecx
je 0x1232b
cmpl $0x1, %ecx
jne 0x122e7
andl $0x0, 0x9c(%rbx,%r12,4)
andl $0x0, 0xa8(%rbx,%r12,4)
movsbl %r12b, %esi
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x12315
decl %ecx
movl %ecx, 0x9c(%rbx,%r12,4)
movl 0xa8(%rbx,%r12,4), %ecx
cmpl $0x1, %ecx
ja 0x1231c
andl $0x0, 0xa8(%rbx,%r12,4)
cmpb $0x30, %al
jne 0x1232b
movsbl %r12b, %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x479d
jmp 0x1232b
cmpl $-0x1, %ecx
je 0x1232b
decl %ecx
movl %ecx, 0xa8(%rbx,%r12,4)
movzbl 0x98(%rbx,%r12), %eax
testb $0x8, %al
je 0x12398
testb $0x7, %al
je 0x1235a
cmpl $0x0, 0x9c(%rbx,%r12,4)
je 0x12387
cmpl $0x0, 0xa8(%rbx,%r12,4)
setne %al
shlb $0x5, %al
orb $0x10, %al
jmp 0x12389
movb 0xeb(%rbx), %cl
notb %cl
testb $0x5, %cl
jne 0x12398
orb $0x1, %al
movsbl %r12b, %esi
movzbl %al, %edx
movq %rbx, %rdi
callq 0x479d
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x12461
jmp 0x12398
movb $0x30, %al
movzbl %al, %edx
movsbl %r12b, %esi
movq %rbx, %rdi
callq 0x479d
incq %r12
addq $0x18, %r15
jmp 0x122a2
movb 0xbba6(%rip), %al       # 0x1df50
testb %al, %al
je 0x123bf
decb %al
movb %al, 0xbb9a(%rip)       # 0x1df50
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb $0x3, 0xbb8a(%rip)      # 0x1df50
leaq 0xb50b(%rip), %rbx      # 0x1d8d8
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x123b6
cmpb $0x0, 0xf0(%rbx)
je 0x123cd
movb 0xeb(%rbx), %al
notb %al
testb $0x5, %al
jne 0x123cd
movzbl 0x98(%rbx), %eax
testb $-0x41, %al
je 0x123cd
movq %rbx, %rdi
callq 0x11f4c
testb %al, %al
jne 0x123cd
decb 0xf0(%rbx)
jmp 0x123cd