/**
* \brief This API is only for Connection CAPI. Don't use this.
*
- * \param[in] enable Enable EAP over Ethernet network.
- * \param[in] pofilename Profile name of ethernet.
+ * \param[in] handle The network info handle.
+ * \param[out] ntp_server IP/URL of NTP Server
+ *
+ ******************************************************************************************/
+int net_get_ntp_server_info(void * handle, char **ntp_server);
+
+/**
+ * \brief This API is only for Connection CAPI. Don't use this.
+ *
+ * \param[in] handle The network info handle.
+ * \param[in] ntp_server The IP/URL of NTP Server.
*
******************************************************************************************/
+int net_set_ntp_server(void *handle, const char *ntp_server);
+
+/**
+ * \brief This API is only for Connection CAPI. Don't use this.
+ *
+ * \param[in] handle The network info handle.
+ *
+ ******************************************************************************************/
+int net_clear_ntp_server(void *handle);
+
+/**
+ * \brief This API is only for Connection CAPI. Don't use this.
+ *
+ * \param[in] enable Enable EAP over Ethernet network.
+ * \param[in] pofilename Profile name of ethernet.
+ *
+ ******************************************************************************************/
+
+
int net_ethernet_eap_enable(gboolean enable, const char *profilename);
/**
int _net_dbus_get_ethernet_cable_state(network_info_t *network_info, int *state);
int _net_dbus_get_metered_state(network_info_t *network_info, int *state);
int _net_dbus_get_clock_updated(network_info_t *network_info, bool *state);
+int _net_dbus_get_ntp_server(network_info_t *network_info, char ** ntp_server);
+int _net_dbus_set_ntp_server(network_info_t *network_info, const char* ntp_server);
+int _net_dbus_clear_ntp_server(network_info_t *network_info);
int _net_dbus_get_preferred_ipv6_address(const char *profilename, char **address);
int _net_dbus_set_agent_passphrase_and_connect(network_info_t *network_info,
const char *passphrase, const char *profilename);
#define NETCONFIG_NETWORK_INTERFACE NETCONFIG_SERVICE ".network"
#define NETCONFIG_TCPDUMP_INTERFACE NETCONFIG_SERVICE ".tcpdump"
#define NETCONFIG_WIFI_INTERFACE NETCONFIG_SERVICE ".wifi"
-#define NETCONFIG_STATISTICS_INTERFACE NETCONFIG_SERVICE ".network_statistics"
+#define NETCONFIG_STATISTICS_INTERFACE NETCONFIG_SERVICE ".network_statistics"
#define NETCONFIG_MPTCP_INTERFACE NETCONFIG_SERVICE ".mptcp"
#define NETCONFIG_ETHERNET_INTERFACE NETCONFIG_SERVICE ".ethernet"
+#define NETCONFIG_CLOCK_INTERFACE NETCONFIG_SERVICE ".clock"
#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
#define NETCONFIG_STATISTICS_PATH "/net/netconfig/network_statistics"
#define NETCONFIG_MPTCP_PATH "/net/netconfig/mptcp"
#define NETCONFIG_ETHERNET_PATH "/net/netconfig/ethernet"
+#define NETCONFIG_CLOCK_PATH "/net/netconfig/clock"
#define NETCONFIG_TV_PROFILE_INTERFACE NETCONFIG_SERVICE ".tv_profile"
const char *ProfileName, GVariantIter *iter,
net_profile_info_t *prof_info);
void _net_extract_clock_updated(GVariantIter *iter, bool *state);
+void _net_extract_ntp_server(GVariantIter *iter, char **ntp_server);
int _net_dbus_create_gdbus_call(network_info_t *network_info);
void _net_dbus_close_gdbus_call(network_info_t *network_info);
return Error;
}
+EXPORT_API int net_get_ntp_server_info(void * handle, char **ntp_server)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
+ network_info_t *network_info = (network_info_t *)handle;
+
+ Error = _net_dbus_get_ntp_server(network_info, ntp_server);
+
+ if (Error != NET_ERR_NONE)
+ NETWORK_LOG(NETWORK_ERROR, "net_get_ntp_server_info failed\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+EXPORT_API int net_set_ntp_server(void *handle, const char *ntp_server)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
+ network_info_t *network_info = (network_info_t *)handle;
+
+ Error = _net_dbus_set_ntp_server(network_info, ntp_server);
+
+ if (Error != NET_ERR_NONE)
+ NETWORK_LOG(NETWORK_ERROR, "net_set_ntp_server failed\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+EXPORT_API int net_clear_ntp_server(void *handle)
+{
+ __NETWORK_FUNC_ENTER__;
+ net_err_t Error = NET_ERR_NONE;
+ network_info_t *network_info = (network_info_t *)handle;
+
+ Error = _net_dbus_clear_ntp_server(network_info);
+
+ if (Error != NET_ERR_NONE)
+ NETWORK_LOG(NETWORK_ERROR, "net_clear_ntp_server failed\n");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+
EXPORT_API void net_set_cs_tid(int tid, void *handle)
{
network_info_t *network_info = (network_info_t *)handle;
return Error;
}
+int _net_dbus_get_ntp_server(network_info_t *network_info, char ** ntp_server)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariantIter *servers = NULL;
+
+ if (ntp_server == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ message = _net_invoke_dbus_method(network_info, CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
+ CONNMAN_CLOCK_INTERFACE, "GetProperties", NULL, &Error);
+
+ /* LCOV_EXCL_START */
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to get NTP Server information\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ /* LCOV_EXCL_STOP */
+
+ g_variant_get(message, "(a{sv})", &servers);
+ _net_extract_ntp_server(servers, ntp_server);
+
+ g_variant_iter_free(servers);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_set_ntp_server(network_info_t *network_info, const char *ntp_server)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params = NULL;
+
+ if (ntp_server == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_INVALID_PARAM;
+ }
+
+ params = g_variant_new("(s)", ntp_server);
+ message = _net_invoke_dbus_method(network_info, NETCONFIG_SERVICE, NETCONFIG_CLOCK_PATH,
+ NETCONFIG_CLOCK_INTERFACE, "SetNtpServer", params, &Error);
+
+ /* LCOV_EXCL_START */
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to set NTP server\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ /* LCOV_EXCL_STOP */
+
+ NETWORK_LOG(NETWORK_LOW, "Set NTP Server [%s]\n", ntp_server);
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_clear_ntp_server(network_info_t *network_info)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_t Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(network_info, NETCONFIG_SERVICE, NETCONFIG_CLOCK_PATH,
+ NETCONFIG_CLOCK_INTERFACE, "UnsetNtpServer", NULL, &Error);
+
+ /* LCOV_EXCL_START */
+ if (message == NULL) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to clear NTP server\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+ /* LCOV_EXCL_STOP */
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
/* LCOV_EXCL_START */
int _net_dbus_get_preferred_ipv6_address(const char *profilename, char **address)
{
__NETWORK_FUNC_EXIT__;
}
+void _net_extract_ntp_server(GVariantIter *iter, char **ntp_server)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ gchar *key = NULL;
+ GVariant *value = NULL;
+ gchar *server = NULL;
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+
+ if (g_strcmp0(key, "Timeservers") == 0) {
+ GVariantIter *iter_sub = NULL;
+
+ g_variant_get(value, "as", &iter_sub);
+ if (!g_variant_iter_loop(iter_sub, "s", &server))
+ NETWORK_LOG(NETWORK_ERROR, "No NTP Server");
+
+ g_variant_iter_free(iter_sub);
+
+ if (server) {
+ *ntp_server = g_strdup(server);
+ g_free(server);
+ }
+
+ g_variant_unref(value);
+ g_free(key);
+ break;
+ }
+ }
+
+ __NETWORK_FUNC_EXIT__;
+}
static int __net_get_mesh_peers(network_info_t *network_info,
const char *profile_name, net_profile_info_t *prof_info)