[Olsr-cvs] olsrd-current/src/unix ifnet.c,1.47,1.48

Bernd Petrovitsch (spam-protected)
Thu Apr 26 00:08:20 CEST 2007


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

Modified Files:
	ifnet.c 
Log Message:
* OLSR_PRINTF() is now a real C expression
* removed superflous type-casts


Index: ifnet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/unix/ifnet.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** ifnet.c	20 Apr 2007 13:46:05 -0000	1.47
--- ifnet.c	25 Apr 2007 22:08:18 -0000	1.48
***************
*** 114,118 ****
  
  #ifdef DEBUG
!   OLSR_PRINTF(3, "Checking for updates in the interface set\n")
  #endif
  
--- 114,118 ----
  
  #ifdef DEBUG
!   OLSR_PRINTF(3, "Checking for updates in the interface set\n");
  #endif
  
***************
*** 164,168 ****
  
  #ifdef DEBUG
!   OLSR_PRINTF(3, "Checking if %s is set down or changed\n", iface->name)
  #endif
  
--- 164,168 ----
  
  #ifdef DEBUG
!   OLSR_PRINTF(3, "Checking if %s is set down or changed\n", iface->name);
  #endif
  
***************
*** 186,190 ****
    if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
      {
!       OLSR_PRINTF(3, "No such interface: %s\n", iface->name)
        goto remove_interface;
      }
--- 186,190 ----
    if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
      {
!       OLSR_PRINTF(3, "No such interface: %s\n", iface->name);
        goto remove_interface;
      }
***************
*** 198,202 ****
    if ((ifp->int_flags & IFF_UP) == 0)
      {
!       OLSR_PRINTF(1, "\tInterface %s not up - removing it...\n", iface->name)
        goto remove_interface;
      }
--- 198,202 ----
    if ((ifp->int_flags & IFF_UP) == 0)
      {
!       OLSR_PRINTF(1, "\tInterface %s not up - removing it...\n", iface->name);
        goto remove_interface;
      }
***************
*** 213,217 ****
        (!(ifp->int_flags & IFF_BROADCAST))) 
      {
!       OLSR_PRINTF(3, "\tNo broadcast - removing\n")
        goto remove_interface;
      }
--- 213,217 ----
        (!(ifp->int_flags & IFF_BROADCAST))) 
      {
!       OLSR_PRINTF(3, "\tNo broadcast - removing\n");
        goto remove_interface;
      }
***************
*** 219,223 ****
    if (ifp->int_flags & IFF_LOOPBACK)
      {
!       OLSR_PRINTF(3, "\tThis is a loopback interface - removing it...\n")
        goto remove_interface;
      }
--- 219,223 ----
    if (ifp->int_flags & IFF_LOOPBACK)
      {
!       OLSR_PRINTF(3, "\tThis is a loopback interface - removing it...\n");
        goto remove_interface;
      }
***************
*** 266,272 ****
  	{
  	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
! 	    OLSR_PRINTF(3, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name)
  	  else
! 	    OLSR_PRINTF(3, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name)
  	  
  	  
--- 266,272 ----
  	{
  	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
! 	    OLSR_PRINTF(3, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name);
  	  else
! 	    OLSR_PRINTF(3, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name);
  	  
  	  
***************
*** 275,286 ****
        
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tAddress: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr))
  #endif
  
        if(memcmp(&tmp_saddr6.sin6_addr, &ifp->int6_addr.sin6_addr, olsr_cnf->ipsize) != 0)
  	{
! 	  OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name)
! 	  OLSR_PRINTF(1, "\tOld: %s\n", ip6_to_string(&ifp->int6_addr.sin6_addr))
! 	  OLSR_PRINTF(1, "\tNew: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr))
  
  	  /* Check main addr */
--- 275,286 ----
        
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tAddress: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr));
  #endif
  
        if(memcmp(&tmp_saddr6.sin6_addr, &ifp->int6_addr.sin6_addr, olsr_cnf->ipsize) != 0)
  	{
! 	  OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name);
! 	  OLSR_PRINTF(1, "\tOld: %s\n", ip6_to_string(&ifp->int6_addr.sin6_addr));
! 	  OLSR_PRINTF(1, "\tNew: %s\n", ip6_to_string(&tmp_saddr6.sin6_addr));
  
  	  /* Check main addr */
