[Olsr-cvs] olsrd-current/src/linux apm.c, 1.16, 1.17 kernel_routes.c, 1.20, 1.21 net.c, 1.32, 1.33

Bernd Petrovitsch (spam-protected)
Fri Apr 20 15:46:07 CEST 2007


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

Modified Files:
	apm.c kernel_routes.c net.c 
Log Message:
cleanup, 1. step (to get some local changes away):
* killed lots of warnings
* added __attribure__((unused)) and __attribure__((format(printf, ..., ...)))
* added "const"
* moved declarations of static functions into .c files
* added "static" declarations
* removed all "inline" declarations. Usually the compiler knows better anyways.
* removed emtpy "return" statements at the end of functions
* localized declarations
* avoided unnecessary data copies
* removed lots of empty lines
There is much more to do.



Index: apm.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/apm.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** apm.c	26 Nov 2006 00:32:14 -0000	1.16
--- apm.c	20 Apr 2007 13:46:05 -0000	1.17
***************
*** 136,140 ****
      method = USE_APM;
    
!   if(method)
      apm_printinfo(&ainfo);
  
--- 136,140 ----
      method = USE_APM;
    
!   if(method != -1)
      apm_printinfo(&ainfo);
  
***************
*** 142,145 ****
--- 142,146 ----
  }
  
+ 
  void
  apm_printinfo(struct olsr_apm_info *ainfo)
***************
*** 149,182 ****
  	      ainfo->battery_percentage,
  	      ainfo->battery_time_left)
- 
-   return;
  }
  
  
- 
  int
  apm_read(struct olsr_apm_info *ainfo)
  {
- 
    switch(method)
      {
      case(USE_APM):
        return apm_read_apm(ainfo);
-       break;
      case(USE_ACPI):
        return apm_read_acpi(ainfo);
-       break;
      default:
-       return 0;
        break;
      }
! 
!   return 1;
  }
  
  
- 
- 
- 
  static int
  apm_read_apm(struct olsr_apm_info *ainfo)
--- 150,172 ----
  	      ainfo->battery_percentage,
  	      ainfo->battery_time_left)
  }
  
  
  int
  apm_read(struct olsr_apm_info *ainfo)
  {
    switch(method)
      {
      case(USE_APM):
        return apm_read_apm(ainfo);
      case(USE_ACPI):
        return apm_read_acpi(ainfo);
      default:
        break;
      }
!   return 0;
  }
  
  
  static int
  apm_read_apm(struct olsr_apm_info *ainfo)
***************
*** 191,195 ****
      return 0;
  
!   if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
      {
        fclose(apm_procfile);
--- 181,185 ----
      return 0;
  
!   if(fgets(buffer, sizeof(buffer), apm_procfile) == NULL)
      {
        fclose(apm_procfile);
***************
*** 198,202 ****
  	return 0;
  
!       if(fgets(buffer, sizeof(buffer) - 1, apm_procfile) == NULL)
  	{
  	  /* Giving up */
--- 188,192 ----
  	return 0;
  
!       if(fgets(buffer, sizeof(buffer), apm_procfile) == NULL)
  	{
  	  /* Giving up */
***************
*** 206,211 ****
  	}
      }
  
-   buffer[sizeof(buffer) - 1] = '\0';
  
    //printf("READ: %s\n", buffer);
--- 196,201 ----
  	}
      }
+   fclose(apm_procfile);
  
  
    //printf("READ: %s\n", buffer);
***************
*** 246,261 ****
    ainfo->battery_time_left = lainfo.battery_time;
    
-   fclose(apm_procfile);
- 
    return 1;
  }
  
  
- 
  static int
  apm_read_acpi(struct olsr_apm_info *ainfo)
  {
    FILE *fd;
-   char s1[32], s2[32], s3[32], s4[32], inbuff[127];
    int bat_max = 5000; /* Find some sane value */
    int bat_val = 0;
--- 236,247 ----
***************
*** 272,291 ****
      }
  
