dlog_print(DLOG_INFO, "MSF_API", "reapService - Service id: %s", it->first.c_str());
if ( info.is_expired()) {
Service service=getServiceByIp(it->first);
- dlog_print(DLOG_ERROR, "MSF", "reapServices - Remove service : [%s]", service.getId().c_str());
+ dlog_print(DLOG_ERROR, "MSF", "reapServices - Remove service : [%s]", it->first.c_str());
aliveMap.erase(it->first);
removeServiceAndNotify(service);
}
std::string SearchProvider::getIP(std::string url)
{
- std::string::size_type pos1 = url.find("192");
+ if (url.empty())
+ return "";
+
+ std::string::size_type pos1 = 7;
std::string::size_type pos2 = url.find(":", 6);
std::string::size_type pos = pos2 - pos1;
static void dnssd_browse_reply(dnssd_service_state_e service_state, dnssd_service_h remote_service, void *user_data)
{
- static map<string, string> service_id_adapter;
-
MSF_DBG("[MSF : API] Debug log Function : [%s] and line [%d] in file [%s]. State : [%d][%d]",__FUNCTION__ ,__LINE__,__FILE__, service_state, DNSSD_SERVICE_STATE_UNAVAILABLE);
mDNSSearchProvider* provider = (mDNSSearchProvider*)user_data;
int rv = 0;
if (rv == DNSSD_ERROR_NONE && name != NULL)
MSF_DBG("Service Name : %s", name);
- string name_s = name;
- string id;
- map<string, string>::iterator iter = service_id_adapter.find(name_s);
- if (iter != service_id_adapter.end()) {
- id = iter->second;
- }
MSF_DBG("State : ");
switch (service_state) {
case DNSSD_SERVICE_STATE_AVAILABLE:
MSF_DBG("Available");
break;
case DNSSD_SERVICE_STATE_UNAVAILABLE:
- MSF_DBG("Un-Available : [%d]", id.c_str());
- provider->updateAlive(0, id, MDNS);
- service_id_adapter.erase(iter);
- provider->reapServices();
+ {
+ char *ip_v4_address = NULL;
+ char *ip_v6_address = NULL;
+
+ MSF_DBG("Un-Available");
+ dnssd_service_get_ip(remote_service, &ip_v4_address, &ip_v6_address);
+ if (ip_v4_address) {
+ MSF_DBG("-> [%s]", ip_v4_address);
+ provider->updateAlive(0, ip_v4_address, MDNS);
+ provider->reapServices();
+
+ free(ip_v4_address);
+ free(ip_v6_address);
+ }
return;
+ }
case DNSSD_SERVICE_STATE_NAME_LOOKUP_FAILED:
MSF_DBG("Lookup failure for service name");
break;
string temp_str(txt_record, txt_len);
- int str_len = strlen(txt_record);
-
- MSF_DBG("TXT Record: %s, %d", temp_str.c_str(), str_len);
+ MSF_DBG("TXT Record: %s", temp_str.c_str());
ServiceInfo service_info; //id, version, name, type, Uri
- MSF_DBG("txt_len %d", txt_len);
if (txt_len > 100) {
extract_service_info(service_info, temp_str);
-
Service::getByURI(service_info.infoURI, 5000, provider->get_service_cb());
- service_id_adapter[name_s] = service_info.infoURI;
}
free(ip_v4_address);