// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xac7f(%rip), %rbx      # 0x1da10
xorl %r14d, %r14d
leaq 0x4a81(%rip), %r15      # 0x1781c
movzbl 0x30(%rbx), %eax
decl %eax
cmpl $0x4, %eax
ja 0x12e48
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x12dc1
cmpb $0x0, 0x31(%rbx)
je 0x12e3f
incl %eax
movl %eax, 0x34(%rbx)
movq 0x18(%rbx), %rdi
movq %rbx, %rsi
movl $0x1, %edx
jmp 0x12df0
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x12de2
cmpb $0x0, 0x31(%rbx)
je 0x12e3f
incl %eax
movl %eax, 0x34(%rbx)
movq 0x18(%rbx), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x13132
jmp 0x12e48
incl 0x34(%rbx)
jmp 0x12e48
movl 0x34(%rbx), %eax
cmpl $0x1, %eax
ja 0x12e31
movb $0x5, 0x30(%rbx)
jmp 0x12e28
cmpq $0x0, 0x28(%rbx)
je 0x12e1a
movsbl %r14b, %edi
callq 0x12438
movl 0x34(%rbx), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
ja 0x12e35
movb $0x3, 0x30(%rbx)
movl $0x0, 0x34(%rbx)
jmp 0x12e48
decl %eax
jmp 0x12e3a
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
movl %eax, 0x34(%rbx)
jmp 0x12e48
movsbl %r14b, %edi
callq 0x130db
incq %r14
addq $0x38, %rbx
cmpq $0xa, %r14
jne 0x12d9b
xorl %ecx, %ecx
leaq 0xaefe(%rip), %rax      # 0x1dd60
incl 0x2c(%rcx,%rax)
addq $0x30, %rcx
cmpq $0x1e0, %rcx            # imm = 0x1E0
jne 0x12e62
xorl %ecx, %ecx
leaq 0xadc4(%rip), %rdx      # 0x1dc40
xorps %xmm0, %xmm0
xorl %esi, %esi
movq %rsi, %rdi
shlq $0x4, %rdi
movq (%rdi,%rdx), %r8
testq %r8, %r8
je 0x12f0f
addq %rdx, %rdi
movl 0x8(%rdi), %r9d
cmpl $0x1, %r9d
ja 0x12f08
xorl %r9d, %r9d
movl 0x14(%r9,%rax), %r10d
cmpl (%r8), %r10d
jne 0x12ee4
movl 0x18(%r9,%rax), %r10d
cmpl 0x4(%r8), %r10d
jne 0x12ee4
movl 0x1c(%r9,%rax), %r10d
cmpl 0x8(%r8), %r10d
jne 0x12ee4
movl 0x20(%r9,%rax), %r10d
cmpl 0xc(%r8), %r10d
jne 0x12ee4
movb 0x24(%r9,%rax), %r10b
cmpb 0x10(%r8), %r10b
jne 0x12ee4
leaq (%rax,%r9), %r10
movaps %xmm0, (%r10)
movb $0x0, 0x10(%r10)
addq $0x30, %r9
cmpq $0x1e0, %r9             # imm = 0x1E0
jne 0x12ea1
movb %cl, 0x31(%r8)
movq $0x0, (%rdi)
movl $0x0, 0x8(%rdi)
movb %cl, 0xc(%rdi)
jmp 0x12f0f
decl %r9d
movl %r9d, 0x8(%rdi)
incq %rsi
cmpq $0x3, %rsi
jne 0x12e81
movl $0x20, %eax
leaq 0xad68(%rip), %rcx      # 0x1dc90
cmpq $0x0, -0x8(%rax,%rcx)
je 0x12f4f
movl (%rax,%rcx), %edx
cmpl $0x1, %edx
ja 0x12f4a
movl $0x0, (%rax,%rcx)
movq $0x0, -0x8(%rax,%rcx)
jmp 0x12f4f
decl %edx
movl %edx, (%rax,%rcx)
addq $0x28, %rax
cmpq $0xe8, %rax
jne 0x12f28
leaq 0xa976(%rip), %r14      # 0x1d8d8
movq (%r14), %rbx
testq %rbx, %rbx
je 0x13074
xorl %r15d, %r15d
leaq 0x98(%rbx), %r12
movq $-0x48, %r13
xorl %ebp, %ebp
movb (%r12,%rbp), %al
testb %al, %al
je 0x12ff4
movl 0x4(%r12,%rbp,4), %ecx
cmpl $-0x1, %ecx
je 0x12fbe
testl %ecx, %ecx
je 0x12ff4
cmpl $0x1, %ecx
jne 0x12fb7
movl %r15d, 0x9c(%rbx,%rbp,4)
movl %r15d, 0xa8(%rbx,%rbp,4)
movsbl %bpl, %esi
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x12fe1
decl %ecx
movl %ecx, 0x4(%r12,%rbp,4)
movl 0x10(%r12,%rbp,4), %ecx
cmpl $0x1, %ecx
ja 0x12fe8
movl $0x0, 0x10(%r12,%rbp,4)
cmpb $0x30, %al
jne 0x12ff4
movsbl %bpl, %esi
movq %rbx, %rdi
movl $0x10, %edx
callq 0x4949
jmp 0x12ff4
cmpl $-0x1, %ecx
je 0x12ff4
decl %ecx
movl %ecx, 0x10(%r12,%rbp,4)
movzbl (%r12,%rbp), %eax
testb $0x8, %al
je 0x1305b
testb $0x7, %al
je 0x13019
cmpl $0x0, 0x4(%r12,%rbp,4)
je 0x1304a
cmpl $0x0, 0x10(%r12,%rbp,4)
setne %al
shlb $0x5, %al
orb $0x10, %al
jmp 0x1304c
movb 0xeb(%rbx), %cl
notb %cl
testb $0x5, %cl
jne 0x1305b
orb $0x1, %al
movsbl %bpl, %esi
movzbl %al, %edx
movq %rbx, %rdi
callq 0x4949
leaq (%r12,%r13), %rsi
movq %rbx, %rdi
movl $0x5, %edx
callq 0x13132
jmp 0x1305b
movb $0x30, %al
movzbl %al, %edx
movsbl %bpl, %esi
movq %rbx, %rdi
callq 0x4949
incq %rbp
addq $0x18, %r13
jne 0x12f81
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x12f71
movb 0xaec6(%rip), %al       # 0x1df40
testb %al, %al
je 0x13095
decb %al
movb %al, 0xaeba(%rip)       # 0x1df40
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x3, 0xaea4(%rip)      # 0x1df40
movq (%r14), %rbx
testq %rbx, %rbx
je 0x13086
cmpb $0x0, 0xf0(%rbx)
je 0x130d6
movb 0xeb(%rbx), %al
notb %al
testb $0x5, %al
jne 0x130d6
movzbl 0x98(%rbx), %eax
testb $-0x41, %al
je 0x130d6
movq %rbx, %rdi
callq 0x12818
testb %al, %al
jne 0x130d6
decb 0xf0(%rbx)
movq (%rbx), %rbx
jmp 0x1309f