- 
    /* Get maxvalue */
    if((fd = fopen(acpi_info[fd_index], "r")) == NULL) 
      return 0;
! 
!   fgets(inbuff, 127, fd);
!   while(!feof(fd)) 
      {
!       sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);
! 	
        if (!strcasecmp(s2, "full")) 
- 	{
  	  bat_max = atoi(s4);
- 	}
- 
-       fgets(inbuff, 127, fd);
      }
    fclose(fd);
--- 258,274 ----
      }
  
    /* Get maxvalue */
    if((fd = fopen(acpi_info[fd_index], "r")) == NULL) 
      return 0;
!   
!   for(;;) 
      {
!       char s1[32], s2[32], s3[32], s4[32], inbuff[127];
!       if (fgets(inbuff, sizeof(inbuff), fd) == NULL)
!         break;
! 
!       sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);	
        if (!strcasecmp(s2, "full")) 
  	  bat_max = atoi(s4);
      }
    fclose(fd);
***************
*** 296,316 ****
  
    /* Extract battery status */
!   fgets(inbuff, 127, fd);
!   while(!feof(fd)) 
      {
        sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);
  
        /* find remaining juice */
        if(!strcasecmp(s1, "Remaining")) 
- 	{
  	  bat_val = atoi(s3);
- 	}
- 
-       fgets(inbuff, 127, fd);
      }
- 
    fclose(fd);
  
- 
    ainfo->ac_line_status = OLSR_BATTERY_POWERED;
    ainfo->battery_percentage = bat_val * 100 / bat_max;
--- 279,295 ----
  
    /* Extract battery status */
!   for(;;)
      {
+       char s1[32], s2[32], s3[32], s4[32], inbuff[127];
+       if (fgets(inbuff, sizeof(inbuff), fd) == NULL)
+         break;
        sscanf(inbuff, "%s %s %s %s", s1, s2, s3, s4);
  
        /* find remaining juice */
        if(!strcasecmp(s1, "Remaining")) 
  	  bat_val = atoi(s3);
      }
    fclose(fd);
  
    ainfo->ac_line_status = OLSR_BATTERY_POWERED;
    ainfo->battery_percentage = bat_val * 100 / bat_max;
***************
*** 320,374 ****
  
  
- 
  static int
  acpi_probe(void)
  {
!   char s1[32], s2[32];
!   FILE *fd;
!   olsr_u16_t i;
    
- 
    /* First check for AC power */
  
    for(i = 0; i < ACPI_AC_CNT; i++)
      {
        /* Try opening the info file */
!       if((fd = fopen(acpi_ac[i], "r")) == NULL)
  	continue;
        
        /* Extract info */
!       if(fscanf(fd, "%s %s", s1, s2) < 2)
! 	{
! 	  fclose(fd);
! 	  continue;
! 	}
!       
        /* Close info entry */
        fclose(fd);
  
        /* Running on AC power */
        if(!strcasecmp(s2, "on-line"))
  	return -1;
- 
      }
  
!   /* Only checking the first found batery entry... */
    for(i = 0; i < ACPI_BT_CNT; i ++)
      {
! 
        /* Try opening the info file */
!       if((fd = fopen(acpi_info[i], "r")) == NULL)
  	continue;
  
        /* Extract info */
!       if(fscanf(fd, "%s %s", s1, s2) < 2)
! 	{
! 	  fclose(fd);
! 	  continue;
! 	}
! 
        /* Close info entry */
        fclose(fd);
  
        /* Check if battery is present */
        if((!strcasecmp(s1, "present:")) && (!strcasecmp(s2, "no"))) 
--- 299,352 ----
  
  
  static int
  acpi_probe(void)
  {
!   unsigned int i;
    
    /* First check for AC power */
  
    for(i = 0; i < ACPI_AC_CNT; i++)
      {
+       char s1[32], s2[32];
+       int rc;
+       FILE *fd = fopen(acpi_ac[i], "r");
+   
        /* Try opening the info file */
!       if(fd == NULL)
  	continue;
        
        /* Extract info */
!       rc = fscanf(fd, "%s %s", s1, s2);
! 
        /* Close info entry */
        fclose(fd);
  
+       if(rc < 2)
+ 	  continue;
+       
        /* Running on AC power */
        if(!strcasecmp(s2, "on-line"))
  	return -1;
      }
  
!   /* Only checking the first found battery entry... */
    for(i = 0; i < ACPI_BT_CNT; i ++)
      {
!       char s1[32], s2[32];
!       int rc;
!       FILE *fd = fopen(acpi_info[i], "r");
!   
        /* Try opening the info file */
!       if(fd == NULL)
  	continue;
  
        /* Extract info */
!       rc = fscanf(fd, "%s %s", s1, s2);
        /* Close info entry */
        fclose(fd);
  
+       if(rc < 2)
+ 	  continue;
+ 
        /* Check if battery is present */
        if((!strcasecmp(s1, "present:")) && (!strcasecmp(s2, "no"))) 
***************
*** 380,384 ****
  
        fclose(fd);
- 
        return i;
      }
--- 358,361 ----
***************
*** 387,389 ****
    return -1;
  }
- 
--- 364,365 ----

Index: net.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/net.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** net.c	4 Feb 2007 23:36:35 -0000	1.32
--- net.c	20 Apr 2007 13:46:05 -0000	1.33
***************
*** 79,83 ****
    OLSR_PRINTF(3, "Binding socket %d to device %s\n", sock, dev_name)
    return setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, dev_name, strlen(dev_name)+1);
- 
  }
  
--- 79,82 ----
***************
*** 99,116 ****
  {
    FILE *proc_fwd;
!   char procfile[FILENAME_MAX];
! 
!   if(version == AF_INET)
!     {
!       strncpy(procfile, "/proc/sys/net/ipv4/ip_forward", FILENAME_MAX);
!     }
!   else
!     if(version == AF_INET6)
!       {
! 	strncpy(procfile, "/proc/sys/net/ipv6/conf/all/forwarding", FILENAME_MAX);
!       }
!     else
!       return -1;
! 
  
    if ((proc_fwd=fopen(procfile, "r"))==NULL)
--- 98,104 ----
  {
    FILE *proc_fwd;
!   const char * const procfile = version == AF_INET
!       ? "/proc/sys/net/ipv4/ip_forward"
!       : "/proc/sys/net/ipv6/conf/all/forwarding";
  
    if ((proc_fwd=fopen(procfile, "r"))==NULL)
***************
*** 127,172 ****
      }
    
    else
      {
!       orig_fwd_state = fgetc(proc_fwd);
!       fclose(proc_fwd);
!       if(orig_fwd_state == '1')
! 	{
! 	  OLSR_PRINTF(3, "\nIP forwarding is enabled on this system\n")
! 	}
        else
! 	{
! 	  if ((proc_fwd=fopen(procfile, "w"))==NULL)
! 	    {
! 	      fprintf(stderr, "Could not open %s for writing!\n", procfile);
! 	      fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that IP forwarding is enabeled!\n\n");
! 	      sleep(3);
! 	      return 0;
! 	    }
! 	  else
! 	    {
! 	      syslog(LOG_INFO, "Writing \"1\" to %s\n", procfile);
! 	      fputs("1", proc_fwd);
! 	    }
! 	  fclose(proc_fwd);
! 
! 	}
      }
!   return 1;
!       
  }
  
