Remove network interface helpers
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jan 2008 06:51:19 +0000 (07:51 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jan 2008 06:51:19 +0000 (07:51 +0100)
plugins/80203.c
plugins/Makefile.am
plugins/net.c [deleted file]
plugins/net.h [deleted file]

index 785c441..65a22aa 100644 (file)
@@ -29,8 +29,6 @@
 #include <connman/plugin.h>
 #include <connman/iface.h>
 
-#include "net.h"
-
 static int iface_probe(struct connman_iface *iface)
 {
        printf("[802.03] probe interface index %d\n", iface->index);
@@ -47,33 +45,6 @@ static int iface_probe(struct connman_iface *iface)
 static void iface_remove(struct connman_iface *iface)
 {
        printf("[802.03] remove interface index %d\n", iface->index);
-
-       __net_clear(iface->index);
-}
-
-static int iface_get_ipv4(struct connman_iface *iface,
-                                       struct connman_ipv4 *ipv4)
-{
-       if (__net_ifaddr(iface->index, &ipv4->address) < 0)
-               return -1;
-
-       printf("[802.03] get address %s\n", inet_ntoa(ipv4->address));
-
-       return 0;
-}
-
-static int iface_set_ipv4(struct connman_iface *iface,
-                                       struct connman_ipv4 *ipv4)
-{
-       printf("[802.03] set address %s\n", inet_ntoa(ipv4->address));
-       printf("[802.03] set netmask %s\n", inet_ntoa(ipv4->netmask));
-       printf("[802.03] set gateway %s\n", inet_ntoa(ipv4->gateway));
-
-       __net_set(iface->index, &ipv4->address, &ipv4->netmask,
-                               &ipv4->gateway, &ipv4->broadcast,
-                                               &ipv4->nameserver);
-
-       return 0;
 }
 
 static struct connman_iface_driver iface_driver = {
@@ -81,8 +52,6 @@ static struct connman_iface_driver iface_driver = {
        .capability     = "net.80203",
        .probe          = iface_probe,
        .remove         = iface_remove,
-       .get_ipv4       = iface_get_ipv4,
-       .set_ipv4       = iface_set_ipv4,
 };
 
 static int plugin_init(void)
index 24e4433..2f789ec 100644 (file)
@@ -4,12 +4,11 @@ plugindir = $(libdir)/connman/plugins
 plugin_LTLIBRARIES = libconnman-80203.la libconnman-80211.la \
                        libconnman-dhclient.la
 
-libconnman_80203_la_SOURCES = 80203.c net.h net.c
+libconnman_80203_la_SOURCES = 80203.c
 
-libconnman_80211_la_SOURCES = 80211.c net.h net.c \
-                               supplicant.h supplicant.c
+libconnman_80211_la_SOURCES = 80211.c supplicant.h supplicant.c
 
-libconnman_dhclient_la_SOURCES = dhclient.c net.h net.c
+libconnman_dhclient_la_SOURCES = dhclient.c
 libconnman_dhclient_la_LIBADD = @GDBUS_LIBS@
 
 AM_LDFLAGS = -module -avoid-version -export-symbols-regex connman_plugin_desc
diff --git a/plugins/net.c b/plugins/net.c
deleted file mode 100644 (file)
index 18927ee..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- *  Connection Manager
- *
- *  Copyright (C) 2007  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 <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <net/if.h>
-
-#include "net.h"
-
-int __net_ifaddr(int ifindex, struct in_addr *addr)
-{
-       struct ifreq ifr;
-       int sk;
-
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
-       if (sk < 0)
-               return -errno;
-
-       memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = ifindex;
-
-       if (ioctl(sk, SIOCGIFNAME, &ifr) < 0) {
-               close(sk);
-               return -errno;
-       }
-
-       if (ioctl(sk, SIOCGIFADDR, &ifr) < 0) {
-               close(sk);
-               return -errno;
-       }
-
-       close(sk);
-
-       *addr = ((struct sockaddr_in *) (&ifr.ifr_addr))->sin_addr;
-
-       return 0;
-}
-
-char *__net_ifname(int ifindex)
-{
-       struct ifreq ifr;
-       int sk, err;
-
-       sk = socket(PF_INET, SOCK_DGRAM, 0);
-       if (sk < 0)
-               return NULL;
-
-       memset(&ifr, 0, sizeof(ifr));
-       ifr.ifr_ifindex = ifindex;
-
-       err = ioctl(sk, SIOCGIFNAME, &ifr);
-
-       close(sk);
-
-       if (err < 0)
-               return NULL;
-
-       return strdup(ifr.ifr_name);
-}
-
-void __net_free(void *ptr)
-{
-       if (ptr)
-               free(ptr);
-}
-
-int __net_clear(int ifindex)
-{
-       char *ifname, cmd[128];
-
-       ifname = __net_ifname(ifindex);
-       if (ifname == NULL)
-               return -1;
-
-       sprintf(cmd, "resolvconf -d %s", ifname);
-       printf("[NET] %s\n", cmd);
-       system(cmd);
-
-       sprintf(cmd, "ip addr flush dev %s", ifname);
-       printf("[NET] %s\n", cmd);
-       system(cmd);
-
-       __net_free(ifname);
-
-       return 0;
-}
-
-int __net_set(int ifindex, struct in_addr *addr, struct in_addr *mask,
-                               struct in_addr *route, struct in_addr *bcast,
-                                               struct in_addr *namesrv)
-{
-       char *ifname, cmd[128], msk[32], brd[32];
-
-       ifname = __net_ifname(ifindex);
-       if (ifname == NULL)
-               return -1;
-
-       __net_clear(ifindex);
-
-       sprintf(msk, "%s", "24");
-       sprintf(brd, "%s", inet_ntoa(*bcast));
-       sprintf(cmd, "ip addr add %s/%s brd %s dev %s",
-                               inet_ntoa(*addr), msk, brd, ifname);
-       printf("[NET] %s\n", cmd);
-       system(cmd);
-
-       sprintf(cmd, "ip route add default via %s dev %s",
-                                       inet_ntoa(*route), ifname);
-       printf("[NET] %s\n", cmd);
-       system(cmd);
-
-       sprintf(cmd, "echo \"nameserver %s\" | resolvconf -a %s",
-                                       inet_ntoa(*namesrv), ifname);
-       printf("[NET] %s\n", cmd);
-       system(cmd);
-
-       __net_free(ifname);
-
-       return 0;
-}
diff --git a/plugins/net.h b/plugins/net.h
deleted file mode 100644 (file)
index 83de416..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- *  Connection Manager
- *
- *  Copyright (C) 2007  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
- *
- */
-
-#include <arpa/inet.h>
-
-int __net_ifaddr(int ifindex, struct in_addr *addr);
-char *__net_ifname(int ifindex);
-void __net_free(void *ptr);
-
-int __net_clear(int ifindex);
-int __net_set(int ifindex, struct in_addr *addr, struct in_addr *mask,
-                               struct in_addr *route, struct in_addr *bcast,
-                                               struct in_addr *namesrv);