#include "soapStub.h"
#include "onvif.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define __DEBUG
#ifdef __DEBUG
#define DBG(fmt,args...) fprintf(stdout, fmt, ##args)
#else
#define DBG(fmt,args...)
#endif
#define ERR(fmt,args...) fprintf(stderr, fmt, ##args)
int _false = 0;
int _true = 1;
NET_IPV4 ip={192,168,1,233};
int onvif_fault(struct soap *soap,char *value1,char *value2)
{
soap->fault = (struct SOAP_ENV__Fault*)soap_malloc(soap,(sizeof(struct SOAP_ENV__Fault)));
soap->fault->SOAP_ENV__Code = (struct SOAP_ENV__Code*)soap_malloc(soap,(sizeof(struct SOAP_ENV__Code)));
soap->fault->SOAP_ENV__Code->SOAP_ENV__Value = "SOAP-ENV:Sender";
soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = (struct SOAP_ENV__Code*)soap_malloc(soap,(sizeof(struct SOAP_ENV__Code)));;
soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value = value1;
soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode = (struct SOAP_ENV__Code*)soap_malloc(soap,(sizeof(struct SOAP_ENV__Code)));
soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode->SOAP_ENV__Value = value2;
soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Subcode->SOAP_ENV__Subcode = NULL;
soap->fault->faultcode = NULL;
soap->fault->faultstring = NULL;
soap->fault->faultactor = NULL;
soap->fault->detail = NULL;
soap->fault->SOAP_ENV__Reason = NULL;
soap->fault->SOAP_ENV__Node = NULL;
soap->fault->SOAP_ENV__Role = NULL;
soap->fault->SOAP_ENV__Detail = NULL;
}
/******************************************************************************\
* *
* Server-Side Operations *
* *
\******************************************************************************/
int __wsdd__Hello(struct soap* soap, struct wsdd__HelloType *wsdd__Hello)
{
}
int __wsdd__Bye(struct soap* soap, struct wsdd__ByeType *wsdd__Bye)
{
}
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__Hello(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct wsdd__HelloType *wsdd__Hello)
{ struct __wsdd__Hello soap_tmp___wsdd__Hello;
if (!soap_action)
soap_action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Hello";
soap->encodingStyle = NULL;
soap_tmp___wsdd__Hello.wsdd__Hello = wsdd__Hello;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___wsdd__Hello(soap, &soap_tmp___wsdd__Hello);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Hello(soap, &soap_tmp___wsdd__Hello, "-wsdd:Hello", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Hello(soap, &soap_tmp___wsdd__Hello, "-wsdd:Hello", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__ProbeMatches(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct wsdd__ProbeMatchesType *wsdd__ProbeMatches)
{ struct __wsdd__ProbeMatches soap_tmp___wsdd__ProbeMatches;
if (!soap_action)
soap_action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches";
soap->encodingStyle = NULL;
soap_tmp___wsdd__ProbeMatches.wsdd__ProbeMatches = wsdd__ProbeMatches;
soap_begin(soap);
soap_serializeheader(soap);
soap_serialize___wsdd__ProbeMatches(soap, &soap_tmp___wsdd__ProbeMatches);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__ProbeMatches(soap, &soap_tmp___wsdd__ProbeMatches, "-wsdd:ProbeMatches", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__ProbeMatches(soap, &soap_tmp___wsdd__ProbeMatches, "-wsdd:ProbeMatches", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
int __wsdd__Probe(struct soap* soap, struct wsdd__ProbeType *wsdd__Probe)
{
DBG("__wsdd__Probe\n");
DBG("Types=%s\n",wsdd__Probe->Types);
char macaddr[MACH_ADDR_LENGTH];
char _IPAddr[INFO_LENGTH];
char _HwId[LARGE_INFO_LENGTH];
SysInfo *oSysInfo = (SysInfo*)malloc(sizeof(SysInfo));
memcpy(oSysInfo,&gSysInfo,sizeof(SysInfo));
int i = 0;
int flag = 0;
char list[20][100];
int len = 0;
int index = 0;
wsdd__ProbeMatchesType ProbeMatches;
ProbeMatches.ProbeMatch = (struct wsdd__ProbeMatchType *)soap_malloc(soap, sizeof(struct wsdd__ProbeMatchType));
ProbeMatches.ProbeMatch->XAddrs = (char *)soap_malloc(soap, sizeof(char) * INFO_LENGTH);
ProbeMatches.ProbeMatch->Types = (char *)soap_malloc(soap, sizeof(char) * INFO_LENGTH);
ProbeMatches.ProbeMatch->Scopes = (struct wsdd__ScopesType*)soap_malloc(soap,sizeof(struct wsdd__ScopesType));
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties = (struct wsa__ReferencePropertiesType*)soap_malloc(soap,sizeof(struct wsa__ReferencePropertiesType));
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters = (struct wsa__ReferenceParametersType*)soap_malloc(soap,sizeof(struct wsa__ReferenceParametersType));
ProbeMatches.ProbeMatch->wsa__EndpointReference.ServiceName = (struct wsa__ServiceNameType*)soap_malloc(soap,sizeof(struct wsa__ServiceNameType));
ProbeMatches.ProbeMatch->wsa__EndpointReference.PortType = (char **)soap_malloc(soap, sizeof(char *) * SMALL_INFO_LENGTH);
ProbeMatches.ProbeMatch->wsa__EndpointReference.__any = (char **)soap_malloc(soap, sizeof(char*) * SMALL_INFO_LENGTH);
ProbeMatches.ProbeMatch->wsa__EndpointReference.__anyAttribute = (char *)soap_malloc(soap, sizeof(char) * SMALL_INFO_LENGTH);
ProbeMatches.ProbeMatch->wsa__EndpointReference.Address = (char *)soap_malloc(soap, sizeof(char) * INFO_LENGTH);
macaddr[0]=0x01;macaddr[1]=0x01;macaddr[2]=0x01;macaddr[3]=0x01;macaddr[4]=0x01;macaddr[5]=0x01;
sprintf(_HwId,"urn:uuid:2419d68a-2dd2-21b2-a205-%02X%02X%02X%02X%02X%02X",macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
sprintf(_IPAddr, "http://%03d.%03d.%1d.%03d/onvif/device_service", 192, 168, 1, 233);
ProbeMatches.__sizeProbeMatch = 1;
ProbeMatches.ProbeMatch->Scopes->__item =(char *)soap_malloc(soap, LARGE_INFO_LENGTH);
memset(ProbeMatches.ProbeMatch->Scopes->__item,0,sizeof(ProbeMatches.ProbeMatch->Scopes->__item));
//Scopes MUST BE
strcat(ProbeMatches.ProbeMatch->Scopes->__item, "onvif://www.onvif.org/type/NetworkVideoTransmitter");
ProbeMatches.ProbeMatch->Scopes->MatchBy = NULL;
strcpy(ProbeMatches.ProbeMatch->XAddrs, _IPAddr);
strcpy(ProbeMatches.ProbeMatch->Types, wsdd__Probe->Types);
DBG("wsdd__Probe->Types=%s\n",wsdd__Probe->Types);
ProbeMatches.ProbeMatch->MetadataVersion = 1;
//ws-discovery规定 为可选项
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties->__size = 0;
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceProperties->__any = NULL;
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters->__size = 0;
ProbeMatches.ProbeMatch->wsa__EndpointReference.ReferenceParameters->__any = NULL;
ProbeMatches.ProbeMatch->wsa__EndpointRefe
- 1
- 2
- 3
- 4
- 5
- 6
前往页