// File: dguglielmi[P]dlan-linux-software/common/packetinterface-linux.cpp
// Function: CPacketInterfaceLinux::RefreshAdapters()
bool CPacketInterfaceLinux::RefreshAdapters()
{
  m_macs.clear();

  std::map<CMACAddress,Interface> newifcs;
  
  std::set<std::string> setIfNames;
  
  if(m_ifcFilter.empty())
    GetInterfaceNames(setIfNames);
  else
    setIfNames = m_ifcFilter;
  
  for(std::set<std::string>::iterator itIfName = setIfNames.begin(); 
    itIfName != setIfNames.end(); ++itIfName)
  {
    CMACAddress mac;
    if (GetCMACAddress(itIfName->c_str(), mac) && m_macs.find(mac) == m_macs.end())
    {
      int ifindex;
      if(InterfaceIsActive(itIfName->c_str(), !m_ifcFilter.empty()) && GetInterfaceIndex(itIfName->c_str(), ifindex))
      {
        m_macs.insert(mac);
        std::map<CMACAddress,Interface>::iterator itIfc;
        if(((itIfc = m_ifcs.find(mac)) != m_ifcs.end()) &&
          (itIfc->second.ifname == *itIfName) && 
          (itIfc->second.ifindex == ifindex))
        {
          newifcs[mac] = itIfc->second;
          m_ifcs.erase(itIfc);
        }
        else
        {
          Interface newIfc;
          newIfc.ifname = *itIfName;
          newIfc.ifindex = ifindex;
          newIfc.fdsocket = openNewSocket(itIfName->c_str(), ifindex);
          if(newIfc.fdsocket != -1)
            newifcs[mac] = newIfc;
        }
      }
    }
  }

  closeAllSockets();
  m_ifcs = newifcs;

  AttachFilter();

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x110(%rbp)
addq $0x38, %rdi
callq 0x18a30
leaq -0x38(%rbp), %rdi
callq 0x344a0
leaq -0x68(%rbp), %rdi
callq 0x6350
movq -0x110(%rbp), %rdi
addq $0x8, %rdi
callq 0x34510
testb $0x1, %al
jne 0x32c7b
jmp 0x32ca0
movq -0x110(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x33190
jmp 0x32c8d
jmp 0x32cb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x33170
movq -0x110(%rbp), %rsi
addq $0x8, %rsi
leaq -0x68(%rbp), %rdi
callq 0x344c0
jmp 0x32cb6
jmp 0x32cb8
leaq -0x68(%rbp), %rdi
callq 0x34530
movq %rax, -0x80(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x34590
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x34560
testb $0x1, %al
jne 0x32cee
jmp 0x3311f
movq %rsp, %rax
movl $0x0, (%rax)
leaq -0x8e(%rbp), %rdi
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x6230
jmp 0x32d14
leaq -0x80(%rbp), %rdi
callq 0x345c0
movq %rax, %rdi
callq 0x5170
movq -0x110(%rbp), %rdi
movq %rax, %rsi
leaq -0x8e(%rbp), %rdx
callq 0x33650
movb %al, -0x111(%rbp)
jmp 0x32d43
movb -0x111(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x112(%rbp)
jne 0x32d58
jmp 0x32db6
movq -0x110(%rbp), %rdi
addq $0x38, %rdi
leaq -0x8e(%rbp), %rsi
callq 0x197a0
movq %rax, -0x120(%rbp)
jmp 0x32d78
movq -0x110(%rbp), %rdi
movq -0x120(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0x38, %rdi
callq 0x179e0
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x17ce0
movb %al, -0x112(%rbp)
movb -0x112(%rbp), %al
testb $0x1, %al
jne 0x32dc5
jmp 0x330f7
leaq -0x80(%rbp), %rdi
callq 0x345c0
movq %rax, %rdi
callq 0x5170
movq -0x110(%rbp), %rdi
movq %rax, -0x130(%rbp)
addq $0x8, %rdi
callq 0x34510
movq -0x110(%rbp), %rdi
movq -0x130(%rbp), %rsi
xorb $0x1, %al
movzbl %al, %edx
callq 0x33750
movb %al, -0x121(%rbp)
jmp 0x32e0d
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x32e1c
jmp 0x330f5
leaq -0x80(%rbp), %rdi
callq 0x345c0
movq %rax, %rdi
callq 0x5170
movq -0x110(%rbp), %rdi
movq %rax, %rsi
leaq -0xa4(%rbp), %rdx
callq 0x33840
movb %al, -0x131(%rbp)
jmp 0x32e4b
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x32e5a
jmp 0x330f5
movq -0x110(%rbp), %rdi
addq $0x38, %rdi
leaq -0x8e(%rbp), %rsi
callq 0x17930
movb %dl, -0x141(%rbp)
movq %rax, -0x140(%rbp)
jmp 0x32e80
movb -0x141(%rbp), %al
movq -0x140(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movb %al, -0xb0(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x345f0
movq -0x110(%rbp), %rdi
addq $0x68, %rdi
leaq -0x8e(%rbp), %rsi
callq 0x34640
movq %rax, -0x150(%rbp)
jmp 0x32ec6
movq -0x110(%rbp), %rdi
movq -0x150(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
addq $0x68, %rdi
callq 0x34670
movq %rax, -0xd0(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x34610
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x151(%rbp)
jne 0x32f1d
jmp 0x32f7b
leaq -0xc0(%rbp), %rdi
callq 0x346a0
addq $0x8, %rax
movq %rax, -0x160(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x346c0
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0xd9d0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x151(%rbp)
jne 0x32f5d
jmp 0x32f7b
leaq -0xc0(%rbp), %rdi
callq 0x346a0
movl 0x28(%rax), %eax
cmpl -0xa4(%rbp), %eax
sete %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x32f8a
jmp 0x33021
leaq -0xc0(%rbp), %rdi
callq 0x346a0
addq $0x8, %rax
movq %rax, -0x170(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x8e(%rbp), %rsi
callq 0x346e0
movq %rax, -0x168(%rbp)
jmp 0x32fba
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rdi
callq 0x347c0
jmp 0x32fcf
movq -0x110(%rbp), %rdi
addq $0x68, %rdi
movq -0xc0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rsi
callq 0x34800
movq %rax, -0x178(%rbp)
jmp 0x32ffd
movq -0x178(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0x330f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x33111
leaq -0x108(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x34840
leaq -0x80(%rbp), %rdi
callq 0x346c0
movq -0x180(%rbp), %rdi
movq %rax, %rsi
callq 0x5050
jmp 0x3304e
movl -0xa4(%rbp), %eax
movl %eax, -0xe8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x345c0
movq %rax, %rdi
callq 0x5170
movq -0x110(%rbp), %rdi
movq %rax, %rsi
movl -0xa4(%rbp), %edx
callq 0x33900
movl %eax, -0x184(%rbp)
jmp 0x33088
movl -0x184(%rbp), %eax
movl %eax, -0xe4(%rbp)
cmpl $-0x1, -0xe4(%rbp)
je 0x330e7
leaq -0x38(%rbp), %rdi
leaq -0x8e(%rbp), %rsi
callq 0x346e0
movq %rax, -0x190(%rbp)
jmp 0x330b6
movq -0x190(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x347c0
jmp 0x330cb
jmp 0x330e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x34860
jmp 0x33111
leaq -0x108(%rbp), %rdi
callq 0x34860
jmp 0x330f5
jmp 0x330f7
leaq -0x8e(%rbp), %rdi
callq 0x6b70
leaq -0x80(%rbp), %rdi
callq 0x34880
jmp 0x32cc5
leaq -0x8e(%rbp), %rdi
callq 0x6b70
jmp 0x33170
movq -0x110(%rbp), %rdi
callq 0x32b50
jmp 0x3312d
movq -0x110(%rbp), %rdi
addq $0x68, %rdi
leaq -0x38(%rbp), %rsi
callq 0x348b0
jmp 0x33143
movq -0x110(%rbp), %rdi
callq 0x339d0
jmp 0x33151
leaq -0x68(%rbp), %rdi
callq 0x6370
leaq -0x38(%rbp), %rdi
callq 0x344f0
movb $0x1, %al
andb $0x1, %al
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x6370
leaq -0x38(%rbp), %rdi
callq 0x344f0
movq -0x70(%rbp), %rdi
callq 0x5530
nopl (%rax,%rax)