gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14206 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r14206 - gnunet/src/vpn
Date: Wed, 19 Jan 2011 09:30:52 +0100

Author: grothoff
Date: 2011-01-19 09:30:52 +0100 (Wed, 19 Jan 2011)
New Revision: 14206

Removed:
   gnunet/src/vpn/gnunet-vpn-helper-p.h
   gnunet/src/vpn/gnunet-vpn-tun.c
   gnunet/src/vpn/gnunet-vpn-tun.h
Modified:
   gnunet/src/vpn/Makefile.am
   gnunet/src/vpn/gnunet-helper-vpn.c
Log:
breaking-indent

Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am  2011-01-19 08:27:28 UTC (rev 14205)
+++ gnunet/src/vpn/Makefile.am  2011-01-19 08:30:52 UTC (rev 14206)
@@ -26,9 +26,7 @@
 
 
 gnunet_helper_vpn_SOURCES = \
- gnunet-helper-vpn.c \
- gnunet-vpn-helper-p.h \
- gnunet-vpn-tun.h gnunet-vpn-tun.c
+ gnunet-helper-vpn.c
 
 gnunet_helper_hijack_dns_SOURCES = \
  gnunet-helper-hijack-dns.c

Modified: gnunet/src/vpn/gnunet-helper-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-helper-vpn.c  2011-01-19 08:27:28 UTC (rev 14205)
+++ gnunet/src/vpn/gnunet-helper-vpn.c  2011-01-19 08:30:52 UTC (rev 14206)
@@ -26,37 +26,101 @@
  * @author Philipp Tölke
  */
 #include <platform.h>
+#include <linux/if_tun.h>
 
-#include "gnunet-vpn-tun.h"
+/**
+ * Need 'struct GNUNET_MessageHeader'.
+ */
 #include "gnunet_common.h"
+
+/**
+ * Need VPN message types.
+ */
 #include "gnunet_protocols.h"
-#include "gnunet-vpn-helper-p.h"
 
+/**
+ * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ */
+#define MAX_SIZE 65536
+
 #ifndef _LINUX_IN6_H
-
-#define MAX_SIZE (65535 - sizeof(struct GNUNET_MessageHeader))
-
-// This is in linux/include/net/ipv6.h.
-struct in6_ifreq
+/**
+ * This is in linux/include/net/ipv6.h, but not always exported...
+ */
+struct in6_ifreq 
 {
   struct in6_addr ifr6_addr;
   uint32_t ifr6_prefixlen;
   unsigned int ifr6_ifindex;
 };
-
 #endif
 
+
+struct suid_packet 
+{
+  struct GNUNET_MessageHeader hdr;
+  unsigned char data[1];
+}
+
 static int running = 1;
 
-static void
-term (int sig)
+static void 
+term (int sig) 
 {
-  fprintf (stderr, "Got SIGTERM...\n");
+  fprintf (stderr, 
+          "Got SIGTERM...\n");
   if (sig == SIGTERM)
     running = 0;
 }
 
+
 /**
+ * Creates a tun-interface called dev;
+ * @param dev is asumed to point to a char[IFNAMSIZ]
+ *        if *dev == '\0', uses the name supplied by the kernel
+ * @return the fd to the tun or -1 on error
+ */
+static int 
+init_tun (char *dev) 
+{
+  struct ifreq ifr;
+  int fd;
+
+  if (NULL == dev) 
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  if (-1 == (fd = open("/dev/net/tun", O_RDWR))) 
+    {
+      fprintf (stderr, 
+              "Error opening `%s': %s\n", 
+              "/dev/net/tun",
+              strerror(errno));
+      return -1;
+    }
+
+  memset(&ifr, 0, sizeof(ifr));
+  ifr.ifr_flags = IFF_TUN;
+
+  if ('\0' == *dev)
+    strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+
+  if (-1 == ioctl(fd, TUNSETIFF, (void *) &ifr))
+    {
+      fprintf (stderr, 
+              "Error with ioctl on `%s': %s\n", 
+              "/dev/net/tun",
+              strerror(errno));
+      close(fd);
+      return -1;
+    }
+  strcpy(dev, ifr.ifr_name);
+  return fd;
+}
+
+/**
  * @brief Sets the IPv6-Address given in address on the interface dev
  *
  * @param dev the interface to configure
@@ -65,7 +129,7 @@
  */
 static void
 set_address6 (char *dev, char *address, unsigned long prefix_len)
-{                              /* {{{ */
+{                          
   int fd = socket (AF_INET6, SOCK_DGRAM, 0);
 
   if (fd < 0)
@@ -111,9 +175,9 @@
   ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
   (void) ioctl (fd, SIOCSIFFLAGS, &ifr);
   close (fd);
-}                              /* }}} */
+}
 