***************
*** 308,317 ****
        if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) 
  	{
! 	  OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n")
  	  goto remove_interface;
  	}
  
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr_to_string(&ifr.ifr_addr))
  #endif
  
--- 308,317 ----
        if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) 
  	{
! 	  OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n");
  	  goto remove_interface;
  	}
  
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr_to_string(&ifr.ifr_addr));
  #endif
  
***************
*** 321,327 ****
  	{
  	  /* New address */
! 	  OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name)
! 	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_addr))
! 	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr))
  
  	  ifp->int_addr = ifr.ifr_addr;
--- 321,327 ----
  	{
  	  /* New address */
! 	  OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name);
! 	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_addr));
! 	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr));
  
  	  ifp->int_addr = ifr.ifr_addr;
***************
*** 331,335 ****
  		    olsr_cnf->ipsize) == 0)
  	    {
! 	      OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
  	      olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
  	      memcpy(&olsr_cnf->main_addr, 
--- 331,335 ----
  		    olsr_cnf->ipsize) == 0)
  	    {
! 	      OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
  	      olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
  	      memcpy(&olsr_cnf->main_addr, 
***************
*** 353,357 ****
  
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr_to_string(&ifr.ifr_netmask))
  #endif
  
--- 353,357 ----
  
  #ifdef DEBUG
!       OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr_to_string(&ifr.ifr_netmask));
  #endif
  
***************
*** 361,367 ****
  	{
  	  /* New address */
! 	  OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name)
! 	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_netmask))
! 	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_netmask))
  
  	  ifp->int_netmask = ifr.ifr_netmask;
--- 361,367 ----
  	{
  	  /* New address */
! 	  OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name);
! 	  OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_netmask));
! 	  OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_netmask));
  
  	  ifp->int_netmask = ifr.ifr_netmask;
***************
*** 380,384 ****
  	  
  #ifdef DEBUG
! 	  OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr))
  #endif
  	  
--- 380,384 ----
  	  
  #ifdef DEBUG
! 	  OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr));
  #endif
  	  
***************
*** 389,395 ****
  	      
  	      /* New address */
! 	      OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name)
! 	      OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_broadaddr))
! 	      OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr))
  	      
  	      ifp->int_broadaddr = ifr.ifr_broadaddr;
--- 389,395 ----
  	      
  	      /* New address */
! 	      OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name);
! 	      OLSR_PRINTF(1, "\tOld:%s\n", sockaddr_to_string(&ifp->int_broadaddr));
! 	      OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_broadaddr));
  	      
  	      ifp->int_broadaddr = ifr.ifr_broadaddr;
***************
*** 406,410 ****
  
   remove_interface:
!   OLSR_PRINTF(1, "Removing interface %s\n", iface->name)
    olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name);
  
--- 406,410 ----
  
   remove_interface:
!   OLSR_PRINTF(1, "Removing interface %s\n", iface->name);
    olsr_syslog(OLSR_LOG_INFO, "Removing interface %s\n", iface->name);
  
***************
*** 442,451 ****
  	  /* No more interfaces */
  	  memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
! 	  OLSR_PRINTF(1, "No more interfaces...\n")
  	}
        else
  	{
  	  COPY_IP(&olsr_cnf->main_addr, &ifnet->ip_addr);
! 	  OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
  	  olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
  	}
--- 442,451 ----
  	  /* No more interfaces */
  	  memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
! 	  OLSR_PRINTF(1, "No more interfaces...\n");
  	}
        else
  	{
  	  COPY_IP(&olsr_cnf->main_addr, &ifnet->ip_addr);
! 	  OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
  	  olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
  	}
***************
*** 510,514 ****
    if((ifnet == NULL) && (!olsr_cnf->allow_no_interfaces))
      {
!       OLSR_PRINTF(1, "No more active interfaces - exiting.\n")
        olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
        olsr_cnf->exit_value = EXIT_FAILURE;
--- 510,514 ----
    if((ifnet == NULL) && (!olsr_cnf->allow_no_interfaces))
      {
!       OLSR_PRINTF(1, "No more active interfaces - exiting.\n");
        olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
        olsr_cnf->exit_value = EXIT_FAILURE;
***************
*** 547,551 ****
    strcpy(ifp->int_name, "hcif01");
  
!   OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name)
  
    OLSR_PRINTF(1, "       Address:%s\n", olsr_ip_to_string(&iface->hemu_ip));
--- 547,551 ----
    strcpy(ifp->int_name, "hcif01");
  
!   OLSR_PRINTF(1, "Adding %s(host emulation):\n", ifp->int_name);
  
    OLSR_PRINTF(1, "       Address:%s\n", olsr_ip_to_string(&iface->hemu_ip));
***************
*** 562,566 ****
      {
        COPY_IP(&olsr_cnf->main_addr, &iface->hemu_ip);
!       OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
  	olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
      }
--- 562,566 ----
      {
        COPY_IP(&olsr_cnf->main_addr, &iface->hemu_ip);
!       OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
  	olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
      }
***************
*** 746,755 ****
    strncpy(ifr.ifr_name, iface->name, IFNAMSIZ);
  
!   OLSR_PRINTF(debuglvl, "Checking %s:\n", ifr.ifr_name)
  
    /* Get flags (and check if interface exists) */
    if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
      {
!       OLSR_PRINTF(debuglvl, "\tNo such interface!\n")
        return 0;
      }
--- 746,755 ----
    strncpy(ifr.ifr_name, iface->name, IFNAMSIZ);
  
!   OLSR_PRINTF(debuglvl, "Checking %s:\n", ifr.ifr_name);
  
    /* Get flags (and check if interface exists) */
    if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0) 
      {
!       OLSR_PRINTF(debuglvl, "\tNo such interface!\n");
        return 0;
      }
***************
*** 761,765 ****
    if ((ifs.int_flags & IFF_UP) == 0)
      {
!       OLSR_PRINTF(debuglvl, "\tInterface not up - skipping it...\n")
        return 0;
      }
--- 761,765 ----
    if ((ifs.int_flags & IFF_UP) == 0)
      {
!       OLSR_PRINTF(debuglvl, "\tInterface not up - skipping it...\n");
        return 0;
      }
***************
*** 770,774 ****
        (!(ifs.int_flags & IFF_BROADCAST))) 
      {
!       OLSR_PRINTF(debuglvl, "\tNo broadcast - skipping\n")
        return 0;
      }
--- 770,774 ----
        (!(ifs.int_flags & IFF_BROADCAST))) 
      {
!       OLSR_PRINTF(debuglvl, "\tNo broadcast - skipping\n");
        return 0;
      }
***************
*** 777,781 ****
    if (ifs.int_flags & IFF_LOOPBACK)
      {
!       OLSR_PRINTF(debuglvl, "\tThis is a loopback interface - skipping it...\n")
        return 0;
      }
--- 777,781 ----
    if (ifs.int_flags & IFF_LOOPBACK)
      {
!       OLSR_PRINTF(debuglvl, "\tThis is a loopback interface - skipping it...\n");
        return 0;
      }
***************
*** 787,793 ****
  
    if(ifs.is_wireless)
!     OLSR_PRINTF(debuglvl, "\tWireless interface detected\n")
    else
!     OLSR_PRINTF(debuglvl, "\tNot a wireless interface\n")
  
    
--- 787,793 ----
  
    if(ifs.is_wireless)
!     OLSR_PRINTF(debuglvl, "\tWireless interface detected\n");
    else
!     OLSR_PRINTF(debuglvl, "\tNot a wireless interface\n");
  
    
***************
*** 800,811 ****
  	{
  	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
! 	    OLSR_PRINTF(debuglvl, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name)
  	  else
! 	    OLSR_PRINTF(debuglvl, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name)
  	  
  	  return 0;
  	}
        
