5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <sys/ioctl.h>
29 #include <linux/sockios.h>
33 #define BRIDGE_NAME "tether"
35 static connman_bool_t tethering_status = FALSE;
37 connman_bool_t __connman_tethering_get_status(void)
39 return tethering_status;
42 static int create_bridge(const char *name)
48 sk = socket(AF_INET, SOCK_STREAM, 0);
52 err = ioctl(sk, SIOCBRADDBR, name);
62 static int remove_bridge(const char *name)
68 sk = socket(AF_INET, SOCK_STREAM, 0);
72 err = ioctl(sk, SIOCBRDELBR, name);
82 int __connman_tethering_set_status(connman_bool_t status)
84 if (status == tethering_status)
88 create_bridge(BRIDGE_NAME);
89 __connman_technology_enable_tethering(BRIDGE_NAME);
91 __connman_technology_disable_tethering(BRIDGE_NAME);
92 remove_bridge(BRIDGE_NAME);
95 tethering_status = status;
100 void __connman_tethering_update_interface(const char *interface)
102 DBG("interface %s", interface);
105 int __connman_tethering_init(void)
112 void __connman_tethering_cleanup(void)
116 if (tethering_status == TRUE)
117 remove_bridge(BRIDGE_NAME);