#include <connman/device.h>
+extern int connman_inet_ifindex(const char *name);
+extern char *connman_inet_ifname(int index);
+
+extern int connman_inet_ifup(int index);
+extern int connman_inet_ifdown(int index);
+
extern struct connman_device *connman_inet_create_device(int index);
#ifdef __cplusplus
if ETHERNET
if ETHERNET_BUILTIN
builtin_modules += ethernet
-builtin_sources += ethernet.c inet.h inet.c
+builtin_sources += ethernet.c
else
plugin_LTLIBRARIES += ethernet.la
-ethernet_la_SOURCES = ethernet.c inet.h inet.c
+ethernet_la_SOURCES = ethernet.c
endif
endif
if WIFI
if WIFI_BUILTIN
builtin_modules += wifi
-builtin_sources += wifi.c inet.h inet.c supplicant.h supplicant.c
+builtin_sources += wifi.c supplicant.h supplicant.c
else
plugin_LTLIBRARIES += wifi.la
-wifi_la_SOURCES = wifi.c inet.h inet.c supplicant.h supplicant.c
+wifi_la_SOURCES = wifi.c supplicant.h supplicant.c
wifi_la_LIBADD = @GDBUS_LIBS@
endif
endif
if BLUETOOTH
if BLUETOOTH_BUILTIN
builtin_modules += bluetooth
-builtin_sources += bluetooth.c inet.h inet.c
+builtin_sources += bluetooth.c
else
plugin_LTLIBRARIES += bluetooth.la
-bluetooth_la_SOURCES = bluetooth.c inet.h inet.c
+bluetooth_la_SOURCES = bluetooth.c
bluetooth_la_LIBADD = @GDBUS_LIBS@
endif
endif
if UDHCP
if UDHCP_BUILTIN
builtin_modules += udhcp
-builtin_sources += udhcp.c inet.h inet.c task.h task.c
+builtin_sources += udhcp.c task.h task.c
builtin_cflags += -DUDHCPC=\"@UDHCPC@\"
else
plugin_LTLIBRARIES += udhcp.la
-udhcp_la_SOURCES = udhcp.c inet.h inet.c task.h task.c
+udhcp_la_SOURCES = udhcp.c task.h task.c
udhcp_la_CFLAGS = $(AM_CFLAGS) -DUDHCPC=\"@UDHCPC@\" \
-DSTATEDIR=\""$(statedir)"\" -DSCRIPTDIR=\""$(scriptdir)"\"
endif
if DHCLIENT
if DHCLIENT_BUILTIN
builtin_modules += dhclient
-builtin_sources += dhclient.c inet.h inet.c
+builtin_sources += dhclient.c
builtin_cflags += -DDHCLIENT=\"@DHCLIENT@\"
else
plugin_LTLIBRARIES += dhclient.la
-dhclient_la_SOURCES = dhclient.c inet.h inet.c
+dhclient_la_SOURCES = dhclient.c
dhclient_la_CFLAGS = $(AM_CFLAGS) -DDHCLIENT=\"@DHCLIENT@\" \
-DSTATEDIR=\""$(statedir)"\" -DSCRIPTDIR=\""$(scriptdir)"\"
endif
if IWMXSDK
plugin_LTLIBRARIES += iwmxsdk.la
-iwmxsdk_la_SOURCES = iwmxsdk.c inet.h inet.c
+iwmxsdk_la_SOURCES = iwmxsdk.c
iwmxsdk_la_LIBADD = @IWMXSDK_LIBS@ @GLIB_LIBS@
iwmxsdk_la_CFLAGS = $(AM_CFLAGS) @IWMXSDK_CFLAGS@
endif
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/device.h>
+#include <connman/inet.h>
#include <connman/dbus.h>
#include <connman/log.h>
-#include "inet.h"
-
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
data->interface = g_strdup(interface);
- index = inet_name2index(interface);
+ index = connman_inet_ifindex(interface);
connman_network_set_index(network, index);
connman_network_set_connected(network, TRUE);
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/driver.h>
+#include <connman/inet.h>
#include <connman/dbus.h>
#include <connman/log.h>
-#include "inet.h"
-
#define DHCLIENT_INTF "org.isc.dhclient"
#define DHCLIENT_PATH "/org/isc/dhclient"
return -ENOMEM;
task->ifindex = element->index;
- task->ifname = inet_index2name(element->index);
+ task->ifname = connman_inet_ifname(element->index);
task->element = element;
if (task->ifname == NULL) {
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/device.h>
+#include <connman/inet.h>
#include <connman/rtnl.h>
#include <connman/log.h>
-#include "inet.h"
-
struct ethernet_data {
int index;
unsigned flags;
DBG("device %p", device);
- return inet_ifup(ethernet->index);
+ return connman_inet_ifup(ethernet->index);
}
static int ethernet_disable(struct connman_device *device)
DBG("device %p", device);
- return inet_ifdown(ethernet->index);
+ return connman_inet_ifdown(ethernet->index);
}
static struct connman_device_driver ethernet_driver = {
+++ /dev/null
-/*
- *
- * Connection Manager
- *
- * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/ethernet.h>
-
-#include "inet.h"
-
-int inet_name2index(const char *name)
-{
- struct ifreq ifr;
- int sk, err;
-
- if (name == NULL)
- return -1;
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-
- err = ioctl(sk, SIOCGIFINDEX, &ifr);
-
- close(sk);
-
- if (err < 0)
- return -1;
-
- return ifr.ifr_ifindex;
-}
-
-char *inet_index2name(int index)
-{
- struct ifreq ifr;
- int sk, err;
-
- if (index < 0)
- return NULL;
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return NULL;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = index;
-
- err = ioctl(sk, SIOCGIFNAME, &ifr);
-
- close(sk);
-
- if (err < 0)
- return NULL;
-
- return strdup(ifr.ifr_name);
-}
-
-char *inet_index2ident(int index, const char *prefix)
-{
- struct ifreq ifr;
- struct ether_addr *eth;
- char *str;
- int sk, err, len;
-
- if (index < 0)
- return NULL;
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return NULL;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = index;
-
- err = ioctl(sk, SIOCGIFNAME, &ifr);
-
- if (err == 0)
- err = ioctl(sk, SIOCGIFHWADDR, &ifr);
-
- close(sk);
-
- if (err < 0)
- return NULL;
-
- len = prefix ? strlen(prefix) + 18 : 18;
-
- str = malloc(len);
- if (!str)
- return NULL;
-
- eth = (void *) &ifr.ifr_hwaddr.sa_data;
- snprintf(str, len, "%s%02X_%02X_%02X_%02X_%02X_%02X",
- prefix ? prefix : "",
- eth->ether_addr_octet[0],
- eth->ether_addr_octet[1],
- eth->ether_addr_octet[2],
- eth->ether_addr_octet[3],
- eth->ether_addr_octet[4],
- eth->ether_addr_octet[5]);
-
- return str;
-}
-
-int inet_ifup(int index)
-{
- struct ifreq ifr;
- int sk, err;
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -errno;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = index;
-
- if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ifr.ifr_flags & IFF_UP) {
- err = -EALREADY;
- goto done;
- }
-
- ifr.ifr_flags |= IFF_UP;
-
- if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- err = 0;
-
-done:
- close(sk);
-
- return err;
-}
-
-int inet_ifdown(int index)
-{
- struct ifreq ifr;
- int sk, err;
-
- sk = socket(PF_INET, SOCK_DGRAM, 0);
- if (sk < 0)
- return -errno;
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_ifindex = index;
-
- if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
- err = -errno;
- goto done;
- }
-
- if (!(ifr.ifr_flags & IFF_UP)) {
- err = -EALREADY;
- goto done;
- }
-
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
- err = -errno;
- else
- err = 0;
-
-done:
- close(sk);
-
- return err;
-}
+++ /dev/null
-/*
- *
- * Connection Manager
- *
- * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-int inet_name2index(const char *name);
-
-char *inet_index2name(int index);
-char *inet_index2ident(int index, const char *prefix);
-
-int inet_ifup(int index);
-int inet_ifdown(int index);
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/device.h>
#include <connman/option.h>
+#include <connman/inet.h>
#include <connman/dbus.h>
#include <connman/log.h>
-#include "inet.h"
#include "supplicant.h"
#define TIMEOUT 5000
connman_device_unref(task->device);
- inet_ifdown(task->ifindex);
+ connman_inet_ifdown(task->ifindex);
free_task(task);
return -ENOMEM;
task->ifindex = connman_device_get_index(device);
- task->ifname = inet_index2name(task->ifindex);
+ task->ifname = connman_inet_ifname(task->ifindex);
if (task->ifname == NULL) {
g_free(task);
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/driver.h>
+#include <connman/inet.h>
#include <connman/dbus.h>
#include <connman/log.h>
-#include "inet.h"
#include "task.h"
#define UDHCPC_INTF "net.busybox.udhcpc"
if (access(UDHCPC, X_OK) < 0)
return -errno;
- ifname = inet_index2name(element->index);
+ ifname = connman_inet_ifname(element->index);
if (ifname == NULL)
return -ENOMEM;
DBG("%s ==> address %s gateway %s", interface, address, gateway);
- index = inet_name2index(interface);
+ index = connman_inet_ifindex(interface);
if (index < 0)
return;
#include <connman/device.h>
#include <connman/log.h>
-#include "inet.h"
#include "supplicant.h"
#define CLEANUP_TIMEOUT 8 /* in seconds */
#include "connman.h"
-static char *index2name(int index)
+int connman_inet_ifindex(const char *name)
+{
+ struct ifreq ifr;
+ int sk, err;
+
+ if (name == NULL)
+ return -1;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return -1;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+
+ err = ioctl(sk, SIOCGIFINDEX, &ifr);
+
+ close(sk);
+
+ if (err < 0)
+ return -1;
+
+ return ifr.ifr_ifindex;
+}
+
+char *connman_inet_ifname(int index)
{
struct ifreq ifr;
int sk, err;
return strdup(ifr.ifr_name);
}
+int connman_inet_ifup(int index)
+{
+ struct ifreq ifr;
+ int sk, err;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return -errno;
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_ifindex = index;
+
+ if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ if (ifr.ifr_flags & IFF_UP) {
+ err = -EALREADY;
+ goto done;
+ }
+
+ ifr.ifr_flags |= IFF_UP;
+
+ if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ err = 0;
+
+done:
+ close(sk);
+
+ return err;
+}
+
+int connman_inet_ifdown(int index)
+{
+ struct ifreq ifr;
+ int sk, err;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return -errno;
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_ifindex = index;
+
+ if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ if (!(ifr.ifr_flags & IFF_UP)) {
+ err = -EALREADY;
+ goto done;
+ }
+
+ ifr.ifr_flags &= ~IFF_UP;
+
+ if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0)
+ err = -errno;
+ else
+ err = 0;
+
+done:
+ close(sk);
+
+ return err;
+}
+
static unsigned short index2type(int index)
{
struct ifreq ifr;
if (index < 0)
return NULL;
- devname = index2name(index);
+ devname = connman_inet_ifname(index);
if (devname == NULL)
return NULL;