[Olsr-cvs] olsrd-current/src net_olsr.c,1.8,1.9

Andreas T�nnesen (spam-protected)
Fri Jan 6 08:21:07 CET 2006


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23197

Modified Files:
	net_olsr.c 
Log Message:
Added dont fragment bit in libnet udp header and better failure handling

Index: net_olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** net_olsr.c	6 Jan 2006 06:54:04 -0000	1.8
--- net_olsr.c	6 Jan 2006 07:21:04 -0000	1.9
***************
*** 410,413 ****
--- 410,414 ----
    struct ptf *tmp_ptf_list;
    union olsr_packet *outmsg;
+   int retval;
  
    sin = NULL;
***************
*** 422,425 ****
--- 423,428 ----
    netbufs[ifp->if_nr]->pending += OLSR_HEADERSIZE;
  
+   retval = netbufs[ifp->if_nr]->pending;
+ 
    outmsg = (union olsr_packet *)netbufs[ifp->if_nr]->buff;
    /* Add the Packet seqno */
***************
*** 471,475 ****
  #ifdef USE_LIBNET
        libnet_ptag_t udp_ptag = 0, ip_ptag = 0;
-       int bytes_written;
  
        printf("LIBNET TX %d bytes on %s\n", 
--- 474,477 ----
***************
*** 489,493 ****
  	{
  	  OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (ifp->libnet_ctx))
! 	  return (0);
  	}
        
--- 491,497 ----
  	{
  	  OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (ifp->libnet_ctx))
! 	  netbufs[ifp->if_nr]->pending = 0;
! 	  libnet_clear_packet(ifp->libnet_ctx);
! 	  return -1;
  	}
        
***************
*** 495,499 ****
  				  olsr_cnf->tos,
  				  ifp->olsr_seqnum,
! 				  0,
  				  255,
  				  IPPROTO_UDP,
--- 499,503 ----
  				  olsr_cnf->tos,
  				  ifp->olsr_seqnum,
! 				  0x4000, /* Don't fragment */
  				  255,
  				  IPPROTO_UDP,
***************
*** 508,523 ****
  	{
  	  OLSR_PRINTF (1, "libnet IP header: %s\n", libnet_geterror (ifp->libnet_ctx))
! 	    return (0);
  	}
        
!       if((bytes_written = libnet_write(ifp->libnet_ctx)) == -1)
  	{
  	  OLSR_PRINTF (1, "libnet packet write: %s\n", libnet_geterror (ifp->libnet_ctx))
- 	    return (0);
  	}
!       if(bytes_written != (int)(LIBNET_IPV4_H + LIBNET_UDP_H + netbufs[ifp->if_nr]->pending))
  	{
  	  printf("libnet_write returned %d, expected %d\n", 
! 		 bytes_written, LIBNET_IPV4_H + LIBNET_UDP_H + netbufs[ifp->if_nr]->pending);
  	}
        
--- 512,528 ----
  	{
  	  OLSR_PRINTF (1, "libnet IP header: %s\n", libnet_geterror (ifp->libnet_ctx))
! 	  netbufs[ifp->if_nr]->pending = 0;
! 	  libnet_clear_packet(ifp->libnet_ctx);
! 	  return -1;
  	}
        
!       if((retval = libnet_write(ifp->libnet_ctx)) == -1)
  	{
  	  OLSR_PRINTF (1, "libnet packet write: %s\n", libnet_geterror (ifp->libnet_ctx))
  	}
!       if(retval != (int)(LIBNET_IPV4_H + LIBNET_UDP_H + netbufs[ifp->if_nr]->pending))
  	{
  	  printf("libnet_write returned %d, expected %d\n", 
! 		 retval, LIBNET_IPV4_H + LIBNET_UDP_H + netbufs[ifp->if_nr]->pending);
  	}
        
***************
*** 535,540 ****
  	  perror("sendto(v4)");
  	  olsr_syslog(OLSR_LOG_ERR, "OLSR: sendto IPv4 %m");
! 	  netbufs[ifp->if_nr]->pending = 0;
! 	  return -1;
  	}
  #endif
--- 540,544 ----
  	  perror("sendto(v4)");
  	  olsr_syslog(OLSR_LOG_ERR, "OLSR: sendto IPv4 %m");
! 	  retval = -1;
  	}
  #endif
***************
*** 556,561 ****
  	  fprintf(stderr, "To: %s (size: %d)\n", ip6_to_string(&sin6->sin6_addr), (int)sizeof(*sin6));
  	  fprintf(stderr, "Outputsize: %d\n", netbufs[ifp->if_nr]->pending);
! 	  netbufs[ifp->if_nr]->pending = 0;
! 	  return -1;
  	}
      }
--- 560,564 ----
  	  fprintf(stderr, "To: %s (size: %d)\n", ip6_to_string(&sin6->sin6_addr), (int)sizeof(*sin6));
  	  fprintf(stderr, "Outputsize: %d\n", netbufs[ifp->if_nr]->pending);
! 	  retval = -1;
  	}
      }
***************
*** 569,573 ****
    lq_tc_pending = OLSR_FALSE;
  
!   return 1;
  }
  
--- 572,576 ----
    lq_tc_pending = OLSR_FALSE;
  
!   return retval;
  }
  





More information about the Olsr-cvs mailing list