Makefile.am 21 KB

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