[Olsr-cvs] olsrd-current/src/bsd net.c,1.43,1.44 net.h,1.5,NONE

Bernd Petrovitsch (spam-protected)
Thu Dec 6 22:01:17 CET 2007


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

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.


Index: net.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/net.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** net.c	2 Dec 2007 19:00:28 -0000	1.43
--- net.c	6 Dec 2007 21:01:14 -0000	1.44
***************
*** 40,52 ****
   */
  
! #include "defs.h"
! #include "net_os.h"
! #include "parser.h" /* dnc: needed for call to packet_parser() */
! #include "net.h"
  
  #include <net/if.h>
  
  #ifdef __NetBSD__
- #include <sys/param.h>
  #include <net/if_ether.h>
  #endif
--- 40,62 ----
   */
  
! #include "../defs.h"
! #include "../net_os.h"
! #include "../parser.h" /* dnc: needed for call to packet_parser() */
! #include "../olsr_protocol.h"
  
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <net/if.h>
+ #include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <syslog.h>
+ #include <netinet/in.h>
  #include <net/if.h>
  
  #ifdef __NetBSD__
  #include <net/if_ether.h>
  #endif
***************
*** 306,321 ****
  
  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");
        syslog(LOG_ERR, "socket: %m");
!       return (-1);
      }
  
    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
      {
--- 316,332 ----
  
  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");
        syslog(LOG_ERR, "socket: %m");
!       return -1;
      }
  
+   on = 1;
    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
      {
***************
*** 323,327 ****
        syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
        close(sock);
!       return (-1);
      }
  
--- 334,338 ----
        syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
        close(sock);
!       return -1;
      }
  
***************
*** 330,334 ****
        perror("SO_REUSEADDR failed");
        close(sock);
!       return (-1);
      }
  
--- 341,345 ----
        perror("SO_REUSEADDR failed");
        close(sock);
!       return -1;
      }
  
***************
*** 337,341 ****
        perror("SO_REUSEPORT failed");
        close(sock);
!       return (-1);
      }
  
--- 348,352 ----
        perror("SO_REUSEPORT failed");
        close(sock);
!       return -1;
      }
  
***************
*** 344,354 ****
        perror("IP_RECVIF failed");
        close(sock);
!       return (-1);
      }
  
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
! 		     &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
--- 355,364 ----
        perror("IP_RECVIF failed");
        close(sock);
!       return -1;
      }
  
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
***************
*** 360,374 ****
      }
  
!   if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
      {
        perror("bind");
        syslog(LOG_ERR, "bind: %m");
        close(sock);
!       return (-1);
      }
  
!   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
!     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
! 
    return (sock);
  }
--- 370,393 ----
      }
  
!   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);
  }
***************
*** 376,393 ****
  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);
      }
  
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
! 		     &on, sizeof (on)) == 0)
! 	break;
        if (on <= 8*1024) 
  	{
--- 395,412 ----
  int getsocket6(struct sockaddr_in6 *sin, int bufspace, char *int_name)
  {
!   int on;
!   int sock = socket(AF_INET6, SOCK_DGRAM, 0);
  
!   if (sock < 0) 
      {
        perror("socket");
        syslog(LOG_ERR, "socket: %m");
!       return -1;
      }
  
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
!           break;
        if (on <= 8*1024) 
  	{
***************
*** 402,406 ****
        perror("SO_REUSEADDR failed");
        close(sock);
!       return (-1);
      }
  
--- 421,425 ----
        perror("SO_REUSEADDR failed");
        close(sock);
!       return -1;
      }
  
***************
*** 408,412 ****
      {
        perror("SO_REUSEPORT failed");
!       return (-1);
      }
  
--- 427,432 ----
      {
        perror("SO_REUSEPORT failed");
!       close(sock);
!       return -1;
      }
  
***************
*** 415,426 ****
      {
        perror("IPV6_RECVPKTINFO failed");
!       return (-1);
      }
  #elif defined IPV6_PKTINFO
!     if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on)) < 0)
!       {
! 	perror("IPV6_PKTINFO failed");
! 	return (-1);
!       }
  #endif
  
--- 435,448 ----
      {
        perror("IPV6_RECVPKTINFO failed");
!       close(sock);
!       return -1;
      }
  #elif defined IPV6_PKTINFO
!   if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on)) < 0)
!     {
!       perror("IPV6_PKTINFO failed");
!       close(sock);
!       return -1;
!     }
  #endif
  
***************
*** 430,440 ****
        syslog(LOG_ERR, "bind: %m");
        close(sock);
!       return (-1);
      }
  
!   if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1)
!     syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
! 
!   return (sock);
  }
  
--- 452,467 ----
        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;
  }
  

--- net.h DELETED ---





More information about the Olsr-cvs mailing list