Nut/OS  5.0.5
API Reference
Discover

Discovering Nut/Net nodes. More...

Collaboration diagram for Discover:

Data Structures

struct  DISCOVERY_OPTIONS

Defines

#define NUT_THREAD_DISTSTACK   320
#define DISCOVERY_PORT   9806

Functions

int NutDiscoveryAnnTele (DISCOVERY_TELE *dist)
 Create an announcement datagram.
int NutDiscoveryAppConf (DISCOVERY_TELE *dist)
 Apply new configuration.
void DiscoveryResponder (void *arg)
NutDiscoveryCallback NutRegisterDiscoveryCallback (NutDiscoveryCallback func)
 Register a custom discovery callback handler.
int NutRegisterDiscovery (uint32_t ipmask, uint16_t port, unsigned int flags)
 Register discovery telegram responder.

Detailed Description

Discovering Nut/Net nodes.


Define Documentation

#define NUT_THREAD_DISTSTACK   320

Referenced by NutRegisterDiscovery().

#define DISCOVERY_PORT   9806

Referenced by NutRegisterDiscovery().


Function Documentation

int NutDiscoveryAnnTele ( DISCOVERY_TELE dist)

Create an announcement datagram.

Parameters:
distPointer to the datagram buffer that will be filled.
Returns:
Number of bytes filled into the datagram buffer.

References _CONFNET::cdn_cip_addr, _CONFNET::cdn_gateway, _CONFNET::cdn_ip_addr, _CONFNET::cdn_ip_mask, _CONFNET::cdn_mac, confnet, confos, DISCOVERY_VERSION, DIST_ANNOUNCE, _DISCOVERY_TELE::dist_cip_addr, _DISCOVERY_TELE::dist_custom, _DISCOVERY_TELE::dist_gateway, _DISCOVERY_TELE::dist_hostname, _DISCOVERY_TELE::dist_ip_addr, _DISCOVERY_TELE::dist_ip_mask, _DISCOVERY_TELE::dist_mac, _DISCOVERY_TELE::dist_type, _DISCOVERY_TELE::dist_ver, _DISCOVERY_TELE::dist_xid, _CONFOS::hostname, memcpy(), memset(), and strlen().

Referenced by DiscoveryResponder().

Here is the call graph for this function:

int NutDiscoveryAppConf ( DISCOVERY_TELE dist)

Apply new configuration.

Parameters:
distPointer to the discovery datagram. It is assumed, that the validity of the datagram contents had been checked by the caller.

References _CONFNET::cdn_cip_addr, _CONFNET::cdn_gateway, _CONFNET::cdn_ip_addr, _CONFNET::cdn_ip_mask, _CONFNET::cdn_mac, confnet, confos, _DISCOVERY_TELE::dist_cip_addr, _DISCOVERY_TELE::dist_gateway, _DISCOVERY_TELE::dist_hostname, _DISCOVERY_TELE::dist_ip_addr, _DISCOVERY_TELE::dist_ip_mask, _DISCOVERY_TELE::dist_mac, _CONFOS::hostname, memcpy(), memset(), NutNetSaveConfig(), NutSaveConfig(), and strncpy().

Here is the call graph for this function:

void DiscoveryResponder ( void *  arg)
NutDiscoveryCallback NutRegisterDiscoveryCallback ( NutDiscoveryCallback  func)

Register a custom discovery callback handler.

When a callback had been registered, all datagrams matching the IP mask are passed to this function, which should inspect the datagram contents and take any required action like calling NutDiscoveryAnnTele() etc. If the callback returns a positive value, a response will be sent back, using that return value as its length.

Parameters:
funcPointer to the callback function or NULL to disable responses.
Returns:
Previously used callback function pointer.

References rc.

int NutRegisterDiscovery ( uint32_t  ipmask,
uint16_t  port,
unsigned int  flags 
)

Register discovery telegram responder.

The first call will activate the responder thread. Any subsequent calls will return a failure.

Note:
Enabling a discovery responder is a potential security hole.
Parameters:
ipmaskUpdate datagrams from remote hosts, which do not fit to this mask are ignored. Set to INADDR_BROADCAST to allow any. If zero, no updates are allowed.
portThe responder will listen to this UDP port. If zero, the default port DISCOVERY_PORT is used.
flagsOption value, may contain any combination of DISF_ flags.
Returns:
0 if a handler thread had been started, -1 otherwise.

References DISCOVERY_PORT, DiscoveryResponder(), DISCOVERY_OPTIONS::disopt_flags, DISCOVERY_OPTIONS::disopt_ipmask, DISCOVERY_OPTIONS::disopt_port, NULL, NUT_THREAD_DISTSTACK, NUT_THREAD_STACK_ADD, NUT_THREAD_STACK_MULT, and NutThreadCreate().

Referenced by main().

Here is the call graph for this function: