// File: yahoo[P]UDPing/src/clientsession.cc
// Function: ClientSessionList::ClientSessionList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int)
ClientSessionList::ClientSessionList (
                string srcHost, string srcPorts, string dstHost, int dstPort,
                string dstMacList, int interval, int maxPacketSize )
{
    this->numPorts = 0;
    this->maxPacketSize = maxPacketSize;
    this->srcAddr = getSockAddr(srcHost.c_str(), dstPort);
    this->dstAddr = getSockAddr(dstHost.c_str(), dstPort);
    this->interval = interval;
    this->dstPort = dstPort;
    memset (srcMac, 0, 6);
    if (getIfInfo(srcHost.c_str(), &ifIndex, srcMac) < 0) {
        cerr << "getIfInfo failed" << endl;
        exit (-1);
    }
    socketFD = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
    if (socketFD < 0) {
        cerr << "socket() failed" << endl;
        exit (-1);
    }
    if (string::npos != srcPorts.find_first_not_of("1234567890,-")) {
        cerr << "Invalid source port descriptor " << srcPorts << endl;
        exit (-1);
    }
    char ports [1000];
    strncpy(ports, srcPorts.c_str(), 1000);
    char* curRange;
    char* curRangePtr = 0 ;
    char* pports = ports;
    while (curRange = strtok_r(pports, ",", &curRangePtr)) {
        pports = 0;
        char* startString = curRange;
        char* endString = 0;
        if (endString = strchr(curRange, '-')) {
            *endString = 0;
            endString++;
        }
        int start = atoi(startString);
        int end = start;
        if (endString) {
            end = atoi(endString);
        }
        if (isValidPort(start) && isValidPort(end) && (start <= end)) {
            for (int ix = start; ix <= end; ix++) {
                if (getOptions()->getFlagOption('v')) {
                    cout << "Adding port " << ix << endl;
                }
                sessions.push_back(new ClientSession(ix, dstMacList, this));
                this->numPorts ++;
            }
        } else {
            cerr << "Invalid port range " << start << "-" << end << endl;
            exit(-1);
        }
        if (sessions.size() > MAX_SOCKETS) {
            cerr << "Too many ports defined"<< endl;
            exit (-1);
        }
        if (sessions.size() == 0) {
            cerr << "No ports defined"<< endl;
            exit (-1);
        }
    }
    this->curSession = this->sessions.begin();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movq %r9, -0x550(%rbp)
movq %rcx, -0x548(%rbp)
movq %rdx, -0x540(%rbp)
movq %rsi, -0x528(%rbp)
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x530(%rbp)
addq $0x8, %rdi
movq %rdi, -0x538(%rbp)
callq 0x5a50
movq -0x530(%rbp), %rdi
addq $0x20, %rdi
callq 0x5a70
movq -0x530(%rbp), %rax
movq -0x528(%rbp), %rdi
movl $0x0, (%rax)
movl 0x18(%rbp), %ecx
movl %ecx, 0x4(%rax)
callq 0x2150
movq %rax, -0x520(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x2430
movq -0x520(%rbp), %rsi
movq -0x518(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x2380
jmp 0x4cbf
movl -0x24(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0x45d0
movq %rax, -0x558(%rbp)
jmp 0x4cd4
movq -0x530(%rbp), %rax
movq -0x558(%rbp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x50(%rbp), %rdi
callq 0x21c0
leaq -0x51(%rbp), %rdi
callq 0x2320
movq -0x548(%rbp), %rdi
callq 0x2150
movq %rax, -0x568(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x560(%rbp)
callq 0x2430
movq -0x568(%rbp), %rsi
movq -0x560(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x2380
jmp 0x4d3a
movl -0x24(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0x45d0
movq %rax, -0x570(%rbp)
jmp 0x4d52
movq -0x530(%rbp), %rax
movq -0x570(%rbp), %rcx
movq %rcx, 0x30(%rax)
leaq -0x88(%rbp), %rdi
callq 0x21c0
leaq -0x89(%rbp), %rdi
callq 0x2320
movq -0x530(%rbp), %rax
movq -0x528(%rbp), %rdi
movl 0x10(%rbp), %ecx
movl %ecx, 0x48(%rax)
movl -0x24(%rbp), %ecx
movl %ecx, 0x4c(%rax)
movw $0x0, 0x40(%rax)
movl $0x0, 0x3c(%rax)
callq 0x2150
movq %rax, -0x580(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0x2430
movq -0x580(%rbp), %rsi
movq -0x578(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x2380
jmp 0x4dde
movq -0x530(%rbp), %rdx
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x3c, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x66f0
movl %eax, -0x584(%rbp)
jmp 0x4e04
leaq -0xb0(%rbp), %rdi
callq 0x21c0
leaq -0xb1(%rbp), %rdi
callq 0x2320
movl -0x584(%rbp), %eax
cmpl $0x0, %eax
jge 0x4f16
movq 0x51be(%rip), %rdi      # 0x9ff0
leaq 0x28d6(%rip), %rsi      # 0x770f
callq 0x22f0
movq %rax, -0x590(%rbp)
jmp 0x4e47
movq -0x590(%rbp), %rdi
movq 0x5163(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x4e5c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x4e89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x21c0
leaq -0x51(%rbp), %rdi
callq 0x2320
jmp 0x5473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x4ebd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x21c0
leaq -0x89(%rbp), %rdi
callq 0x2320
jmp 0x5473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x4ef4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x21c0
leaq -0xb1(%rbp), %rdi
callq 0x2320
jmp 0x5473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x5473
movl $0x3, %edi
callq 0x2060
movzwl %ax, %edx
movl $0x11, %edi
movl $0x3, %esi
callq 0x20d0
movl %eax, %ecx
movq -0x530(%rbp), %rax
movl %ecx, 0x44(%rax)
cmpl $0x0, 0x44(%rax)
jge 0x4f7f
movq 0x50a5(%rip), %rdi      # 0x9ff0
leaq 0x27ce(%rip), %rsi      # 0x7720
callq 0x22f0
movq %rax, -0x598(%rbp)
jmp 0x4f60
movq -0x598(%rbp), %rdi
movq 0x504a(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x4f75
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movq -0x540(%rbp), %rdi
leaq 0x27a3(%rip), %rsi      # 0x7730
xorl %eax, %eax
movl %eax, %edx
callq 0x21b0
movq %rax, %rcx
movq $-0x1, %rax
cmpq %rcx, %rax
je 0x4ffc
movq 0x5044(%rip), %rdi      # 0x9ff0
leaq 0x278a(%rip), %rsi      # 0x773d
callq 0x22f0
movq %rax, -0x5a0(%rbp)
jmp 0x4fc1
movq -0x540(%rbp), %rsi
movq -0x5a0(%rbp), %rdi
callq 0x2260
movq %rax, -0x5a8(%rbp)
jmp 0x4fdd
movq -0x5a8(%rbp), %rdi
movq 0x4fcd(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x4ff2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movq -0x540(%rbp), %rdi
leaq -0x4a0(%rbp), %rax
movq %rax, -0x5b0(%rbp)
callq 0x2150
movq -0x5b0(%rbp), %rdi
movq %rax, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x2190
movq $0x0, -0x4b0(%rbp)
leaq -0x4a0(%rbp), %rax
movq %rax, -0x4b8(%rbp)
movq -0x4b8(%rbp), %rdi
leaq 0x270c(%rip), %rsi      # 0x775d
leaq -0x4b0(%rbp), %rdx
callq 0x2450
movq %rax, -0x4a8(%rbp)
cmpq $0x0, %rax
je 0x543e
movq $0x0, -0x4b8(%rbp)
movq -0x4a8(%rbp), %rax
movq %rax, -0x4c0(%rbp)
movq $0x0, -0x4c8(%rbp)
movq -0x4a8(%rbp), %rdi
movl $0x2d, %esi
callq 0x2130
movq %rax, -0x4c8(%rbp)
cmpq $0x0, %rax
je 0x50cc
movq -0x4c8(%rbp), %rax
movb $0x0, (%rax)
movq -0x4c8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4c8(%rbp)
movq -0x4c0(%rbp), %rdi
callq 0x23e0
movl %eax, -0x4cc(%rbp)
movl -0x4cc(%rbp), %eax
movl %eax, -0x4d0(%rbp)
cmpq $0x0, -0x4c8(%rbp)
je 0x5106
movq -0x4c8(%rbp), %rdi
callq 0x23e0
movl %eax, -0x4d0(%rbp)
movl -0x4cc(%rbp), %edi
callq 0x4b60
movl %eax, -0x5b4(%rbp)
jmp 0x5119
movl -0x5b4(%rbp), %eax
cmpl $0x0, %eax
je 0x5308
movl -0x4d0(%rbp), %edi
callq 0x4b60
movl %eax, -0x5b8(%rbp)
jmp 0x513b
movl -0x5b8(%rbp), %eax
cmpl $0x0, %eax
je 0x5308
movl -0x4cc(%rbp), %eax
cmpl -0x4d0(%rbp), %eax
jg 0x5308
movl -0x4cc(%rbp), %eax
movl %eax, -0x4d4(%rbp)
movl -0x4d4(%rbp), %eax
cmpl -0x4d0(%rbp), %eax
jg 0x5303
callq 0x4180
movq %rax, -0x5c0(%rbp)
jmp 0x5188
movq -0x5c0(%rbp), %rdi
movl $0x76, %esi
callq 0x40c0
movl %eax, -0x5c4(%rbp)
jmp 0x51a1
movl -0x5c4(%rbp), %eax
cmpl $0x0, %eax
je 0x51fa
movq 0x4e1d(%rip), %rdi      # 0x9fd0
leaq 0x25a5(%rip), %rsi      # 0x775f
callq 0x22f0
movq %rax, -0x5d0(%rbp)
jmp 0x51c8
movq -0x5d0(%rbp), %rdi
movl -0x4d4(%rbp), %esi
callq 0x2400
movq %rax, -0x5d8(%rbp)
jmp 0x51e3
movq -0x5d8(%rbp), %rdi
movq 0x4dc7(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x51f8
jmp 0x51fa
movq -0x530(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x5e8(%rbp)
movl $0x840, %edi            # imm = 0x840
callq 0x2300
movq %rax, -0x5e0(%rbp)
jmp 0x521f
movq -0x550(%rbp), %rsi
movb $0x1, -0x501(%rbp)
movl -0x4d4(%rbp), %eax
movl %eax, -0x5ec(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x2160
jmp 0x5247
movq -0x530(%rbp), %rcx
movl -0x5ec(%rbp), %esi
movq -0x5e0(%rbp), %rdi
leaq -0x500(%rbp), %rdx
callq 0x5670
jmp 0x5269
movq -0x5e8(%rbp), %rdi
movq -0x5e0(%rbp), %rax
movb $0x0, -0x501(%rbp)
movq %rax, -0x4e0(%rbp)
leaq -0x4e0(%rbp), %rsi
callq 0x5a90
jmp 0x5293
leaq -0x500(%rbp), %rdi
callq 0x21c0
movq -0x530(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x4d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d4(%rbp)
jmp 0x5168
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x52e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x21c0
testb $0x1, -0x501(%rbp)
jne 0x52f2
jmp 0x52fe
movq -0x5e0(%rbp), %rdi
callq 0x22b0
jmp 0x5473
jmp 0x5395
movq 0x4ce1(%rip), %rdi      # 0x9ff0
leaq 0x2456(%rip), %rsi      # 0x776c
callq 0x22f0
movq %rax, -0x5f8(%rbp)
jmp 0x5324
movq -0x5f8(%rbp), %rdi
movl -0x4cc(%rbp), %esi
callq 0x2400
movq %rax, -0x600(%rbp)
jmp 0x533f
movq -0x600(%rbp), %rdi
leaq 0x23ee(%rip), %rsi      # 0x773b
callq 0x22f0
movq %rax, -0x608(%rbp)
jmp 0x535b
movq -0x608(%rbp), %rdi
movl -0x4d0(%rbp), %esi
callq 0x2400
movq %rax, -0x610(%rbp)
jmp 0x5376
movq -0x610(%rbp), %rdi
movq 0x4c34(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x538b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movq -0x530(%rbp), %rdi
addq $0x8, %rdi
callq 0x5ad0
cmpq $0x1388, %rax           # imm = 0x1388
jbe 0x53e8
movq 0x4c3c(%rip), %rdi      # 0x9ff0
leaq 0x23c5(%rip), %rsi      # 0x7780
callq 0x22f0
movq %rax, -0x618(%rbp)
jmp 0x53c9
movq -0x618(%rbp), %rdi
movq 0x4be1(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x53de
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
movq -0x530(%rbp), %rdi
addq $0x8, %rdi
callq 0x5ad0
cmpq $0x0, %rax
jne 0x5439
movq 0x4beb(%rip), %rdi      # 0x9ff0
leaq 0x238b(%rip), %rsi      # 0x7797
callq 0x22f0
movq %rax, -0x620(%rbp)
jmp 0x541a
movq -0x620(%rbp), %rdi
movq 0x4b90(%rip), %rsi      # 0x9fb8
callq 0x2310
jmp 0x542f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2340
jmp 0x5043
movq -0x530(%rbp), %rdi
addq $0x8, %rdi
callq 0x5b00
movq %rax, %rcx
movq -0x530(%rbp), %rax
movq %rcx, -0x510(%rbp)
movq -0x510(%rbp), %rcx
movq %rcx, 0x20(%rax)
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
movq -0x538(%rbp), %rdi
callq 0x5b30
movq -0x60(%rbp), %rdi
callq 0x2420
nopl (%rax,%rax)