- 
  int
  disable_redirects_global(int version)
  {
    FILE *proc_redirect;
!   char procfile[FILENAME_MAX];
  
    if(version == AF_INET6)
      return -1;
  
-   strcpy(procfile, "/proc/sys/net/ipv4/conf/all/send_redirects");
- 
    if((proc_redirect = fopen(procfile, "r")) == NULL)
      {
--- 115,152 ----
      }
    
+   orig_fwd_state = fgetc(proc_fwd);
+   fclose(proc_fwd);
+   if(orig_fwd_state == '1')
+     {
+       OLSR_PRINTF(3, "\nIP forwarding is enabled on this system\n")
+     }
    else
      {
!       if ((proc_fwd=fopen(procfile, "w"))==NULL)
!         {
!           fprintf(stderr, "Could not open %s for writing!\n", procfile);
!           fprintf(stderr, "I will continue(in 3 sec) - but you should mannually ensure that IP forwarding is enabeled!\n\n");
!           sleep(3);
!           return 0;
!         }
        else
!         {
!           syslog(LOG_INFO, "Writing \"1\" to %s\n", procfile);
!           fputs("1", proc_fwd);
!         }
!       fclose(proc_fwd);
      }
!   return 1;      
  }
  
  int
  disable_redirects_global(int version)
  {
    FILE *proc_redirect;
!   const char * const procfile = "/proc/sys/net/ipv4/conf/all/send_redirects";
  
    if(version == AF_INET6)
      return -1;
  
    if((proc_redirect = fopen(procfile, "r")) == NULL)
      {
***************
*** 176,189 ****
        return -1;
      }
!   else
!     {
!       orig_global_redirect_state = fgetc(proc_redirect);
!       fclose(proc_redirect);
!     }
  
    if(orig_global_redirect_state == '0')
-     {
        return 0;
-     }
  
    if ((proc_redirect = fopen(procfile, "w"))==NULL)
--- 156,164 ----
        return -1;
      }
!   orig_global_redirect_state = fgetc(proc_redirect);
!   fclose(proc_redirect);
  
    if(orig_global_redirect_state == '0')
        return 0;
  
    if ((proc_redirect = fopen(procfile, "w"))==NULL)
***************
*** 194,208 ****
        return 0;
      }
!   else
!     {
!       syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!       fputs("0", proc_redirect);
!     }
!   fclose(proc_redirect);
!   
    return 1;
  }
  
- 
  /**
   *
--- 169,178 ----
        return 0;
      }
!   syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!   fputs("0", proc_redirect);
!   fclose(proc_redirect);  
    return 1;
  }
  
  /**
   *
***************
*** 219,238 ****
  
    /* Generate the procfile name */
!   sprintf(procfile, REDIRECT_PROC, if_name);
  
  
    if((proc_redirect = fopen(procfile, "r")) == NULL)
      {
!       fprintf(stderr, "WARNING! Could not open the %s file to check/disable ICMP redirects!\nAre you using the procfile filesystem?\nDoes your system support IPv4?\nI will continue(in 3 sec) - but you should mannually ensure that ICMP redirects are disabled!\n\n", procfile);
!       
        sleep(3);
        return 0;
      }
!   else
!     {
!       iface->nic_state.redirect = fgetc(proc_redirect);
!       fclose(proc_redirect);
!       
!     }
  
    if ((proc_redirect = fopen(procfile, "w"))==NULL)
--- 189,203 ----
  
    /* Generate the procfile name */
!   snprintf(procfile, sizeof(procfile), REDIRECT_PROC, if_name);
  
  
    if((proc_redirect = fopen(procfile, "r")) == NULL)
      {
!       fprintf(stderr, "WARNING! Could not open the %s file to check/disable ICMP redirects!\nAre you using the procfile filesystem?\nDoes your system support IPv4?\nI will continue(in 3 sec) - but you should mannually ensure that ICMP redirects are disabled!\n\n", procfile);      
        sleep(3);
        return 0;
      }
!   iface->nic_state.redirect = fgetc(proc_redirect);
!   fclose(proc_redirect);      
  
    if ((proc_redirect = fopen(procfile, "w"))==NULL)
***************
*** 243,258 ****
        return 0;
      }
!   else
!     {
!       syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!       fputs("0", proc_redirect);
!     }
    fclose(proc_redirect);
- 
    return 1;
  }
  
- 
- 
  /**
   *
--- 208,217 ----
        return 0;
      }
!   syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!   fputs("0", proc_redirect);
    fclose(proc_redirect);
    return 1;
  }
  
  /**
   *
***************
*** 268,276 ****
      return -1;
  
- 
    /* Generate the procfile name */
    sprintf(procfile, SPOOF_PROC, if_name);
  
