[Olsr-cvs] olsrd-current/src/linux net.c,1.37,1.38 net.h,1.9,NONE

Bernd Petrovitsch (spam-protected)
Thu Dec 6 21:43:17 CET 2007


Update of /cvsroot/olsrd/olsrd-current/src/linux
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8923/src/linux

Modified Files:
	net.c 
Removed Files:
	net.h 
Log Message:
* src/linux/net.h is used by one .c file only. No need for a separate file.
* removed an "extern" declaration which doesn't belong here
* removed superflous #include's


Index: net.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/net.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** net.c	2 Dec 2007 19:00:28 -0000	1.37
--- net.c	6 Dec 2007 20:43:15 -0000	1.38
***************
*** 45,56 ****
   */
  
- #include "net.h"
- #include "../ipcalc.h"
- #include "../defs.h"
  #include "../net_os.h"
! #include "../parser.h"
! #include "../net_olsr.h"
  
  
  /*
   *Wireless definitions for ioctl calls
--- 45,67 ----
   */
  
  #include "../net_os.h"
! #include "../ipcalc.h"
! 
! #include <net/if.h>
! 
! #include <sys/ioctl.h>
! 
! #include <fcntl.h>
! #include <string.h>
! #include <stdio.h>
! #include <syslog.h>
  
  
+ /* Redirect proc entry */
+ #define REDIRECT_PROC "/proc/sys/net/ipv4/conf/%s/send_redirects"
+ 
+ /* IP spoof proc entry */
+ #define SPOOF_PROC "/proc/sys/net/ipv4/conf/%s/rp_filter"
+ 
  /*
   *Wireless definitions for ioctl calls
***************
*** 395,404 ****
   */
  int
! getsocket(struct sockaddr *sa, int bufspace, char *int_name)
  {
!   struct sockaddr_in *sin=(struct sockaddr_in *)sa;
!   int sock, on = 1;
! 
!   if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
      {
        perror("socket");
--- 406,415 ----
   */
  int
! getsocket(int bufspace, char *int_name)
  {
!   struct sockaddr_in sin;
!   int on;
!   int sock = socket(AF_INET, SOCK_DGRAM, 0);
!   if (sock < 0) 
      {
        perror("socket");
***************
*** 407,410 ****
--- 418,422 ----
      }
  
+   on = 1;
  #ifdef SO_BROADCAST
    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
***************
*** 451,468 ****
      }
  
!   if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
!     {
        perror("bind");
        syslog(LOG_ERR, "bind: %m");
        close(sock);
        return -1;
!     }
!   /*
!    *FIXME: One should probably fetch the flags first
!    *using F_GETFL....
!    */
!   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
!     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
    return sock;
  }
--- 463,485 ----
      }
  
!   memset(&sin, 0, sizeof (sin));
!   sin.sin_family = AF_INET;
!   sin.sin_port = htons(OLSRPORT);
!   sin.sin_addr.s_addr = INADDR_ANY;
!   if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
        perror("bind");
        syslog(LOG_ERR, "bind: %m");
        close(sock);
        return -1;
!   }
  
+   on = fcntl(sock, F_GETFL);
+   if (on == -1) {
+       syslog(LOG_ERR, "fcntl (F_GETFL): %m\n");
+   } else {
+       if (fcntl(sock, F_SETFL, on|O_NONBLOCK) == -1) {
+           syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
+       }
+   }
    return sock;
  }
***************
*** 475,494 ****
   */
  int
! getsocket6(struct sockaddr_in6 *sin, int bufspace, char *int_name)
  {
!   int sock, on = 1;
!   if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) 
!     {
!       perror("socket");
!       syslog(LOG_ERR, "socket: %m");
!       return (-1);
!     }
  
  #ifdef IPV6_V6ONLY
!   if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) 
!     {
!       perror("setsockopt(IPV6_V6ONLY)");
!       syslog(LOG_ERR, "setsockopt(IPV6_V6ONLY): %m");
!     }
  #endif
  
--- 492,512 ----
   */
  int
! getsocket6(int bufspace, char *int_name)
  {
!   struct sockaddr_in6 sin;
!   int on;
!   int sock = socket(AF_INET6, SOCK_DGRAM, 0);
!   if (sock < 0) {
!     perror("socket");
!     syslog(LOG_ERR, "socket: %m");
!     return (-1);
!   }
  
  #ifdef IPV6_V6ONLY
!   on = 1;
!   if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
!     perror("setsockopt(IPV6_V6ONLY)");
!     syslog(LOG_ERR, "setsockopt(IPV6_V6ONLY): %m");
!   }
  #endif
  
***************
*** 540,544 ****
      }
  
!   if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
      {
        perror("bind");
--- 558,566 ----
      }
  
!   memset(&sin, 0, sizeof(sin));
!   sin.sin6_family = AF_INET6;
!   sin.sin6_port = htons(OLSRPORT);
!   //(addrsock6.sin6_addr).s_addr = IN6ADDR_ANY_INIT;
!   if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) 
      {
        perror("bind");
***************
*** 547,557 ****
        return (-1);
      }
-   /*
-    *One should probably fetch the flags first
-    *using F_GETFL....
-    */
-   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
-     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
    return sock;
  }
--- 569,581 ----
        return (-1);
      }
  
+   on = fcntl(sock, F_GETFL);
+   if (on == -1) {
+       syslog(LOG_ERR, "fcntl (F_GETFL): %m\n");
+   } else {
+       if (fcntl(sock, F_SETFL, on|O_NONBLOCK) == -1) {
+           syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
+       }
+   }
    return sock;
  }

--- net.h DELETED ---





More information about the Olsr-cvs mailing list