Genivia Home Documentation
wsddapi.c File Reference

updated Thu Nov 19 2020 by Robert van Engelen
 
Functions | Variables
wsddapi.c File Reference
#include "wsddapi.h"
Include dependency graph for wsddapi.c:

Functions

static int soap_wsdd_serve___wsdd__Hello (struct soap *soap)
 
static int soap_wsdd_serve___wsdd__Bye (struct soap *soap)
 
static int soap_wsdd_serve___wsdd__Probe (struct soap *soap)
 
static int soap_wsdd_serve___wsdd__ProbeMatches (struct soap *soap)
 
static int soap_wsdd_serve___wsdd__Resolve (struct soap *soap)
 
static int soap_wsdd_serve___wsdd__ResolveMatches (struct soap *soap)
 
static void soap_wsdd_set_AppSequence (struct soap *)
 
static void soap_wsdd_reset_AppSequence (struct soap *)
 
static void soap_wsdd_delay (struct soap *)
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Hello (struct soap *soap, soap_wsdd_mode mode, const char *endpoint, const char *MessageID, const char *RelatesTo, const char *EndpointReference, const char *Types, const char *Scopes, const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion)
 TS or DP Hello message to join a network. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Bye (struct soap *soap, soap_wsdd_mode mode, const char *endpoint, const char *MessageID, const char *EndpointReference, const char *Types, const char *Scopes, const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion)
 TS or DP Bye message to leave a network. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Probe (struct soap *soap, soap_wsdd_mode mode, soap_wsdd_to to, const char *endpoint, const char *MessageID, const char *ReplyTo, const char *Types, const char *Scopes, const char *MatchBy)
 Client Probe message to a TS or DP. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Resolve (struct soap *soap, soap_wsdd_mode mode, soap_wsdd_to to, const char *endpoint, const char *MessageID, const char *ReplyTo, const char *EndpointReference)
 Client Resolve message to a TS or DP. More...
 
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_init_ProbeMatches (struct soap *soap, struct wsdd__ProbeMatchesType *matches)
 Initalize the probe matches container. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_add_ProbeMatch (struct soap *soap, struct wsdd__ProbeMatchesType *matches, const char *EndpointReference, const char *Types, const char *Scopes, const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion)
 Add a match to the probe matches container. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_ProbeMatches (struct soap *soap, const char *endpoint, const char *MessageID, const char *RelatesTo, const char *To, struct wsdd__ProbeMatchesType *matches)
 TS or DP ProbeMatches message. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_ResolveMatches (struct soap *soap, const char *endpoint, const char *MessageID, const char *RelatesTo, const char *To, const char *EndpointReference, const char *Types, const char *Scopes, const char *MatchBy, const char *XAddrs, unsigned int MetadataVersion)
 TS or DP ResolveMatches message. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_listen (struct soap *soap, int timeout)
 Listen on a port for inbound WS-Discovery messages, also cleans up memory with soap_destroy and soap_end. More...
 
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_serve_request (struct soap *soap)
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Hello (struct soap *soap, struct wsdd__HelloType *Hello)
 Internal WS-Discovery service operation. More...
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Bye (struct soap *soap, struct wsdd__ByeType *Bye)
 Internal WS-Discovery service operation. More...
 
static int soap_wsdd_http (struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, ULONG64 count)
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Probe (struct soap *soap, struct wsdd__ProbeType *Probe)
 Internal WS-Discovery service operation. More...
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__ProbeMatches (struct soap *soap, struct wsdd__ProbeMatchesType *ProbeMatches)
 Internal WS-Discovery service operation. More...
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Resolve (struct soap *soap, struct wsdd__ResolveType *Resolve)
 Internal WS-Discovery service operation. More...
 
SOAP_FMAC5 int SOAP_FMAC6 __wsdd__ResolveMatches (struct soap *soap, struct wsdd__ResolveMatchesType *ResolveMatches)
 Internal WS-Discovery service operation. More...
 
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_set_InstanceId (unsigned int InstanceId)
 Set the global AppSequence InstanceId that is used to populate messages. More...
 
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_set_SequenceId (const char *SequenceId)
 Set the global AppSequence SequenceId that is used to populate messages. More...
 

