SET(CAPI_LIB "nsd-ssdp nsd-dns-sd")
SET(TC_SOURCES
+ utc-nsd-common.c
utc-nsd-ssdp-browse.c
utc-nsd-ssdp-register.c
utc-nsd-dnssd-browse.c
--- /dev/null
+//
+// Copyright (c) 2022 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "utc-nsd-common.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <system_info.h>
+
+static int bIsEmulator = -1;
+
+static bool _is_emulator()
+{
+ char *val = NULL;
+
+ if (bIsEmulator != -1)
+ return bIsEmulator;
+
+ if (system_info_get_platform_string(MODEL_NAME_KEY, &val) < 0) {
+ free(val);
+ return false;
+ }
+
+ bIsEmulator = strncmp(val, MODEL_NAME_EMULATOR, strlen(MODEL_NAME_EMULATOR)) == 0 ? true : false;
+ free(val);
+ return bIsEmulator;
+}
+
+const char *nsd_get_interface_name()
+{
+ if (_is_emulator())
+ return ETHERNET_INTF;
+ else
+ return WIFI_INTF;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//#ifndef _UTC_NSD_COMMON_H_
+//#define _UTC_NSD_COMMON_H_
+
+#define MODEL_NAME_KEY "http://tizen.org/system/model_name"
+#define MODEL_NAME_EMULATOR "Emulator"
+
+#define WIFI_INTF "wlan0"
+#define ETHERNET_INTF "eth0"
+
+const char *nsd_get_interface_name();
+
+//#endif /* _UTC_NSD_COMMON_H_ */
#include <glib.h>
#include <stdlib.h>
#include <string.h>
-
#include <system_info.h>
+
+#include "utc-nsd-common.h"
//& set: Nsd-dnssd-browse
static bool g_feature = true;
return 0;
}
- ret = dnssd_browse_service("_ftp._tcp", "wlan0", &browser_id, __found_cb, NULL);
+ ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), &browser_id, __found_cb, NULL);
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_cancel_browse_service(browser_id);
return 0;
}
- ret = dnssd_browse_service("_ftp._tcp", "wlan0", NULL, __found_cb, NULL);
+ ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), NULL, __found_cb, NULL);
assert_eq(ret, DNSSD_ERROR_INVALID_PARAMETER);
return 0;
}
return 0;
}
- ret = dnssd_browse_service("_ftp._tcp", "wlan0", &browser_id, __found_cb, NULL);
+ ret = dnssd_browse_service("_ftp._tcp", nsd_get_interface_name(), &browser_id, __found_cb, NULL);
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_cancel_browse_service(0);
return 0;
}
- ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+ ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
assert_eq(ret, DNSSD_ERROR_NONE);
dnssd_destroy_remote_service(serv_id);
return 0;
}
- ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", NULL);
+ ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), NULL);
assert_eq(ret, DNSSD_ERROR_INVALID_PARAMETER);
return 0;
return 0;
}
- ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+ ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_destroy_remote_service(serv_id);
return 0;
}
- ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &serv_id);
+ ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &serv_id);
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_destroy_remote_service(serv_id + 1);
return 0;
}
- ret = dnssd_create_remote_service("_ftp._tcp", "test", "wlan0", &service);
+ ret = dnssd_create_remote_service("_ftp._tcp", "test", nsd_get_interface_name(), &service);
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_resolve_service(service, __resolved_cb, NULL);
#include <system_info.h>
#include <dns-sd.h>
+#include "utc-nsd-common.h"
+
//& set: Nsd-dnssd-register
static GMainLoop* loop = NULL;
dnssd_create_local_service("_ftp._tcp", &serv_id);
- ret = dnssd_service_set_interface(serv_id, "wlan0");
+ ret = dnssd_service_set_interface(serv_id, nsd_get_interface_name());
assert_eq(ret, DNSSD_ERROR_NONE);
dnssd_destroy_local_service(serv_id);
dnssd_create_local_service("_ftp._tcp", &serv_id);
- ret = dnssd_service_set_interface(serv_id + 1, "wlan0");
+ ret = dnssd_service_set_interface(serv_id + 1, nsd_get_interface_name());
assert_eq(ret, DNSSD_ERROR_SERVICE_NOT_FOUND);
dnssd_destroy_local_service(serv_id);
dnssd_create_local_service("_ftp._tcp", &serv_id);
- ret = dnssd_service_set_interface(serv_id, "wlan0");
+ ret = dnssd_service_set_interface(serv_id, nsd_get_interface_name());
assert_eq(ret, DNSSD_ERROR_NONE);
ret = dnssd_service_get_interface(serv_id, &interface);