Makefile.am 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. # $Id$
  2. MAKEFLAGS=-s -k
  3. PRINTF = @PRINTF@
  4. HOST = @host@
  5. TARGET = @target@
  6. BUILD = @build@
  7. nic1 = @nic1@
  8. nic2 = @nic2@
  9. ENABLE_DEBUG = @debug_run_time_flag@
  10. TCPPREP=../src/tcpprep --no-arg-comment
  11. TCPREPLAY=../src/tcpreplay
  12. TCPREWRITE=../src/tcprewrite
  13. TCPBRIDGE=../src/tcpbridge
  14. EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \
  15. test.auto_server test.auto_first test.cidr test.comment test.port test.mac \
  16. test.cidr_reverse test.mac_reverse test.regex_reverse \
  17. test.prep_config test.primary test.regex test.secondary \
  18. test.rewrite_seed test.rewrite_portmap test.rewrite_endpoint \
  19. test.rewrite_pnat test.rewrite_pad test.rewrite_trunc \
  20. test.rewrite_mac test.rewrite_layer2 test.rewrite_config \
  21. test.rewrite_skip test.rewrite_dltuser test.rewrite_dlthdlc \
  22. test.rewrite_vlandel test.rewrite_efcs test.rewrite_1ttl \
  23. test.rewrite_2ttl test.rewrite_3ttl test.rewrite_enet_subsmac \
  24. test.rewrite_mtutrunc test.rewrite_mac_seed \
  25. test.rewrite_mac_seed_keep test.rewrite_l7fuzzing\
  26. test2.rewrite_seed test2.rewrite_portmap test2.rewrite_endpoint \
  27. test2.rewrite_pnat test2.rewrite_pad test2.rewrite_trunc \
  28. test2.rewrite_mac test2.rewrite_layer2 test2.rewrite_config \
  29. test2.rewrite_skip test2.rewrite_dltuser test2.rewrite_dlthdlc \
  30. test2.rewrite_vlandel test2.rewrite_efcs test2.rewrite_1ttl \
  31. test2.rewrite_mtutrunc test2.rewrite_enet_subsmac \
  32. test2.rewrite_2ttl test2.rewrite_3ttl test.rewrite_tos test2.rewrite_tos \
  33. test2.rewrite_enet_subsmac test2.rewrite_mac_seed \
  34. test2.rewrite_mac_seed_keep test2.rewrite_l7fuzzing
  35. test: all
  36. all: clearlog check tcpprep tcpreplay tcprewrite
  37. clearlog:
  38. -rm test.log
  39. check:
  40. $(PRINTF) "%s\n" "NOTICE: Tests must be run as root"
  41. $(PRINTF) "%s\n" "Sending traffic on '$(nic1)' and '$(nic2)'"
  42. if WORDS_BIGENDIAN
  43. STANDARD_REWRITE = standard_bigendian
  44. REWRITE_WARN = "big"
  45. else
  46. STANDARD_REWRITE = standard_littleendian
  47. REWRITE_WARN = "little"
  48. endif
  49. standard: standard_prep $(STANDARD_REWRITE)
  50. $(PRINTF) "Warning: only creating %s endian standard test files\n" $(REWRITE_WARN)
  51. standard_prep:
  52. $(TCPPREP) -i test.pcap -o test.auto_router -a router
  53. $(TCPPREP) -i test.pcap -o test.auto_bridge -a bridge
  54. $(TCPPREP) -i test.pcap -o test.auto_client -a client
  55. $(TCPPREP) -i test.pcap -o test.auto_server -a server
  56. $(TCPPREP) -i test.pcap -o test.auto_first -a first
  57. $(TCPPREP) --load-opts config -o test.prep_config
  58. $(TCPPREP) -i test.pcap -o test.port -p
  59. $(TCPPREP) -i test.pcap -o test.mac -e 00:02:3b:00:3d:ce
  60. $(TCPPREP) -i test.pcap -o test.cidr -c '216.27.178.0/24'
  61. $(TCPPREP) -i test.pcap -o test.regex -r '216.27.178.*'
  62. $(TCPPREP) -i test.pcap -o test.comment -C "This is a comment" -p
  63. $(TCPPREP) -i test.pcap -o test.mac_reverse -e 00:02:3b:00:3d:ce --reverse
  64. $(TCPPREP) -i test.pcap -o test.cidr_reverse -c '216.27.178.0/24' --reverse
  65. $(TCPPREP) -i test.pcap -o test.regex_reverse -r '216.27.178.*' --reverse
  66. standard_bigendian:
  67. $(TCPREWRITE) -i test.pcap -o test.rewrite_seed -s 55
  68. $(TCPREWRITE) -i test.pcap -o test.rewrite_tos --tos=50
  69. $(TCPREWRITE) -i test.pcap -o test.rewrite_portmap -r 80:8080
  70. $(TCPREWRITE) -i test.pcap -o test.rewrite_endpoint \
  71. -e 10.10.0.1:10.10.0.2 -c test.auto_router
  72. $(TCPREWRITE) -i test.pcap -o test.rewrite_pnat \
  73. -N 216.27.178.0/24:172.16.0.0/24
  74. $(TCPREWRITE) -i test.pcap -o test.rewrite_pad -F pad
  75. $(TCPREWRITE) -i test.pcap -o test.rewrite_trunc -F trunc
  76. $(TCPREWRITE) -i test.pcap -o test.rewrite_mac \
  77. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  78. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  79. $(TCPREWRITE) -i test.pcap -o test.rewrite_enet_subsmac \
  80. --enet-subsmac=00:1f:f3:3c:e1:13,00:22:33:44:55:66 \
  81. --enet-subsmac=f8:1e:df:e5:84:3a,00:66:55:44:33:22
  82. $(TCPREWRITE) -i test.pcap -o test.rewrite_mac_seed --enet-mac-seed=42
  83. $(TCPREWRITE) -i test.pcap -o test.rewrite_mac_seed_keep --enet-mac-seed=42 \
  84. --enet-mac-seed-keep-bytes=3
  85. $(TCPREWRITE) -i test.pcap -o test.rewrite_layer2 \
  86. --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0
  87. $(TCPREWRITE) -i test.pcap -o test.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \
  88. --enet-vlan-cfi=1 --enet-vlan-pri=5
  89. $(TCPREWRITE) -i test.pcap -o test.rewrite_skip -b -s 55 \
  90. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  91. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  92. $(TCPREWRITE) -i test.pcap -o test.rewrite_dltuser --dlt=user \
  93. --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104
  94. $(TCPREWRITE) -i test.pcap -o test.rewrite_dlthdlc --dlt=hdlc \
  95. --hdlc-control=0 --hdlc-address=0x0F
  96. $(TCPREWRITE) -i test.rewrite_config -o test.rewrite_vlandel \
  97. --enet-vlan=del
  98. $(TCPREWRITE) -i test.pcap -o test.rewrite_efcs --efcs
  99. $(TCPREWRITE) -i test.pcap -o test.rewrite_1ttl --ttl=58
  100. $(TCPREWRITE) -i test.pcap -o test.rewrite_2ttl --ttl=+58
  101. $(TCPREWRITE) -i test.pcap -o test.rewrite_3ttl --ttl=-58
  102. $(TCPREWRITE) -i test.pcap -o test.rewrite_mtutrunc --mtu-trunc --mtu=300
  103. $(TCPREWRITE) -i test.pcap -o test.rewrite_l7fuzzing --fuzz-seed=42
  104. standard_littleendian:
  105. $(TCPREWRITE) -i test.pcap -o test2.rewrite_seed -s 55
  106. $(TCPREWRITE) -i test.pcap -o test2.rewrite_tos --tos=50
  107. $(TCPREWRITE) -i test.pcap -o test2.rewrite_portmap -r 80:8080
  108. $(TCPREWRITE) -i test.pcap -o test2.rewrite_endpoint \
  109. -e 10.10.0.1:10.10.0.2 -c test.auto_router
  110. $(TCPREWRITE) -i test.pcap -o test2.rewrite_pnat \
  111. -N 216.27.178.0/24:172.16.0.0/24
  112. $(TCPREWRITE) -i test.pcap -o test2.rewrite_pad -F pad
  113. $(TCPREWRITE) -i test.pcap -o test2.rewrite_trunc -F trunc
  114. $(TCPREWRITE) -i test.pcap -o test2.rewrite_mac \
  115. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  116. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  117. $(TCPREWRITE) -i test.pcap -o test2.rewrite_enet_subsmac \
  118. --enet-subsmac=00:1f:f3:3c:e1:13,00:22:33:44:55:66 \
  119. --enet-subsmac=f8:1e:df:e5:84:3a,00:66:55:44:33:22
  120. $(TCPREWRITE) -i test.pcap -o test2.rewrite_mac_seed --enet-mac-seed=42
  121. $(TCPREWRITE) -i test.pcap -o test2.rewrite_mac_seed_keep --enet-mac-seed=42 \
  122. --enet-mac-seed-keep-bytes=3
  123. $(TCPREWRITE) -i test.pcap -o test2.rewrite_layer2 \
  124. --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0
  125. $(TCPREWRITE) -i test.pcap -o test2.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \
  126. --enet-vlan-cfi=1 --enet-vlan-pri=5
  127. $(TCPREWRITE) -i test.pcap -o test2.rewrite_skip -b -s 55 \
  128. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  129. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router
  130. $(TCPREWRITE) -i test.pcap -o test2.rewrite_dltuser --dlt=user \
  131. --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104
  132. $(TCPREWRITE) -i test.pcap -o test2.rewrite_dlthdlc --dlt=hdlc \
  133. --hdlc-control=0 --hdlc-address=0x0F
  134. $(TCPREWRITE) -i test.rewrite_config -o test2.rewrite_vlandel \
  135. --enet-vlan=del
  136. $(TCPREWRITE) -i test.pcap -o test2.rewrite_efcs --efcs
  137. $(TCPREWRITE) -i test.pcap -o test2.rewrite_1ttl --ttl=58
  138. $(TCPREWRITE) -i test.pcap -o test2.rewrite_2ttl --ttl=+58
  139. $(TCPREWRITE) -i test.pcap -o test2.rewrite_3ttl --ttl=-58
  140. $(TCPREWRITE) -i test.pcap -o test2.rewrite_mtutrunc --mtu-trunc --mtu=300
  141. $(TCPREWRITE) -i test.pcap -o test2.rewrite_l7fuzzing --fuzz-seed=42
  142. tcpprep: auto_router auto_bridge auto_client auto_server auto_first cidr regex \
  143. port mac comment print_info print_comment prep_config \
  144. mac_reverse cidr_reverse regex_reverse
  145. tcprewrite: rewrite_portmap rewrite_endpoint rewrite_pnat rewrite_trunc \
  146. rewrite_pad rewrite_seed rewrite_mac rewrite_layer2 rewrite_config \
  147. rewrite_skip rewrite_dltuser rewrite_dlthdlc rewrite_vlandel rewrite_efcs \
  148. rewrite_1ttl rewrite_2ttl rewrite_3ttl rewrite_tos rewrite_mtutrunc \
  149. rewrite_enet_subsmac rewrite_mac_seed rewrite_mac_seed_keep rewrite_l7fuzzing
  150. tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top \
  151. replay_config replay_multi replay_pps_multi replay_precache \
  152. replay_stats replay_dualfile replay_maxsleep
  153. prep_config:
  154. $(PRINTF) "%s" "[tcpprep] Config mode test: "
  155. $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log
  156. $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 >>test.log 2>&1
  157. diff test.$@ test.$@1 >>test.log 2>&1
  158. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  159. auto_router:
  160. $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: "
  161. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log
  162. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router >>test.log 2>&1
  163. diff test.$@ test.$@1 >>test.log 2>&1
  164. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  165. auto_bridge:
  166. $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: "
  167. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log
  168. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge >>test.log 2>&1
  169. diff test.$@ test.$@1 >>test.log 2>&1
  170. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  171. auto_client:
  172. $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: "
  173. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log
  174. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client >>test.log 2>&1
  175. diff test.$@ test.$@1 >>test.log 2>&1
  176. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  177. auto_server:
  178. $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: "
  179. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log
  180. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server >>test.log 2>&1
  181. diff test.$@ test.$@1 >>test.log 2>&1
  182. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  183. auto_first:
  184. $(PRINTF) "%s" "[tcpprep] Auto/First mode test: "
  185. $(PRINTF) "%s\n" "*** [tcpprep] Auto/First mode test: " >>test.log
  186. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a first >>test.log 2>&1
  187. diff test.$@ test.$@1 >>test.log 2>&1
  188. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  189. regex:
  190. $(PRINTF) "%s" "[tcpprep] Regex mode test: "
  191. $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log
  192. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' >>test.log 2>&1
  193. diff test.$@ test.$@1 >>test.log 2>&1
  194. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  195. cidr:
  196. $(PRINTF) "%s" "[tcpprep] CIDR mode test: "
  197. $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log
  198. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' >>test.log 2>&1
  199. diff test.$@ test.$@1 >>test.log 2>&1
  200. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  201. port:
  202. $(PRINTF) "%s" "[tcpprep] Port mode test: "
  203. $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log
  204. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p >>test.log 2>&1
  205. diff test.$@ test.$@1 >>test.log 2>&1
  206. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  207. mac:
  208. $(PRINTF) "%s" "[tcpprep] MAC mode test: "
  209. $(PRINTF) "%s\n" "*** [tcpprep] MAC mode test: " >>test.log
  210. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce >>test.log 2>&1
  211. diff test.$@ test.$@1 >>test.log 2>&1
  212. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  213. comment:
  214. $(PRINTF) "%s" "[tcpprep] Comment mode test: "
  215. $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log
  216. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p >>test.log 2>&1
  217. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  218. print_comment:
  219. $(PRINTF) "%s" "[tcpprep] Print comment mode test: "
  220. $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log
  221. $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 >>test.log 2>&1
  222. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  223. print_info:
  224. $(PRINTF) "%s" "[tcpprep] Print info mode test: "
  225. $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log
  226. $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 >>test.log 2>&1
  227. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  228. regex_reverse:
  229. $(PRINTF) "%s" "[tcpprep] Regex reverse mode test: "
  230. $(PRINTF) "%s\n" "*** [tcpprep] Regex reverse mode test: " >>test.log
  231. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' --reverse >>test.log 2>&1
  232. diff test.$@ test.$@1 >>test.log 2>&1
  233. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  234. cidr_reverse:
  235. $(PRINTF) "%s" "[tcpprep] CIDR reverse mode test: "
  236. $(PRINTF) "%s\n" "*** [tcpprep] CIDR reverse mode test: " >>test.log
  237. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' --reverse >>test.log 2>&1
  238. diff test.$@ test.$@1 >>test.log 2>&1
  239. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  240. mac_reverse:
  241. $(PRINTF) "%s" "[tcpprep] MAC reverse mode test: "
  242. $(PRINTF) "%s\n" "*** [tcpprep] MAC reverse mode test: " >>test.log
  243. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce --reverse >>test.log 2>&1
  244. diff test.$@ test.$@1 >>test.log 2>&1
  245. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  246. replay_basic:
  247. $(PRINTF) "%s" "[tcpreplay] Basic test: "
  248. $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log
  249. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  250. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  251. replay_cache:
  252. $(PRINTF) "%s" "[tcpreplay] Cache test: "
  253. $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log
  254. $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1
  255. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  256. replay_accurate:
  257. $(PRINTF) "%s" "[tcpreplay] Accurate test: "
  258. $(PRINTF) "%s\n" "*** [tcpreplay] Accurate test: " >>test.log
  259. $(TCPREPLAY) $(ENABLE_DEBUG) -a -i $(nic1) test.pcap >>test.log 2>&1
  260. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  261. replay_stats:
  262. $(PRINTF) "%s" "[tcpreplay] Statistics test: "
  263. $(PRINTF) "%s\n" "*** [tcpreplay] Statistics test: " >>test.log
  264. $(TCPREPLAY) $(ENABLE_DEBUG) --stats=1 -i $(nic1) test.pcap >>test.log 2>&1
  265. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  266. rewrite_portmap:
  267. $(PRINTF) "%s" "[tcprewrite] Portmap test: "
  268. $(PRINTF) "%s\n" "*** [tcprewrite] Portmap test: " >>test.log
  269. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r 80:8080 >>test.log 2>&1
  270. if WORDS_BIGENDIAN
  271. diff test.$@ test.$@1 >>test.log 2>&1
  272. else
  273. diff test2.$@ test.$@1 >>test.log 2>&1
  274. endif
  275. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  276. rewrite_endpoint:
  277. $(PRINTF) "%s" "[tcprewrite] Endpoint test: "
  278. $(PRINTF) "%s\n" "*** [tcprewrite] Endpoint test: " >>test.log
  279. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 10.10.0.1:10.10.0.2 \
  280. -c test.auto_router >>test.log 2>&1
  281. if WORDS_BIGENDIAN
  282. diff test.$@ test.$@1 >>test.log 2>&1
  283. else
  284. diff test2.$@ test.$@1 >>test.log 2>&1
  285. endif
  286. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  287. rewrite_pnat:
  288. $(PRINTF) "%s" "[tcprewrite] Pseudo NAT test: "
  289. $(PRINTF) "%s\n" "*** [tcprewrite] Pseudo NAT test: " >>test.log
  290. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 \
  291. -N 216.27.178.0/24:172.16.0.0/24 >>test.log 2>&1
  292. if WORDS_BIGENDIAN
  293. diff test.$@ test.$@1 >>test.log 2>&1
  294. else
  295. diff test2.$@ test.$@1 >>test.log 2>&1
  296. endif
  297. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  298. rewrite_mac:
  299. $(PRINTF) "%s" "[tcprewrite] Src/Dst MAC test: "
  300. $(PRINTF) "%s\n" "*** [tcprewrite] Src/Dst MAC test: " >>test.log
  301. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 \
  302. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  303. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1
  304. if WORDS_BIGENDIAN
  305. diff test.$@ test.$@1 >>test.log 2>&1
  306. else
  307. diff test2.$@ test.$@1 >>test.log 2>&1
  308. endif
  309. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  310. rewrite_enet_subsmac:
  311. $(PRINTF) "%s" "[tcprewrite] Substitute Src/Dst MAC test: "
  312. $(PRINTF) "%s\n" "*** [tcprewrite] Substitute Src/Dst MAC test: " >>test.log
  313. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 \
  314. --enet-subsmac=00:1f:f3:3c:e1:13,00:22:33:44:55:66 \
  315. --enet-subsmac=f8:1e:df:e5:84:3a,00:66:55:44:33:22 >>test.log 2>&1
  316. if WORDS_BIGENDIAN
  317. diff test.$@ test.$@1 >>test.log 2>&1
  318. else
  319. diff test2.$@ test.$@1 >>test.log 2>&1
  320. endif
  321. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  322. rewrite_mac_seed:
  323. $(PRINTF) "%s" "[tcprewrite] Seeded MAC test: "
  324. $(PRINTF) "%s\n" "*** [tcprewrite] Seeded MAC test: " >>test.log
  325. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 \
  326. --enet-mac-seed=42 >>test.log 2>&1
  327. if WORDS_BIGENDIAN
  328. diff test.$@ test.$@1 >>test.log 2>&1
  329. else
  330. diff test2.$@ test.$@1 >>test.log 2>&1
  331. endif
  332. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  333. rewrite_mac_seed_keep:
  334. $(PRINTF) "%s" "[tcprewrite] Seeded Keep MAC test: "
  335. $(PRINTF) "%s\n" "*** [tcprewrite] Seeded Keep MAC test: " >>test.log
  336. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 \
  337. --enet-mac-seed=42 --enet-mac-seed-keep-bytes=3 >>test.log 2>&1
  338. if WORDS_BIGENDIAN
  339. diff test.$@ test.$@1 >>test.log 2>&1
  340. else
  341. diff test2.$@ test.$@1 >>test.log 2>&1
  342. endif
  343. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  344. rewrite_trunc:
  345. $(PRINTF) "%s" "[tcprewrite] Truncate test: "
  346. $(PRINTF) "%s\n" "*** [tcprewrite] Truncate test: " >>test.log
  347. $(TCPREWRITE) $(ENABLE_DEBUG) -F trunc -i test.pcap -o test.$@1 >>test.log 2>&1
  348. if WORDS_BIGENDIAN
  349. diff test.$@ test.$@1 >>test.log 2>&1
  350. else
  351. diff test2.$@ test.$@1 >>test.log 2>&1
  352. endif
  353. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  354. rewrite_pad:
  355. $(PRINTF) "%s" "[tcprewrite] Pad test: "
  356. $(PRINTF) "%s\n" "*** [tcprewrite] Pad test: " >>test.log
  357. $(TCPREWRITE) $(ENABLE_DEBUG) -F pad -i test.pcap -o test.$@1 >>test.log 2>&1
  358. if WORDS_BIGENDIAN
  359. diff test.$@ test.$@1 >>test.log 2>&1
  360. else
  361. diff test2.$@ test.$@1 >>test.log 2>&1
  362. endif
  363. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  364. rewrite_seed:
  365. $(PRINTF) "%s" "[tcprewrite] Seed IP test: "
  366. $(PRINTF) "%s\n" "*** [tcprewrite] Seed IP test: " >>test.log
  367. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -s 55 >>test.log 2>&1
  368. if WORDS_BIGENDIAN
  369. diff test.$@ test.$@1 >>test.log 2>&1
  370. else
  371. diff test2.$@ test.$@1 >>test.log 2>&1
  372. endif
  373. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  374. rewrite_layer2:
  375. $(PRINTF) "%s" "[tcprewrite] Layer2 test: "
  376. $(PRINTF) "%s\n" "*** [tcprewrite] Layer2 test: " >>test.log
  377. $(TCPREWRITE) $(ENABLE_DEBUG) --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 \
  378. -i test.pcap -o test.$@1 >>test.log 2>&1
  379. if WORDS_BIGENDIAN
  380. diff test.$@ test.$@1 >>test.log 2>&1
  381. else
  382. diff test2.$@ test.$@1 >>test.log 2>&1
  383. endif
  384. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  385. rewrite_config:
  386. $(PRINTF) "%s" "[tcprewrite] Config/VLAN Add test: "
  387. $(PRINTF) "%s\n" "*** [tcprewrite] Config/VLAN Add test: " >>test.log
  388. $(TCPREWRITE) $(ENABLE_DEBUG) --load-opts config >>test.log 2>&1
  389. if WORDS_BIGENDIAN
  390. diff test.$@ test.$@1 >>test.log 2>&1
  391. else
  392. diff test2.$@ test.$@1 >>test.log 2>&1
  393. endif
  394. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  395. rewrite_skip:
  396. $(PRINTF) "%s" "[tcprewrite] Skip bcast test: "
  397. $(PRINTF) "%s\n" "*** [tcprewrite] Skip bcast test: " >>test.log
  398. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -b -s 55 \
  399. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  400. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1
  401. if WORDS_BIGENDIAN
  402. diff test.$@ test.$@1 >>test.log 2>&1
  403. else
  404. diff test2.$@ test.$@1 >>test.log 2>&1
  405. endif
  406. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  407. rewrite_dltuser:
  408. $(PRINTF) "%s" "[tcprewrite] DLT User test: "
  409. $(PRINTF) "%s\n" "*** [tcprewrite] DLT User test: " >>test.log
  410. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --dlt=user \
  411. --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 >>test.log 2>&1
  412. if WORDS_BIGENDIAN
  413. diff test.$@ test.$@1 >>test.log 2>&1
  414. else
  415. diff test2.$@ test.$@1 >>test.log 2>&1
  416. endif
  417. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  418. rewrite_dlthdlc:
  419. $(PRINTF) "%s" "[tcprewrite] DLT Cisco HDLC test: "
  420. $(PRINTF) "%s\n" "*** [tcprewrite] DLT Cisco HDLC test: " >>test.log
  421. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --dlt=hdlc \
  422. --hdlc-control=0 --hdlc-address=0x0F >>test.log 2>&1
  423. if WORDS_BIGENDIAN
  424. diff test.$@ test.$@1 >>test.log 2>&1
  425. else
  426. diff test2.$@ test.$@1 >>test.log 2>&1
  427. endif
  428. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  429. rewrite_vlandel:
  430. $(PRINTF) "%s" "[tcprewrite] VLAN Delete test: "
  431. $(PRINTF) "%s\n" "*** [tcprewrite] VLAN Delete test: " >>test.log
  432. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.rewrite_config -o test.$@1 \
  433. --enet-vlan=del >>test.log 2>&1
  434. if WORDS_BIGENDIAN
  435. diff test.$@ test.$@1 >>test.log 2>&1
  436. else
  437. diff test2.$@ test.$@1 >>test.log 2>&1
  438. endif
  439. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  440. rewrite_efcs:
  441. $(PRINTF) "%s" "[tcprewrite] Remove EFCS: "
  442. $(PRINTF) "%s\n" "*** [tcprewrite] Remove EFCS: " >>test.log
  443. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --efcs >>test.log 2>&1
  444. if WORDS_BIGENDIAN
  445. diff test.$@ test.$@1 >>test.log 2>&1
  446. else
  447. diff test2.$@ test.$@1 >>test.log 2>&1
  448. endif
  449. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  450. rewrite_1ttl:
  451. $(PRINTF) "%s" "[tcprewrite] Force TTL: "
  452. $(PRINTF) "%s\n" "*** [tcprewrite] Force TTL: " >>test.log
  453. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=58 >>test.log 2>&1
  454. if WORDS_BIGENDIAN
  455. diff test.$@ test.$@1 >>test.log 2>&1
  456. else
  457. diff test2.$@ test.$@1 >>test.log 2>&1
  458. endif
  459. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  460. rewrite_2ttl:
  461. $(PRINTF) "%s" "[tcprewrite] Increase TTL: "
  462. $(PRINTF) "%s\n" "*** [tcprewrite] Increase TTL: " >>test.log
  463. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=+58 >>test.log 2>&1
  464. if WORDS_BIGENDIAN
  465. diff test.$@ test.$@1 >>test.log 2>&1
  466. else
  467. diff test2.$@ test.$@1 >>test.log 2>&1
  468. endif
  469. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  470. rewrite_3ttl:
  471. $(PRINTF) "%s" "[tcprewrite] Reduce TTL: "
  472. $(PRINTF) "%s\n" "*** [tcprewrite] Reduce TTL: " >>test.log
  473. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=-58 >>test.log 2>&1
  474. if WORDS_BIGENDIAN
  475. diff test.$@ test.$@1 >>test.log 2>&1
  476. else
  477. diff test2.$@ test.$@1 >>test.log 2>&1
  478. endif
  479. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  480. rewrite_tos:
  481. $(PRINTF) "%s" "[tcprewrite] TOS test: "
  482. $(PRINTF) "%s\n" "*** [tcprewrite] TOS test: " >>test.log
  483. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --tos=50 >>test.log 2>&1
  484. if WORDS_BIGENDIAN
  485. diff test.$@ test.$@1 >>test.log 2>&1
  486. else
  487. diff test2.$@ test.$@1 >>test.log 2>&1
  488. endif
  489. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  490. rewrite_mtutrunc:
  491. $(PRINTF) "%s" "[tcprewrite] MTU Truncate test: "
  492. $(PRINTF) "%s\n" "*** [tcprewrite] MTU Truncate test: " >>test.log
  493. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --mtu-trunc --mtu=300 >>test.log 2>&1
  494. if WORDS_BIGENDIAN
  495. diff test.$@ test.$@1 >>test.log 2>&1
  496. else
  497. diff test2.$@ test.$@1 >>test.log 2>&1
  498. endif
  499. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  500. rewrite_l7fuzzing:
  501. $(PRINTF) "%s" "[tcprewrite] L7 fuzzing test: "
  502. $(PRINTF) "%s\n" "*** [tcprewrite] L7 fuzzing test: " >>test.log
  503. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --fuzz-seed=42 >>test.log 2>&1
  504. if WORDS_BIGENDIAN
  505. diff test.$@ test.$@1 >>test.log 2>&1
  506. else
  507. diff test2.$@ test.$@1 >>test.log 2>&1
  508. endif
  509. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  510. replay_pps:
  511. $(PRINTF) "%s" "[tcpreplay] Packets/sec test: "
  512. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log
  513. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1
  514. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  515. replay_rate:
  516. $(PRINTF) "%s" "[tcpreplay] Mbps test: "
  517. $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log
  518. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1
  519. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  520. replay_multi:
  521. $(PRINTF) "%s" "[tcpreplay] Multiplier test: "
  522. $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log
  523. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -x 25.0 test.pcap >>test.log 2>&1
  524. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  525. replay_pps_multi:
  526. $(PRINTF) "%s" "[tcpreplay] Packets/sec Multiplier test: "
  527. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec Multiplier test: " >>test.log
  528. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 100 --pps-multi=5 test.pcap >>test.log 2>&1
  529. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  530. replay_top:
  531. $(PRINTF) "%s" "[tcpreplay] Topspeed test: "
  532. $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log
  533. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  534. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  535. replay_precache:
  536. $(PRINTF) "%s" "[tcpreplay] Precache test: "
  537. $(PRINTF) "%s\n" "*** [tcpreplay] Precache test: " >>test.log
  538. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --preload-pcap test.pcap >>test.log 2>&1
  539. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  540. datadump_mode:
  541. $(PRINTF) "%s" "[tcpreplay] Data dump test: "
  542. $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log
  543. $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -I $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1
  544. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  545. replay_config:
  546. $(PRINTF) "%s" "[tcpreplay] Config file/VLAN add test: "
  547. $(PRINTF) "%s\n" "*** [tcpreplay] Config file/VLAN add test: " >>test.log
  548. $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1
  549. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  550. replay_dualfile:
  551. $(PRINTF) "%s" "[tcpreplay] Dual file test: "
  552. $(PRINTF) "%s\n" "*** [tcpreplay] Dual file test: " >>test.log
  553. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -I $(nic2) --dualfile test.pcap test.pcap >>test.log 2>&1
  554. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  555. replay_maxsleep:
  556. $(PRINTF) "%s" "[tcpreplay] Maximum sleep test: "
  557. $(PRINTF) "%s\n" "*** [tcpreplay] Maximum sleep test: " >>test.log
  558. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --maxsleep=20 test.pcap test.pcap >>test.log 2>&1
  559. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  560. clean:
  561. rm -f *1 test.log core* *~ primary.data secondary.data
  562. distclean: clean
  563. rm -f Makefile config
  564. maintainer-clean: distclean