Variables

const char * to_ts_URL = "urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01"
 
static MUTEX_TYPE soap_wsdd_state = MUTEX_INITIALIZER
 
static unsigned int soap_wsdd_InstanceId = 0
 
static const char * soap_wsdd_SequenceId = NULL
 
static unsigned int soap_wsdd_MessageNumber = 1
 

Function Documentation

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Bye ( struct soap *  soap,
struct wsdd__ByeType Bye 
)

Internal WS-Discovery service operation.

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Hello ( struct soap *  soap,
struct wsdd__HelloType Hello 
)

Internal WS-Discovery service operation.

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Probe ( struct soap *  soap,
struct wsdd__ProbeType Probe 
)

Internal WS-Discovery service operation.

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__ProbeMatches ( struct soap *  soap,
struct wsdd__ProbeMatchesType ProbeMatches 
)

Internal WS-Discovery service operation.

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__Resolve ( struct soap *  soap,
struct wsdd__ResolveType Resolve 
)

Internal WS-Discovery service operation.

SOAP_FMAC5 int SOAP_FMAC6 __wsdd__ResolveMatches ( struct soap *  soap,
struct wsdd__ResolveMatchesType ResolveMatches 
)

Internal WS-Discovery service operation.

SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_add_ProbeMatch ( struct soap *  soap,
struct wsdd__ProbeMatchesType matches,
const char *  EndpointReference,
const char *  Types,
const char *  Scopes,
const char *  MatchBy,
const char *  XAddrs,
unsigned int  MetadataVersion 
)

Add a match to the probe matches container.

Parameters
soapcontext
matchesthe container to update with a new match
[in]EndpointReferenceof this Target Server or Discovery Proxy
[in]Typesan unordered string of QNames or NULL, a Discovery Proxy MUST include "wsdd:DiscoveryProxy"
[in]Scopesan unordered set of scopes or NULL
[in]MatchByNULL (unused, reserved)
[in]XAddrscontains the transport address(es) that MAY be used to communicate with the Target Service or Discovery Proxy
[in]MetadataVersionincremented by a positive value (>= 1) whenever there is a change in the metadata of the Target Service
Returns
SOAP_OK or error code

To populate a Probe matches container, first initialize with soap_wsdd_init_ProbeMatches, then use this function to add each match. The container is deallocated with soap_end(soap) and can be initialized again (without leaks).

SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Bye ( struct soap *  soap,
soap_wsdd_mode  mode,
const char *  endpoint,
const char *  MessageID,
const char *  EndpointReference,
const char *  Types,
const char *  Scopes,
const char *  MatchBy,
const char *  XAddrs,
unsigned int  MetadataVersion 
)

TS or DP Bye message to leave a network.

Parameters
soapcontext
[in]modeSOAP_WSDD_MANAGED or SOAP_WSDD_ADHOC
[in]endpointto send Bye message to (unicast or multicast)
[in]MessageIDunique WS-Addressing message ID (soap_wsa_rand_uuid)
[in]EndpointReferenceof this Target Server or Discovery Proxy
[in]Typesan unordered string of QNames or NULL, a Discovery Proxy MUST include "wsdd:DiscoveryProxy"
[in]Scopesan unordered set of scopes or NULL
[in]MatchByNULL (unused, reserved)
[in]XAddrscontains the transport address(es) that MAY be used to communicate with the Target Service or Discovery Proxy
[in]MetadataVersionincremented by a positive value (>= 1) whenever there is a change in the metadata of the Target Service
Returns
SOAP_OK or error code

Bye is a one-way message sent by a Target Service to announce its unavailability as a best effort when it leaves the network.

static void soap_wsdd_delay ( struct soap *  soap)
static
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Hello ( struct soap *  soap,
soap_wsdd_mode  mode,
const char *  endpoint,
const char *  MessageID,
const char *  RelatesTo,
const char *  EndpointReference,
const char *  Types,
const char *  Scopes,
const char *  MatchBy,
const char *  XAddrs,
unsigned int  MetadataVersion 
)

TS or DP Hello message to join a network.

Parameters
soapcontext
[in]modeSOAP_WSDD_MANAGED or SOAP_WSDD_ADHOC
[in]endpointto send Hello message to (unicast or multicast)
[in]MessageIDunique WS-Addressing message ID (soap_wsa_rand_uuid)
[in]RelatesToWS-Addressing message ID
[in]EndpointReferenceof this Target Server or Discovery Proxy
[in]Typesan unordered string of QNames or NULL, a Discovery Proxy MUST include "wsdd:DiscoveryProxy"
[in]Scopesan unordered set of scopes or NULL
[in]MatchByNULL (unused, reserved)
[in]XAddrscontains the transport address(es) that MAY be used to communicate with the Target Service or Discovery Proxy
[in]MetadataVersionincremented by a positive value (>= 1) whenever there is a change in the metadata of the Target Service
Returns
SOAP_OK or error code

Hello is a one-way message sent by a Target Service to announce its availability when it joins the network. It is also sent by a Discovery Proxy to reduce multicast traffic on an ad hoc network.

static int soap_wsdd_http ( struct soap *  soap,
const char *  endpoint,
const char *  host,
int  port,
const char *  path,
const char *  action,
ULONG64  count 
)
static
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_init_ProbeMatches ( struct soap *  soap,
struct wsdd__ProbeMatchesType matches 
)

Initalize the probe matches container.

Parameters
soapcontext
matchesthe container with matches to initialize
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_listen ( struct soap *  soap,
int  timeout 
)

Listen on a port for inbound WS-Discovery messages, also cleans up memory with soap_destroy and soap_end.

Parameters
soapcontext
[in]timeoutseconds to listen (use negative value for micro seconds)
Returns
SOAP_OK or error code

First you need to open a port with soap_bind(soap). Then invoke this function to listen to WS-Discovery messages on that port. Inbound messages are accepted and the information is relayed to the event handlers, see Section WS-Discovery Event Handlers. Use soap->user to pass a pointer to a state object that the event hanlders can use. The timeout allows a Client to periodically poll the port for messages. A value of zero will loop the listener forever or until an error occurs.

SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Probe ( struct soap *  soap,
soap_wsdd_mode  mode,
soap_wsdd_to  to,
const char *  endpoint,
const char *  MessageID,
const char *  ReplyTo,
const char *  Types,
const char *  Scopes,
const char *  MatchBy 
)

Client Probe message to a TS or DP.

Parameters
soapcontext
[in]modeSOAP_WSDD_MANAGED or SOAP_WSDD_ADHOC
[in]toSOAP_WSDD_TO_TS or SOAP_WSDD_TO_DP
[in]endpointto send Probe to (unicast or multicast)
[in]MessageIDWS-Addressing message ID of the message
[in]ReplyToWS-Addressing ReplyTo message ID of the message
[in]Typesan unordered string of QNames to probe
[in]Scopesan unordered set of scopes to probe
[in]MatchBymatching rule to apply for this probe
Returns
SOAP_OK or error code

A Client sends a probe to find Target Services by the Type of the Target Service, a Scope in which the Target Service resides, both, or simply all Target Services. The matches will be delivered to wsdd_event_ProbeMatches when soap_wsdd_listen receives a ProbeMatch response. The RelatesTo of the ProbeMatches is the MessageID of the Probe.

SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_ProbeMatches ( struct soap *  soap,
const char *  endpoint,
const char *  MessageID,
const char *  RelatesTo,
const char *  To,
struct wsdd__ProbeMatchesType matches 
)

TS or DP ProbeMatches message.

Parameters
soapcontext
[in]endpointto send Probe to (unicast or multicast)
[in]MessageIDWS-Addressing message ID of the message
[in]RelatesToWS-Addressing RelatesTo message ID of the message
[in]ToWS-Addressing endpoint IP and port or NULL for anonymous
[in]matchescontains the probe matches, use soap_wsdd_add_ProbeMatch to populate this container
Returns
SOAP_OK or error code