- 
    if((proc_spoof = fopen(procfile, "r")) == NULL)
      {
--- 227,233 ----
***************
*** 280,289 ****
        return 0;
      }
!   else
!     {
!       iface->nic_state.spoof = fgetc(proc_spoof);
!       fclose(proc_spoof);
!       
!     }
  
    if ((proc_spoof = fopen(procfile, "w")) == NULL)
--- 237,242 ----
        return 0;
      }
!   iface->nic_state.spoof = fgetc(proc_spoof);
!   fclose(proc_spoof);
  
    if ((proc_spoof = fopen(procfile, "w")) == NULL)
***************
*** 294,318 ****
        return 0;
      }
!   else
!     {
!       syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!       fputs("0", proc_spoof);
!     }
    fclose(proc_spoof);
- 
    return 1;
  }
  
- 
- 
  /**
   *Resets the spoof filter and ICMP redirect settings
   */
- 
  int
  restore_settings(int version)
  {
-   FILE *proc_fd;
-   char procfile[FILENAME_MAX];
    struct interface *ifs;
  
--- 247,262 ----
        return 0;
      }
!   syslog(LOG_INFO, "Writing \"0\" to %s", procfile);
!   fputs("0", proc_spoof);
    fclose(proc_spoof);
    return 1;
  }
  
  /**
   *Resets the spoof filter and ICMP redirect settings
   */
  int
  restore_settings(int version)
  {
    struct interface *ifs;
  
***************
*** 322,333 ****
    if(orig_fwd_state == '0')
      {
!       if(version == AF_INET)
! 	{
! 	  strcpy(procfile, "/proc/sys/net/ipv4/ip_forward");
! 	}
!       else if(version == AF_INET6)
! 	{
! 	  strcpy(procfile, "/proc/sys/net/ipv6/conf/all/forwarding");
! 	}
  
        if ((proc_fd = fopen(procfile, "w")) == NULL)
--- 266,273 ----
    if(orig_fwd_state == '0')
      {
!       const char * const procfile = version == AF_INET
!         ? "/proc/sys/net/ipv4/ip_forward"
!         : "/proc/sys/net/ipv6/conf/all/forwarding";
!       FILE *proc_fd;
  
        if ((proc_fd = fopen(procfile, "w")) == NULL)
***************
*** 341,345 ****
  	  fclose(proc_fd);
  	}
- 
      }
  
--- 281,284 ----
***************
*** 349,353 ****
        if(version == AF_INET)
  	{
! 	  strcpy(procfile, "/proc/sys/net/ipv4/conf/all/send_redirects");
  
  	  if ((proc_fd = fopen(procfile, "w")) == NULL)
--- 288,293 ----
        if(version == AF_INET)
  	{
! 	  const char * const procfile = "/proc/sys/net/ipv4/conf/all/send_redirects";
!           FILE *proc_fd;
  
  	  if ((proc_fd = fopen(procfile, "w")) == NULL)
***************
*** 364,368 ****
      }
  
- 
    if(version == AF_INET6)
      return 0;
--- 304,307 ----
***************
*** 370,373 ****
--- 309,314 ----
    for(ifs = ifnet; ifs != NULL; ifs = ifs->int_next)
      {
+       char procfile[FILENAME_MAX];
+       FILE *proc_fd;
        /* Discard host-emulation interfaces */
        if(ifs->is_hcif)
***************
*** 376,385 ****
        
        /* Generate the procfile name */
!       sprintf(procfile, REDIRECT_PROC, ifs->int_name);
        
        if ((proc_fd = fopen(procfile, "w")) == NULL)
- 	{
  	  fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
- 	}
        else
  	{
--- 317,324 ----
        
        /* Generate the procfile name */
!       snprintf(procfile, sizeof(procfile), REDIRECT_PROC, ifs->int_name);
        
        if ((proc_fd = fopen(procfile, "w")) == NULL)
  	  fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
        else
  	{
***************
*** 389,393 ****
  	  fclose(proc_fd);
  	}
- 
        
        /* Spoof filter */
--- 328,331 ----
***************
*** 395,403 ****
        /* Generate the procfile name */
        sprintf(procfile, SPOOF_PROC, ifs->int_name);
- 
        if ((proc_fd = fopen(procfile, "w")) == NULL)
- 	{
  	  fprintf(stderr, "Could not open %s for writing!\nSettings not restored!\n", procfile);
- 	}
        else
  	{
--- 333,338 ----
***************
*** 407,417 ****
  	  fclose(proc_fd);
  	}
- 
      }
    return 1;
- 
  }
  
- 
  /**
   *Creates a nonblocking broadcast socket.
--- 342,349 ----
***************
*** 425,435 ****
  
    OLSR_PRINTF(1, "       Connecting to switch daemon port 10150...");
- 
- 
    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) 
      {
        perror("hcsocket");
        syslog(LOG_ERR, "hcsocket: %m");
!       return (-1);
      }
  
--- 357,365 ----
  
    OLSR_PRINTF(1, "       Connecting to switch daemon port 10150...");
    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) 
      {
        perror("hcsocket");
        syslog(LOG_ERR, "hcsocket: %m");
!       return -1;
      }
  
***************
*** 438,442 ****
        perror("SO_REUSEADDR failed");
        close(sock);
!       return (-1);
      }
    /* connect to PORT on HOST */
--- 368,372 ----
        perror("SO_REUSEADDR failed");
        close(sock);
!       return -1;
      }
    /* connect to PORT on HOST */
***************
*** 447,451 ****
        printf("connection refused\n");
        close(sock);
!       return (-1);
      }
  
--- 377,381 ----
        printf("connection refused\n");
        close(sock);
!       return -1;
      }
  
***************
*** 453,457 ****
  
    /* Keep TCP socket blocking */  
!   return (sock);
  }
  
--- 383,387 ----
  
    /* Keep TCP socket blocking */  
!   return sock;
  }
  
***************
*** 468,482 ****
    int sock, on = 1;
  
- 
- 
    if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
      {
        perror("socket");
        syslog(LOG_ERR, "socket: %m");
!       return (-1);
      }
  
- 
- 
  #ifdef SO_BROADCAST
    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
--- 398,408 ----
    int sock, on = 1;
  
    if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 
      {
        perror("socket");
        syslog(LOG_ERR, "socket: %m");
!       return -1;
      }
  
  #ifdef SO_BROADCAST
    if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
***************
*** 485,489 ****
        syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
        close(sock);
!       return (-1);
      }
  #endif
--- 411,415 ----
        syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
        close(sock);
!       return -1;
      }
  #endif
***************
*** 493,507 ****
        perror("SO_REUSEADDR failed");
        close(sock);
!       return (-1);
      }
  
- 
- 
  #ifdef SO_RCVBUF
- 
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
! 		     &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
--- 419,429 ----
        perror("SO_REUSEADDR failed");
        close(sock);
!       return -1;
      }
  
  #ifdef SO_RCVBUF
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
***************
*** 512,520 ****
  	}
      }
- 
- 
  #endif
  
- 
    /*
     * WHEN USING KERNEL 2.6 THIS MUST HAPPEN PRIOR TO THE PORT BINDING!!!!
--- 434,439 ----
***************
*** 530,534 ****
      }
  
- 
    if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
      {
--- 449,452 ----
***************
*** 536,544 ****
        syslog(LOG_ERR, "bind: %m");
        close(sock);
!       return (-1);
      }
- 
    /*
!    *One should probably fetch the flags first
     *using F_GETFL....
     */
--- 454,461 ----
        syslog(LOG_ERR, "bind: %m");
        close(sock);
!       return -1;
      }
    /*
!    *FIXME: One should probably fetch the flags first
     *using F_GETFL....
     */
***************
*** 546,550 ****
      syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
