Makefile.am 23 KB

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