"Fossies" - the Fresh Open Source Software Archive

Member "xstress/include/common.h" (19 Feb 2009, 5424 Bytes) of package /linux/privat/old/xstress-src-0.375-beta-20090219.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "common.h" see the Fossies "Dox" file reference documentation.

    1 
    2 /*
    3  * xstress - xk0derz SMTP Stress Tester
    4  *
    5  * (c) Amit Singh amit@xkoder.com
    6  * http://xkoder.com, http://blog.xkoder.com
    7  *
    8  * This software and related files are licensed under GNU GPL version 2
    9  * Please visit the following webpage for more details
   10  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
   11  */
   12 
   13 #ifndef __COMMON_H__
   14 
   15 #define __COMMON_H__
   16 
   17 #include <sys/socket.h>
   18 #include <netinet/in.h>
   19 #include <arpa/inet.h>
   20 #include <sys/poll.h>
   21 #include <unistd.h>
   22 #include <fcntl.h>
   23 #include <errno.h>
   24 
   25 #include <string>
   26 #include <iostream>
   27 
   28 /*Common*/
   29 using namespace std;
   30 
   31 const unsigned int MAX_THREADS=10;
   32 
   33 const unsigned int DEFAULT_TIMEOUT=15; // seconds
   34 
   35 
   36 const string BOUNDARY="AABBCCDDEEFFGGHHIIaabbccdd";
   37 const string DEFAULT_CONFIG_FILE="xstress.conf";
   38 const string DEFAULT_LOG_FILE="xstress.log";
   39 const int DEFAULT_CACHE_THRESHOLD = 1024*4;
   40 
   41 const string VERSION="xstress version 0.375b - xk0derz SMTP Stress Tester";
   42 const string COPYRIGHT="(c) 2007-09 Amit Singh (aka xk0der), amit@xkoder.com, http://xkoder.com\n"
   43            "This software and related files are licensed under GNU GPL version 2\n"
   44            "Please visit the following webpage for more details\n"
   45            "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n"
   46            "\nThis software uses the base64 utility by Bob Trower\n"
   47            "Please visit the following link to know the terms of use for this utility\n"
   48            "http://base64.sourceforge.net/\n";
   49 
   50 
   51 const string HELP_MSG = 
   52 "Syntax:\n"
   53 "       $ xstress [options]\n"
   54 "\n"
   55 "Here options are one or more of the following...\n"
   56 "\n"
   57 "-v, --ver, --version           Display xstress version and exit.\n"
   58 "-h, --help                     Display this help message.\n"
   59 "-t <value>, --threads <value>  Set number of threads to spawn.\n"
   60 "                               Range for value is 1 to 100, inclusive.\n"
   61 "-m <value>, --mails <value>    Set number of mails to send per thread.\n"
   62 "                               range for value is 0 to 60000, inclusive.\n"
   63 "                               * A Value of 0 for mails means unlimited mail.\n"
   64 "-s <IP>, --server <IP>         Set the mail server IP\n"
   65 "                               IP is in dotted decimal format\n"
   66 "-p <value>, --port <value>     Set the mail server port\n"
   67 "                               value is the port number of the mail server\n"
   68 "-u <username>\n"
   69 "--username <username>          Use either of these two switches to specify\n"
   70 "                               your SMTP server username.\n"
   71 "-P <password>\n"
   72 "--password <password>          Use this switch to specify the password for username\n"
   73 "                               specified using -u or --username switch.\n"
   74 "                               * Both username and password must be specified for\n"
   75 "                               Authentication to occur else it will be skipped.\n"
   76 "-a <type>, --auth-type <type>  Use this switch to specify authentication type\n"
   77 "                               * currently only PLAIN is supported\n"
   78 "--timeout <value>              Set connection timeout (in seconds)\n"
   79 "                               values is a non zero positive integer\n"
   80 "--conf <filename>              Configuration file to use, instead of the\n"
   81 "                               default file 'xstress.conf'.\n"
   82 "                               `filename` is the full path to the alternate\n"
   83 "                               configuration file.\n"
   84 "--logfile <filename>           Set alternate log file to use, instead of the\n"
   85 "                               default 'xstress.log' file.\n"
   86 "                               `filename` is the full path to the alternate\n"
   87 "                               log file.\n"
   88 "-d, --debug                    If this switch is provided, verbose debug messages\n"
   89 "                               With complete traffic will be printed on screen.\n"
   90 "                               Usefull for checking if things are working as expected.\n"
   91 "--license                      View disclaimer and short license notice.\n"
   92 "\n"
   93 "**Note: command line options always override configuration file settings\n";
   94 
   95 enum eCmdOpts
   96 {
   97   CO_NONE,
   98   CO_V,
   99   CO_VER,
  100   CO_VERSION,
  101   CO_HELP,
  102   CO_H,
  103   CO_THREADS,
  104   CO_T,
  105   CO_M,
  106   CO_MAILS_PER_THREADS,
  107   CO_SERVER,
  108   CO_S,
  109   CO_PORT,
  110   CO_P,
  111   CO_TIMEOUT,
  112   CO_CONF,
  113   CO_LOGFILE,
  114   CO_LICENSE,
  115   CO_U,
  116   CO_USERNAME,
  117   CO_BIG_P,
  118   CO_PASSWORD,
  119   CO_A,
  120   CO_AUTH_TYPE,
  121   CO_D,
  122   CO_DEBUG,
  123   CO_MAX
  124 };
  125 
  126 enum eSections
  127 {
  128   S_NO_SECTION,
  129   S_CONFIG,
  130   S_TO,
  131   S_FROM,
  132   S_SUBJECT,
  133   S_BODY,
  134   S_ATTACH,
  135   S_MAX
  136 };
  137 
  138 extern const char *SectionsStr[];
  139 
  140 enum eConfigVars 
  141 {
  142   C_NO_VAR,
  143   C_SERVER,
  144   C_PORT,
  145   C_THREADS,
  146   C_MAILS_PER_THREAD,
  147   C_LOG_FILE,
  148   C_TIMEOUT,
  149   C_REPORT_AFTER,
  150   C_LOG_TIMEOUT,
  151   C_MAX_RECIPIENTS,
  152   C_USERNAME,
  153   C_PASSWORD,
  154   C_AUTH_TYPE,
  155   C_DEBUG,
  156   C_MAX
  157 };
  158 
  159 extern const char * ConfigVarsStr[];
  160 
  161 enum eError
  162 {
  163   NO_ERR,
  164   ERR_TIMEOUT,
  165   ERR_INVALID_SOCKET,
  166   ERR_CONNECT,
  167   ERR_IO
  168 };
  169 
  170 enum eState
  171 {
  172   IDLE,     // 0
  173   CONNECT,  // 1
  174   EHLO,     // 2
  175   AUTH,     // 3
  176   MAILFROM, // 4
  177   RCPTTO,   // 5 
  178   DATA,     // 6
  179   MAIL,     // 7
  180   FINISHED  // 8
  181 };
  182 
  183 enum eAuthType
  184 {
  185     SIMPLE,
  186     PLAIN,
  187     LOGIN,
  188     CRAM_MD5,
  189     NONE
  190 };
  191 
  192 enum eSockState
  193 {
  194   WRITE_READY,
  195   READ_READY
  196 };
  197 
  198 enum eMIMETypes
  199 {
  200   MT_NONE,
  201   MT_PLAIN,
  202   MT_HTML,
  203   MT_BIN,
  204   MT_IMAGE,
  205   MT_MAX
  206 };
  207 
  208 extern int bDebug;
  209 
  210 void debug(string _msg);
  211 
  212 #endif