From c65048760d5026d6d84c5641e371e429c242a368 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Mon, 2 Jul 2018 13:55:55 +0900 Subject: [PATCH] Modify the ipsp agent for gtest Change-Id: Ie35a740c356f5c2c93ef23784d75252222714a87 Signed-off-by: DoHyun Pyun --- ipsp-agent/CMakeLists.txt | 2 +- ...uetooth_ipsp_agent.c => bluetooth-ipsp-agent.c} | 14 +-- ipsp-agent/bluetooth-ipsp-agent.h | 106 +++++++++++++++++++++ ipsp-agent/bluetooth_ipsp_agent.h | 6 ++ 4 files changed, 120 insertions(+), 8 deletions(-) rename ipsp-agent/{bluetooth_ipsp_agent.c => bluetooth-ipsp-agent.c} (98%) create mode 100644 ipsp-agent/bluetooth-ipsp-agent.h diff --git a/ipsp-agent/CMakeLists.txt b/ipsp-agent/CMakeLists.txt index 476752d..7735666 100644 --- a/ipsp-agent/CMakeLists.txt +++ b/ipsp-agent/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(bluetooth-ipsp-agent C CXX) -SET(SRCS bluetooth_ipsp_agent.c +SET(SRCS bluetooth-ipsp-agent.c ../include/bluetooth-agent-profile.c) IF("${CMAKE_BUILD_TYPE}" STREQUAL "") diff --git a/ipsp-agent/bluetooth_ipsp_agent.c b/ipsp-agent/bluetooth-ipsp-agent.c similarity index 98% rename from ipsp-agent/bluetooth_ipsp_agent.c rename to ipsp-agent/bluetooth-ipsp-agent.c index ca8ef0e..fc5e831 100644 --- a/ipsp-agent/bluetooth_ipsp_agent.c +++ b/ipsp-agent/bluetooth-ipsp-agent.c @@ -23,7 +23,7 @@ #include #include -#include "bluetooth_ipsp_agent.h" +#include "bluetooth-ipsp-agent.h" #include "bluetooth-api.h" #include #include @@ -110,7 +110,7 @@ void _bt_ipsp_terminate(void) } } -GDBusConnection * _bt_ipsp_get_gdbus_connection(void) +static GDBusConnection *__bt_ipsp_get_gdbus_connection(void) { GError *err = NULL; @@ -135,7 +135,7 @@ void _bt_ipsp_unregister_dbus(void) BT_DBG(""); - conn = _bt_ipsp_get_gdbus_connection(); + conn = __bt_ipsp_get_gdbus_connection(); if (!conn) return; @@ -556,7 +556,7 @@ int __bt_ipsp_create_ipv6_remote_address(char *remote_address, char **ipv6_addre return BT_ERROR_NONE; } -static int _execute_ip_command(const char *ip_args) +static int __execute_ip_command(const char *ip_args) { if (ip_args == NULL) { BT_ERR("Invalid param\n"); @@ -627,7 +627,7 @@ gboolean __bt_ipsp_add_ipv6_neigh_proxy(char *if_name, char *ip) snprintf(args, sizeof(args), IPV6_NEIGH_PROXY, ip, if_name); - if (_execute_ip_command(args)) { + if (__execute_ip_command(args)) { BT_ERR("%s is failed\n", args); return FALSE; } @@ -661,7 +661,7 @@ gboolean __bt_ipsp_add_ipv6_route(char *if_name, char *ip, int prefix) ip, prefix, if_name); } - if (_execute_ip_command(args)) { + if (__execute_ip_command(args)) { BT_ERR("%s is failed\n", args); return FALSE; } @@ -846,7 +846,7 @@ gboolean _bt_ipsp_register_dbus(void) gchar *path; GDBusConnection *conn; - conn = _bt_ipsp_get_gdbus_connection(); + conn = __bt_ipsp_get_gdbus_connection(); if (!conn) return FALSE; diff --git a/ipsp-agent/bluetooth-ipsp-agent.h b/ipsp-agent/bluetooth-ipsp-agent.h new file mode 100644 index 0000000..256b784 --- /dev/null +++ b/ipsp-agent/bluetooth-ipsp-agent.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 __BLUETOOTH_IPSP_AGENT_H__ +#define __BLUETOOTH_IPSP_AGENT_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CONNMAN_DBUS_NAME "net.connman" +#define CONNMAN_BLUETOOTH_TECHNOLOGY_PATH "/net/connman/technology/bluetooth" +#define CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE "net.connman.Technology" + +#define BT_IPSP_NAME "org.projectx.bt_ipsp" +#define BT_IPSP_PATH "/org/projectx/bt_ipsp" + +#define LOG_COLOR_RESET "\033[0m" +#define LOG_COLOR_RED "\033[31m" +#define LOG_COLOR_YELLOW "\033[33m" +#define LOG_COLOR_GREEN "\033[32m" +#define LOG_COLOR_BLUE "\033[36m" +#define LOG_COLOR_PURPLE "\033[35m" + +#define BT_INFO_C(fmt, arg...) \ + SLOGI_IF(TRUE, LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg) +#define BT_ERR_C(fmt, arg...) \ + SLOGI_IF(TRUE, LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg) + + +#define MH_MAX_IPV6_ADDRESS_STR_LEN 40 +#define MH_IF_INET6_PATH "/proc/net/if_inet6" +#define MH_MAX_INTERFACE_NAME_LEN 20 +#define MAX_BUF_SIZE (256u) + + typedef enum { + MOBILE_AP_IPV6_SCOPE_GLOBAL = 0, + MOBILE_AP_IPV6_SCOPE_LINK = 20, + MOBILE_AP_IPV6_SCOPE_SITE = 40, +} mobile_ap_ipv6_scope_e; + +#define DNSMASQ_CONF_LEN 1024 +#define DNSMASQ_LEASES_FILE "/var/lib/misc/dnsmasq.leases" +#define DNSMASQ_CONF_FILE "/tmp/dnsmasq.conf" +#define DNSMASQ_CONF6 \ + "dhcp-range=192.168.43.3,192.168.43.254,255.255.255.0\n" \ + "dhcp-range=192.168.130.2,192.168.130.150,255.255.255.0\n" \ + "dhcp-range=192.168.131.2,192.168.131.150,255.255.255.0\n" \ + "dhcp-range=192.168.132.2,192.168.132.150,255.255.255.0\n" \ + "dhcp-range=192.168.133.2,192.168.133.150,255.255.255.0\n" \ + "dhcp-range=192.168.134.2,192.168.134.150,255.255.255.0\n" \ + "dhcp-range=192.168.135.2,192.168.135.150,255.255.255.0\n" \ + "dhcp-range=192.168.136.2,192.168.136.150,255.255.255.0\n" \ + "dhcp-range=192.168.137.2,192.168.137.150,255.255.255.0\n" \ + "dhcp-range=set:blue,192.168.129.4,192.168.129.150,255.255.255.0\n"\ + "enable-dbus\n" \ + "group=system\n" \ + "user=system\n" \ + "dhcp-option=tag:blue,option:router,192.168.129.3\n" \ + "dhcp-option=6,%s\n" \ + "log-dhcp\n"\ + "log-queries\n"\ + "log-facility=/opt/var/log/dnsmasq.log\n"\ + "enable-ra\n" \ + "dhcp-range=%s::, ra-names, ra-stateless, 64, 12h\n" + +#define IPV6_FORWARDING "/proc/sys/net/ipv6/conf/all/forwarding" +#define IPV6_PROXY_NDP "/proc/sys/net/ipv6/conf/all/proxy_ndp" + +#define IPV6_INTERFACE_ROUTING "%s/%d dev %s" +#define IPV6_NEIGH_PROXY "proxy %s dev %s" +#define IP_CMD "/usr/sbin/ip" + +void _bt_ipsp_gdbus_deinit_proxys(void); +void _bt_ipsp_terminate(void); +gboolean _bt_ipsp_register_dbus(void); +void _bt_ipsp_unregister_dbus(void); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ipsp-agent/bluetooth_ipsp_agent.h b/ipsp-agent/bluetooth_ipsp_agent.h index 1a66af7..079e01f 100644 --- a/ipsp-agent/bluetooth_ipsp_agent.h +++ b/ipsp-agent/bluetooth_ipsp_agent.h @@ -91,6 +91,12 @@ extern "C" { #define IPV6_NEIGH_PROXY "proxy %s dev %s" #define IP_CMD "/usr/sbin/ip" +void _bt_ipsp_gdbus_deinit_proxys(void); +void _bt_ipsp_terminate(void); +gboolean _bt_ipsp_register_dbus(void); +void _bt_ipsp_unregister_dbus(void); + + #ifdef __cplusplus } -- 2.7.4