!       OLSR_PRINTF(debuglvl, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr))
        
        /* Multicast */
--- 800,811 ----
  	{
  	  if(iface->cnf->ipv6_addrtype == IPV6_ADDR_SITELOCAL)
! 	    OLSR_PRINTF(debuglvl, "\tCould not find site-local IPv6 address for %s\n", ifr.ifr_name);
  	  else
! 	    OLSR_PRINTF(debuglvl, "\tCould not find global IPv6 address for %s\n", ifr.ifr_name);
  	  
  	  return 0;
  	}
        
!       OLSR_PRINTF(debuglvl, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr));
        
        /* Multicast */
***************
*** 822,826 ****
  #endif
  
!       OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
        
      }
--- 822,826 ----
  #endif
  
!       OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr));
        
      }
***************
*** 831,835 ****
        if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) 
  	{
! 	  OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n")
  	  return 0;
  	}
--- 831,835 ----
        if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0) 
  	{
! 	  OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n");
  	  return 0;
  	}
***************
*** 886,890 ****
    else
      ifs.int_metric = calculate_if_metric(ifr.ifr_name);
!   OLSR_PRINTF(1, "\tMetric: %d\n", ifs.int_metric)
  
    /* setting the interfaces number*/
--- 886,890 ----
    else
      ifs.int_metric = calculate_if_metric(ifr.ifr_name);
!   OLSR_PRINTF(1, "\tMetric: %d\n", ifs.int_metric);
  
    /* setting the interfaces number*/
***************
*** 905,923 ****
    net_add_buffer(&ifs);
  	       
!   OLSR_PRINTF(1, "\tMTU - IPhdr: %d\n", ifs.int_mtu)
  
    olsr_syslog(OLSR_LOG_INFO, "Adding interface %s\n", iface->name);
!   OLSR_PRINTF(1, "\tIndex %d\n", ifs.if_nr)
  
    if(olsr_cnf->ip_version == AF_INET)
      {
!       OLSR_PRINTF(1, "\tAddress:%s\n", sockaddr_to_string(&ifs.int_addr))
!       OLSR_PRINTF(1, "\tNetmask:%s\n", sockaddr_to_string(&ifs.int_netmask))
!       OLSR_PRINTF(1, "\tBroadcast address:%s\n", sockaddr_to_string(&ifs.int_broadaddr))
      }
    else
      {
!       OLSR_PRINTF(1, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr))
!       OLSR_PRINTF(1, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
      }
    
--- 905,923 ----
    net_add_buffer(&ifs);
  	       
!   OLSR_PRINTF(1, "\tMTU - IPhdr: %d\n", ifs.int_mtu);
  
    olsr_syslog(OLSR_LOG_INFO, "Adding interface %s\n", iface->name);
!   OLSR_PRINTF(1, "\tIndex %d\n", ifs.if_nr);
  
    if(olsr_cnf->ip_version == AF_INET)
      {
!       OLSR_PRINTF(1, "\tAddress:%s\n", sockaddr_to_string(&ifs.int_addr));
!       OLSR_PRINTF(1, "\tNetmask:%s\n", sockaddr_to_string(&ifs.int_netmask));
!       OLSR_PRINTF(1, "\tBroadcast address:%s\n", sockaddr_to_string(&ifs.int_broadaddr));
      }
    else
      {
!       OLSR_PRINTF(1, "\tAddress: %s\n", ip6_to_string(&ifs.int6_addr.sin6_addr));
!       OLSR_PRINTF(1, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr));
      }
    
***************
*** 1016,1020 ****
      {
        COPY_IP(&olsr_cnf->main_addr, &ifp->ip_addr);
!       OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
        olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
      }
--- 1016,1020 ----
      {
        COPY_IP(&olsr_cnf->main_addr, &ifp->ip_addr);
!       OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
        olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
      }





More information about the Olsr-cvs mailing list