This email list is read-only. Emails sent to this list will be discarded
----------------------------------
plugins/Makefile.am | 4 +-
plugins/loopback.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 1 deletions(-)
New commits:
commit 6751366d75406726fb533f842fd59b69feb95292
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Dec 6 00:27:49 2008 +0100
Set loopback interface parameters during setup
commit 555b6e45c2746818d2c2a8816b4069c7b4a967f9
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Dec 6 00:08:47 2008 +0100
Add skeleton for loopback setup plugin
Diff in this email is a maximum of 400 lines.
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index ef5a82d..b9011f9 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,10 +1,12 @@
plugindir = $(libdir)/connman/plugins
-plugin_LTLIBRARIES = ethernet.la wifi.la bluetooth.la \
+plugin_LTLIBRARIES = loopback.la ethernet.la wifi.la bluetooth.la \
netdev.la dhclient.la ipv4.la \
resolvconf.la resolvfile.la rtnllink.la
+loopback_la_SOURCES = loopback.c
+
ethernet_la_SOURCES = ethernet.c
wifi_la_SOURCES = wifi.c inet.h inet.c supplicant.h supplicant.c
diff --git a/plugins/loopback.c b/plugins/loopback.c
new file mode 100644
index 0000000..184ea73
--- /dev/null
+++ b/plugins/loopback.c
@@ -0,0 +1,108 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2008 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 <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+
+#include <connman/plugin.h>
+#include <connman/log.h>
+
+static int loopback_init(void)
+{
+ struct ifreq ifr;
+ struct sockaddr_in *addr;
+ int sk, err;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return -1;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strcpy(ifr.ifr_name, "lo");
+
+ if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ if (ifr.ifr_flags & IFF_UP) {
+ err = -EALREADY;
+ connman_info("The loopback interface is already up");
+ goto done;
+ }
+
+ addr = (struct sockaddr_in *) &ifr.ifr_addr;
+ addr->sin_family = AF_INET;
+ addr->sin_addr.s_addr = inet_addr("127.0.0.0");
+
+ err = ioctl(sk, SIOCSIFADDR, &ifr);
+ if (err < 0) {
+ err = -errno;
+ connman_error("Setting address failed (%s)", strerror(-err));
+ goto done;
+ }
+
+ addr = (struct sockaddr_in *) &ifr.ifr_netmask;
+ addr->sin_family = AF_INET;
+ addr->sin_addr.s_addr = inet_addr("255.0.0.0");
+
+ err = ioctl(sk, SIOCSIFNETMASK, &ifr);
+ if (err < 0) {
+ err = -errno;
+ connman_error("Setting netmask failed (%s)", strerror(-err));
+ goto done;
+ }
+
+ if (ioctl(sk, SIOCGIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ goto done;
+ }
+
+ ifr.ifr_flags |= IFF_UP;
+
+ if (ioctl(sk, SIOCSIFFLAGS, &ifr) < 0) {
+ err = -errno;
+ connman_error("Activating loopback interface failed (%s)",
+ strerror(-err));
+ goto done;
+ }
+
+done:
+ close(sk);
+
+ return err;
+}
+
+static void loopback_exit(void)
+{
+}
+
+CONNMAN_PLUGIN_DEFINE("loopback", "Loopback device plugin", VERSION,
+ loopback_init, loopback_exit)
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits