JDNS
Loading...
Searching...
No Matches
jdns_callbacks Struct Reference

Public Attributes

void * app
 user-supplied context
int(* time_now )(jdns_session_t *s, void *app)
int(* rand_int )(jdns_session_t *s, void *app)
void(* debug_line )(jdns_session_t *s, void *app, const char *str)
int(* udp_bind )(jdns_session_t *s, void *app, const jdns_address_t *addr, int port, const jdns_address_t *maddr)
void(* udp_unbind )(jdns_session_t *s, void *app, int handle)
int(* udp_read )(jdns_session_t *s, void *app, int handle, jdns_address_t *addr, int *port, unsigned char *buf, int *bufsize)
int(* udp_write )(jdns_session_t *s, void *app, int handle, const jdns_address_t *addr, int port, unsigned char *buf, int bufsize)

Member Data Documentation

◆ debug_line

void(* jdns_callbacks::debug_line) (jdns_session_t *s, void *app, const char *str)
Parameters
ssession
appuser-supplied context
stra line of debug text

◆ rand_int

int(* jdns_callbacks::rand_int) (jdns_session_t *s, void *app)
Parameters
ssession
appuser-supplied context
Returns
random integer between 0-65535

◆ time_now

int(* jdns_callbacks::time_now) (jdns_session_t *s, void *app)
Parameters
ssession
appuser-supplied context
Returns
milliseconds since session started

◆ udp_bind

int(* jdns_callbacks::udp_bind) (jdns_session_t *s, void *app, const jdns_address_t *addr, int port, const jdns_address_t *maddr)
Note
For multicast, the following must be done:
  • use SO_REUSEPORT to share with other mdns programs
  • use IP_ADD_MEMBERSHIP to associate addr and maddr
  • set IP_MULTICAST_TTL to 255
Parameters
ssession
appuser-supplied context
addrip address of interface to bind to. 0 for all
portport of interface to bind to. 0 for any
maddrmulticast address. 0 if not using multicast
Returns
handle (>0) of bound socket, or 0 on error

◆ udp_read

int(* jdns_callbacks::udp_read) (jdns_session_t *s, void *app, int handle, jdns_address_t *addr, int *port, unsigned char *buf, int *bufsize)
Parameters
ssession
appuser-supplied context
handlehandle of socket obtained with udp_bind
addrstore ip address of sender
portstore port of sender
bufstore packet content
bufsizevalue contains max size, to be changed to real size
Returns
1 if packet read, 0 if none available

◆ udp_unbind

void(* jdns_callbacks::udp_unbind) (jdns_session_t *s, void *app, int handle)
Parameters
ssession
appuser-supplied context
handlehandle of socket obtained with udp_bind

◆ udp_write

int(* jdns_callbacks::udp_write) (jdns_session_t *s, void *app, int handle, const jdns_address_t *addr, int port, unsigned char *buf, int bufsize)
Parameters
ssession
appuser-supplied context
handlehandle of socket obtained with udp_bind
addrip address of recipient
portport of recipient
bufpacket content
bufsizesize of packet
Returns
1 if packet taken for writing, 0 if this is a bad time

The documentation for this struct was generated from the following file: