"Fossies" - the Fresh Open Source Software Archive

Member "httperf-0.9.0/src/call.h" (7 Apr 2007, 5096 Bytes) of package /linux/www/old/httperf-0.9.0.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 "call.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2     httperf -- a tool for measuring web server performance
    3     Copyright 2000-2007 Hewlett-Packard Company and Contributors listed in
    4     AUTHORS file. Originally contributed by David Mosberger-Tang
    5 
    6     This file is part of httperf, a web server performance measurment
    7     tool.
    8 
    9     This program is free software; you can redistribute it and/or
   10     modify it under the terms of the GNU General Public License as
   11     published by the Free Software Foundation; either version 2 of the
   12     License, or (at your option) any later version.
   13     
   14     In addition, as a special exception, the copyright holders give
   15     permission to link the code of this work with the OpenSSL project's
   16     "OpenSSL" library (or with modified versions of it that use the same
   17     license as the "OpenSSL" library), and distribute linked combinations
   18     including the two.  You must obey the GNU General Public License in
   19     all respects for all of the code used other than "OpenSSL".  If you
   20     modify this file, you may extend this exception to your version of the
   21     file, but you are not obligated to do so.  If you do not wish to do
   22     so, delete this exception statement from your version.
   23 
   24     This program is distributed in the hope that it will be useful,
   25     but WITHOUT ANY WARRANTY; without even the implied warranty of
   26     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27     General Public License for more details.
   28 
   29     You should have received a copy of the GNU General Public License
   30     along with this program; if not, write to the Free Software
   31     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
   32     02110-1301, USA
   33 */
   34 #ifndef call_h
   35 #define call_h
   36 
   37 #include <sys/types.h>
   38 #include <sys/uio.h>
   39 
   40 #include <httperf.h>
   41 #include <conn.h>
   42 #include <object.h>
   43 
   44 /* Max. # of additional request header lines we allow: */
   45 #define MAX_EXTRA_HEADERS   4
   46 
   47 typedef enum IOV_Element
   48   {
   49     IE_METHOD,
   50     IE_BLANK,       /* space separating method from location */
   51     IE_LOC,     /* for proxy requests only */
   52     IE_URI,
   53     IE_PROTL,
   54     IE_HOST,        /* for the "Host:" header */
   55     IE_NEWLINE1,
   56     IE_FIRST_HEADER,
   57     IE_LAST_HEADER = IE_FIRST_HEADER + MAX_EXTRA_HEADERS - 1,
   58     IE_NEWLINE2,
   59     IE_CONTENT,
   60     IE_LEN      /* must be last */
   61   }
   62 IOV_Element;
   63 
   64 /* I call this a "call" because "transaction" is too long and because
   65    it's basically a remote procedure call consisting of a request that
   66    is answered by a reply.  */
   67 typedef struct Call
   68   {
   69     Object obj;
   70 
   71     u_long id;          /* unique id */
   72 
   73     /* Connection this call is being sent on.  This pointer is NOT
   74        reference counted as otherwise we would get a recursive
   75        dependency between connections and calls....  */
   76     struct Conn *conn;
   77     struct Call *sendq_next;
   78     struct Call *recvq_next;
   79     Time timeout;       /* used for watchdog management */
   80 
   81     struct
   82       {
   83     Time time_send_start;
   84     Time time_recv_start;
   85       }
   86     basic;
   87 
   88     /* the request: */
   89     struct
   90       {
   91     int version;        /* 0x10000*major + minor */
   92     u_int num_extra_hdrs;   /* number of additional headers in use */
   93     int iov_index;      /* first iov element that has data */
   94     size_t size;        /* # of bytes sent */
   95     struct iovec iov_saved; /* saved copy of iov[iov_index] */
   96     struct iovec iov[IE_LEN];
   97       }
   98     req;
   99 
  100     /* the reply: */
  101     struct
  102       {
  103     int status;
  104     int version;        /* 0x10000*major + minor */
  105     size_t header_bytes;    /* # of header bytes received so far */
  106     size_t content_bytes;   /* # of reply data bytes received so far */
  107     size_t footer_bytes;    /* # of footer bytes received so far */
  108       }
  109     reply;
  110   }
  111 Call;
  112 
  113 /* Initialize the new call object C.  */
  114 extern void call_init (Call *c);
  115 
  116 /* Destroy the call-specific state in call object C.  */
  117 extern void call_deinit (Call *c);
  118 
  119 #define call_new()  ((Call *) object_new (OBJ_CALL))
  120 #define call_inc_ref(c) object_inc_ref ((Object *) (c))
  121 #define call_dec_ref(c) object_dec_ref ((Object *) (c))
  122 
  123 /* Append the additional request header line(s) HDR to the request
  124    headers.  The total length of the additional headers is LEN bytes.
  125    The headers must be end with a carriage-return, line-feed sequence
  126    ("\r\n").  */
  127 extern int call_append_request_header (Call *c, const char *hdr, size_t len);
  128 
  129 #define call_set_method(c, method, method_len)          \
  130   do                                \
  131     {                               \
  132       c->req.iov[IE_METHOD].iov_base = (caddr_t) method;    \
  133       c->req.iov[IE_METHOD].iov_len = method_len;       \
  134     }                               \
  135   while (0)
  136 
  137 #define call_set_location(c, loc, loc_len)      \
  138   do                            \
  139     {                           \
  140       c->req.iov[IE_LOC].iov_base = (caddr_t) loc;  \
  141       c->req.iov[IE_LOC].iov_len = loc_len;     \
  142     }                           \
  143   while (0)
  144 
  145 #define call_set_uri(c, uri, uri_len)           \
  146   do                            \
  147     {                           \
  148       c->req.iov[IE_URI].iov_base = (caddr_t) uri;  \
  149       c->req.iov[IE_URI].iov_len = uri_len;     \
  150     }                           \
  151   while (0)
  152 
  153 #define call_set_contents(c, content, content_len)      \
  154   do                                \
  155     {                               \
  156       c->req.iov[IE_CONTENT].iov_base = (caddr_t) content;  \
  157       c->req.iov[IE_CONTENT].iov_len = content_len;     \
  158     }                               \
  159   while (0)
  160 
  161 #endif /* call_h */