diff -rbu Libnet-1.1.1-RC-005/src/libnet_build_ip.c Libnet-1.1.1-RC-005-no-inner-ip-bug/src/libnet_build_ip.c
--- Libnet-1.1.1-RC-005/src/libnet_build_ip.c 2003-06-18 22:05:34.000000000 +0200
+++ Libnet-1.1.1-RC-005-no-inner-ip-bug/src/libnet_build_ip.c 2003-06-29 14:33:56.000000000 +0200
@@ -217,7 +217,7 @@
memset(l->err_buf, 0, sizeof (l->err_buf));
}
}
- if (sum == 0 && l->injection_type != LIBNET_RAW4)
+ if ( sum == 0 )
{
/*
* If checksum is zero, by default libnet will compute a checksum
@@ -300,10 +300,7 @@
goto bad;
}
- if (l->injection_type != LIBNET_RAW4)
- {
libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM);
- }
return (libnet_pblock_update(l, p, LIBNET_IPV4_H, LIBNET_PBLOCK_IPV4_H));
bad:
libnet_pblock_delete(l, p);
@@ -487,16 +484,7 @@
}
}
- if (l->injection_type != LIBNET_RAW6)
- {
- /*
- * If checksum is zero, by default libnet will compute a checksum
- * for the user. The programmer can override this by calling
- * libnet_toggle_checksum(l, ptag, 1);
- */
- libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM);
- }
-
+ /* ipv6 doesn't have checksum any more!!! */
return (ptag ? ptag : libnet_pblock_update(l, p, LIBNET_IPV6_H,
LIBNET_PBLOCK_IPV6_H));
bad:
diff -rbu Libnet-1.1.1-RC-005/src/libnet_pblock.c Libnet-1.1.1-RC-005-no-inner-ip-bug/src/libnet_pblock.c
--- Libnet-1.1.1-RC-005/src/libnet_pblock.c 2003-06-19 00:25:20.000000000 +0200
+++ Libnet-1.1.1-RC-005-no-inner-ip-bug/src/libnet_pblock.c 2003-06-29 15:06:26.000000000 +0200
@@ -328,6 +328,50 @@
return (-1);
}
+ if ( l->injection_type == LIBNET_RAW4 && l->pblock_end->type == LIBNET_PBLOCK_IPV4_H )
+ {
+ libnet_pblock_setflags(l->pblock_end, LIBNET_PBLOCK_DO_CHECKSUM);
+ }
+
+ /* some new sanity checks */
+ if ( 0 == (l->injection_type & LIBNET_ADV_MASK) )
+ {
+ switch(l->injection_type)
+ {
+ case LIBNET_LINK:
+ if ( ( l->pblock_end->type != LIBNET_PBLOCK_TOKEN_RING_H ) &&
+ ( l->pblock_end->type != LIBNET_PBLOCK_FDDI_H ) &&
+ ( l->pblock_end->type != LIBNET_PBLOCK_ETH_H ) )
+ {
+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): trying to inject a non link-layer unit over the link interface",
+ __FUNCTION__);
+ return (-1);
+ }
+ break;
+ case LIBNET_RAW4:
+ if ( ( l->pblock_end->type != LIBNET_PBLOCK_IPV4_H ) )
+ {
+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): trying to inject a non ipv4 unit over the raw4 interface",
+ __FUNCTION__);
+ return (-1);
+ }
+ break;
+ case LIBNET_RAW6:
+ if ( ( l->pblock_end->type != LIBNET_PBLOCK_IPV6_H ) )
+ {
+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): trying to inject a non ipv6 unit over the raw6 interface",
+ __FUNCTION__);
+ return (-1);
+ }
+ break;
+ default:
+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): some change happened that broke libnet, please refer to the author",
+ __FUNCTION__);
+ return (-1);
+ break;
+ }
+ }
+
q = NULL;
for (n = l->aligner + l->total_size, p = l->protocol_blocks; p || q; )
{
|