-static void
+
 /**
  * @brief Sets the IPv4-Address given in address on the interface dev
  *
@@ -121,8 +185,9 @@
  * @param address the IPv4-Address
  * @param mask the netmask
  */
+static void
 set_address4 (char *dev, char *address, char *mask)
-{                              /* {{{ */
+{
   int fd = 0;
   struct sockaddr_in *addr;
   struct ifreq ifr;
@@ -175,8 +240,9 @@
   ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
   (void) ioctl (fd, SIOCSIFFLAGS, &ifr);
   close (fd);
-}                              /* }}} */
+}
 
+
 /**
  * @brief sets the socket to nonblocking
  *
@@ -186,22 +252,20 @@
 setnonblocking (int fd)
 {                              /*{{{ */
   int opts;
+       opts = fcntl(fd,F_GETFL);
+       if (opts < 0) {
+                       perror("fcntl(F_GETFL)");
+       }
+       opts = (opts | O_NONBLOCK);
+       if (fcntl(fd,F_SETFL,opts) < 0) {
+                       perror("fcntl(F_SETFL)");
+       }
+       return;
+}
 
-  opts = fcntl (fd, F_GETFL);
-  if (opts < 0)
-    {
-      perror ("fcntl(F_GETFL)");
-    }
-  opts = (opts | O_NONBLOCK);
-  if (fcntl (fd, F_SETFL, opts) < 0)
-    {
-      perror ("fcntl(F_SETFL)");
-    }
-  return;
-}                              /*}}} */
 
-int
-main (int argc, char **argv)
+int 
+main(int argc, char** argv) 
 {
   unsigned char buf[MAX_SIZE];
 

Deleted: gnunet/src/vpn/gnunet-vpn-helper-p.h
===================================================================
--- gnunet/src/vpn/gnunet-vpn-helper-p.h        2011-01-19 08:27:28 UTC (rev 
14205)
+++ gnunet/src/vpn/gnunet-vpn-helper-p.h        2011-01-19 08:30:52 UTC (rev 
14206)
@@ -1,12 +0,0 @@
-#ifndef GN_VPN_HELPER_P_H
-#define GN_VPN_HELPER_P_H
-
-#include "platform.h"
-#include "gnunet_common.h"
-
-struct suid_packet {
-       struct GNUNET_MessageHeader hdr;
-       unsigned char data[1];
-};
-
-#endif

Deleted: gnunet/src/vpn/gnunet-vpn-tun.c
===================================================================
--- gnunet/src/vpn/gnunet-vpn-tun.c     2011-01-19 08:27:28 UTC (rev 14205)
+++ gnunet/src/vpn/gnunet-vpn-tun.c     2011-01-19 08:30:52 UTC (rev 14206)
@@ -1,39 +0,0 @@
-#include "platform.h"
-#include <linux/if_tun.h>
-
-/**
- * Creates a tun-interface called dev;
- * dev is asumed to point to a char[IFNAMSIZ]
- * if *dev == 0, uses the name supplied by the kernel
- * returns the fd to the tun or -1
- */
-int init_tun(char *dev) {{{
-       if (!dev) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       struct ifreq ifr;
-       int fd, err;
-
-       if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
-               fprintf(stderr, "opening /dev/net/tun: %s\n", strerror(errno));
-               return -1;
-       }
-
-       memset(&ifr, 0, sizeof(ifr));
-
-       ifr.ifr_flags = IFF_TUN;
-
-       if (*dev)
-               strncpy(ifr.ifr_name, dev, IFNAMSIZ);
-
-       if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
-               close(fd);
-               fprintf(stderr, "ioctl'ing /dev/net/tun: %s\n", 
strerror(errno));
-               return err;
-       }
-
-       strcpy(dev, ifr.ifr_name);
-       return fd;
-}}}

Deleted: gnunet/src/vpn/gnunet-vpn-tun.h
===================================================================
--- gnunet/src/vpn/gnunet-vpn-tun.h     2011-01-19 08:27:28 UTC (rev 14205)
+++ gnunet/src/vpn/gnunet-vpn-tun.h     2011-01-19 08:30:52 UTC (rev 14206)
@@ -1,11 +0,0 @@
-#ifndef _GNTUN_TUN_H_
-#define _GNTUN_TUN_H_
-
-/**
- * Creates a tun-interface called dev;
- * if *dev == 0, uses the name supplied by the kernel
- * returns the fd to the tun or -1
- */
-int init_tun(char *dev);
-
-#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]