Prosody generic: API: sm_udp_dispatcher_create
Prototype Definition
int sm_udp_dispatcher_create(struct sm_udp_dispatcher_create_parms *dp)
Parameters
- *dp
-
a structure of the following type:
typedef struct sm_udp_dispatcher_create_parms {
tSMDispatcherId dispatcher; /* out */
tSMModuleId module; /* in */
enum kSMDispatcherType {
kSMDispatcherTypeIPv4,
kSMDispatcherTypeIPv6,
} type; /* in */
SOCKADDR_IN destination; /* in */
SOCKADDR_IN source; /* in */
int TOS; /* in */
SOCKADDR_IN6 destination_ipv6; /* in */
SOCKADDR_IN6 source_ipv6; /* in */
} SM_UDP_DISPATCHER_CREATE_PARMS;
Description
Allocates, on a specific module, a new UDP dispatcher
to transmit data. If the call completes
successfully, the parameter
dispatcher
will be set to the identifier for that dispatcher.
This requires the module
toudp
to have been downloaded.
Fields
- dispatcher
- The newly created dispatcher.
- module
- A value obtained from
sm_open_module()
which indicates the module where the dispatcher to be allocated.
- type
-
One of these values:
- kSMDispatcherTypeIPv4
- The dispatcher is to receive IPv4 packets
- kSMDispatcherTypeIPv6
- The dispatcher is to receive IPv6 packets
- destination
- The SOCKADDR_IN structure specifying the destination IP address
and port for the UDP stream. A struct SOCKADDR_IN must be
configured with an address family, an IP address and a port.
Note that most operating systems define this structure such that
fields are in network byte order.
The structure must be correctly cast such that an IP V4
address is specified.
This field is ignored unless
type
is
kSMDispatcherTypeIPv4.
- source
- The SOCKADDR_IN structure allows you to specify the source IP
address and port for the UDP stream. A struct SOCKADDR_IN must
be configured with an address family. The IP address may be
specified, or the value INADDR_ANY may be used to indicate
that any suitable address may be used. The port number may be
specified, or the value zero may be used to indicate that a
suitable port number is to be automatically allocated and
used.
Note that most operating systems define this structure such that
fields are in network byte order.
The structure must be correctly cast such that an IP V4
address is specified.
This field is ignored unless
type
is
kSMDispatcherTypeIPv4.
- TOS
- The Type Of Service (TOS) indicator to be sent in the UDP packets
This field is ignored unless
type
is
kSMDispatcherTypeIPv4.
- destination_ipv6
- The SOCKADDR_IN6 structure specifying the destination IP address
and port for the UDP stream. A struct SOCKADDR_IN6 must be
configured with an address family, an IPv6 address and a port.
Note that most operating systems define this structure such that
fields are in network byte order.
This field is ignored unless
type
is
kSMDispatcherTypeIPv6.
- source_ipv6
- The SOCKADDR_IN6 structure allows you to specify the source IPv6
address and port for the UDP stream. A struct SOCKADDR_IN6 must
be configured with an address family. The IPv6 address may be
specified, or the value INADDR_ANY may be used to indicate
that any suitable address may be used. The port number may be
specified, or the value zero may be used to indicate that a
suitable port number is to be automatically allocated and
used.
Note that most operating systems define this structure such that
fields are in network byte order.
This field is ignored unless
type
is
kSMDispatcherTypeIPv6.
Returns
0
if call completed successfully, otherwise a standard error such as:
- ERR_SM_DEVERR - device error
This function is part of the Prosody generic API.