Makefile.am 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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
  132. prep_config:
  133. $(PRINTF) "%s" "[tcpprep] Config mode test: "
  134. $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log
  135. $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 >>test.log 2>&1
  136. diff test.$@ test.$@1 >>test.log 2>&1
  137. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  138. auto_router:
  139. $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: "
  140. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log
  141. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router >>test.log 2>&1
  142. diff test.$@ test.$@1 >>test.log 2>&1
  143. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  144. auto_bridge:
  145. $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: "
  146. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log
  147. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge >>test.log 2>&1
  148. diff test.$@ test.$@1 >>test.log 2>&1
  149. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  150. auto_client:
  151. $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: "
  152. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log
  153. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client >>test.log 2>&1
  154. diff test.$@ test.$@1 >>test.log 2>&1
  155. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  156. auto_server:
  157. $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: "
  158. $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log
  159. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server >>test.log 2>&1
  160. diff test.$@ test.$@1 >>test.log 2>&1
  161. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  162. auto_first:
  163. $(PRINTF) "%s" "[tcpprep] Auto/First mode test: "
  164. $(PRINTF) "%s\n" "*** [tcpprep] Auto/First mode test: " >>test.log
  165. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a first >>test.log 2>&1
  166. diff test.$@ test.$@1 >>test.log 2>&1
  167. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  168. regex:
  169. $(PRINTF) "%s" "[tcpprep] Regex mode test: "
  170. $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log
  171. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' >>test.log 2>&1
  172. diff test.$@ test.$@1 >>test.log 2>&1
  173. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  174. cidr:
  175. $(PRINTF) "%s" "[tcpprep] CIDR mode test: "
  176. $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log
  177. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' >>test.log 2>&1
  178. diff test.$@ test.$@1 >>test.log 2>&1
  179. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  180. port:
  181. $(PRINTF) "%s" "[tcpprep] Port mode test: "
  182. $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log
  183. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p >>test.log 2>&1
  184. diff test.$@ test.$@1 >>test.log 2>&1
  185. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  186. mac:
  187. $(PRINTF) "%s" "[tcpprep] MAC mode test: "
  188. $(PRINTF) "%s\n" "*** [tcpprep] MAC mode test: " >>test.log
  189. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce >>test.log 2>&1
  190. diff test.$@ test.$@1 >>test.log 2>&1
  191. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  192. comment:
  193. $(PRINTF) "%s" "[tcpprep] Comment mode test: "
  194. $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log
  195. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p >>test.log 2>&1
  196. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  197. print_comment:
  198. $(PRINTF) "%s" "[tcpprep] Print comment mode test: "
  199. $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log
  200. $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 >>test.log 2>&1
  201. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  202. print_info:
  203. $(PRINTF) "%s" "[tcpprep] Print info mode test: "
  204. $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log
  205. $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 >>test.log 2>&1
  206. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  207. regex_reverse:
  208. $(PRINTF) "%s" "[tcpprep] Regex reverse mode test: "
  209. $(PRINTF) "%s\n" "*** [tcpprep] Regex reverse mode test: " >>test.log
  210. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' --reverse >>test.log 2>&1
  211. diff test.$@ test.$@1 >>test.log 2>&1
  212. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  213. cidr_reverse:
  214. $(PRINTF) "%s" "[tcpprep] CIDR reverse mode test: "
  215. $(PRINTF) "%s\n" "*** [tcpprep] CIDR reverse mode test: " >>test.log
  216. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' --reverse >>test.log 2>&1
  217. diff test.$@ test.$@1 >>test.log 2>&1
  218. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  219. mac_reverse:
  220. $(PRINTF) "%s" "[tcpprep] MAC reverse mode test: "
  221. $(PRINTF) "%s\n" "*** [tcpprep] MAC reverse mode test: " >>test.log
  222. $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce --reverse >>test.log 2>&1
  223. diff test.$@ test.$@1 >>test.log 2>&1
  224. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  225. replay_basic:
  226. $(PRINTF) "%s" "[tcpreplay] Basic test: "
  227. $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log
  228. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  229. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  230. replay_cache:
  231. $(PRINTF) "%s" "[tcpreplay] Cache test: "
  232. $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log
  233. $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1
  234. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  235. replay_accurate:
  236. $(PRINTF) "%s" "[tcpreplay] Accurate test: "
  237. $(PRINTF) "%s\n" "*** [tcpreplay] Accurate test: " >>test.log
  238. $(TCPREPLAY) $(ENABLE_DEBUG) -a -i $(nic1) test.pcap >>test.log 2>&1
  239. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  240. rewrite_portmap:
  241. $(PRINTF) "%s" "[tcprewrite] Portmap test: "
  242. $(PRINTF) "%s\n" "*** [tcprewrite] Portmap test: " >>test.log
  243. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_portmap1 -r 80:8080 >>test.log 2>&1
  244. if WORDS_BIGENDIAN
  245. diff test.$@ test.$@1 >>test.log 2>&1
  246. else
  247. diff test2.$@ test.$@1 >>test.log 2>&1
  248. endif
  249. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  250. rewrite_endpoint:
  251. $(PRINTF) "%s" "[tcprewrite] Endpoint test: "
  252. $(PRINTF) "%s\n" "*** [tcprewrite] Endpoint test: " >>test.log
  253. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_endpoint1 -e 10.10.0.1:10.10.0.2 \
  254. -c test.auto_router >>test.log 2>&1
  255. if WORDS_BIGENDIAN
  256. diff test.$@ test.$@1 >>test.log 2>&1
  257. else
  258. diff test2.$@ test.$@1 >>test.log 2>&1
  259. endif
  260. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  261. rewrite_pnat:
  262. $(PRINTF) "%s" "[tcprewrite] Pseudo NAT test: "
  263. $(PRINTF) "%s\n" "*** [tcprewrite] Pseudo NAT test: " >>test.log
  264. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_pnat1 \
  265. -N 216.27.178.0/24:172.16.0.0/24 >>test.log 2>&1
  266. if WORDS_BIGENDIAN
  267. diff test.$@ test.$@1 >>test.log 2>&1
  268. else
  269. diff test2.$@ test.$@1 >>test.log 2>&1
  270. endif
  271. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  272. rewrite_mac:
  273. $(PRINTF) "%s" "[tcprewrite] Src/Dst MAC test: "
  274. $(PRINTF) "%s\n" "*** [tcprewrite] Src/Dst MAC test: " >>test.log
  275. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_mac1 \
  276. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  277. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1
  278. if WORDS_BIGENDIAN
  279. diff test.$@ test.$@1 >>test.log 2>&1
  280. else
  281. diff test2.$@ test.$@1 >>test.log 2>&1
  282. endif
  283. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  284. rewrite_trunc:
  285. $(PRINTF) "%s" "[tcprewrite] Truncate test: "
  286. $(PRINTF) "%s\n" "*** [tcprewrite] Truncate test: " >>test.log
  287. $(TCPREWRITE) $(ENABLE_DEBUG) -F trunc -i test.pcap -o test.rewrite_trunc1 >>test.log 2>&1
  288. if WORDS_BIGENDIAN
  289. diff test.$@ test.$@1 >>test.log 2>&1
  290. else
  291. diff test2.$@ test.$@1 >>test.log 2>&1
  292. endif
  293. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  294. rewrite_pad:
  295. $(PRINTF) "%s" "[tcprewrite] Pad test: "
  296. $(PRINTF) "%s\n" "*** [tcprewrite] Pad test: " >>test.log
  297. $(TCPREWRITE) $(ENABLE_DEBUG) -F pad -i test.pcap -o test.rewrite_pad1 >>test.log 2>&1
  298. if WORDS_BIGENDIAN
  299. diff test.$@ test.$@1 >>test.log 2>&1
  300. else
  301. diff test2.$@ test.$@1 >>test.log 2>&1
  302. endif
  303. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  304. rewrite_seed:
  305. $(PRINTF) "%s" "[tcprewrite] Seed IP test: "
  306. $(PRINTF) "%s\n" "*** [tcprewrite] Seed IP test: " >>test.log
  307. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_seed1 -s 55 >>test.log 2>&1
  308. if WORDS_BIGENDIAN
  309. diff test.$@ test.$@1 >>test.log 2>&1
  310. else
  311. diff test2.$@ test.$@1 >>test.log 2>&1
  312. endif
  313. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  314. rewrite_layer2:
  315. $(PRINTF) "%s" "[tcprewrite] Layer2 test: "
  316. $(PRINTF) "%s\n" "*** [tcprewrite] Layer2 test: " >>test.log
  317. $(TCPREWRITE) $(ENABLE_DEBUG) --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 \
  318. -i test.pcap -o test.rewrite_layer21 >>test.log 2>&1
  319. if WORDS_BIGENDIAN
  320. diff test.$@ test.$@1 >>test.log 2>&1
  321. else
  322. diff test2.$@ test.$@1 >>test.log 2>&1
  323. endif
  324. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  325. rewrite_config:
  326. $(PRINTF) "%s" "[tcprewrite] Config/VLAN Add test: "
  327. $(PRINTF) "%s\n" "*** [tcprewrite] Config/VLAN Add test: " >>test.log
  328. $(TCPREWRITE) $(ENABLE_DEBUG) --load-opts config >>test.log 2>&1
  329. if WORDS_BIGENDIAN
  330. diff test.$@ test.$@1 >>test.log 2>&1
  331. else
  332. diff test2.$@ test.$@1 >>test.log 2>&1
  333. endif
  334. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  335. rewrite_skip:
  336. $(PRINTF) "%s" "[tcprewrite] Skip bcast test: "
  337. $(PRINTF) "%s\n" "*** [tcprewrite] Skip bcast test: " >>test.log
  338. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_skip1 -b -s 55 \
  339. --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \
  340. --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1
  341. if WORDS_BIGENDIAN
  342. diff test.$@ test.$@1 >>test.log 2>&1
  343. else
  344. diff test2.$@ test.$@1 >>test.log 2>&1
  345. endif
  346. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  347. rewrite_dltuser:
  348. $(PRINTF) "%s" "[tcprewrite] DLT User test: "
  349. $(PRINTF) "%s\n" "*** [tcprewrite] DLT User test: " >>test.log
  350. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dltuser1 --dlt=user \
  351. --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 >>test.log 2>&1
  352. if WORDS_BIGENDIAN
  353. diff test.$@ test.$@1 >>test.log 2>&1
  354. else
  355. diff test2.$@ test.$@1 >>test.log 2>&1
  356. endif
  357. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  358. rewrite_dlthdlc:
  359. $(PRINTF) "%s" "[tcprewrite] DLT Cisco HDLC test: "
  360. $(PRINTF) "%s\n" "*** [tcprewrite] DLT Cisco HDLC test: " >>test.log
  361. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dlthdlc1 --dlt=hdlc \
  362. --hdlc-control=0 --hdlc-address=0x0F >>test.log 2>&1
  363. if WORDS_BIGENDIAN
  364. diff test.$@ test.$@1 >>test.log 2>&1
  365. else
  366. diff test2.$@ test.$@1 >>test.log 2>&1
  367. endif
  368. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  369. rewrite_vlandel:
  370. $(PRINTF) "%s" "[tcprewrite] VLAN Delete test: "
  371. $(PRINTF) "%s\n" "*** [tcprewrite] VLAN Delete test: " >>test.log
  372. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.rewrite_config -o test.rewrite_vlandel1 \
  373. --enet-vlan=del >>test.log 2>&1
  374. if WORDS_BIGENDIAN
  375. diff test.$@ test.$@1 >>test.log 2>&1
  376. else
  377. diff test2.$@ test.$@1 >>test.log 2>&1
  378. endif
  379. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  380. rewrite_efcs:
  381. $(PRINTF) "%s" "[tcprewrite] Remove EFCS: "
  382. $(PRINTF) "%s\n" "*** [tcprewrite] Remove EFCS: " >>test.log
  383. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_efcs1 --efcs >>test.log 2>&1
  384. if WORDS_BIGENDIAN
  385. diff test.$@ test.$@1 >>test.log 2>&1
  386. else
  387. diff test2.$@ test.$@1 >>test.log 2>&1
  388. endif
  389. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  390. rewrite_1ttl:
  391. $(PRINTF) "%s" "[tcprewrite] Force TTL: "
  392. $(PRINTF) "%s\n" "*** [tcprewrite] Force TTL: " >>test.log
  393. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=58 >>test.log 2>&1
  394. if WORDS_BIGENDIAN
  395. diff test.$@ test.$@1 >>test.log 2>&1
  396. else
  397. diff test2.$@ test.$@1 >>test.log 2>&1
  398. endif
  399. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  400. rewrite_2ttl:
  401. $(PRINTF) "%s" "[tcprewrite] Increase TTL: "
  402. $(PRINTF) "%s\n" "*** [tcprewrite] Increase TTL: " >>test.log
  403. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=+58 >>test.log 2>&1
  404. if WORDS_BIGENDIAN
  405. diff test.$@ test.$@1 >>test.log 2>&1
  406. else
  407. diff test2.$@ test.$@1 >>test.log 2>&1
  408. endif
  409. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  410. rewrite_3ttl:
  411. $(PRINTF) "%s" "[tcprewrite] Reduce TTL: "
  412. $(PRINTF) "%s\n" "*** [tcprewrite] Reduce TTL: " >>test.log
  413. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=-58 >>test.log 2>&1
  414. if WORDS_BIGENDIAN
  415. diff test.$@ test.$@1 >>test.log 2>&1
  416. else
  417. diff test2.$@ test.$@1 >>test.log 2>&1
  418. endif
  419. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  420. rewrite_tos:
  421. $(PRINTF) "%s" "[tcprewrite] TOS test: "
  422. $(PRINTF) "%s\n" "*** [tcprewrite] TOS test: " >>test.log
  423. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --tos=50 >>test.log 2>&1
  424. if WORDS_BIGENDIAN
  425. diff test.$@ test.$@1 >>test.log 2>&1
  426. else
  427. diff test2.$@ test.$@1 >>test.log 2>&1
  428. endif
  429. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  430. rewrite_mtutrunc:
  431. $(PRINTF) "%s" "[tcprewrite] MTU Truncate test: "
  432. $(PRINTF) "%s\n" "*** [tcprewrite] MTU Truncate test: " >>test.log
  433. $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --mtu-trunc --mtu=300 >>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%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  440. replay_pps:
  441. $(PRINTF) "%s" "[tcpreplay] Packets/sec test: "
  442. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log
  443. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1
  444. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  445. replay_rate:
  446. $(PRINTF) "%s" "[tcpreplay] Mbps test: "
  447. $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log
  448. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1
  449. if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi
  450. replay_multi:
  451. $(PRINTF) "%s" "[tcpreplay] Multiplier test: "
  452. $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log
  453. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -x 25.0 test.pcap >>test.log 2>&1
  454. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  455. replay_pps_multi:
  456. $(PRINTF) "%s" "[tcpreplay] Packets/sec Multiplier test: "
  457. $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec Multiplier test: " >>test.log
  458. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 100 --pps-multi=5 test.pcap >>test.log 2>&1
  459. if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi
  460. replay_top:
  461. $(PRINTF) "%s" "[tcpreplay] Topspeed test: "
  462. $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log
  463. $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1
  464. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  465. datadump_mode:
  466. $(PRINTF) "%s" "[tcpreplay] Data dump test: "
  467. $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log
  468. $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -j $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1
  469. if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi
  470. replay_config:
  471. $(PRINTF) "%s" "[tcpreplay] Config file/VLAN add test: "
  472. $(PRINTF) "%s\n" "*** [tcpreplay] Config file/VLAN add test: " >>test.log
  473. $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1
  474. if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi
  475. clean:
  476. rm -f *1 test.log core* *~ primary.data secondary.data
  477. distclean: clean
  478. rm -f Makefile config
  479. maintainer-clean: distclean