// File: qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: isServerAddressAllowed(char*)
static bool isServerAddressAllowed(char *serverIp)
{
    int ii;
    addrParts srvAddr;
    bool allow;
    
    srvAddr = getAddrPartsFromString(serverIp);
    
    for(ii = 0; ii < SERVERS_LIST_SIZE; ii++) {
        allow = true;

        //List 255 == denied
        if ((srvListAllow[ii].a == 255) || (srvListAllow[ii].b == 255) || 
            (srvListAllow[ii].c == 255) || (srvListAllow[ii].d == 255))
            allow = false;
            
        //server 255 == denied
        if ((srvAddr.a == 255) || (srvAddr.b == 255) || (srvAddr.c == 255) || (srvAddr.d == 255))
            allow = false;
            
        //server 0 == denied
	//Fix by PFaf - 20101122
	//Server address can be X.0.0.Y i.e. 10.0.0.1 
        //since these are valid addresses, so we should not exclude them.
        //Only exclude addresses that start or end with zeros (0).
        //if ((srvAddr.a == 0) || (srvAddr.b == 0) || (srvAddr.c == 0) || (srvAddr.d == 0))
        if ((srvAddr.a == 0) || (srvAddr.d == 0))
            allow = false;
        
        //allowed so far ? 
        if (allow)
        {
            //allow if exact match or if place is 0 in allow list
            if (((srvAddr.a == srvListAllow[ii].a) || (srvListAllow[ii].a == 0)) &&
                ((srvAddr.b == srvListAllow[ii].b) || (srvListAllow[ii].b == 0)) &&
                ((srvAddr.c == srvListAllow[ii].c) || (srvListAllow[ii].c == 0)) &&
                ((srvAddr.d == srvListAllow[ii].d) || (srvListAllow[ii].d == 0)) ) {
                    //Allowed so far, check denial
                    if (!isServerAddressDenied(srvAddr)) {
                        debug(LEVEL_3, "isServerAddressAllowed(): address is OK, allowing (%s)\n", serverIp);
                        return true;
                    }
            }
        }
    }
    
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8f40
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x1c(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x32, -0x14(%rbp)
jge 0x6573
movb $0x1, -0x25(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x9053(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0xff, (%rax)
je 0x640d
movslq -0x14(%rbp), %rcx
leaq 0x9039(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0xff, 0x4(%rax)
je 0x640d
movslq -0x14(%rbp), %rcx
leaq 0x901e(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0xff, 0x8(%rax)
je 0x640d
movslq -0x14(%rbp), %rcx
leaq 0x9003(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0xff, 0xc(%rax)
jne 0x6411
movb $0x0, -0x25(%rbp)
cmpl $0xff, -0x24(%rbp)
je 0x6435
cmpl $0xff, -0x20(%rbp)
je 0x6435
cmpl $0xff, -0x1c(%rbp)
je 0x6435
cmpl $0xff, -0x18(%rbp)
jne 0x6439
movb $0x0, -0x25(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x6445
cmpl $0x0, -0x18(%rbp)
jne 0x6449
movb $0x0, -0x25(%rbp)
testb $0x1, -0x25(%rbp)
je 0x6563
movl -0x24(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x8f9f(%rip), %rcx      # 0xf400
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
je 0x6487
movslq -0x14(%rbp), %rcx
leaq 0x8f89(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x6561
movl -0x20(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x8f6b(%rip), %rcx      # 0xf400
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
je 0x64bd
movslq -0x14(%rbp), %rcx
leaq 0x8f54(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0x6561
movl -0x1c(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x8f35(%rip), %rcx      # 0xf400
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x64ef
movslq -0x14(%rbp), %rcx
leaq 0x8f1e(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jne 0x6561
movl -0x18(%rbp), %eax
movslq -0x14(%rbp), %rdx
leaq 0x8f03(%rip), %rcx      # 0xf400
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
je 0x6521
movslq -0x14(%rbp), %rcx
leaq 0x8eec(%rip), %rax      # 0xf400
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jne 0x6561
movq -0x24(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x1c(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x6590
testb $0x1, %al
jne 0x655f
movq -0x10(%rbp), %rdx
movl $0x3, %edi
leaq 0x5361(%rip), %rsi      # 0xb8b3
movb $0x0, %al
callq 0x2480
movb $0x1, -0x1(%rbp)
jmp 0x6577
jmp 0x6561
jmp 0x6563
jmp 0x6565
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6394
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)