• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

SpdyCommon.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   SpdyCommon.h
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef __P_SPDY_COMMON_H__
00025 #define __P_SPDY_COMMON_H__
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <unistd.h>
00030 #include <getopt.h>
00031 #include <limits.h>
00032 #include <string.h>
00033 #include <string>
00034 #include <vector>
00035 #include <map>
00036 
00037 #include "P_Net.h"
00038 #include "ts/ts.h"
00039 #include "ts/libts.h"
00040 #include "ts/experimental.h"
00041 #include <spdylay/spdylay.h>
00042 using namespace std;
00043 
00044 #define STATUS_200      "200 OK"
00045 #define STATUS_304      "304 Not Modified"
00046 #define STATUS_400      "400 Bad Request"
00047 #define STATUS_404      "404 Not Found"
00048 #define STATUS_405      "405 Method Not Allowed"
00049 #define STATUS_500      "500 Internal Server Error"
00050 #define DEFAULT_HTML    "index.html"
00051 #define SPDYD_SERVER    "ATS Spdylay/" SPDYLAY_VERSION
00052 
00053 #define atomic_fetch_and_add(a, b)  __sync_fetch_and_add(&a, b)
00054 #define atomic_fetch_and_sub(a, b)  __sync_fetch_and_sub(&a, b)
00055 #define atomic_inc(a)   atomic_fetch_and_add(a, 1)
00056 #define atomic_dec(a)   atomic_fetch_and_sub(a, 1)
00057 
00058 // SPDYlay callbacks
00059 extern spdylay_session_callbacks spdy_callbacks;
00060 
00061 // Configurations
00062 extern uint32_t spdy_max_concurrent_streams;
00063 extern uint32_t spdy_initial_window_size;
00064 extern int32_t spdy_accept_no_activity_timeout;
00065 extern int32_t spdy_no_activity_timeout_in;
00066 
00067 // Statistics
00068 extern RecRawStatBlock* spdy_rsb;
00069 
00070 enum {
00071   SPDY_STAT_CURRENT_CLIENT_SESSION_COUNT, ///< Current # of active SPDY sessions.
00072   SPDY_STAT_CURRENT_CLIENT_STREAM_COUNT, ///< Current # of active SPDY streams.
00073   SPDY_STAT_TOTAL_TRANSACTIONS_TIME,  //< Total stream time and streams
00074   SPDY_STAT_TOTAL_CLIENT_CONNECTION_COUNT, //< Total connections running spdy
00075 
00076   SPDY_N_STATS ///< Terminal counter, NOT A STAT INDEX.
00077 };
00078 
00079 // Spdy Name/Value pairs
00080 class SpdyNV {
00081 public:
00082 
00083   SpdyNV(TSFetchSM fetch_sm);
00084   ~SpdyNV();
00085 
00086 public:
00087   const char **nv;
00088 
00089 private:
00090   SpdyNV();
00091   void *mime_hdr;
00092   char status[64];
00093   char version[64];
00094 };
00095 
00096 string http_date(time_t t);
00097 int spdy_config_load();
00098 
00099 // Stat helper functions. ToDo: These probably should be turned into #define's as we do elsewhere
00100 #define SPDY_INCREMENT_THREAD_DYN_STAT(_s, _t)     \
00101   RecIncrRawStat(spdy_rsb, _t, (int) _s, 1);
00102 
00103 #define SPDY_DECREMENT_THREAD_DYN_STAT(_s, _t)     \
00104   RecIncrRawStat(spdy_rsb, _t, (int) _s, -1);
00105 
00106 #define SPDY_SUM_THREAD_DYN_STAT(_s, _t, _v)       \
00107   RecIncrRawStat(spdy_rsb, _t, (int) _s, _v);
00108 
00109 #endif

Generated by  doxygen 1.7.1