!   return (sock);
  }
  
--- 463,467 ----
      syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
!   return sock;
  }
  
***************
*** 559,565 ****
  {
    int sock, on = 1;
- 
- 
- 
    if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) 
      {
--- 476,479 ----
***************
*** 590,601 ****
    //#endif
  
- 
- 
- 
  #ifdef SO_RCVBUF
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
! 		     &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
--- 504,511 ----
    //#endif
  
  #ifdef SO_RCVBUF
    for (on = bufspace; ; on -= 1024) 
      {
!       if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &on, sizeof (on)) == 0)
  	break;
        if (on <= 8*1024) 
***************
*** 606,611 ****
  	}
      }
- 
- 
  #endif
  
--- 516,519 ----
***************
*** 617,621 ****
      }
  
- 
    /*
     * WHEN USING KERNEL 2.6 THIS MUST HAPPEN PRIOR TO THE PORT BINDING!!!!
--- 525,528 ----
***************
*** 631,635 ****
      }
  
- 
    if (bind(sock, (struct sockaddr *)sin, sizeof (*sin)) < 0) 
      {
--- 538,541 ----
***************
*** 639,643 ****
        return (-1);
      }
- 
    /*
     *One should probably fetch the flags first
--- 545,548 ----
***************
*** 647,656 ****
      syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
! 
! 
!   return (sock);
  }
  
- 
  int
  join_mcast(struct interface *ifs, int sock)
--- 552,558 ----
      syslog(LOG_ERR, "fcntl O_NONBLOCK: %m\n");
  
!   return sock;
  }
  
  int
  join_mcast(struct interface *ifs, int sock)
***************
*** 701,707 ****
        perror("Join multicast send");
        return -1;
!     }
  
-   
    if(setsockopt(sock, 
  		IPPROTO_IPV6, 
--- 603,608 ----
        perror("Join multicast send");
        return -1;
!     }  
  
    if(setsockopt(sock, 
  		IPPROTO_IPV6, 
***************
*** 720,730 ****
  }
  
- 
- 
  /*
   *From net-tools lib/interface.c
   *
   */
- 
  int
  get_ipv6_address(char *ifname, struct sockaddr_in6 *saddr6, int scope_in)
--- 621,628 ----
***************
*** 763,768 ****
  	}
        fclose(f);
!     }
!   
    return 0;
  }
--- 661,665 ----
  	}
        fclose(f);
!     }  
    return 0;
  }
***************
*** 772,776 ****
   * Wrapper for sendto(2)
   */
- 
  ssize_t
  olsr_sendto(int s, 
--- 669,672 ----
***************
*** 823,827 ****
  
  int
! check_wireless_interface(char *ifname)
  {
    struct ifreq ifr;
--- 719,723 ----
  
  int
! check_wireless_interface(char * ifname)
  {
    struct ifreq ifr;

Index: kernel_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/kernel_routes.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** kernel_routes.c	31 Jan 2007 12:36:50 -0000	1.20
--- kernel_routes.c	20 Apr 2007 13:46:05 -0000	1.21
***************
*** 347,354 ****
  
  int
! delete_all_inet_gws()
! {
!   struct rtentry kernel_route;
!   
    int s;
    char buf[BUFSIZ], *cp, *cplim;
--- 347,352 ----
  
  int
! delete_all_inet_gws(void)
! {  
    int s;
    char buf[BUFSIZ], *cp, *cplim;
***************
*** 376,383 ****
  
    ifr = ifc.ifc_req;
- #define size(p) (sizeof (p))
    cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
!   for (cp = buf; cp < cplim;cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) 
      {
        ifr = (struct ifreq *)cp;
        
--- 374,381 ----
  
    ifr = ifc.ifc_req;
    cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
!   for (cp = buf; cp < cplim;cp += sizeof (ifr->ifr_name) + sizeof(ifr->ifr_addr)) 
      {
+       struct rtentry kernel_route;
        ifr = (struct ifreq *)cp;
        





More information about the Olsr-cvs mailing list