Skip to content

Commit

Permalink
update comments and return NULL for Frag/ESP. refs appneta#11
Browse files Browse the repository at this point in the history
  • Loading branch information
synfinatic committed May 6, 2009
1 parent 36727c8 commit 45df3ed
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/common/get.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ get_layer4_v4(const ipv4_hdr_t *ip_hdr)

/**
* returns a pointer to the layer 4 header which is just beyond the IPv6 header
* and any exension headers or NULL when there is none. Function is recursive.
* and any exension headers or NULL when there is none as in the case of
* v6 Frag or ESP header. Function is recursive.
*/
void *
get_layer4_v6(const ipv6_hdr_t *ip6_hdr)
Expand Down Expand Up @@ -347,12 +348,17 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr)
break;

/*
* no further processing, either TCP, UDP or an unparsable
* IPv6 fragment/encrypted data
* Can't handle. Unparsable IPv6 fragment/encrypted data
*/
default:
case TCPR_IPV6_NH_FRAGMENT:
case TCPR_IPV6_NH_ESP:
return NULL;
break;

/*
* no further processing, either TCP, UDP, ICMP, etc...
*/
default:
if (proto != ip6_hdr->ip_nh) {
dbgx(3, "Returning byte offset of this ext header: %u", IPV6_EXTLEN_TO_BYTES(next->ip_len));
return (void *)((u_char *)next + IPV6_EXTLEN_TO_BYTES(next->ip_len));
Expand All @@ -368,7 +374,7 @@ get_layer4_v6(const ipv6_hdr_t *ip6_hdr)

/**
* returns the next payload or header of the current extention header
* returns NULL for none.
* returns NULL for none/ESP.
*/
void *
get_ipv6_next(struct tcpr_ipv6_ext_hdr_base *exthdr)
Expand Down
68 changes: 66 additions & 2 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
test2.rewrite_skip test2.rewrite_dltuser test2.rewrite_dlthdlc \
test2.rewrite_vlandel test2.rewrite_efcs test2.rewrite_1ttl \
test2.rewrite_mtutrunc \
test2.rewrite_2ttl test2.rewrite_3ttl test.rewrite_tos test2.rewrite_tos
test2.rewrite_2ttl test2.rewrite_3ttl test.rewrite_tos test2.rewrite_tos \
test6.pcap test6.auto_bridge test6.auto_client test6.auto_router \
test6.auto_server test6.auto_first test6.cidr test6.comment \
test6.port test6.mac test6.cidr_reverse test6.mac_reverse \
test6.regex_reverse \
test6.rewrite_portmap6 test6.rewrite_endpoint6 \
test2.rewrite_portmap6 test2.rewrite_endpoint6

test: all
all: clearlog check tcpprep tcpreplay tcprewrite
all: clearlog check tcpprep tcpreplay tcprewrite tcprewrite6

clearlog:
-rm test.log
Expand Down Expand Up @@ -66,6 +72,14 @@ standard_prep:
$(TCPPREP) -i test.pcap -o test.mac_reverse -e 00:02:3b:00:3d:ce --reverse
$(TCPPREP) -i test.pcap -o test.cidr_reverse -c '216.27.178.0/24' --reverse
$(TCPPREP) -i test.pcap -o test.regex_reverse -r '216.27.178.*' --reverse
# Not working - yet
# $(TCPPREP) -i test6.pcap -o test6.auto_router -a router
$(TCPPREP) -i test6.pcap -o test6.auto_bridge -a bridge
$(TCPPREP) -i test6.pcap -o test6.auto_client -a client
$(TCPPREP) -i test6.pcap -o test6.auto_server -a server
$(TCPPREP) -i test6.pcap -o test6.auto_first -a first
$(TCPPREP) -i test6.pcap -o test6.port -p
$(TCPPREP) -i test6.pcap -o test6.mac -e '00:11:25:13:ec:dd'

standard_bigendian:
$(TCPREWRITE) -i test.pcap -o test.rewrite_seed -s 55
Expand Down Expand Up @@ -97,6 +111,12 @@ standard_bigendian:
$(TCPREWRITE) -i test.pcap -o test.rewrite_1ttl --ttl=58
$(TCPREWRITE) -i test.pcap -o test.rewrite_2ttl --ttl=+58
$(TCPREWRITE) -i test.pcap -o test.rewrite_3ttl --ttl=-58
# IPv6 tests
$(TCPREWRITE) -i test6.pcap -o test.rewrite_portmap6 -r 80:8080
$(TCPREWRITE) -i test6.pcap -o test.rewrite_endpoint6 -e test6.mac \
-e '[2002::202]:[3003::303]'
$(TCPREWRITE) -i test6.pcap -o test.rewrite_pnat6 \
-N '[1001::/64]:[2002:/64]'

standard_littleendian:
$(TCPREWRITE) -i test.pcap -o test2.rewrite_seed -s 55
Expand Down Expand Up @@ -129,6 +149,12 @@ standard_littleendian:
$(TCPREWRITE) -i test.pcap -o test2.rewrite_2ttl --ttl=+58
$(TCPREWRITE) -i test.pcap -o test2.rewrite_3ttl --ttl=-58
$(TCPREWRITE) -i test.pcap -o test2.rewrite_mtutrunc --mtu-trunc --mtu=300
# IPv6 tests
$(TCPREWRITE) -i test6.pcap -o test2.rewrite_portmap6 -r 80:8080
$(TCPREWRITE) -i test6.pcap -o test2.rewrite_endpoint6 -c test6.mac \
-e '[2002::202]:[3003::303]'
$(TCPREWRITE) -i test6.pcap -o test2.rewrite_pnat6 \
-N '[1001::/64]:[2002:/64]'


tcpprep: auto_router auto_bridge auto_client auto_server auto_first cidr regex \
Expand All @@ -140,6 +166,8 @@ tcprewrite: rewrite_portmap rewrite_endpoint rewrite_pnat rewrite_trunc \
rewrite_skip rewrite_dltuser rewrite_dlthdlc rewrite_vlandel rewrite_efcs \
rewrite_1ttl rewrite_2ttl rewrite_3ttl rewrite_tos rewrite_mtutrunc

tcprewrite6: rewrite_portmap6 rewrite_endpoint6 rewrite_pnat6

tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top \
replay_config replay_multi replay_pps_multi

Expand Down Expand Up @@ -490,6 +518,42 @@ else
endif
if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi

rewrite_portmap6:
$(PRINTF) "%s" "[tcprewrite6] Portmap test: "
$(PRINTF) "%s\n" "*** [tcprewrite6] Portmap test: " >>test.log
$(TCPREWRITE) $(ENABLE_DEBUG) -i test6.pcap -o test.$@1 -r 80:8080 >>test.log 2>&1
if WORDS_BIGENDIAN
diff test.$@ test.$@1 >>test.log 2>&1
else
diff test2.$@ test.$@1 >>test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

rewrite_endpoint6:
$(PRINTF) "%s" "[tcprewrite6] Endpoint test: "
$(PRINTF) "%s\n" "*** [tcprewrite6] Endpoint test: " >>test.log
$(TCPREWRITE) $(ENABLE_DEBUG) -i test6.pcap -o test6.$@1 \
-e [2002::202]:[3003::303] \
-c test6.mac >>test.log 2>&1
if WORDS_BIGENDIAN
diff test.$@ test.$@1 >>test.log 2>&1
else
diff test2.$@ test.$@1 >>test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

rewrite_pnat6:
$(PRINTF) "%s" "[tcprewrite6] Pseudo NAT test: "
$(PRINTF) "%s\n" "*** [tcprewrite6] Pseudo NAT test: " >>test.log
$(TCPREWRITE) $(ENABLE_DEBUG) -i test6.pcap -o test6.$@1 \
-N '[1001::/64]:[2002::/64]' >>test.log 2>&1
if WORDS_BIGENDIAN
diff test.$@ test.$@1 >>test.log 2>&1
else
diff test2.$@ test.$@1 >>test.log 2>&1
endif
if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi

replay_pps:
$(PRINTF) "%s" "[tcpreplay] Packets/sec test: "
$(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log
Expand Down

0 comments on commit 45df3ed

Please sign in to comment.