Discover
[User Protocols]

Discovering Nut/Net nodes. More...

Collaboration diagram for Discover:

Defines

#define NUT_THREAD_DISTSTACK   320

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

Definition at line 93 of file discover.c.

Referenced by NutRegisterDiscovery().


Function Documentation

int NutDiscoveryAnnTele ( DISCOVERY_TELE dist  ) 

Create an announcement datagram.

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

Definition at line 120 of file discover.c.

References confnet, confos, 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, memcpy(), memset(), and strlen().

Referenced by DiscoveryResponder().

int NutDiscoveryAppConf ( DISCOVERY_TELE dist  ) 

Apply new configuration.

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

Definition at line 148 of file discover.c.

References 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, memcpy(), memset(), NutNetSaveConfig(), NutSaveConfig(), and strncpy().

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:
func Pointer to the callback function or NULL to disable responses.
Returns:
Previously used callback function pointer.

Definition at line 280 of file discover.c.

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:
ipmask Update 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.
port The responder will listen to this UDP port. If zero, the default port DISCOVERY_PORT is used.
flags Option value, may contain any combination of DISF_ flags.
Returns:
0 if a handler thread had been started, -1 otherwise.

Definition at line 306 of file discover.c.

References DiscoveryResponder(), NUT_THREAD_DISTSTACK, NUT_THREAD_STACK_ADD, and NutThreadCreate().

Referenced by main().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/