ldclt.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. #ident "ldclt @(#)ldclt.h 1.66 01/05/04"
  2. /** BEGIN COPYRIGHT BLOCK
  3. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  4. * Copyright (C) 2006 Red Hat, Inc.
  5. * All rights reserved.
  6. *
  7. * License: GPL (version 3 or any later version).
  8. * See LICENSE for details.
  9. * END COPYRIGHT BLOCK **/
  10. #ifdef HAVE_CONFIG_H
  11. # include <config.h>
  12. #endif
  13. /*
  14. FILE : ldclt.h
  15. AUTHOR : Jean-Luc SCHWING
  16. VERSION : 1.0
  17. DATE : 03 December 1998
  18. DESCRIPTION :
  19. This file is the main include file of the tool named
  20. "ldclt"
  21. LOCAL : None.
  22. HISTORY :
  23. ---------+--------------+------------------------------------------------------
  24. dd/mm/yy | Author | Comments
  25. ---------+--------------+------------------------------------------------------
  26. 03/12/98 | JL Schwing | Creation
  27. ---------+--------------+------------------------------------------------------
  28. 10/12/98 | JL Schwing | 1.2 : Add stats numbers in main_context.
  29. ---------+--------------+------------------------------------------------------
  30. 10/12/98 | JL Schwing | 1.3 : Implement asynchronous mode.
  31. ---------+--------------+------------------------------------------------------
  32. 11/12/98 | JL Schwing | 1.4 : Implement max errors threshold.
  33. ---------+--------------+------------------------------------------------------
  34. 14/12/98 | JL Schwing | 1.5 : Implement "-e close".
  35. ---------+--------------+------------------------------------------------------
  36. 16/12/98 | JL Schwing | 1.6 : Implement "-e add" and "-e delete".
  37. | Add counter nb timeouts (no activity).
  38. ---------+--------------+------------------------------------------------------
  39. 28/12/98 | JL Schwing | 1.7 : Add tag asyncHit.
  40. ---------+--------------+------------------------------------------------------
  41. 29/12/98 | JL Schwing | 1.8 : Implement -Q.
  42. ---------+--------------+------------------------------------------------------
  43. 11/01/99 | JL Schwing | 1.9 : Implement "-e emailPerson".
  44. ---------+--------------+------------------------------------------------------
  45. 13/01/99 | JL Schwing | 1.10: Implement "-e string".
  46. ---------+--------------+------------------------------------------------------
  47. 14/01/99 | JL Schwing | 1.11: Implement "-s <scope>".
  48. ---------+--------------+------------------------------------------------------
  49. 18/01/99 | JL Schwing | 1.12: Implement "-e randombase".
  50. ---------+--------------+------------------------------------------------------
  51. 18/01/99 | JL Schwing | 1.13: Implement "-e v2".
  52. ---------+--------------+------------------------------------------------------
  53. 21/01/99 | JL Schwing | 1.14: Implement "-e ascii".
  54. ---------+--------------+------------------------------------------------------
  55. 26/01/99 | JL Schwing | 1.15: Implement "-e noloop".
  56. ---------+--------------+------------------------------------------------------
  57. 28/01/99 | JL Schwing | 1.16: Implement "-T <total>".
  58. ---------+--------------+------------------------------------------------------
  59. 04/05/99 | JL Schwing | 1.17: Implement operations list.
  60. ---------+--------------+------------------------------------------------------
  61. 06/05/99 | JL Schwing | 1.22: Implement "-e modrdn".
  62. ---------+--------------+------------------------------------------------------
  63. 19/05/99 | JL Schwing | 1.25: Implement "-e rename".
  64. ---------+--------------+------------------------------------------------------
  65. 27/05/99 | JL Schwing | 1.26 : Add statistics to check threads.
  66. ---------+--------------+------------------------------------------------------
  67. 28/05/99 | JL Schwing | 1.27 : Add new option -W (wait).
  68. ---------+--------------+------------------------------------------------------
  69. 02/06/99 | JL Schwing | 1.28 : Add flag in main ctx to know if slave was
  70. | connected or not.
  71. | Add counter of operations received in check threads.
  72. ---------+--------------+------------------------------------------------------
  73. 04/08/00 | JL Schwing | 1.29: Add stats on nb inactivity per thread.
  74. ---------+--------------+------------------------------------------------------
  75. 08/08/00 | JL Schwing | 1.30: Print global statistics every 1000 loops.
  76. ---------+--------------+------------------------------------------------------
  77. 18/08/00 | JL Schwing | 1.31: Print global statistics every 15'
  78. | Print begin and end dates.
  79. ---------+--------------+------------------------------------------------------
  80. 25/08/00 | JL Schwing | 1.32: Implement consistent exit status...
  81. ---------+--------------+------------------------------------------------------
  82. 19/09/00 | JL Schwing | 1.33: Port on Netscape's libldap. This is realized in
  83. | such a way that this library become the default
  84. | way so a ifdef for Solaris will be used...
  85. ---------+--------------+----------------------------------------------------
  86. 11/10/00 | B Kolics | 1.34: Added 'SSL' to the list of running modes and
  87. | | certfile to main_context structure
  88. ---------+--------------+------------------------------------------------------
  89. 07/11/00 | JL Schwing | 1.35: Add handlers for dynamic load of ssl-related
  90. | functions.
  91. -----------------------------------------------------------------------------
  92. 07/11/00 | JL Schwing | 1.36: Implement "-e inetOrgPerson".
  93. ---------+--------------+------------------------------------------------------
  94. 13/11/00 | JL Schwing | 1.37: Add new options "-e randombaselow and ...high"
  95. ---------+--------------+------------------------------------------------------
  96. 16/11/00 | JL Schwing | 1.38: Implement "-e imagesdir=path".
  97. | lint-cleanup.
  98. ---------+--------------+------------------------------------------------------
  99. 17/11/00 | JL Schwing | 1.39: Implement "-e smoothshutdown".
  100. ---------+--------------+------------------------------------------------------
  101. 21/11/00 | JL Schwing | 1.40: Implement "-e attreplace=name:mask"
  102. | Increase max number of threads from 512 to 1000.
  103. ---------+--------------+------------------------------------------------------
  104. 22/11/00 | JL Schwing | 1.41: Will now use LD_LIBRARY_PATH to load libssl.
  105. ---------+--------------+------------------------------------------------------
  106. 24/11/00 | JL Schwing | 1.41: Added SSL client authentication
  107. ---------+--------------+------------------------------------------------------
  108. 28/11/00 | JL Schwing | 1.43: Port on NT 4.
  109. ---------+--------------+------------------------------------------------------
  110. 15/12/00 | JL Schwing | 1.44: Add more trace in VERY_VERBOSE mode.
  111. ---------+--------------+------------------------------------------------------
  112. 15/12/00 | JL Schwing | 1.45: Implement "-e counteach".
  113. | Implement "-e withnewparent".
  114. ---------+--------------+------------------------------------------------------
  115. 18/12/00 | JL Schwing | 1.46: Add exit status EXIT_INIT and EXIT_RESSOURCE.
  116. ---------+--------------+------------------------------------------------------
  117. 03/01/01 | JL Schwing | 1.47: Implement "-e attrsonly=value".
  118. ---------+--------------+------------------------------------------------------
  119. 05/01/01 | JL Schwing | 1.48: Implement "-e randombinddn" and associated
  120. | "-e randombinddnlow/high"
  121. ---------+--------------+------------------------------------------------------
  122. 08/01/01 | JL Schwing | 1.49: Implement "-e scalab01".
  123. ---------+--------------+------------------------------------------------------
  124. 12/01/01 | JL Schwing | 1.50: Second set of options for -e scalab01
  125. ---------+--------------+------------------------------------------------------
  126. 06/03/01 | JL Schwing | 1.51: Change DEF_ATTRSONLY from 1 to 0
  127. ---------+--------------+------------------------------------------------------
  128. 08/03/01 | JL Schwing | 1.52: Change referrals handling.
  129. ---------+--------------+------------------------------------------------------
  130. 14/03/01 | JL Schwing | 1.53: Implement "-e commoncounter"
  131. ---------+--------------+------------------------------------------------------
  132. 14/03/01 | JL Schwing | 1.54: Implement "-e dontsleeponserverdown".
  133. ---------+--------------+------------------------------------------------------
  134. 14/03/01 | JL Schwing | 1.55: Lint cleanup.
  135. ---------+--------------+------------------------------------------------------
  136. 15/03/01 | JL Schwing | 1.56: Implement "-e attrlist=name:name:name"
  137. | Implement "-e randomattrlist=name:name:name"
  138. ---------+--------------+------------------------------------------------------
  139. 19/03/01 | JL Schwing | 1.57: Implement "-e object=filename"
  140. | Implement "-e genldif=filename"
  141. ---------+--------------+------------------------------------------------------
  142. 21/03/01 | JL Schwing | 1.58: Implements variables in "-e object=filename"
  143. ---------+--------------+------------------------------------------------------
  144. 23/03/01 | JL Schwing | 1.59: Implements data file list support in variants.
  145. | Implements "-e rdn=value".
  146. ---------+--------------+------------------------------------------------------
  147. 28/03/01 | JL Schwing | 1.60: Update options checking for "-e rdn=value".
  148. ---------+--------------+------------------------------------------------------
  149. 28/03/01 | JL Schwing | 1.61: Support -e commoncounter with -e rdn/object
  150. | Increase MAX_ATTRIBS from 20 to 40
  151. | Remove MAX_ATTRLIST - use MAX_ATTRIBS.
  152. ---------+--------------+------------------------------------------------------
  153. 02/04/01 | JL Schwing | 1.62: Bug fix : large files support for -e genldif.
  154. ---------+--------------+------------------------------------------------------
  155. 05/04/01 | JL Schwing | 1.63: Implement -e append.
  156. ---------+--------------+------------------------------------------------------
  157. 11/04/01 | JL Schwing | 1.64: Implement [INCRFROMFILE<NOLOOP>(myfile)]
  158. ---------+--------------+------------------------------------------------------
  159. 03/05/01 | JL Schwing | 1.64: Implement -e randombinddnfromfile=filename.
  160. ---------+--------------+------------------------------------------------------
  161. 04/05/01 | JL Schwing | 1.65: Implement -e bindonly.
  162. ---------+--------------+------------------------------------------------------
  163. */
  164. #ifndef LDCLT_H
  165. #define LDCLT_H
  166. #if defined(USE_OPENLDAP)
  167. #define ABS(x) ((x > 0) ? (x) : (-x))
  168. #endif
  169. /*
  170. * Misc constant definitions
  171. */
  172. #define DEF_ATTRSONLY 0 /* ldap_search() default */ /*JLS 06-03-01*/
  173. #define DEF_GLOBAL_NB 90 /* Prt glob stats every 15' */ /*JLS 18-08-00*/
  174. #define DEF_INACTIV_MAX 3 /* Inactivity max nb times */
  175. #define DEF_MAX_ERRORS 1000 /* Max errors before exit */
  176. #define DEF_NB_THREADS 10 /* Nb client threads */
  177. #define DEF_PORT 389 /* Ldap server port */
  178. #define DEF_SAMPLING 10 /* Default sampling rate */
  179. #define DEF_TIMEOUT 30 /* Ldap operations timeout */
  180. #define DEF_PORT_CHECK 16000 /* Port used for check processing */
  181. #define MAX_ATTRIBS 40 /* Max number of attributes */ /*JLS 28-03-01*/
  182. #define MAX_DN_LENGTH 1024 /* Max length for a DN */
  183. #define MAX_ERROR_NB 0x7b /* Max ldap err number + 1 */
  184. #if defined(USE_OPENLDAP)
  185. #define NEGATIVE_MAX_ERROR_NB (LDAP_X_CONNECTING - 1) /* Mininum ldap err number */
  186. #endif
  187. #define MAX_IGN_ERRORS 20 /* Max errors ignored */
  188. #define MAX_FILTER 512 /* Max filters length */
  189. #define MAX_THREADS 1000 /* Max number of threads */ /*JLS 21-11-00*/
  190. #define MAX_SLAVES 20 /* Max number of slaves */
  191. #define DEF_IMAGES_PATH "../../data/ldclt/images"
  192. #define DEF_REFERRAL REFERRAL_ON /*JLS 08-03-01*/
  193. #define DEF_SCOPE LDAP_SCOPE_SUBTREE /* Default for -s */
  194. /*
  195. * Referral choices...
  196. */
  197. #define REFERRAL_OFF 0 /*JLS 08-03-01*/
  198. #define REFERRAL_ON 1 /*JLS 08-03-01*/
  199. #define REFERRAL_REBIND 2 /*JLS 08-03-01*/
  200. /*
  201. * Running modes
  202. * Will be used as well for main_context and for thread_context
  203. * Don't forget to update dumpModeValues().
  204. */
  205. #define NOTHING 0x00000000 /* Nothing special */
  206. #define VERBOSE 0x00000001 /* -v : verbose */
  207. #define VERY_VERBOSE 0x00000002 /* -V : very verbose */
  208. #define ASYNC 0x00000004 /* -a : asynchonous mode */
  209. #define QUIET 0x00000008 /* -q : quiet */
  210. #define SUPER_QUIET 0x00000010 /* -Q : super quiet */
  211. #define SSL 0x00000020 /* -Z certfile :SSL enabled *//*BK 11-10-00*/
  212. #define CLTAUTH 0x00000040 /* .... */ /* BK 23-11-00*/
  213. /**/
  214. #define RANDOM_ATTRLIST 0x00000080 /* -e randomattrlist*/ /*JLS 15-03-01*/
  215. #define DONT_SLEEP_DOWN 0x00000100 /* -e dontsleeponserverdown*//*JLS 14-03-01*/
  216. #define COMMON_COUNTER 0x00000200 /* -e commoncounter */ /*JLS 14-03-01*/
  217. #define SCALAB01 0x00000400 /* -e scalab01 */ /*JLS 08-01-01*/
  218. #define RANDOM_BINDDN 0x00000800 /* -e randombinddn */ /*JLS 05-01-01*/
  219. #define WITH_NEWPARENT 0x00001000 /* -e withnewparent */ /*JLS 15-12-00*/
  220. #define COUNT_EACH 0x00002000 /* -e counteach */ /*JLS 15-12-00*/
  221. #define ATTR_REPLACE 0x00004000 /* -e attreplace */ /*JLS 21-11-00*/
  222. #define SMOOTHSHUTDOWN 0x00008000 /* -e smoothshutdown */ /*JLS 17-11-00*/
  223. #define OC_INETORGPRSON 0x00010000 /* -e inetOrgPerson : oc= */ /*JLS 07-11-00*/
  224. #define RENAME_ENTRIES 0x00020000 /* -e rename : rename entries */
  225. #define NOLOOP 0x00040000 /* -e noloop : don't loop nb */
  226. #define ASCII_7BITS 0x00080000 /* -e ascii : ascii 7bits */
  227. #define LDAP_V2 0x00100000 /* -e v2 : ldap v2 */
  228. #define RANDOM_BASE 0x00200000 /* -e randombase : string mode */
  229. #define STRING 0x00400000 /* -e string : string mode */
  230. #define OC_EMAILPERSON 0x00800000 /* -e emailPerson : oc = person */
  231. #define DELETE_ENTRIES 0x01000000 /* -e delete : delete */
  232. #define OC_PERSON 0x02000000 /* -e person : oc = person */
  233. #define ADD_ENTRIES 0x04000000 /* -e add : add entries */
  234. #define INCREMENTAL 0x08000000 /* -e incr : incremental */
  235. #define CLOSE_FD 0x10000000 /* -e close : close fd */
  236. #define RANDOM 0x20000000 /* -e random : rnd values */
  237. #define BIND_EACH_OPER 0x40000000 /* -e bindeach : bnd each op */
  238. #define EXACT_SEARCH 0x80000000 /* -e esearch : exact srch */
  239. #define M2_OBJECT 0x00000001 /* -e object */ /*JLS 19-03-01*/
  240. #define M2_GENLDIF 0x00000002 /* -e genldif */ /*JLS 19-03-01*/
  241. #define M2_RDN_VALUE 0x00000004 /* -e rdn */ /*JLS 23-03-01*/
  242. #define M2_APPEND 0x00000008 /* -e append */ /*JLS 05-04-01*/
  243. #define M2_RNDBINDFILE 0x00000010 /* -e randombinddnfromfile *//*JLS 03-05-01*/
  244. #define M2_BINDONLY 0x00000020 /* -e bindonly */ /*JLS 04-05-01*/
  245. #define M2_SASLAUTH 0x00000040 /* -o : SASL authentication */
  246. #define M2_RANDOM_SASLAUTHID 0x00000080 /* -e randomauthid */
  247. #define M2_ABANDON 0x00000100 /* -e abandon */
  248. #define M2_DEREF 0x00000200 /* -e deref */
  249. #define M2_ATTR_REPLACE_FILE 0x00000400 /* -e attreplacefile */
  250. #define M2_NOZEROPAD 0x00000800 /* -e nozeropad */
  251. /*
  252. * Combinatory defines
  253. * - NEED_FILTER : filter required
  254. * - NEED_RANGE : -r and -R required
  255. * - NEED_RND_INCR : need entry generator
  256. * - VALID_OPERS : valid operations
  257. */
  258. #define NEED_FILTER (ADD_ENTRIES|DELETE_ENTRIES|EXACT_SEARCH|RENAME_ENTRIES|ATTR_REPLACE|SCALAB01)
  259. #define M2_NEED_FILTER (M2_ABANDON|M2_ATTR_REPLACE_FILE|M2_DEREF)
  260. #define NEED_RANGE (INCREMENTAL|RANDOM)
  261. #define NEED_RND_INCR (ADD_ENTRIES|DELETE_ENTRIES|RENAME_ENTRIES)
  262. #define VALID_OPERS (ADD_ENTRIES|DELETE_ENTRIES|EXACT_SEARCH|RENAME_ENTRIES|ATTR_REPLACE|SCALAB01)
  263. #define M2_VALID_OPERS (M2_GENLDIF|M2_BINDONLY|M2_ABANDON|M2_ATTR_REPLACE_FILE|M2_DEREF)
  264. #define NEED_CLASSES (ADD_ENTRIES)
  265. #define THE_CLASSES (OC_PERSON|OC_EMAILPERSON|OC_INETORGPRSON)
  266. /*
  267. * The threads status - check thread_context.status
  268. */
  269. #define FREE -1 /* Slot is free */
  270. #define CREATED 0 /* Just created */
  271. #define INITIATED 1 /* Initiated */
  272. #define RUNNING 2 /* Doing it's job */
  273. #define DEAD 9 /* Thread is dead */
  274. #define MUST_SHUTDOWN 10 /* Monitor command this */ /*JLS 17-11-00*/
  275. /*
  276. * Exit status
  277. * The biggest is the number, the higher priority is.
  278. * Cf the end of monitorThem().
  279. */
  280. #define EXIT_OK 0 /* No problem during execution */ /*JLS 25-08-00*/
  281. #define EXIT_PARAMS 2 /* Error in parameters */ /*JLS 25-08-00*/
  282. #define EXIT_MAX_ERRORS 3 /* Max errors reached */ /*JLS 25-08-00*/
  283. #define EXIT_NOBIND 4 /* Cannot bind */ /*JLS 25-08-00*/
  284. #define EXIT_LOADSSL 5 /* Cannot load libssl */ /*JLS 07-11-00*/
  285. #define EXIT_MUTEX 6 /* Mutex error */ /*JLS 17-11-00*/
  286. #define EXIT_INIT 7 /* Initialization error */ /*JLS 18-12-00*/
  287. #define EXIT_RESSOURCE 8 /* Ressource limitation */ /*JLS 18-12-00*/
  288. #define EXIT_OTHER 99 /* Other kind of error */ /*JLS 25-08-00*/
  289. /*
  290. * Some constants from Sun's ldap.h are not provided by
  291. * Netscape implementation...
  292. */
  293. #ifdef SOLARIS_LIBLDAP /*JLS 19-09-00*/
  294. #define WORKAROUND_4197228 1 /*JLS 19-09-00*/
  295. #else /*JLS 19-09-00*/
  296. #ifndef LDAP_REQ_BIND
  297. #define LDAP_REQ_BIND 0x60 /*JLS 19-09-00*/
  298. #endif
  299. #ifndef LDAP_REQ_UNBIND
  300. #define LDAP_REQ_UNBIND 0x42 /*JLS 19-09-00*/
  301. #endif
  302. #ifndef LDAP_REQ_SEARCH
  303. #define LDAP_REQ_SEARCH 0x63 /*JLS 19-09-00*/
  304. #endif
  305. #ifndef LDAP_REQ_MODIFY
  306. #define LDAP_REQ_MODIFY 0x66 /*JLS 19-09-00*/
  307. #endif
  308. #ifndef LDAP_REQ_ADD
  309. #define LDAP_REQ_ADD 0x68 /*JLS 19-09-00*/
  310. #endif
  311. #ifndef LDAP_REQ_DELETE
  312. #define LDAP_REQ_DELETE 0x4a /*JLS 19-09-00*/
  313. #endif
  314. #ifndef LDAP_REQ_MODRDN
  315. #define LDAP_REQ_MODRDN 0x6c /*JLS 19-09-00*/
  316. #endif
  317. #ifndef LDAP_REQ_COMPARE
  318. #define LDAP_REQ_COMPARE 0x6e /*JLS 19-09-00*/
  319. #endif
  320. #ifndef LDAP_REQ_ABANDON
  321. #define LDAP_REQ_ABANDON 0x50 /*JLS 19-09-00*/
  322. #endif
  323. #ifndef LDAP_REQ_EXTENDED
  324. #define LDAP_REQ_EXTENDED 0x77 /*JLS 19-09-00*/
  325. #endif
  326. #ifndef LDAP_REQ_UNBIND_30
  327. #define LDAP_REQ_UNBIND_30 0x62 /*JLS 19-09-00*/
  328. #endif
  329. #ifndef LDAP_REQ_DELETE_30
  330. #define LDAP_REQ_DELETE_30 0x6a /*JLS 19-09-00*/
  331. #endif
  332. #ifndef LDAP_REQ_ABANDON_30
  333. #define LDAP_REQ_ABANDON_30 0x70 /*JLS 19-09-00*/
  334. #endif /*JLS 19-09-00*/
  335. #endif
  336. #ifndef LBER_SOCKET
  337. #ifdef LBER_SOCKET_T
  338. #define LBER_SOCKET LBER_SOCKET_T
  339. #else
  340. #define LBER_SOCKET int
  341. #endif
  342. #endif
  343. /*
  344. * This structure is the internal representation of an image
  345. */
  346. typedef struct image {
  347. char *name;
  348. int length;
  349. char *data;
  350. } image;
  351. /*
  352. * Internal representation of a data list file
  353. */
  354. typedef struct data_list_file { /*JLS 23-03-01*/
  355. char *fname; /* File name */
  356. char **str; /* Strings array */
  357. int strNb; /* Nb of strings */
  358. struct data_list_file *next; /* Next file */
  359. } data_list_file;
  360. /*
  361. * This structure is the internal representation of an LDAP attribute
  362. */
  363. typedef struct {
  364. char *type; /* e.g. "objectclass" or "cn" */
  365. int length; /* Length of the value */
  366. char *value; /* The attribute value */
  367. int dontFree; /* Don't free the value */
  368. } attribute;
  369. /*
  370. * This structure is used to memorize an operation successfully
  371. * performed by the tool in order to be checked later on.
  372. * The operation type is a LDAP constant LDAP_REQ_ADD, etc...
  373. * ATTENTION: don't forget to maintain in sync with the struct thoper below.
  374. */
  375. typedef struct oper {
  376. int type; /* Operation type */
  377. char *dn; /* Target's DN */
  378. attribute attribs[MAX_ATTRIBS]; /* Attributes to check */
  379. /* attribs[i].type == NULL marks the */
  380. /* end of the attributes */
  381. char *newRdn; /* For rename operation */
  382. char *newParent; /* For rename operation */
  383. int skipped; /* Thread that skipped it */
  384. ldclt_mutex_t skipped_mutex; /* Protect skipped */ /*JLS 28-11-00*/
  385. struct oper *next; /* Next operation */
  386. } oper;
  387. /*
  388. * Same as before, but this is a per thread "lost" operation list
  389. */
  390. typedef struct _simpl_op {
  391. int type;
  392. int first; /* Keeps in order replies */
  393. char *dn;
  394. attribute attribs[MAX_ATTRIBS];
  395. char *newRdn;
  396. char *newParent;
  397. struct _simpl_op *next;
  398. } thoper;
  399. /*
  400. * Versatile object attribute's field
  401. * - If ldclt should use a common counter, then this counter will
  402. * be in the mctx structure and will be found by the commonField
  403. * pointer.
  404. */
  405. #define HOW_CONSTANT 0 /* Constant value */
  406. #define HOW_INCR_FROM_FILE 1 /* Increment string from file *//*JLS 11-04-01*/
  407. #define HOW_INCR_FROM_FILE_NL 2 /* Incr string file noloop*/ /*JLS 11-04-01*/
  408. #define HOW_INCR_NB 3 /* Increment number */ /*JLS 23-03-01*/
  409. #define HOW_INCR_NB_NOLOOP 4 /* Increment number no loop */ /*JLS 23-03-01*/
  410. #define HOW_RND_FROM_FILE 5 /* Random string from file */ /*JLS 23-03-01*/
  411. #define HOW_RND_NUMBER 6 /* Random number */
  412. #define HOW_RND_STRING 7 /* Random string */
  413. #define HOW_VARIABLE 8 /* Retrieve variable value */ /*JLS 21-03-01*/
  414. typedef struct vers_field { /*JLS 21-03-01*/
  415. int how; /* How to build this field */
  416. int cnt; /* Counter */ /*JLS 23-03-01*/
  417. ldclt_mutex_t cnt_mutex; /* Protect cnt */ /*JLS 28-03-01*/
  418. struct vers_field *commonField; /* Common field */ /*JLS 28-03-01*/
  419. char *cst; /* Constant field */
  420. data_list_file *dlf; /* Data list file */ /*JLS 23-03-01*/
  421. int high; /* High value */
  422. int low; /* Low value */
  423. int nb; /* Number of items */
  424. int var; /* Variable number */
  425. struct vers_field *next; /* Next field */
  426. } vers_field;
  427. /*
  428. * Versatile object's attribute
  429. */
  430. typedef struct vers_attribute { /*JLS 19-03-01*/
  431. char *buf; /* Store the generated value */ /*JLS 21-03-01*/
  432. char *name; /* Attribute name */
  433. char *src; /* Source line */
  434. vers_field *field; /* First field */ /*JLS 21-03-01*/
  435. } vers_attribute;
  436. /*
  437. * This structure contains the definitions related to the versatile
  438. * object classes managed by ldclt.
  439. * The field 'rdn' of vers_object is a trick we will use to be
  440. * able to support the same random mechanism for the entry's rdn
  441. * generation than for the attributes themselves.
  442. */
  443. #define VAR_MIN 'A' /*JLS 21-03-01*/
  444. #define VAR_MAX 'H' /*JLS 21-03-01*/
  445. typedef struct vers_object { /*JLS 19-03-01*/
  446. vers_attribute attribs[MAX_ATTRIBS];
  447. int attribsNb;
  448. vers_attribute *rdn; /* Object's rdn */ /*JLS 23-03-01*/
  449. char *rdnName; /* Attrib. name */ /*JLS 23-03-01*/
  450. char *var[VAR_MAX-VAR_MIN]; /*JLS 21-03-01*/
  451. char *fname; /* Object definition */
  452. } vers_object;
  453. /*
  454. * This structure contain the *process* context, used only by the
  455. * main thread(s).
  456. * Another dedicated structure is used by each test thread.
  457. */
  458. typedef struct main_context {
  459. int asyncMin; /* Min pend for read */
  460. int asyncMax; /* Max async pending */
  461. char *attrlist[MAX_ATTRIBS]; /*JLS 15-03-01*/
  462. int attrlistNb; /* Nb attrib in list */ /*JLS 15-03-01*/
  463. char *attRef; /* Name of referenced attribute name */
  464. char *attRefDef; /* Name of dereferenced attribute name*/
  465. char *attrpl; /* Attrib argument */ /*JLS 21-11-00*/
  466. char *attrplFile; /* Attrib file to get value from */
  467. char *attrplFileContent; /* Attrib file content */
  468. int attrplFileSize; /* Attrib file size*/
  469. char *attrplHead; /* Attrib value head */ /*JLS 21-11-00*/
  470. char *attrplName; /* Attrib name */ /*JLS 21-11-00*/
  471. int attrplNbDigit; /* Attrib nb digits */ /*JLS 21-11-00*/
  472. char *attrplTail; /* Attrib value tail */ /*JLS 21-11-00*/
  473. int attrsonly; /* search() param. */ /*JLS 03-01-01*/
  474. char *baseDN; /* Base DN to use */
  475. int baseDNLow; /* Base DN's low val */ /*JLS 13-11-00*/
  476. int baseDNHigh; /* Base DN's high val *//*JLS 13-11-00*/
  477. int baseDNNbDigit; /* Base DN's nb of digits */
  478. char *baseDNHead; /* Base DN's head string */
  479. char *baseDNTail; /* Base DN's tail string */
  480. char *bindDN; /* Bind DN */
  481. int bindDNLow; /* Bind DN's low val */ /*JLS 05-01-01*/
  482. int bindDNHigh; /* Bind DN's high val *//*JLS 05-01-01*/
  483. int bindDNNbDigit; /* Bind DN's ndigits */ /*JLS 05-01-01*/
  484. char *bindDNHead; /* Bind DN's head */ /*JLS 05-01-01*/
  485. char *bindDNTail; /* Bind DN's tail */ /*JLS 05-01-01*/
  486. char *certfile; /* certificate file */ /* BK 11-10-00 */
  487. char *cltcertname; /* client cert name */ /* BK 23 11-00 */
  488. data_list_file *dlf; /* Data list files */ /*JLS 23-03-01*/
  489. #if defined(USE_OPENLDAP)
  490. int negativeErrors[ABS(NEGATIVE_MAX_ERROR_NB)]; /* Err stats */
  491. #endif
  492. int errors[MAX_ERROR_NB]; /* Err stats */
  493. int errorsBad; /* Bad errors */
  494. ldclt_mutex_t errors_mutex; /* Protect errors */ /*JLS 28-11-00*/
  495. int exitStatus; /* Exit status */ /*JLS 25-08-00*/
  496. char *filter; /* Filter for req. */
  497. char *genldifName; /* Where to put ldif */ /*JLS 19-03-01*/
  498. int genldifFile; /* Where to put ldif */ /*JLS 19-03-01*/
  499. char *hostname; /* Host to connect */
  500. int globStatsCnt; /* Global stats loop */ /*JLS 08-08-00*/
  501. int ignErr[MAX_IGN_ERRORS]; /* Err ignor */
  502. int ignErrNb; /* Nb err ignored */
  503. image *images; /* The images */
  504. char *imagesDir; /* Where are images */ /*JLS 16-11-00*/
  505. int imagesNb; /* Nb of images */
  506. int imagesLast; /* Last selected image */
  507. ldclt_mutex_t imagesLast_mutex; /* Protect imagesLast */
  508. int inactivMax; /* Allowed inactivity */
  509. int incr; /* in incremental mode, number to use to increment (default 1) */
  510. char *keydbfile; /* key DB file */ /* BK 23-11-00*/
  511. char *keydbpin; /* key DB password */ /* BK 23-11-00*/
  512. int lastVal; /* To build filters */ /*JLS 14-03-01*/
  513. ldclt_mutex_t lastVal_mutex; /* Protect lastVal */ /*JLS 14-03-01*/
  514. int ldapauth; /* Used to indicate auth type */
  515. int maxErrors; /* Max allowed errors */
  516. unsigned int mode; /* Running mode */
  517. unsigned int mod2; /* Running mode - 2 */ /*JLS 19-03-01*/
  518. int nbNoActivity; /* Nb times no activ. */
  519. int nbSamples; /* Samples to get */
  520. int nbThreads; /* Nb of client */
  521. vers_object object; /* Object to generate *//*JLS 19-03-01*/
  522. oper *opListTail; /* Tail of operation list */
  523. ldclt_mutex_t opListTail_mutex; /* Protect opListTail */
  524. char *passwd; /* Bind passwd */
  525. int passwdNbDigit; /* Passwd's ndigits */ /*JLS 05-01-01*/
  526. char *passwdHead; /* Passwd's head */ /*JLS 05-01-01*/
  527. char *passwdTail; /* Passwd's tail */ /*JLS 05-01-01*/
  528. int pid; /* Process ID */
  529. int port; /* Port to use */
  530. int randomLow; /* Rnd's low value */
  531. int randomHigh; /* Rnd's high val */
  532. int randomNbDigit; /* Rnd's nb of digits */
  533. char *randomHead; /* Rnd's head string */
  534. char *randomTail; /* Rnd's tail string */
  535. data_list_file *rndBindDlf; /* Rnd bind file data *//*JLS 03-05-01*/
  536. char *rndBindFname; /* Rnd bind file name *//*JLS 03-05-01*/
  537. int referral; /* Referral followed */ /*JLS 08-03-01*/
  538. int sampling; /* Sampling frequency */
  539. char *sasl_authid;
  540. int sasl_authid_low; /* authid's low val */
  541. int sasl_authid_high; /* authid's high val */
  542. int sasl_authid_nbdigit; /* authid's ndigits */
  543. char *sasl_authid_head; /* authid's head */
  544. char *sasl_authid_tail; /* authid's tail */
  545. unsigned sasl_flags;
  546. char *sasl_mech;
  547. char *sasl_realm;
  548. char *sasl_secprops;
  549. char *sasl_username;
  550. int scope; /* Searches scope */
  551. int slaveConn; /* Slave has connected */
  552. char *slaves[MAX_SLAVES]; /* Slaves list */
  553. int slavesNb; /* Number of slaves */
  554. int srch_nentries; /* number of entries that must be returned by each search op */
  555. int timeout; /* LDAP op. t.o. */
  556. struct timeval timeval; /* Timeval structure */
  557. struct timeval timevalZero; /* Timeout of zero */
  558. int totalReq; /* Total requested */
  559. int totNbOpers; /* Total opers number */
  560. int totNbSamples; /* Total samples nb */
  561. #define DEFAULT_TIMESTAMP_FMT "%s"
  562. char *tsfmt; /* if non-null, use this strftime format to print timestamps for status updates */
  563. int waitSec; /* Wait between two operations */
  564. } main_context;
  565. /*
  566. * This structure is aimed to ease the managing of asynchronous
  567. * operations, keeping in memory the msgid returned by the library and
  568. * a free string meaning something for the user.
  569. * It is targeted that this string is something like a DN, and is
  570. * locally managed by the list functions.
  571. */
  572. typedef struct msgid_cell {
  573. LDAPMod **attribs; /* Attributes */
  574. char dn[MAX_DN_LENGTH]; /* entry's dn */
  575. int msgid; /* msg id */
  576. char str[MAX_DN_LENGTH]; /* free str */
  577. struct msgid_cell *next; /* next cell */
  578. } msgid_cell;
  579. /*
  580. * This structure contain the context associated with each thread.
  581. * It is targeted to be initiated by the main thread, and maintained
  582. * by each thread.
  583. */
  584. typedef struct thread_context {
  585. int active; /* thread is active */
  586. int asyncHit; /* async max hit */
  587. char *attrlist[MAX_ATTRIBS]; /*JLS 15-03-01*/
  588. int binded; /* thread is binded */
  589. int exitStatus; /* Exit status */ /*JLS 25-08-00*/
  590. int fd; /* fd to the server */
  591. int lastVal; /* To build filters */
  592. LDAP *ldapCtx; /* LDAP context */
  593. unsigned int mode; /* Running mode */
  594. int nbInactRow; /* Nb inactive in row *//*JLS 04-08-00*/
  595. int nbInactTot; /* Nb inactive total */ /*JLS 04-08-00*/
  596. int nbOpers; /* Nb of operations */
  597. ldclt_mutex_t nbOpers_mutex; /* Protect nbOpers */ /*JLS 28-11-00*/
  598. vers_object *object; /* Template */ /*JLS 21-03-01*/
  599. int pendingNb; /* Pending opers */
  600. int status; /* Status */
  601. ldclt_mutex_t status_mutex; /* Protect status */ /*JLS 28-11-00*/
  602. ldclt_tid tid; /* Thread's id */ /*JLS 28-11-00*/
  603. char thrdId[8]; /* This thread ident */ /*JLS 08-01-01*/
  604. int thrdNum; /* This thread number */
  605. int totOpers; /* Total nb operations */
  606. int totalReq; /* Total nb operations requested */
  607. /*
  608. * Now some convenient buffers ;-)
  609. */
  610. char buf2 [MAX_FILTER];
  611. char *bufObject1; /*JLS 19-03-01*/
  612. char *bufAttrpl; /* Attribute replace */ /*JLS 21-11-00*/
  613. char *bufBaseDN; /* Base DN to use */
  614. char *bufBindDN; /* Bind DN to use */ /*JLS 05-01-01*/
  615. char *bufFilter; /* Filter to use */
  616. char *bufPasswd; /* Bind passwd to use *//*JLS 05-01-01*/
  617. char *bufSaslAuthid; /* Sasl Authid to use */
  618. /*
  619. * Note about matcheddnp management. This pointer is managed by the
  620. * function dnFromMessage() that need it to free or remember the string
  621. * returned by the library. DO NOT manage this field another way.
  622. */
  623. char *matcheddnp; /* See above */ /*JLS 15-12-00*/
  624. int startAttrpl; /* Insert random here *//*JLS 21-11-00*/
  625. int startBaseDN; /* Insert random here */
  626. int startBindDN; /* Insert random here *//*JLS 05-01-01*/
  627. int startPasswd; /* Insert random here *//*JLS 05-01-01*/
  628. int startRandom; /* Insert random here */
  629. int startSaslAuthid; /* Insert random here */
  630. msgid_cell *firstMsgId; /* pending messages */
  631. msgid_cell *lastMsgId; /* last one */
  632. } thread_context;
  633. /*
  634. * This structure gather the information used by a check thread
  635. */
  636. typedef struct check_context {
  637. oper *headListOp; /* Head list of operation */
  638. thoper *dcOper; /* Double check operation list */
  639. char *slaveName; /* Name of the slave */
  640. int sockfd; /* Socket fd after accept() */
  641. int status; /* Status */
  642. int thrdNum; /* Thread number */
  643. int calls; /* Number of timeouts */
  644. ldclt_tid tid; /* Thread's id */ /*JLS 28-11-00*/
  645. int nbEarly; /* err = Early */
  646. int nbLate; /* err = Late replica */
  647. int nbLostOp; /* err = Lost op */
  648. int nbNotOnList; /* err = Not on list */
  649. int nbOpRecv; /* Nb operations received */
  650. int nbRepFail32; /* err = Replica failed err=32 */
  651. int nbRepFail68; /* err = Replica failed err=68 */
  652. int nbRepFailX; /* err = Replica failed err=X */
  653. int nbStillOnQ; /* err = still on Queue */
  654. } check_context;
  655. /*
  656. * Extern declarations of global variables.
  657. */
  658. extern main_context mctx; /* Main context */
  659. extern thread_context tctx[]; /* Thread contextes */
  660. extern check_context cctx[]; /* Check thread contextes */
  661. /*
  662. * Extern functions prototypes (for exported functions)
  663. */
  664. /* From ldclt.c */
  665. extern void ldcltExit (int status); /*JLS 18-08-00*/
  666. extern int printGlobalStatistics (void); /*JLS 16-11-00*/
  667. /* From ldcltU.c */
  668. extern void usage (void);
  669. /* From threadMain.c */
  670. extern int addErrorStat (int err);
  671. extern int getThreadStatus (thread_context *tttctx, /*JLS 17-11-00*/
  672. int *status); /*JLS 17-11-00*/
  673. extern int ignoreError (int err);
  674. extern int incrementCommonCounter (thread_context *tttctx); /*14-03-01*/
  675. extern int incrementCommonCounterObject ( /*JLS 28-03-01*/
  676. thread_context *tttctx, /*JLS 28-03-01*/
  677. vers_field *field); /*JLS 28-03-01*/
  678. extern int incrementNbOpers (thread_context *tttctx);
  679. extern int msgIdAdd (thread_context *tttctx, int msgid, char *str,
  680. char *dn, LDAPMod **attribs);
  681. extern LDAPMod **msgIdAttribs (thread_context *tttctx, int msgid);
  682. extern int msgIdDel (thread_context *tttctx, int msgid, int freeAttr);
  683. extern char *msgIdDN (thread_context *tttctx, int msgid);
  684. extern char *msgIdStr (thread_context *tttctx, int msgid);
  685. extern int randomString (thread_context *tttctx, int nbDigits);
  686. extern char **selectRandomAttrList (thread_context *tttctx); /*JLS 15-03-01*/
  687. extern int setThreadStatus (thread_context *tttctx, /*JLS 17-11-00*/
  688. int status); /*JLS 17-11-00*/
  689. extern void *threadMain (void *);
  690. /* From ldapfct.c */
  691. extern LDAP* connectToLDAP (thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2);
  692. extern int connectToServer (thread_context *tttctx); /*JLS 14-03-01*/
  693. extern char *dnFromMessage (thread_context *tttctx, LDAPMessage *res);
  694. extern int doAddEntry (thread_context *tttctx);
  695. extern int doAttrReplace (thread_context *tttctx); /*JLS 21-11-00*/
  696. extern int doAttrFileReplace (thread_context *tttctx);
  697. extern int doBindOnly (thread_context *tttctx); /*JLS 04-05-01*/
  698. extern int doDeleteEntry (thread_context *tttctx);
  699. extern int doExactSearch (thread_context *tttctx);
  700. extern int doAbandon (thread_context *tttctx);
  701. extern int doGenldif (thread_context *tttctx); /*JLS 19-03-01*/
  702. extern int doRename (thread_context *tttctx);
  703. extern int freeAttrib (LDAPMod **attrs);
  704. extern void ldclt_flush_genldif (void); /*JLS 02-04-01*/
  705. extern char *my_ldap_err2string (int err);
  706. extern char **strList1 (char *str1); /*JLS 08-01-01*/
  707. /* From data.c */
  708. extern data_list_file *dataListFile (char *fname); /*JLS 23-03-01*/
  709. extern int getImage (LDAPMod *attribute);
  710. extern int loadImages (char *dirpath);
  711. /* From workarounds.c */
  712. extern int getFdFromLdapSession (LDAP *ld, int *fd);
  713. /* From opCheck.c */
  714. extern int opAdd (thread_context *tttctx, int type, char *dn,
  715. LDAPMod **attribs, char *newRdn, char *newParent);
  716. extern void *opCheckMain (void *);
  717. extern void *opCheckLoop (void *);
  718. extern int opNext (check_context *ctctx, oper **op);
  719. extern int opRead (check_context *ctctx, int num, oper **op);
  720. /* From parser.c */
  721. extern int parseAttribValue (char *fname, /*JLS 23-03-01*/
  722. vers_object *obj, char *line, /*JLS 23-03-01*/
  723. vers_attribute *attrib); /*JLS 23-03-01*/
  724. extern int readObject (vers_object *obj); /*JLS 19-03-01*/
  725. #endif /* LDCLT_H */
  726. /* End of file */