From: Marcel Holtmann Date: Thu, 3 Jan 2008 06:51:19 +0000 (+0100) Subject: Remove network interface helpers X-Git-Tag: 0.1~452 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=047005ba15de74a21a39240d85ba37927db9cdb0;p=platform%2Fupstream%2Fconnman.git Remove network interface helpers --- diff --git a/plugins/80203.c b/plugins/80203.c index 785c441..65a22aa 100644 --- a/plugins/80203.c +++ b/plugins/80203.c @@ -29,8 +29,6 @@ #include #include -#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) diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 24e4433..2f789ec 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -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 index 18927ee..0000000 --- a/plugins/net.c +++ /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 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 index 83de416..0000000 --- a/plugins/net.h +++ /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 - -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);