// File: /workspace/github_c_makefile_star2_O2/hkshenSmart[P]ONVIF-discovery_cs/discovery-nvt.c
// Function: _dndl__Probe
SOAP_FMAC6 __dndl__Probe(struct soap* soap, struct d__ProbeType *d__Probe, struct d__ProbeMatchesType *d__ProbeMatches)
{
	static struct d__ProbeMatchType ProbeMatch;
	static struct d__ScopesType scopes;
    static char MessageID[100];
    static char szXAddr[64];
    static char szEndpointReference[64];
    static struct wsa__Relationship wsa_RelatesTo;

   	unsigned char MacAddr[8] ={0x00, 0x16, 0xe8, 0x53, 0x13, 0xc7};
    int localIP = inet_addr("192.168.7.33");  //0x6207A8C0
    //localIP = niGetLocalIPAddr(g_netEthNi);
    //memcpy(MacAddr, niGetHwAddr(g_netEthNi), 6);

    //    if(d__Probe->Types && strcasecmp(d__Probe->Types,"dn:NetworkVideoTransmitter")==0)

    sprintf(szXAddr, "http://%s/onvif/device_service", inet_ntoa(*((struct in_addr *)&localIP)));
	sprintf(szEndpointReference, "urn:uuid:11229344-5566-7788-99aa-%02x%02x%02x%02x%02x%02x",
                        MacAddr[0],MacAddr[1],MacAddr[2],MacAddr[3],MacAddr[4],MacAddr[5]);

	printf("__dndl__Probe %p, %p, %d\n", d__ProbeMatches, d__ProbeMatches->ProbeMatch, d__ProbeMatches->__sizeProbeMatch);
	soap_default_d__ProbeMatchType(soap, &ProbeMatch);
	soap_default_d__ScopesType(soap, &scopes);
	
	if (soap->header)
	{
        //uuid_t uuid;
		
        //uuid_generate(uuid);
        strcpy(MessageID, "urn:uuid:");//urn:uuid:
        //uuid_unparse(uuid, MessageID+9);

		if(soap->header->wsa__MessageID)
		{
			//printf("remote wsa__MessageID : %s\n",soap->header->wsa__MessageID);
 			soap->header->wsa__RelatesTo =&wsa_RelatesTo;
			soap_default__wsa__RelatesTo(soap, soap->header->wsa__RelatesTo);
			soap->header->wsa__RelatesTo->__item = soap->header->wsa__MessageID;

			soap->header->wsa__MessageID = MessageID;
			soap->header->wsa__To = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
			soap->header->wsa__Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches";
		}
	}

	scopes.__item =  "onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/hardware/IPC-model onvif://www.onvif.org/name/IPC-model";
	
	ProbeMatch.wsa__EndpointReference.Address = szEndpointReference;                 //"urn:uuid:464A4854-4656-5242-4530-313035394100";
	ProbeMatch.Types = "dn:NetworkVideoTransmitter";
	ProbeMatch.Scopes = &scopes;
	ProbeMatch.XAddrs = szXAddr;                                                    //"http://192.168.7.97/onvif/device_service";
	ProbeMatch.MetadataVersion = 1;

	d__ProbeMatches->__sizeProbeMatch = 1;
	d__ProbeMatches->ProbeMatch = &ProbeMatch;

    return SOAP_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r15
leaq 0x1eb60(%rip), %rdi     # 0x22004
callq 0x31f0
movl %eax, %edi
callq 0x30f0
leaq 0x2ff79(%rip), %r14     # 0x33430
leaq 0x1eb53(%rip), %rsi     # 0x22011
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3320
leaq 0x2ff9e(%rip), %r12     # 0x33470
leaq 0x1eb57(%rip), %rsi     # 0x22030
pushq $0x16
popq %rcx
pushq $0x53
popq %r9
movq %r12, %rdi
xorl %edx, %edx
movl $0xe8, %r8d
xorl %eax, %eax
pushq $0xc7
pushq $0x13
callq 0x3320
popq %rcx
popq %rdx
movq 0x8(%rbx), %rdx
movl (%rbx), %ecx
leaq 0x1eb62(%rip), %rdi     # 0x2206a
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3150
leaq 0x2fe17(%rip), %r13     # 0x33330
movq %r15, %rdi
movq %r13, %rsi
callq 0xd6c0
leaq 0x2fe75(%rip), %rbp     # 0x333a0
movq %r15, %rdi
movq %rbp, %rsi
callq 0xd9a9
movq 0xbf30(%r15), %rax
testq %rax, %rax
je 0x35a6
movabsq $0x646975753a6e7275, %rcx # imm = 0x646975753A6E7275
movq %rcx, 0x2fe6d(%rip)     # 0x333c0
movw $0x3a, 0x2fe6c(%rip)    # 0x333c8
cmpq $0x0, (%rax)
je 0x35a6
leaq 0x2ff47(%rip), %rsi     # 0x334b0
movq %rsi, 0x8(%rax)
movq %r15, %rdi
callq 0xdba2
movq 0xbf30(%r15), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
leaq 0x2fe33(%rip), %rcx     # 0x333c0
movq %rcx, (%rax)
leaq 0x1eaf7(%rip), %rcx     # 0x2208e
movq %rcx, 0x28(%rax)
leaq 0x1eb2c(%rip), %rcx     # 0x220ce
movq %rcx, 0x30(%rax)
leaq 0x1eb5e(%rip), %rax     # 0x2210b
movq %rax, 0x2fdec(%rip)     # 0x333a0
movq %r12, 0x2fd75(%rip)     # 0x33330
leaq 0x1ebe9(%rip), %rax     # 0x221ab
movq %rax, 0x2fda7(%rip)     # 0x33370
movq %rbp, 0x2fda8(%rip)     # 0x33378
movq %r14, 0x2fda9(%rip)     # 0x33380
pushq $0x1
popq %rax
movl %eax, 0x2fda8(%rip)     # 0x33388
movl %eax, (%rbx)
movq %r13, 0x8(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq