tcprewrite_opts.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcprewrite_opts.h)
  4. *
  5. * It has been AutoGen-ed
  6. * From the definitions tcprewrite_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 41:0:16 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 tcprewrite 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 tcprewrite program is copyrighted and licensed
  20. * under the following terms:
  21. *
  22. * Copyright (C) 2000-2017 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. * tcprewrite 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. * tcprewrite 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 tcprewrite 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_TCPREWRITE_OPTS_H_GUARD
  47. #define AUTOOPTS_TCPREWRITE_OPTS_H_GUARD 1
  48. #include "config.h"
  49. #include <autoopts/options.h>
  50. /**
  51. * Ensure that the library used for compiling this generated header is at
  52. * least as new as the version current when the header template was released
  53. * (not counting patch version increments). Also ensure that the oldest
  54. * tolerable version is at least as old as what was current when the header
  55. * template was released.
  56. */
  57. #define AO_TEMPLATE_VERSION 167936
  58. #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  59. || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
  60. # error option template version mismatches autoopts/options.h header
  61. Choke Me.
  62. #endif
  63. /**
  64. * Enumeration of each option type for tcprewrite
  65. */
  66. typedef enum {
  67. INDEX_OPT_PORTMAP = 1,
  68. INDEX_OPT_SEED = 2,
  69. INDEX_OPT_PNAT = 3,
  70. INDEX_OPT_SRCIPMAP = 4,
  71. INDEX_OPT_DSTIPMAP = 5,
  72. INDEX_OPT_ENDPOINTS = 6,
  73. INDEX_OPT_SKIPBROADCAST = 7,
  74. INDEX_OPT_FIXCSUM = 8,
  75. INDEX_OPT_MTU = 9,
  76. INDEX_OPT_MTU_TRUNC = 10,
  77. INDEX_OPT_EFCS = 11,
  78. INDEX_OPT_TTL = 12,
  79. INDEX_OPT_TOS = 13,
  80. INDEX_OPT_TCLASS = 14,
  81. INDEX_OPT_FLOWLABEL = 15,
  82. INDEX_OPT_FIXLEN = 16,
  83. INDEX_OPT_FUZZ_SEED = 17,
  84. INDEX_OPT_SKIPL2BROADCAST = 18,
  85. INDEX_OPT_DLT = 19,
  86. INDEX_OPT_ENET_DMAC = 20,
  87. INDEX_OPT_ENET_SMAC = 21,
  88. INDEX_OPT_ENET_SUBSMAC = 22,
  89. INDEX_OPT_ENET_MAC_SEED = 23,
  90. INDEX_OPT_ENET_MAC_SEED_KEEP_BYTES = 24,
  91. INDEX_OPT_ENET_VLAN = 25,
  92. INDEX_OPT_ENET_VLAN_TAG = 26,
  93. INDEX_OPT_ENET_VLAN_CFI = 27,
  94. INDEX_OPT_ENET_VLAN_PRI = 28,
  95. INDEX_OPT_HDLC_CONTROL = 29,
  96. INDEX_OPT_HDLC_ADDRESS = 30,
  97. INDEX_OPT_USER_DLT = 31,
  98. INDEX_OPT_USER_DLINK = 32,
  99. INDEX_OPT_DBUG = 33,
  100. INDEX_OPT_INFILE = 34,
  101. INDEX_OPT_OUTFILE = 35,
  102. INDEX_OPT_CACHEFILE = 36,
  103. INDEX_OPT_VERBOSE = 37,
  104. INDEX_OPT_DECODE = 38,
  105. INDEX_OPT_FRAGROUTE = 39,
  106. INDEX_OPT_FRAGDIR = 40,
  107. INDEX_OPT_SKIP_SOFT_ERRORS = 41,
  108. INDEX_OPT_VERSION = 42,
  109. INDEX_OPT_LESS_HELP = 43,
  110. INDEX_OPT_HELP = 44,
  111. INDEX_OPT_MORE_HELP = 45,
  112. INDEX_OPT_SAVE_OPTS = 46,
  113. INDEX_OPT_LOAD_OPTS = 47
  114. } teOptIndex;
  115. /** count of all options for tcprewrite */
  116. #define OPTION_CT 48
  117. /**
  118. * Interface defines for all options. Replace "n" with the UPPER_CASED
  119. * option name (as in the teOptIndex enumeration above).
  120. * e.g. HAVE_OPT(TCPEDIT)
  121. */
  122. #define DESC(n) (tcprewriteOptions.pOptDesc[INDEX_OPT_## n])
  123. /** 'true' if an option has been specified in any way */
  124. #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
  125. /** The string argument to an option. The argument type must be \"string\". */
  126. #define OPT_ARG(n) (DESC(n).optArg.argString)
  127. /** Mask the option state revealing how an option was specified.
  128. * It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
  129. * \a OPTST_DEFINED, \a OPTST_RESET or zero.
  130. */
  131. #define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
  132. /** Count of option's occurrances *on the command line*. */
  133. #define COUNT_OPT(n) (DESC(n).optOccCt)
  134. /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
  135. #define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
  136. /** 'true' if \a HAVE_OPT would yield 'false'. */
  137. #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
  138. /** 'true' if OPTST_DISABLED bit not set. */
  139. #define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
  140. /** number of stacked option arguments.
  141. * Valid only for stacked option arguments. */
  142. #define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
  143. /** stacked argument vector.
  144. * Valid only for stacked option arguments. */
  145. #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
  146. /** Reset an option. */
  147. #define CLEAR_OPT(n) STMTS( \
  148. DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \
  149. if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
  150. DESC(n).fOptState |= OPTST_DISABLED; \
  151. DESC(n).optCookie = NULL )
  152. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  153. /**
  154. * Enumeration of tcprewrite exit codes
  155. */
  156. typedef enum {
  157. TCPREWRITE_EXIT_SUCCESS = 0,
  158. TCPREWRITE_EXIT_FAILURE = 1,
  159. TCPREWRITE_EXIT_USAGE_ERROR = 64,
  160. TCPREWRITE_EXIT_NO_CONFIG_INPUT = 66,
  161. TCPREWRITE_EXIT_LIBOPTS_FAILURE = 70
  162. } tcprewrite_exit_code_t;
  163. /**
  164. * Interface defines for specific options.
  165. * @{
  166. */
  167. #define VALUE_OPT_PORTMAP 'r'
  168. #define VALUE_OPT_SEED 's'
  169. #define OPT_VALUE_SEED (DESC(SEED).optArg.argInt)
  170. #define VALUE_OPT_PNAT 'N'
  171. #define VALUE_OPT_SRCIPMAP 'S'
  172. #define VALUE_OPT_DSTIPMAP 'D'
  173. #define VALUE_OPT_ENDPOINTS 'e'
  174. #define VALUE_OPT_SKIPBROADCAST 'b'
  175. #define VALUE_OPT_FIXCSUM 'C'
  176. #define VALUE_OPT_MTU 'm'
  177. #define OPT_VALUE_MTU (DESC(MTU).optArg.argInt)
  178. #define VALUE_OPT_MTU_TRUNC 0x1001
  179. #define VALUE_OPT_EFCS 'E'
  180. #define VALUE_OPT_TTL 0x1002
  181. #define VALUE_OPT_TOS 0x1003
  182. #define OPT_VALUE_TOS (DESC(TOS).optArg.argInt)
  183. #define VALUE_OPT_TCLASS 0x1004
  184. #define OPT_VALUE_TCLASS (DESC(TCLASS).optArg.argInt)
  185. #define VALUE_OPT_FLOWLABEL 0x1005
  186. #define OPT_VALUE_FLOWLABEL (DESC(FLOWLABEL).optArg.argInt)
  187. #define VALUE_OPT_FIXLEN 'F'
  188. #define VALUE_OPT_FUZZ_SEED 0x1006
  189. #define OPT_VALUE_FUZZ_SEED (DESC(FUZZ_SEED).optArg.argInt)
  190. #define VALUE_OPT_SKIPL2BROADCAST 0x1007
  191. #define VALUE_OPT_DLT 0x1008
  192. #define VALUE_OPT_ENET_DMAC 0x1009
  193. #define VALUE_OPT_ENET_SMAC 0x100A
  194. #define VALUE_OPT_ENET_SUBSMAC 0x100B
  195. #define VALUE_OPT_ENET_MAC_SEED 0x100C
  196. #define OPT_VALUE_ENET_MAC_SEED (DESC(ENET_MAC_SEED).optArg.argInt)
  197. #define VALUE_OPT_ENET_MAC_SEED_KEEP_BYTES 0x100D
  198. #define OPT_VALUE_ENET_MAC_SEED_KEEP_BYTES (DESC(ENET_MAC_SEED_KEEP_BYTES).optArg.argInt)
  199. #define VALUE_OPT_ENET_VLAN 0x100E
  200. #define VALUE_OPT_ENET_VLAN_TAG 0x100F
  201. #define OPT_VALUE_ENET_VLAN_TAG (DESC(ENET_VLAN_TAG).optArg.argInt)
  202. #define VALUE_OPT_ENET_VLAN_CFI 0x1010
  203. #define OPT_VALUE_ENET_VLAN_CFI (DESC(ENET_VLAN_CFI).optArg.argInt)
  204. #define VALUE_OPT_ENET_VLAN_PRI 0x1011
  205. #define OPT_VALUE_ENET_VLAN_PRI (DESC(ENET_VLAN_PRI).optArg.argInt)
  206. #define VALUE_OPT_HDLC_CONTROL 0x1012
  207. #define OPT_VALUE_HDLC_CONTROL (DESC(HDLC_CONTROL).optArg.argInt)
  208. #define VALUE_OPT_HDLC_ADDRESS 0x1013
  209. #define OPT_VALUE_HDLC_ADDRESS (DESC(HDLC_ADDRESS).optArg.argInt)
  210. #define VALUE_OPT_USER_DLT 0x1014
  211. #define OPT_VALUE_USER_DLT (DESC(USER_DLT).optArg.argInt)
  212. #define VALUE_OPT_USER_DLINK 0x1015
  213. #define VALUE_OPT_DBUG 'd'
  214. #ifdef DEBUG
  215. #define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt)
  216. #endif /* DEBUG */
  217. #define VALUE_OPT_INFILE 'i'
  218. #define VALUE_OPT_OUTFILE 'o'
  219. #define VALUE_OPT_CACHEFILE 'c'
  220. #define SET_OPT_CACHEFILE(a) STMTS( \
  221. DESC(CACHEFILE).optActualIndex = 36; \
  222. DESC(CACHEFILE).optActualValue = VALUE_OPT_CACHEFILE; \
  223. DESC(CACHEFILE).fOptState &= OPTST_PERSISTENT_MASK; \
  224. DESC(CACHEFILE).fOptState |= OPTST_SET; \
  225. DESC(CACHEFILE).optArg.argString = (a); \
  226. (*(DESC(CACHEFILE).pOptProc))(&tcprewriteOptions, \
  227. tcprewriteOptions.pOptDesc + 36); )
  228. #define VALUE_OPT_VERBOSE 'v'
  229. #ifdef ENABLE_VERBOSE
  230. #define SET_OPT_VERBOSE STMTS( \
  231. DESC(VERBOSE).optActualIndex = 37; \
  232. DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
  233. DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \
  234. DESC(VERBOSE).fOptState |= OPTST_SET )
  235. #endif /* ENABLE_VERBOSE */
  236. #define VALUE_OPT_DECODE 'A'
  237. #define VALUE_OPT_FRAGROUTE 0x1016
  238. #define VALUE_OPT_FRAGDIR 0x1017
  239. #define VALUE_OPT_SKIP_SOFT_ERRORS 0x1018
  240. #define VALUE_OPT_VERSION 'V'
  241. #define VALUE_OPT_LESS_HELP 'h'
  242. /** option flag (value) for help-value option */
  243. #define VALUE_OPT_HELP 'H'
  244. /** option flag (value) for more-help-value option */
  245. #define VALUE_OPT_MORE_HELP '!'
  246. /** option flag (value) for save-opts-value option */
  247. #define VALUE_OPT_SAVE_OPTS 0x1019
  248. /** option flag (value) for load-opts-value option */
  249. #define VALUE_OPT_LOAD_OPTS 0x101A
  250. #define SET_OPT_SAVE_OPTS(a) STMTS( \
  251. DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
  252. DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
  253. DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
  254. /*
  255. * Interface defines not associated with particular options
  256. */
  257. #define ERRSKIP_OPTERR STMTS(tcprewriteOptions.fOptSet &= ~OPTPROC_ERRSTOP)
  258. #define ERRSTOP_OPTERR STMTS(tcprewriteOptions.fOptSet |= OPTPROC_ERRSTOP)
  259. #define RESTART_OPT(n) STMTS( \
  260. tcprewriteOptions.curOptIdx = (n); \
  261. tcprewriteOptions.pzCurOpt = NULL )
  262. #define START_OPT RESTART_OPT(1)
  263. #define USAGE(c) (*tcprewriteOptions.pUsageProc)(&tcprewriteOptions, c)
  264. #ifdef __cplusplus
  265. extern "C" {
  266. #endif
  267. /* * * * * *
  268. *
  269. * Declare the tcprewrite option descriptor.
  270. */
  271. extern tOptions tcprewriteOptions;
  272. #if defined(ENABLE_NLS)
  273. # ifndef _
  274. # include <stdio.h>
  275. # ifndef HAVE_GETTEXT
  276. extern char * gettext(char const *);
  277. # else
  278. # include <libintl.h>
  279. # endif
  280. # ifndef ATTRIBUTE_FORMAT_ARG
  281. # define ATTRIBUTE_FORMAT_ARG(_a)
  282. # endif
  283. static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
  284. static inline char* aoGetsText(char const* pz) {
  285. if (pz == NULL) return NULL;
  286. return (char*)gettext(pz);
  287. }
  288. # define _(s) aoGetsText(s)
  289. # endif /* _() */
  290. # define OPT_NO_XLAT_CFG_NAMES STMTS(tcprewriteOptions.fOptSet |= \
  291. OPTPROC_NXLAT_OPT_CFG;)
  292. # define OPT_NO_XLAT_OPT_NAMES STMTS(tcprewriteOptions.fOptSet |= \
  293. OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
  294. # define OPT_XLAT_CFG_NAMES STMTS(tcprewriteOptions.fOptSet &= \
  295. ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
  296. # define OPT_XLAT_OPT_NAMES STMTS(tcprewriteOptions.fOptSet &= \
  297. ~OPTPROC_NXLAT_OPT;)
  298. #else /* ENABLE_NLS */
  299. # define OPT_NO_XLAT_CFG_NAMES
  300. # define OPT_NO_XLAT_OPT_NAMES
  301. # define OPT_XLAT_CFG_NAMES
  302. # define OPT_XLAT_OPT_NAMES
  303. # ifndef _
  304. # define _(_s) _s
  305. # endif
  306. #endif /* ENABLE_NLS */
  307. #ifdef __cplusplus
  308. }
  309. #endif
  310. #endif /* AUTOOPTS_TCPREWRITE_OPTS_H_GUARD */
  311. /* tcprewrite_opts.h ends here */