2 * Network Configuration Module
4 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
25 #include "network-state.h"
26 #include "clatd-handler.h"
28 #define CLAT_EXEC_PATH "/usr/sbin/clatd"
29 #define ROUTE_EXEC_PATH "/sbin/route"
30 #define KILLALL_EXEC_PATH "/usr/bin/killall"
31 #define IFCONFIG_EXEC_PATH "/sbin/ifconfig"
33 char g_ifname[32] = {0, };
35 int netconfig_clatd_enable(void)
39 if (g_ifname[0] != '\0') {
40 rv = netconfig_clatd_disable();
43 DBG("Failed to disable existing clatd process");
48 const char *if_name = netconfig_get_default_ifname();
50 if (if_name == NULL) {
51 DBG("There is no interface name");
55 memset(g_ifname, 0, sizeof(g_ifname));
56 g_strlcat(g_ifname, if_name, 32);
58 const char *path = CLAT_EXEC_PATH;
59 char *const args[] = { "/usr/sbin/clatd", "-i", g_ifname, NULL };
61 rv = netconfig_execute_clatd(path, args);
64 DBG("Failed to enable clatd process %d", rv);
68 DBG("Successfully enabled clatd process with %s interface", g_ifname);
72 int netconfig_clatd_disable(void)
76 const char *path = KILLALL_EXEC_PATH;
77 char *const args[] = { "/usr/bin/kill -15", "clatd", NULL };
78 char *const envs[] = { NULL };
80 if (g_ifname[0] == '\0') {
81 DBG("There is no clatd process");
85 memset(g_ifname, 0, sizeof(g_ifname));
87 rv = netconfig_execute_file(path, args, envs);
90 DBG("Failed to disable clatd process %d", rv);
94 DBG("Successfully disable clatd process");;