A Client sends a probe to find Target Services by the Type of the Target Service, a Scope in which the Target Service resides, both, or simply all Target Services. The Target Server(s) or Discovery Proxy responds by sending ProbeMatches to the Client.

static void soap_wsdd_reset_AppSequence ( struct soap *  soap)
static
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_Resolve ( struct soap *  soap,
soap_wsdd_mode  mode,
soap_wsdd_to  to,
const char *  endpoint,
const char *  MessageID,
const char *  ReplyTo,
const char *  EndpointReference 
)

Client Resolve message to a TS or DP.

Parameters
soapcontext
[in]modeSOAP_WSDD_MANAGED or SOAP_WSDD_ADHOC
[in]toSOAP_WSDD_TO_TS or SOAP_WSDD_TO_DP
[in]endpointto send Resolve to (unicast or multicast)
[in]MessageIDWS-Addressing message ID of the message
[in]ReplyToWS-Addressing ReplyTo message ID of the message
[in]EndpointReferenceof the Target Service or Discovery Proxy
Returns
SOAP_OK or error code

A Client sends a resolve to locate a Target Service, i.e., to retrieve its transport address(es). This server-side event handler returns the match(es). The matches will be delivered to wsdd_event_ResolveMatches when soap_wsdd_listen receives a ResolveMatch response. The RelatesTo of the ResolveMatches is the MessageID of the Resolve.

SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_ResolveMatches ( struct soap *  soap,
const char *  endpoint,
const char *  MessageID,
const char *  RelatesTo,
const char *  To,
const char *  EndpointReference,
const char *  Types,
const char *  Scopes,
const char *  MatchBy,
const char *  XAddrs,
unsigned int  MetadataVersion 
)

TS or DP ResolveMatches message.

Parameters
soapcontext
[in]endpointto send Probe to (unicast or multicast)
[in]MessageIDWS-Addressing message ID of the message
[in]RelatesToWS-Addressing RelatesTo message ID of the message
[in]ToWS-Addressing endpoint IP and port or NULL for anonymous
[in]EndpointReferenceof the Target Service
[in]Typesan unordered string of QNames or NULL, a Discovery Proxy MUST include "wsdd:DiscoveryProxy"
[in]Scopesan unordered set of scopes or NULL
[in]MatchByNULL (unused, reserved)
[in]XAddrscontains the transport address(es) that MAY be used to communicate with the Target Service or Discovery Proxy
[in]MetadataVersionincremented by a positive value (>= 1) whenever there is a change in the metadata of the Target Service
Returns
SOAP_OK or error code

A Client sends a resolve to locate a Target Service, i.e., to retrieve its transport address(es). The Target Server(s) or Discovery Proxy responds by sending ResolveMatches to the Client.

static int soap_wsdd_serve___wsdd__Bye ( struct soap *  soap)
static
static int soap_wsdd_serve___wsdd__Hello ( struct soap *  soap)
static
static int soap_wsdd_serve___wsdd__Probe ( struct soap *  soap)
static
static int soap_wsdd_serve___wsdd__ProbeMatches ( struct soap *  soap)
static
static int soap_wsdd_serve___wsdd__Resolve ( struct soap *  soap)
static
static int soap_wsdd_serve___wsdd__ResolveMatches ( struct soap *  soap)
static
SOAP_FMAC1 int SOAP_FMAC2 soap_wsdd_serve_request ( struct soap *  soap)
static void soap_wsdd_set_AppSequence ( struct soap *  soap)
static
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_set_InstanceId ( unsigned int  InstanceId)

Set the global AppSequence InstanceId that is used to populate messages.

Parameters
[in]InstanceId
SOAP_FMAC1 void SOAP_FMAC2 soap_wsdd_set_SequenceId ( const char *  SequenceId)

Set the global AppSequence SequenceId that is used to populate messages.

Parameters
[in]SequenceId

Variable Documentation

unsigned int soap_wsdd_InstanceId = 0
static
unsigned int soap_wsdd_MessageNumber = 1
static
const char* soap_wsdd_SequenceId = NULL
static
MUTEX_TYPE soap_wsdd_state = MUTEX_INITIALIZER
static
const char* to_ts_URL = "urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01"