tcpreplay_opts.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpreplay_opts.h)
  4. *
  5. * It has been AutoGen-ed
  6. * From the definitions ../../src/tcpreplay_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 42:1:17 templates.
  10. *
  11. * AutoOpts is a copyrighted work. This header file is not encumbered
  12. * by AutoOpts licensing, but is provided under the licensing terms chosen
  13. * by the tcpreplay author or copyright holder. AutoOpts is
  14. * licensed under the terms of the LGPL. The redistributable library
  15. * (``libopts'') is licensed under the terms of either the LGPL or, at the
  16. * users discretion, the BSD license. See the AutoOpts and/or libopts sources
  17. * for details.
  18. *
  19. * The tcpreplay program is copyrighted and licensed
  20. * under the following terms:
  21. *
  22. * Copyright (C) 2000-2022 Aaron Turner and Fred Klassen, all rights reserved.
  23. * This is free software. It is licensed for use, modification and
  24. * redistribution under the terms of the GNU General Public License,
  25. * version 3 or later <http://gnu.org/licenses/gpl.html>
  26. *
  27. * tcpreplay is free software: you can redistribute it and/or modify it
  28. * under the terms of the GNU General Public License as published by the
  29. * Free Software Foundation, either version 3 of the License, or
  30. * (at your option) any later version.
  31. *
  32. * tcpreplay is distributed in the hope that it will be useful, but
  33. * WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  35. * See the GNU General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU General Public License along
  38. * with this program. If not, see <http://www.gnu.org/licenses/>.
  39. */
  40. /**
  41. * This file contains the programmatic interface to the Automated
  42. * Options generated for the tcpreplay program.
  43. * These macros are documented in the AutoGen info file in the
  44. * "AutoOpts" chapter. Please refer to that doc for usage help.
  45. */
  46. #ifndef AUTOOPTS_TCPREPLAY_OPTS_H_GUARD
  47. #define AUTOOPTS_TCPREPLAY_OPTS_H_GUARD 1
  48. #include "config.h"
  49. #include <autoopts/options.h>
  50. #include <stdarg.h>
  51. #include <stdnoreturn.h>
  52. /**
  53. * Ensure that the library used for compiling this generated header is at
  54. * least as new as the version current when the header template was released
  55. * (not counting patch version increments). Also ensure that the oldest
  56. * tolerable version is at least as old as what was current when the header
  57. * template was released.
  58. */
  59. #define AO_TEMPLATE_VERSION 172033
  60. #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  61. || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
  62. # error option template version mismatches autoopts/options.h header
  63. Choke Me.
  64. #endif
  65. #if GCC_VERSION > 40400
  66. #define NOT_REACHED __builtin_unreachable();
  67. #else
  68. #define NOT_REACHED
  69. #endif
  70. /**
  71. * Enumeration of each option type for tcpreplay
  72. */
  73. typedef enum {
  74. INDEX_OPT_DBUG = 0,
  75. INDEX_OPT_QUIET = 1,
  76. INDEX_OPT_TIMER = 2,
  77. INDEX_OPT_MAXSLEEP = 3,
  78. INDEX_OPT_VERBOSE = 4,
  79. INDEX_OPT_DECODE = 5,
  80. INDEX_OPT_PRELOAD_PCAP = 6,
  81. INDEX_OPT_CACHEFILE = 7,
  82. INDEX_OPT_DUALFILE = 8,
  83. INDEX_OPT_INTF1 = 9,
  84. INDEX_OPT_INTF2 = 10,
  85. INDEX_OPT_LISTNICS = 11,
  86. INDEX_OPT_LOOP = 12,
  87. INDEX_OPT_LOOPDELAY_MS = 13,
  88. INDEX_OPT_PKTLEN = 14,
  89. INDEX_OPT_LIMIT = 15,
  90. INDEX_OPT_DURATION = 16,
  91. INDEX_OPT_MULTIPLIER = 17,
  92. INDEX_OPT_PPS = 18,
  93. INDEX_OPT_MBPS = 19,
  94. INDEX_OPT_TOPSPEED = 20,
  95. INDEX_OPT_ONEATATIME = 21,
  96. INDEX_OPT_PPS_MULTI = 22,
  97. INDEX_OPT_UNIQUE_IP = 23,
  98. INDEX_OPT_UNIQUE_IP_LOOPS = 24,
  99. INDEX_OPT_NETMAP = 25,
  100. INDEX_OPT_NM_DELAY = 26,
  101. INDEX_OPT_NO_FLOW_STATS = 27,
  102. INDEX_OPT_FLOW_EXPIRY = 28,
  103. INDEX_OPT_PID = 29,
  104. INDEX_OPT_STATS = 30,
  105. INDEX_OPT_VERSION = 31,
  106. INDEX_OPT_LESS_HELP = 32,
  107. INDEX_OPT_HELP = 33,
  108. INDEX_OPT_MORE_HELP = 34,
  109. INDEX_OPT_SAVE_OPTS = 35,
  110. INDEX_OPT_LOAD_OPTS = 36
  111. } teOptIndex;
  112. /** count of all options for tcpreplay */
  113. #define OPTION_CT 37
  114. /**
  115. * Interface defines for all options. Replace "n" with the UPPER_CASED
  116. * option name (as in the teOptIndex enumeration above).
  117. * e.g. HAVE_OPT(DBUG)
  118. */
  119. #define DESC(n) (tcpreplayOptions.pOptDesc[INDEX_OPT_## n])
  120. /** 'true' if an option has been specified in any way */
  121. #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
  122. /** The string argument to an option. The argument type must be \"string\". */
  123. #define OPT_ARG(n) (DESC(n).optArg.argString)
  124. /** Mask the option state revealing how an option was specified.
  125. * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
  126. * \a OPTST_DEFINED, \a OPTST_RESET or zero.
  127. */
  128. #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
  129. /** Count of option's occurrances *on the command line*. */
  130. #define COUNT_OPT(n) (DESC(n).optOccCt)
  131. /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
  132. #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
  133. /** 'true' if \a HAVE_OPT would yield 'false'. */
  134. #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
  135. /** 'true' if OPTST_DISABLED bit not set. */
  136. #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
  137. /** number of stacked option arguments.
  138. * Valid only for stacked option arguments. */
  139. #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
  140. /** stacked argument vector.
  141. * Valid only for stacked option arguments. */
  142. #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
  143. /** Reset an option. */
  144. #define CLEAR_OPT(n) STMTS( \
  145. DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
  146. if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  147. DESC(n).fOptState |= OPTST_DISABLED; \
  148. DESC(n).optCookie = NULL )
  149. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  150. /**
  151. * Enumeration of tcpreplay exit codes
  152. */
  153. typedef enum {
  154. TCPREPLAY_EXIT_SUCCESS = 0,
  155. TCPREPLAY_EXIT_FAILURE = 1,
  156. TCPREPLAY_EXIT_USAGE_ERROR = 64,
  157. TCPREPLAY_EXIT_NO_CONFIG_INPUT = 66,
  158. TCPREPLAY_EXIT_LIBOPTS_FAILURE = 70
  159. } tcpreplay_exit_code_t;
  160. /**
  161. * Interface defines for specific options.
  162. * @{
  163. */
  164. #define VALUE_OPT_DBUG 'd'
  165. #ifdef DEBUG
  166. #define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt)
  167. #endif /* DEBUG */
  168. #define VALUE_OPT_QUIET 'q'
  169. #define VALUE_OPT_TIMER 'T'
  170. #define VALUE_OPT_MAXSLEEP 0x1001
  171. #define OPT_VALUE_MAXSLEEP (DESC(MAXSLEEP).optArg.argInt)
  172. #define VALUE_OPT_VERBOSE 'v'
  173. #ifdef ENABLE_VERBOSE
  174. #define SET_OPT_VERBOSE STMTS( \
  175. DESC(VERBOSE).optActualIndex = 4; \
  176. DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
  177. DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \
  178. DESC(VERBOSE).fOptState |= OPTST_SET )
  179. #endif /* ENABLE_VERBOSE */
  180. #define VALUE_OPT_DECODE 'A'
  181. #define VALUE_OPT_PRELOAD_PCAP 'K'
  182. #define VALUE_OPT_CACHEFILE 'c'
  183. #define VALUE_OPT_DUALFILE '2'
  184. #define VALUE_OPT_INTF1 'i'
  185. #define VALUE_OPT_INTF2 'I'
  186. #define VALUE_OPT_LISTNICS 0x1002
  187. #define VALUE_OPT_LOOP 'l'
  188. #define OPT_VALUE_LOOP (DESC(LOOP).optArg.argInt)
  189. #define VALUE_OPT_LOOPDELAY_MS 0x1003
  190. #define OPT_VALUE_LOOPDELAY_MS (DESC(LOOPDELAY_MS).optArg.argInt)
  191. #define VALUE_OPT_PKTLEN 0x1004
  192. #define VALUE_OPT_LIMIT 'L'
  193. #define OPT_VALUE_LIMIT (DESC(LIMIT).optArg.argInt)
  194. #define VALUE_OPT_DURATION 0x1005
  195. #define OPT_VALUE_DURATION (DESC(DURATION).optArg.argInt)
  196. #define VALUE_OPT_MULTIPLIER 'x'
  197. #define VALUE_OPT_PPS 'p'
  198. #define VALUE_OPT_MBPS 'M'
  199. #define VALUE_OPT_TOPSPEED 't'
  200. #define VALUE_OPT_ONEATATIME 'o'
  201. #define VALUE_OPT_PPS_MULTI 0x1006
  202. #define OPT_VALUE_PPS_MULTI (DESC(PPS_MULTI).optArg.argInt)
  203. #define VALUE_OPT_UNIQUE_IP 0x1007
  204. #define VALUE_OPT_UNIQUE_IP_LOOPS 0x1008
  205. #define VALUE_OPT_NETMAP 0x1009
  206. #define VALUE_OPT_NM_DELAY 0x100A
  207. #ifdef HAVE_NETMAP
  208. #define OPT_VALUE_NM_DELAY (DESC(NM_DELAY).optArg.argInt)
  209. #endif /* HAVE_NETMAP */
  210. #define VALUE_OPT_NO_FLOW_STATS 0x100B
  211. #define VALUE_OPT_FLOW_EXPIRY 0x100C
  212. #define OPT_VALUE_FLOW_EXPIRY (DESC(FLOW_EXPIRY).optArg.argInt)
  213. #define VALUE_OPT_PID 'P'
  214. #define VALUE_OPT_STATS 0x100D
  215. #define OPT_VALUE_STATS (DESC(STATS).optArg.argInt)
  216. #define VALUE_OPT_VERSION 'V'
  217. #define VALUE_OPT_LESS_HELP 'h'
  218. /** option flag (value) for help-value option */
  219. #define VALUE_OPT_HELP 'H'
  220. /** option flag (value) for more-help-value option */
  221. #define VALUE_OPT_MORE_HELP '!'
  222. /** option flag (value) for save-opts-value option */
  223. #define VALUE_OPT_SAVE_OPTS 0x100E
  224. /** option flag (value) for load-opts-value option */
  225. #define VALUE_OPT_LOAD_OPTS 0x100F
  226. #define SET_OPT_SAVE_OPTS(a) STMTS( \
  227. DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
  228. DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
  229. DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
  230. /*
  231. * Interface defines not associated with particular options
  232. */
  233. #define ERRSKIP_OPTERR STMTS(tcpreplayOptions.fOptSet &= ~OPTPROC_ERRSTOP)
  234. #define ERRSTOP_OPTERR STMTS(tcpreplayOptions.fOptSet |= OPTPROC_ERRSTOP)
  235. #define RESTART_OPT(n) STMTS( \
  236. tcpreplayOptions.curOptIdx = (n); \
  237. tcpreplayOptions.pzCurOpt = NULL )
  238. #define START_OPT RESTART_OPT(1)
  239. #define USAGE(c) (*tcpreplayOptions.pUsageProc)(&tcpreplayOptions, c)
  240. #ifdef __cplusplus
  241. extern "C" {
  242. #endif
  243. /* * * * * *
  244. *
  245. * Declare the tcpreplay option descriptor.
  246. */
  247. extern tOptions tcpreplayOptions;
  248. #if defined(ENABLE_NLS)
  249. # ifndef _
  250. # include <stdio.h>
  251. # ifndef HAVE_GETTEXT
  252. extern char * gettext(char const *);
  253. # else
  254. # include <libintl.h>
  255. # endif
  256. # ifndef ATTRIBUTE_FORMAT_ARG
  257. # define ATTRIBUTE_FORMAT_ARG(_a)
  258. # endif
  259. static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
  260. static inline char* aoGetsText(char const* pz) {
  261. if (pz == NULL) return NULL;
  262. return (char*)gettext(pz);
  263. }
  264. # define _(s) aoGetsText(s)
  265. # endif /* _() */
  266. # define OPT_NO_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet |= \
  267. OPTPROC_NXLAT_OPT_CFG;)
  268. # define OPT_NO_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet |= \
  269. OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
  270. # define OPT_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet &= \
  271. ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
  272. # define OPT_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet &= \
  273. ~OPTPROC_NXLAT_OPT;)
  274. #else /* ENABLE_NLS */
  275. # define OPT_NO_XLAT_CFG_NAMES
  276. # define OPT_NO_XLAT_OPT_NAMES
  277. # define OPT_XLAT_CFG_NAMES
  278. # define OPT_XLAT_OPT_NAMES
  279. # ifndef _
  280. # define _(_s) _s
  281. # endif
  282. #endif /* ENABLE_NLS */
  283. #ifdef __cplusplus
  284. }
  285. #endif
  286. #endif /* AUTOOPTS_TCPREPLAY_OPTS_H_GUARD */
  287. /* tcpreplay_opts.h ends here */