[Olsr-cvs] olsrd-current/src net_olsr.c, 1.7, 1.8 interfaces.h, 1.30, 1.31
Andreas T�nnesen
(spam-protected)
Fri Jan 6 07:54:06 CET 2006
Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18909/src
Modified Files:
net_olsr.c interfaces.h
Log Message:
Initial libnet code for testing. Works on Linux now, do make USE_LIBNET=1 to use
Index: net_olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** net_olsr.c 29 Dec 2005 18:37:16 -0000 1.7
--- net_olsr.c 6 Jan 2006 06:54:04 -0000 1.8
***************
*** 47,50 ****
--- 47,55 ----
#include "link_set.h"
#include <stdlib.h>
+ #include <assert.h>
+
+ #ifdef USE_LIBNET
+ #include <libnet.h>
+ #endif
extern olsr_bool lq_tc_pending;
***************
*** 88,91 ****
--- 93,105 ----
};
+ #ifdef USE_LIBNET
+ static char errbuf[LIBNET_ERRBUF_SIZE];
+
+ char *
+ get_libnet_errbuf()
+ {
+ return errbuf;
+ }
+ #endif
void
***************
*** 455,458 ****
--- 469,527 ----
if(olsr_cnf->ip_version == AF_INET)
{
+ #ifdef USE_LIBNET
+ libnet_ptag_t udp_ptag = 0, ip_ptag = 0;
+ int bytes_written;
+
+ printf("LIBNET TX %d bytes on %s\n",
+ netbufs[ifp->if_nr]->pending, ifp->int_name);
+
+ assert(ifp->libnet_ctx != NULL);
+
+ udp_ptag = libnet_build_udp(OLSRPORT,
+ OLSRPORT,
+ LIBNET_UDP_H + netbufs[ifp->if_nr]->pending,
+ 0,
+ (u_int8_t *)netbufs[ifp->if_nr]->buff,
+ netbufs[ifp->if_nr]->pending,
+ ifp->libnet_ctx,
+ udp_ptag);
+ if(udp_ptag == -1)
+ {
+ OLSR_PRINTF (1, "libnet UDP header: %s\n", libnet_geterror (ifp->libnet_ctx))
+ return (0);
+ }
+
+ ip_ptag = libnet_build_ipv4(LIBNET_IPV4_H + LIBNET_UDP_H + netbufs[ifp->if_nr]->pending,
+ olsr_cnf->tos,
+ ifp->olsr_seqnum,
+ 0,
+ 255,
+ IPPROTO_UDP,
+ 0,
+ ifp->ip_addr.v4,
+ sin->sin_addr.s_addr,
+ NULL,
+ 0,
+ ifp->libnet_ctx,
+ ip_ptag);
+ if(ip_ptag == -1)
+ {
+ 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);
+ }
+
+ libnet_clear_packet(ifp->libnet_ctx);
+ #else
/* IP version 4 */
if(olsr_sendto(ifp->olsr_socket,
***************
*** 469,472 ****
--- 538,542 ----
return -1;
}
+ #endif
}
else
Index: interfaces.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** interfaces.h 3 Jun 2005 08:00:55 -0000 1.30
--- interfaces.h 6 Jan 2006 06:54:04 -0000 1.31
***************
*** 136,139 ****
--- 136,141 ----
struct vtimes valtimes;
+ void *libnet_ctx; /* libnet context(void to avoid dependency */
+
struct if_gen_property *gen_properties;/* Generic interface properties */
More information about the Olsr-cvs
mailing list