/* * rend_callback * * This gets called from the main thread when there is a * message waiting to be processed. */ void rend_callback(void) { REND_MESSAGE msg; sw_discovery_oid rend_oid; sw_result result; /* here, we've seen the message, now we have to process it */ if(rend_read_message(&msg) != sizeof(msg)) { DPRINTF(E_FATAL,L_REND,"Rendezvous socket closed (daap server crashed?) Aborting.\n"); exit(EXIT_FAILURE); } switch(msg.cmd) { case REND_MSG_TYPE_REGISTER: DPRINTF(E_DBG,L_REND,"Registering %s.%s (%d)\n",msg.type,msg.name,msg.port); if((result=sw_discovery_publish(rend_handle, 0, /* interface handle */ msg.name, msg.type, NULL, /* domain */ NULL, /* host */ msg.port, "\011txtvers=1\034Database ID=beddab1edeadbea7", /* text record */ 39, /* text record length */ rend_howl_reply, NULL, &rend_oid)) != SW_OKAY) { DPRINTF(E_WARN,L_REND,"Error registering name\n"); rend_send_response(-1); } else { rend_send_response(0); /* success */ } break; case REND_MSG_TYPE_UNREGISTER: DPRINTF(E_WARN,L_REND,"Unsupported function: UNREGISTER\n"); rend_send_response(-1); /* error */ break; case REND_MSG_TYPE_STOP: DPRINTF(E_DBG,L_REND,"Stopping mDNS\n"); rend_send_response(0); //sw_rendezvous_stop_publish(rend_handle); sw_discovery_fina(rend_handle); break; case REND_MSG_TYPE_STATUS: DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 0\n"); rend_send_response(0); /* success */ break; default: break; } }
/* * rend_callback * * This gets called from the main thread when there is a * message waiting to be processed. */ void rend_callback(void *info) { REND_MESSAGE msg; unsigned short usPort; dns_service_discovery_ref dns_ref=NULL; /* here, we've seen the message, now we have to process it */ if(rend_read_message(&msg) != sizeof(msg)) { DPRINTF(E_FATAL,L_REND,"Rendezvous socket closed (daap server crashed?) Aborting.\n"); exit(EXIT_FAILURE); } switch(msg.cmd) { case REND_MSG_TYPE_REGISTER: DPRINTF(E_DBG,L_REND,"Registering %s.%s (%d)\n",msg.type,msg.name,msg.port); usPort=htons(msg.port); dns_ref=DNSServiceRegistrationCreate(msg.name,msg.type,"",usPort, "txtvers=1\001Database ID=bedabb1edeadbea7",rend_reply,nil); if(rend_addtorunloop(dns_ref)) { DPRINTF(E_WARN,L_REND,"Add to runloop failed\n"); rend_send_response(-1); } else { rend_send_response(0); /* success */ } break; case REND_MSG_TYPE_UNREGISTER: DPRINTF(E_WARN,L_REND,"Unsupported function: UNREGISTER\n"); rend_send_response(-1); /* error */ break; case REND_MSG_TYPE_STOP: DPRINTF(E_DBG,L_REND,"Stopping mDNS\n"); rend_send_response(0); rend_stoprunloop(); break; case REND_MSG_TYPE_STATUS: DPRINTF(E_DBG,L_REND,"Status inquiry -- returning 0\n"); rend_send_response(0); /* success */ break; default: break; } }
/* * rend_callback * * This is borrowed from the OSX rend client */ void rend_callback(void) { REND_MESSAGE msg; int result; int err; mDNSInterfaceID id; DPRINTF(E_DBG,L_REND,"Processing rendezvous message\n"); /* here, we've seen the message, now we have to process it */ if((result=rend_read_message(&msg)) != sizeof(msg)) { err=errno; DPRINTF(E_FATAL,L_REND,"Rendezvous socket closed (daap server crashed?) Aborting.\n"); gStopNow=mDNStrue; return; } switch(msg.cmd) { case REND_MSG_TYPE_REGISTER: id=rend_get_interface_id(msg.iface); DPRINTF(E_DBG,L_REND,"Registering %s.%s (%d)\n",msg.name,msg.type,msg.port); RegisterOneService(msg.name,msg.type,"local.",msg.txt,strlen(msg.txt), msg.port,id); rend_send_response(0); /* success */ break; case REND_MSG_TYPE_UNREGISTER: rend_send_response(1); /* error */ break; case REND_MSG_TYPE_STOP: DPRINTF(E_INF,L_REND,"Stopping mDNS\n"); gStopNow = mDNStrue; rend_send_response(0); break; case REND_MSG_TYPE_STATUS: rend_send_response(1); break; default: break; } }