// File: /workspace/github_cpp_makefile_star2_O2/dguglielmi[P]dlan-linux-software/tools/dlanlist.cpp
// Function: main
int main(int argc, char** argv)
{
  int result = 0;
  std::set<std::string> setIfcNames;

  for(int i = 1; i < argc; ++i)
  {
    if(argv[i][0] == '-')
      result = -1;
    else
      setIfcNames.insert(argv[i]);
  }
  
  if(result == -1)
  {
    printf("Usage: dlanlist [IFACES...]\n"
           "\n"
           "List dlan devices found on the given network interfaces,\n"
           "or on all interfaces, if none where given.\n"
           "\n");

    return result;
  }

  CPacketInterfaceLinux pktIfc(setIfcNames);
  CDlanMonitor m(pktIfc);
  CPacketTaskRunner(pktIfc, m).Run(1000, MSCounter());

  if(m.GetLocalDevices().empty())
  {
    printf("no devices found\n");
    return 1;
  }

  printf("Type    MAC address        Mbps TX/RX       Version/Product\n");
  for(CDlanLocalDeviceList::const_iterator itLocal = m.GetLocalDevices().begin();
    (itLocal != m.GetLocalDevices().end()); ++itLocal)
  {
    printf("local   %s  ---.-- / ---.--  %s\n",
      itLocal->GetAddress().ToString().c_str(),
      VersionProductString(*itLocal).c_str());
 
    for(CDlanRemoteDeviceList::const_iterator itRemote = itLocal->GetRemoteDevices().begin();
      (itRemote != itLocal->GetRemoteDevices().end()); ++itRemote)
    {
      if(itRemote->GetType() == CDlanDevice::eThunderbolt)
      {
        printf("remote  %s  %6.02f / %6.02f  %s\n",
          itRemote->GetAddress().ToString().c_str(),
          itRemote->GetTxRate(),
          itRemote->GetRxRate(),
          itRemote->GetVersion().c_str());
      }
      else
      {
        printf("remote  %s  %6.02f / ---.--  %s\n",
          itRemote->GetAddress().ToString().c_str(),
          itRemote->GetTxRate(),
          VersionProductString(*itRemote).c_str());
      }
    }
  }
  
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %rbx
leaq 0x68(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movslq %edi, %r13
xorl %r12d, %r12d
pushq $0x1
popq %rbp
pushq $-0x1
popq %r15
leaq 0xb0(%rsp), %r14
cmpq %r13, %rbp
jge 0x46d1
movq (%rbx,%rbp,8), %rsi
cmpb $0x2d, (%rsi)
movl %r15d, %eax
je 0x46c9
movq %r14, %rdi
leaq 0x188(%rsp), %rdx
callq 0x4a2a
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
callq 0x532c
movq %r14, %rdi
callq 0x4170
movl %r12d, %eax
incq %rbp
movl %eax, %r12d
jmp 0x4690
cmpl $-0x1, %r12d
je 0x4903
leaq 0x188(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x113cc
leaq 0xea94(%rip), %rcx      # 0x13188
leaq 0xb0(%rsp), %rbx
leaq 0x188(%rsp), %r14
pushq $0x3f
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4a66
leaq 0x20(%rsp), %rdi
movq %r14, (%rdi)
movq %rbx, 0x8(%rdi)
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x4b74
leaq 0x140(%rsp), %r14
cmpq %r14, (%r14)
je 0x4914
leaq 0xe977(%rip), %rdi      # 0x130b7
callq 0x43a0
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %r13
leaq 0x90(%rsp), %r12
xorl %ebx, %ebx
movq %r14, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq %r14, %rax
je 0x4923
movq %r15, %rdi
leaq 0xe8cb(%rip), %rsi      # 0x13049
leaq 0x7(%rsp), %rdx
callq 0x4a2a
movq 0x8(%rsp), %rax
leaq 0x10(%rax), %rbx
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x11178
movq 0x20(%rsp), %r14
movq %r12, %rdi
movq %rbx, %rsi
callq 0x45ac
movq 0x90(%rsp), %rdx
leaq 0xe86a(%rip), %rdi      # 0x13028
movq %r14, %rsi
xorl %eax, %eax
callq 0x4040
movq %r12, %rdi
callq 0x4170
movq %r13, %rdi
callq 0x4170
movq %r15, %rdi
callq 0x4170
movq 0x8(%rsp), %rax
leaq 0xb0(%rax), %rbp
movq %rbp, %r14
movq %rbp, 0x10(%rsp)
movq (%r14), %r14
cmpq %rbp, %r14
je 0x48f4
leaq 0x10(%r14), %rbx
cmpl $0x2, 0x18(%r14)
jne 0x4866
movq %r15, %rdi
leaq 0xe834(%rip), %rsi      # 0x13049
movq %r12, %rdx
callq 0x4a2a
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x11178
movq 0x20(%rsp), %rsi
movsd 0xa0(%r14), %xmm0
movsd 0xa8(%r14), %xmm1
movq 0x20(%r14), %rdx
leaq 0xe7fe(%rip), %rdi      # 0x1304b
movb $0x2, %al
callq 0x4040
movq %r13, %rdi
callq 0x4170
movq %r15, %rdi
callq 0x4170
jmp 0x47f4
movq %r15, %rdi
leaq 0xe7d9(%rip), %rsi      # 0x13049
leaq 0x7(%rsp), %rdx
callq 0x4a2a
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x11178
movq %r15, %rbp
movq %r13, %r15
movq 0x20(%rsp), %r13
movsd 0xa0(%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x45ac
movq 0x90(%rsp), %rdx
leaq 0xe7b0(%rip), %rdi      # 0x1306c
movq %r13, %rsi
movsd 0x18(%rsp), %xmm0
movb $0x1, %al
callq 0x4040
movq %r12, %rdi
callq 0x4170
movq %r15, %r13
movq %r15, %rdi
callq 0x4170
movq %rbp, %r15
movq %rbp, %rdi
callq 0x4170
movq 0x10(%rsp), %rbp
jmp 0x47f4
xorl %ebx, %ebx
leaq 0x140(%rsp), %r14
jmp 0x475e
leaq 0xe7fa(%rip), %rdi      # 0x13104
callq 0x43a0
pushq $-0x1
popq %rbx
jmp 0x493d
leaq 0xe7d8(%rip), %rdi      # 0x130f3
callq 0x43a0
pushq $0x1
popq %rbx
leaq 0xb0(%rsp), %rdi
callq 0x9954
leaq 0x188(%rsp), %rdi
callq 0x114ae
leaq 0x60(%rsp), %rdi
callq 0x5232
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4985
movq %rax, %rbx
jmp 0x49b3
jmp 0x497c
jmp 0x4985
jmp 0x4999
jmp 0x498a
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x4170
jmp 0x49c0
movq %rax, %rbx
jmp 0x49c0
jmp 0x4999
jmp 0x4985
movq %rax, %rbx
jmp 0x49a6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4170
jmp 0x499c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4170
leaq 0xb0(%rsp), %rdi
callq 0x9954
leaq 0x188(%rsp), %rdi
callq 0x114ae
leaq 0x60(%rsp), %rdi
callq 0x5232
movq %rbx, %rdi
callq 0x4410