ecore
edbus
capi-network-connection
- glib-2.0
)
pkg_check_modules(PKGS REQUIRED ${PKG_MODULE})
[Service]
Type=simple
ExecStart=/usr/bin/emuld
-KillSignal=SIGUSR1
[Install]
WantedBy=emulator.target
#define HEADER_SIZE 4
#define STATUS 15
-#define TID_BOOT 1
+#define TID_NETWORK 1
#define TID_SDCARD 2
#define TID_LOCATION 3
#define TID_HDS_ATTACH 4
# define LOGERR LOGE
# define LOGDEBUG LOGD
#else
-# define LOGINFO(fmt, ...) { writelog(fmt, ##__VA_ARGS__); }
-# define LOGERR LOGINFO
-# define LOGDEBUG LOGINFO
+# define LOG_TAG "EMULD"
+# include <dlog/dlog.h>
+# define LOGINFO(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGI(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGERR(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGE(fmt, ##__VA_ARGS__); \
+ } while (0)
+# define LOGDEBUG(fmt, ...) \
+ do { \
+ writelog(fmt, ##__VA_ARGS__); \
+ LOGD(fmt, ##__VA_ARGS__); \
+ } while (0)
#endif
typedef unsigned short CliSN;
void recv_from_evdi(evdi_fd fd);
bool accept_proc(const int server_fd);
void get_guest_addr(void);
-int register_connection(void);
+void register_connection(void);
void destroy_connection(void);
void set_vconf_cb(void);
void send_emuld_connection(void);
void send_default_suspend_req(void);
void send_default_mount_req(void);
-void* dbus_booting_done_check(void* data);
void systemcall(const char* param);
int parse_val(char *buff, unsigned char data, char *parsbuf);
Name: emuld
-Version: 0.9.10
+Version: 0.9.11
Release: 0
Summary: Emulator daemon
License: Apache-2.0
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(edbus)
BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-network-connection)
-BuildRequires: pkgconfig(network)
-BuildRequires: pkgconfig(glib-2.0)
%description
A emulator daemon is used for communication between guest and host
#include <sys/time.h>
#include <sys/reboot.h>
-#include <sys/ioctl.h>
#include <sys/mount.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <utility>
-#include <E_DBus.h>
-#include <Ecore.h>
-
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
}
}
-enum ioctl_cmd {
- IOCTL_CMD_BOOT_DONE,
-};
-
-void send_to_kernel(void)
-{
- if(ioctl(g_fd[fdtype_device], IOCTL_CMD_BOOT_DONE, NULL) == -1) {
- LOGERR("Failed to send ioctl to kernel");
- return;
- }
- LOGINFO("[DBUS] sent booting done to kernel");
-}
-
-#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core"
-#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core"
-#define BOOT_DONE_SIGNAL "BootingDone"
-
-static void boot_done(void *data, DBusMessage *msg)
-{
- if (dbus_message_is_signal(msg,
- DBUS_IFACE_BOOT_DONE,
- BOOT_DONE_SIGNAL) != 0) {
- LOGINFO("[DBUS] sending booting done to ecs.");
- send_to_ecs(IJTYPE_BOOT, 0, 0, NULL);
- LOGINFO("[DBUS] sending booting done to kernel for log.");
- send_to_kernel();
- }
-}
-
-static void sig_handler(int signo)
-{
- LOGINFO("received signal: %d. EXIT!", signo);
- _exit(0);
-}
-
-static void add_sig_handler(int signo)
-{
- sighandler_t sig;
-
- sig = signal(signo, sig_handler);
- if (sig == SIG_ERR) {
- LOGERR("adding %d signal failed : %d", signo, errno);
- }
-}
-
-void* dbus_booting_done_check(void* data)
-{
- E_DBus_Connection *connection;
- E_DBus_Signal_Handler *boot_handler = NULL;
-
- ecore_init();
- e_dbus_init();
-
- connection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
- if (!connection) {
- LOGERR("[DBUS] Failed to get dbus bus.");
- e_dbus_shutdown();
- ecore_shutdown();
- return NULL;
- }
-
- boot_handler = e_dbus_signal_handler_add(
- connection,
- NULL,
- DBUS_PATH_BOOT_DONE,
- DBUS_IFACE_BOOT_DONE,
- BOOT_DONE_SIGNAL,
- boot_done,
- NULL);
- if (!boot_handler) {
- LOGERR("[DBUS] Failed to register handler");
- e_dbus_signal_handler_del(connection, boot_handler);
- e_dbus_shutdown();
- ecore_shutdown();
- return NULL;
- }
- LOGINFO("[DBUS] signal handler is added.");
-
- add_sig_handler(SIGINT);
- add_sig_handler(SIGTERM);
- add_sig_handler(SIGUSR1);
-
- ecore_main_loop_begin();
-
- e_dbus_signal_handler_del(connection, boot_handler);
- e_dbus_shutdown();
- ecore_shutdown();
-
- return NULL;
-}
-
char SDpath[256];
// Location
#include <stdarg.h>
#include <stdio.h>
#include <arpa/inet.h>
+#include <sys/ioctl.h>
#include <unistd.h>
#include "emuld.h"
#include "synbuf.h"
+#include <E_DBus.h>
+#include <Ecore.h>
+
#include <queue>
/* global definition */
return false;
}
-int main( int argc , char *argv[])
+enum ioctl_cmd {
+ IOCTL_CMD_BOOT_DONE,
+};
+
+void send_to_kernel(void)
+{
+ if(ioctl(g_fd[fdtype_device], IOCTL_CMD_BOOT_DONE, NULL) == -1) {
+ LOGERR("Failed to send ioctl to kernel");
+ return;
+ }
+ LOGINFO("[DBUS] sent booting done to kernel");
+}
+
+#define DBUS_PATH_BOOT_DONE "/Org/Tizen/System/DeviceD/Core"
+#define DBUS_IFACE_BOOT_DONE "org.tizen.system.deviced.core"
+#define BOOT_DONE_SIGNAL "BootingDone"
+
+static void boot_done(void *data, DBusMessage *msg)
+{
+ if (dbus_message_is_signal(msg,
+ DBUS_IFACE_BOOT_DONE,
+ BOOT_DONE_SIGNAL) != 0) {
+ LOGINFO("[DBUS] sending booting done to ecs.");
+ send_to_ecs(IJTYPE_BOOT, 0, 0, NULL);
+ LOGINFO("[DBUS] sending booting done to kernel for log.");
+ send_to_kernel();
+ }
+}
+
+static void sig_handler(int signo)
+{
+ LOGINFO("received signal: %d. EXIT!", signo);
+ _exit(0);
+}
+
+static void add_sig_handler(int signo)
+{
+ sighandler_t sig;
+
+ sig = signal(signo, sig_handler);
+ if (sig == SIG_ERR) {
+ LOGERR("adding %d signal failed : %d", signo, errno);
+ }
+}
+
+void* handling_network(void* data)
{
int ret = -1;
exit(0);
}
- ret = register_connection();
-
send_default_suspend_req();
- if (pthread_create(&tid[TID_BOOT], NULL, dbus_booting_done_check, NULL) != 0)
- {
- LOGERR("boot noti pthread create fail!");
- return -1;
- }
-
LOGINFO("[START] epoll & device init success");
send_default_mount_req();
add_vconf_map_profile();
set_vconf_cb();
+ send_emuld_connection();
+
while(!exit_flag)
{
exit_flag = server_process();
}
stop_listen();
- if (ret == 1)
+
+ exit(0);
+}
+
+int main( int argc , char *argv[])
+{
+ int ret;
+ void* retval = NULL;
+
+ E_DBus_Connection *dbus_conn;
+ E_DBus_Signal_Handler *boot_handler = NULL;
+
+ ecore_init();
+
+ dbus_threads_init_default();
+
+ ret = e_dbus_init();
+ if (ret == 0) {
+ LOGERR("[DBUS] init value : %d", ret);
+ exit(-1);
+ }
+
+ dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (!dbus_conn) {
+ LOGERR("[DBUS] Failed to get dbus bus.");
+ e_dbus_shutdown();
+ ecore_shutdown();
+ exit(-1);
+ }
+
+ boot_handler = e_dbus_signal_handler_add(
+ dbus_conn,
+ NULL,
+ DBUS_PATH_BOOT_DONE,
+ DBUS_IFACE_BOOT_DONE,
+ BOOT_DONE_SIGNAL,
+ boot_done,
+ NULL);
+ if (!boot_handler) {
+ LOGERR("[DBUS] Failed to register handler");
+ e_dbus_signal_handler_del(dbus_conn, boot_handler);
+ e_dbus_shutdown();
+ ecore_shutdown();
+ exit(-1);
+ }
+ LOGINFO("[DBUS] signal handler is added.");
+
+ add_sig_handler(SIGINT);
+ add_sig_handler(SIGTERM);
+
+ register_connection();
+
+ if (pthread_create(&tid[TID_NETWORK], NULL, handling_network, NULL) != 0)
{
- LOGINFO("destroy connection");
- destroy_connection();
+ LOGERR("boot noti pthread create fail!");
+ return -1;
}
+ ecore_main_loop_begin();
+
+ e_dbus_signal_handler_del(dbus_conn, boot_handler);
+ e_dbus_shutdown();
+ ecore_shutdown();
+
+ destroy_connection();
LOGINFO("emuld exit");
+ ret = pthread_join(tid[TID_NETWORK], &retval);
+ if (ret < 0) {
+ LOGERR("validate package pthread join is failed.");
+ }
+
return 0;
}
#include <fcntl.h>
#include "emuld.h"
#include <net_connection.h>
-
#define PROC_CMDLINE_PATH "/proc/cmdline"
#define IP_SUFFIX " ip="
#define IJTYPE_GUESTIP "guest_ip"
free(packet);
}
-void *g_main_thread_cb(void *arg)
+void register_connection(void)
{
- mainloop = g_main_loop_new(NULL, FALSE);
-
- int err = connection_create(&connection);
- if (CONNECTION_ERROR_NONE == err) {
+ int ret = connection_create(&connection);
+ if (CONNECTION_ERROR_NONE == ret) {
LOGINFO("connection_create() success!: [%p]", connection);
connection_set_ip_address_changed_cb(connection, ip_changed_cb, NULL);
} else {
- LOGERR("Client registration failed %d", err);
- return NULL;
+ LOGERR("Client registration failed %d", ret);
+ return;
}
get_guest_addr();
- g_main_loop_run(mainloop);
- return NULL;
}
-int register_connection()
-{
- LOGINFO("register_connection");
-
- if(pthread_create(&g_main_thread, NULL, g_main_thread_cb, NULL) != 0) {
- LOGERR("fail to create g_main_thread!");
- return -1;
- }
- return 1;
-}
-
-void destroy_connection()
+void destroy_connection(void)
{
if (connection != NULL) {
connection_destroy(connection);
}
connection_profile_destroy(profile);
- g_main_loop_quit(mainloop);
- pthread_detach(g_main_thread);
}
static char *s_strncpy(char *dest, const char *source, size_t n)
} else {
LOGINFO("use dynamic IP. do not need update network information.");
}
-
- send_emuld_connection();
}