Skip to content

Commit

Permalink
mdns: Don't pass mdns_recv return to the announce callback
Browse files Browse the repository at this point in the history
mdns_recv returns -1 on error and 0 on success, but we don't invoke the
callback when mdns_recv fails, so we were passing a useless parameter
always equal to 0.
  • Loading branch information
chouquette committed Aug 31, 2020
1 parent 5555e67 commit 6b619d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/announce.c
Expand Up @@ -42,7 +42,7 @@ static bool stop(void *cbarg)
return (sigflag ? true : false);
}

static void callback(void *cbarg, int r, const struct sockaddr *mdns_ip, const char* service)
static void callback(void *cbarg, const struct sockaddr *mdns_ip, const char* service)
{
if ( service != NULL && strcmp( service, "_googlecast._tcp.local" ) )
return;
Expand Down
3 changes: 1 addition & 2 deletions include/microdns/microdns.h
Expand Up @@ -83,7 +83,6 @@ typedef void (*mdns_listen_callback)(void*, int, const struct rr_entry *);
* @brief mdns_announce_callback Will be invoked for each received question
*
* @param cookie The pointer provided as last parameter to mdns_serve
* @param r The mdns_recv result
* @param addr The address for which a probe was received
* @param service The service being probed
*
Expand All @@ -95,7 +94,7 @@ typedef void (*mdns_listen_callback)(void*, int, const struct rr_entry *);
* service, so that the application can announce itself as it sees fit (for
* instance it can announce both an A and AAAA records)
*/
typedef void (*mdns_announce_callback)(void* cookie, int r,
typedef void (*mdns_announce_callback)(void* cookie,
const struct sockaddr *addr,
const char* service);

Expand Down
4 changes: 2 additions & 2 deletions src/mdns.c
Expand Up @@ -824,7 +824,7 @@ mdns_serve(struct mdns_ctx *ctx, mdns_stop_func stop, void *p_cookie)
/* Send the initial announce (RFC 6762 §8.3) */
for (svc = ctx->services; svc; svc = svc->next) {
for ( size_t i = 0; i < ctx->nb_conns; ++i ) {
svc->announce_callback(svc->p_cookie, 0,
svc->announce_callback(svc->p_cookie,
(struct sockaddr*)&ctx->conns[i].intf_addr, NULL);
}
}
Expand All @@ -850,7 +850,7 @@ mdns_serve(struct mdns_ctx *ctx, mdns_stop_func stop, void *p_cookie)

for (svc = ctx->services; svc; svc = svc->next) {
if (question->type == svc->type) {
svc->announce_callback(svc->p_cookie, r,
svc->announce_callback(svc->p_cookie,
(struct sockaddr*)&ctx->conns[i].intf_addr,
question->name);
goto again;
Expand Down

0 comments on commit 6b619d5

Please sign in to comment.