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

experimental.h

Go to the documentation of this file.
00001 /** @file
00002 
00003     A brief file description
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 /* 
00025  *   Interfaces in this header file are experimental, undocumented and
00026  *   are subject to change even across minor releases of Traffic Server.
00027  *   None of the interfaces in this file are committed to be stable
00028  *   unless they are migrated to ts/ts.h  If you require stable APIs to
00029  *   Traffic Server, DO NOT USE anything in this file.
00030  */
00031 
00032 #ifndef __TS_API_EXPERIMENTAL_H__
00033 #define __TS_API_EXPERIMENTAL_H__
00034 
00035 #ifdef __cplusplus
00036 extern "C"
00037 {
00038 #endif                          /* __cplusplus */
00039 
00040   typedef enum
00041   {
00042     TS_FETCH_EVENT_EXT_HEAD_READY = -1,
00043     TS_FETCH_EVENT_EXT_HEAD_DONE = -2,
00044     TS_FETCH_EVENT_EXT_BODY_READY = -3,
00045     TS_FETCH_EVENT_EXT_BODY_DONE = -4,
00046   } TSFetchEventExt;
00047 
00048   typedef enum
00049   {
00050     TS_FETCH_FLAGS_NONE = 0,           // do nothing
00051     TS_FETCH_FLAGS_STREAM = 1 << 1,    // enable stream IO
00052     TS_FETCH_FLAGS_DECHUNK = 1 << 2,   // dechunk body content
00053     TS_FETCH_FLAGS_NEWLOCK = 1 << 3,   // allocate new lock for fetch sm
00054     TS_FETCH_FLAGS_NOT_INTERNAL_REQUEST = 1 << 4 // Allow this fetch to be created as a non-internal request.
00055   } TSFetchFlags;
00056 
00057   typedef struct tsapi_fetchsm* TSFetchSM;
00058 
00059   /* Forward declaration of in_addr, any user of these APIs should probably 
00060      include net/netinet.h or whatever is appropriate on the platform. */
00061   struct in_addr;
00062 
00063   /* Cache APIs that are not yet fully supported and/or frozen nor complete. */
00064   tsapi TSReturnCode TSCacheBufferInfoGet(TSCacheTxn txnp, uint64_t *length, uint64_t *offset);
00065 
00066   tsapi TSCacheHttpInfo TSCacheHttpInfoCreate();
00067   tsapi void TSCacheHttpInfoReqGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *obj);
00068   tsapi void TSCacheHttpInfoRespGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *obj);
00069   tsapi void TSCacheHttpInfoReqSet(TSCacheHttpInfo infop, TSMBuffer bufp, TSMLoc obj);
00070   tsapi void TSCacheHttpInfoRespSet(TSCacheHttpInfo infop, TSMBuffer bufp, TSMLoc obj);
00071   tsapi void TSCacheHttpInfoKeySet(TSCacheHttpInfo infop, TSCacheKey key);
00072   tsapi void TSCacheHttpInfoSizeSet(TSCacheHttpInfo infop, int64_t size);
00073   tsapi int TSCacheHttpInfoVector(TSCacheHttpInfo infop, void *data, int length);
00074   tsapi time_t TSCacheHttpInfoReqSentTimeGet(TSCacheHttpInfo infop);
00075   tsapi time_t TSCacheHttpInfoRespReceivedTimeGet(TSCacheHttpInfo infop);
00076   int64_t TSCacheHttpInfoSizeGet(TSCacheHttpInfo infop);
00077 
00078   /* Do not edit these apis, used internally */
00079   tsapi int TSMimeHdrFieldEqual(TSMBuffer bufp, TSMLoc hdr_obj, TSMLoc field1, TSMLoc field2);
00080   tsapi TSReturnCode TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp);
00081 
00082   /* for Media-IXT mms over http */
00083   typedef enum
00084     {
00085       TS_HTTP_CNTL_GET_LOGGING_MODE,
00086       TS_HTTP_CNTL_SET_LOGGING_MODE,
00087       TS_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE,
00088       TS_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE
00089     } TSHttpCntlType;
00090 
00091 #define TS_HTTP_CNTL_OFF  (void*) 0
00092 #define TS_HTTP_CNTL_ON   (void*) 1
00093   /* usage:
00094      void *onoff = 0;
00095      TSHttpTxnCntl(.., TS_HTTP_CNTL_GET_LOGGING_MODE, &onoff);
00096      if (onoff == TS_HTTP_CNTL_ON) ....
00097   */
00098   tsapi TSReturnCode TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data);
00099 
00100 
00101   /* Protocols APIs */
00102   tsapi void TSVConnCacheHttpInfoSet(TSVConn connp, TSCacheHttpInfo infop);
00103 
00104   /* ICP freshness functions */
00105   typedef int (*TSPluginFreshnessCalcFunc) (TSCont contp);
00106   tsapi void TSICPFreshnessFuncSet(TSPluginFreshnessCalcFunc funcp);
00107 
00108   tsapi TSReturnCode TSICPCachedReqGet(TSCont contp, TSMBuffer *bufp, TSMLoc *obj);
00109   tsapi TSReturnCode TSICPCachedRespGet(TSCont contp, TSMBuffer *bufp, TSMLoc *obj);
00110 
00111 
00112   /* The rest is from the old "froze" private API include, we should consider
00113      moving some of these over to ts/ts.h as well. TODO */
00114 
00115   /****************************************************************************
00116    *  Test if cache ready to accept request for a specific type of data
00117    ****************************************************************************/
00118   tsapi TSReturnCode TSCacheDataTypeReady(TSCacheDataType type, int *is_ready);
00119 
00120   /****************************************************************************
00121    *  When reenabling a txn in error, keep the connection open in case
00122    *  of keepalive.
00123    ****************************************************************************/
00124   tsapi void TSHttpTxnClientKeepaliveSet(TSHttpTxn txnp, int set);
00125 
00126   /****************************************************************************
00127    *  Allow to set the body of a POST request.
00128    ****************************************************************************/
00129   tsapi void TSHttpTxnServerRequestBodySet(TSHttpTxn txnp, char *buf, int64_t buflength);
00130 
00131   /* ===== High Resolution Time ===== */
00132 #define TS_HRTIME_FOREVER  (10*TS_HRTIME_DECADE)
00133 #define TS_HRTIME_DECADE   (10*TS_HRTIME_YEAR)
00134 #define TS_HRTIME_YEAR     (365*TS_HRTIME_DAY+TS_HRTIME_DAY/4)
00135 #define TS_HRTIME_WEEK     (7*TS_HRTIME_DAY)
00136 #define TS_HRTIME_DAY      (24*TS_HRTIME_HOUR)
00137 #define TS_HRTIME_HOUR     (60*TS_HRTIME_MINUTE)
00138 #define TS_HRTIME_MINUTE   (60*TS_HRTIME_SECOND)
00139 #define TS_HRTIME_SECOND   (1000*TS_HRTIME_MSECOND)
00140 #define TS_HRTIME_MSECOND  (1000*TS_HRTIME_USECOND)
00141 #define TS_HRTIME_USECOND  (1000*TS_HRTIME_NSECOND)
00142 #define TS_HRTIME_NSECOND  (1LL)
00143 
00144 #define TS_HRTIME_APPROX_SECONDS(_x) ((_x)>>30)    /*  off by 7.3% */
00145 #define TS_HRTIME_APPROX_FACTOR      (((float)(1<<30))/(((float)HRTIME_SECOND)))
00146 
00147   /*
00148 ////////////////////////////////////////////////////////////////////
00149 //
00150 //      Map from units to ts_hrtime values
00151 //
00152 ////////////////////////////////////////////////////////////////////
00153 */
00154 #define TS_HRTIME_YEARS(_x)    ((_x)*TS_HRTIME_YEAR)
00155 #define TS_HRTIME_WEEKS(_x)    ((_x)*TS_HRTIME_WEEK)
00156 #define TS_HRTIME_DAYS(_x)     ((_x)*TS_HRTIME_DAY)
00157 #define TS_HRTIME_HOURS(_x)    ((_x)*TS_HRTIME_HOUR)
00158 #define TS_HRTIME_MINUTES(_x)  ((_x)*TS_HRTIME_MINUTE)
00159 #define TS_HRTIME_SECONDS(_x)  ((_x)*TS_HRTIME_SECOND)
00160 #define TS_HRTIME_MSECONDS(_x) ((_x)*TS_HRTIME_MSECOND)
00161 #define TS_HRTIME_USECONDS(_x) ((_x)*TS_HRTIME_USECOND)
00162 #define TS_HRTIME_NSECONDS(_x) ((_x)*TS_HRTIME_NSECOND)
00163 
00164   tsapi TSReturnCode TSHttpTxnCachedRespTimeGet(TSHttpTxn txnp, time_t *resp_time);
00165 
00166   /* ===== Cache ===== */
00167   tsapi TSReturnCode TSCacheKeyDataTypeSet(TSCacheKey key, TSCacheDataType type);
00168 
00169 
00170   /* ===== Utility ===== */
00171   /****************************************************************************
00172    *  Create a random number
00173    *  Return random integer between <X> and <Y>
00174    ****************************************************************************/
00175   tsapi unsigned int TSrandom(void);
00176 
00177   /****************************************************************************
00178    *  Create a random double
00179    *  Return random double between <X> and <Y>
00180    ****************************************************************************/
00181   tsapi double TSdrandom(void);
00182 
00183   /****************************************************************************
00184    *  Return Hi-resolution current time. (int64_t)
00185    ****************************************************************************/
00186   tsapi TSHRTime TShrtime(void);
00187 
00188   /* =====  CacheHttpInfo =====  */
00189 
00190   tsapi TSCacheHttpInfo TSCacheHttpInfoCopy(TSCacheHttpInfo infop);
00191   tsapi void TSCacheHttpInfoReqGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *offset);
00192   tsapi void TSCacheHttpInfoRespGet(TSCacheHttpInfo infop, TSMBuffer *bufp, TSMLoc *offset);
00193   tsapi void TSCacheHttpInfoDestroy(TSCacheHttpInfo infop);
00194 
00195 
00196   /* =====  ICP =====  */
00197   tsapi void TSHttpIcpDynamicSet(int value);
00198 
00199   /****************************************************************************
00200    *  TSHttpTxnCacheLookupCountGet
00201    *  Return: TS_SUCESS/TS_ERROR
00202    ****************************************************************************/
00203   tsapi TSReturnCode TSHttpTxnCacheLookupCountGet(TSHttpTxn txnp, int *lookup_count);
00204   tsapi TSReturnCode TSHttpTxnRedirectRequest(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc url_loc);
00205   tsapi TSReturnCode TSHttpTxnServerRespIgnore(TSHttpTxn txnp);
00206   tsapi TSReturnCode TSHttpTxnShutDown(TSHttpTxn txnp, TSEvent event);
00207   tsapi TSReturnCode TSHttpTxnCloseAfterResponse(TSHttpTxn txnp, int should_close);
00208 
00209   /* TS-1996: These API swill be removed after v3.4.0 is cut. Do not use them! */
00210   tsapi TSReturnCode TSHttpTxnNewCacheLookupDo(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc url_loc);
00211   tsapi TSReturnCode TSHttpTxnSecondUrlTryLock(TSHttpTxn txnp);
00212 
00213   /****************************************************************************
00214    *  ??
00215    *  Return ??
00216    ****************************************************************************/
00217   tsapi int TSHttpTxnClientReqIsServerStyle(TSHttpTxn txnp);
00218 
00219   /****************************************************************************
00220    *  ??
00221    *  Return ??
00222    ****************************************************************************/
00223   tsapi void TSHttpTxnOverwriteExpireTime(TSHttpTxn txnp, time_t expire_time);
00224 
00225   /****************************************************************************
00226    *  ??
00227    *  Return ??
00228    ****************************************************************************/
00229   tsapi TSReturnCode TSHttpTxnUpdateCachedObject(TSHttpTxn txnp);
00230 
00231   /****************************************************************************
00232    *  ??
00233    *  TODO: This returns a LookingUp_t value, we need to SDK'ify it.
00234    ****************************************************************************/
00235   tsapi int TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp);
00236 
00237   /**
00238      Attempt to attach the contp continuation to sockets that have already been
00239      opened by the traffic manager and defined as belonging to plugins (based on
00240      records.config configuration). If a connection is successfully accepted,
00241      the TS_EVENT_NET_ACCEPT is delivered to the continuation. The event
00242      data will be a valid TSVConn bound to the accepted connection.
00243      In order to configure such a socket, add the "plugin" keyword to a port
00244      in proxy.config.http.server_ports like "8082:plugin"
00245      Transparency/IP settings can also be defined, but a port cannot have
00246      both the "ssl" or "plugin" keywords configured.
00247 
00248      Need to update records.config comments on proxy.config.http.server_ports
00249      when this option is promoted from experimental.
00250    */
00251   tsapi TSReturnCode TSPluginDescriptorAccept(TSCont contp);
00252 
00253 
00254   /**
00255       Opens a network connection to the host specified by the 'to' sockaddr
00256       spoofing the client addr to equal the 'from' sockaddr.
00257       If the connection is successfully opened, contp
00258       is called back with the event TS_EVENT_NET_CONNECT and the new
00259       network vconnection will be passed in the event data parameter.
00260       If the connection is not successful, contp is called back with
00261       the event TS_EVENT_NET_CONNECT_FAILED.
00262 
00263       Note: It is possible to receive TS_EVENT_NET_CONNECT
00264       even if the connection failed, because of the implementation of
00265       network sockets in the underlying operating system. There is an
00266       exception: if a plugin tries to open a connection to a port on
00267       its own host machine, then TS_EVENT_NET_CONNECT is sent only
00268       if the connection is successfully opened. In general, however,
00269       your plugin needs to look for an TS_EVENT_VCONN_WRITE_READY to
00270       be sure that the connection is successfully opened.
00271 
00272       @return TSAction which allows you to check if the connection is complete,
00273         or cancel the attempt to connect.
00274 
00275    */
00276   tsapi TSAction TSNetConnectTransparent(TSCont contp, /**< continuation that is called back when the attempted net connection either succeeds or fails. */
00277                                          struct sockaddr const* from, /**< Address to spoof as connection origin */
00278                                          struct sockaddr const* to /**< Address to which to connect. */
00279   );
00280 
00281 
00282   /* =====  Matcher Utils =====  */
00283 #define               TS_MATCHER_LINE_INVALID 0
00284   typedef struct tsapi_matcheline* TSMatcherLine;
00285 
00286   /****************************************************************************
00287    *  ??
00288    *  Return
00289    ****************************************************************************/
00290   tsapi char *TSMatcherReadIntoBuffer(char *file_name, int *file_len);
00291 
00292   /****************************************************************************
00293    *  ??
00294    *  Return
00295    ****************************************************************************/
00296   tsapi char *TSMatcherTokLine(char *buffer, char **last);
00297 
00298   /****************************************************************************
00299    *  ??
00300    *  Return
00301    ****************************************************************************/
00302   tsapi char *TSMatcherExtractIPRange(char *match_str, uint32_t *addr1, uint32_t *addr2);
00303 
00304   /****************************************************************************
00305    *  ??
00306    *  Return
00307    ****************************************************************************/
00308   tsapi TSMatcherLine TSMatcherLineCreate();
00309 
00310   /****************************************************************************
00311    *  ??
00312    *  Return
00313    ****************************************************************************/
00314   tsapi void TSMatcherLineDestroy(TSMatcherLine ml);
00315 
00316   /****************************************************************************
00317    *  ??
00318    *  Return
00319    ****************************************************************************/
00320   tsapi const char *TSMatcherParseSrcIPConfigLine(char *line, TSMatcherLine ml);
00321 
00322   /****************************************************************************
00323    *  ??
00324    *  Return
00325    ****************************************************************************/
00326   tsapi char *TSMatcherLineName(TSMatcherLine ml, int element);
00327 
00328   /****************************************************************************
00329    *  ??
00330    *  Return
00331    ****************************************************************************/
00332   tsapi char *TSMatcherLineValue(TSMatcherLine ml, int element);
00333 
00334   /****************************************************************************
00335    *  Set a records.config integer variable
00336    ****************************************************************************/
00337   tsapi TSReturnCode TSMgmtConfigIntSet(const char *var_name, TSMgmtInt value);
00338 
00339   /* ----------------------------------------------------------------------
00340    * Interfaces used by Wireless group
00341    * ---------------------------------------------------------------------- */
00342 
00343 #define TS_NET_EVENT_DATAGRAM_READ_COMPLETE  TS_EVENT_INTERNAL_206
00344 #define TS_NET_EVENT_DATAGRAM_READ_ERROR     TS_EVENT_INTERNAL_207
00345 #define TS_NET_EVENT_DATAGRAM_WRITE_COMPLETE TS_EVENT_INTERNAL_208
00346 #define TS_NET_EVENT_DATAGRAM_WRITE_ERROR    TS_EVENT_INTERNAL_209
00347 #define TS_NET_EVENT_DATAGRAM_READ_READY     TS_EVENT_INTERNAL_210
00348 #define TS_NET_EVENT_DATAGRAM_OPEN           TS_EVENT_INTERNAL_211
00349 #define TS_NET_EVENT_DATAGRAM_ERROR          TS_EVENT_INTERNAL_212
00350 
00351   /*****************************************************************************
00352    *                    Cluster RPC API support                              *
00353    *****************************************************************************/
00354   /*
00355    *  Usage notes:
00356    *    1) User is responsible for marshalling and unmarshaling data.
00357    *    2) RPC message incompatiblities due to different plugin versions
00358    *     must be dealt with by the user.
00359    *    3) Upon receipt of a machine offline, no guarantees are made about
00360    *     messages sent prior to the machine offline.
00361    *    4) A node transitioning to the online state in an active cluster,
00362    *     is assumed to have no prior knowledge of messages processed in
00363    *     the past.
00364    *    5) Key point to reiterate, actions taken in the functions specified in
00365    *     TSAddClusterStatusFunction() and TSAddClusterRPCFunction() must
00366    *       be non-blocking (i.e. usage of TSMutexLock() and file i/o is
00367    *       not allowed).
00368    *    6) TSSendClusterRPC() can only process TSClusterRPCMsg_t generated
00369    *     by TSAllocClusterRPCMsg().  Failure to adhere to this rule will
00370    *     result in heap corruption.
00371    *    7) Messages sent via TSSendClusterRPC() must be at least 4 bytes in
00372    *     length.
00373    *    8) The user is not provided with any alignment guarantees on the
00374    *     'm_data' field in the TSClusterRPCMsg_t returned via
00375    *     TSAllocClusterRPCMsg().  Assume byte alignment.
00376    *    9) TSSendClusterRPC() interface owns the memory and is responsible
00377    *       for freeing the memory.
00378    *   10) RPC functions defined via TSAddClusterRPCFunction() own the
00379    *       memory when invoked and are responsible for freeing it via
00380    *     TSFreeRPCMsg().
00381    */
00382 #define MAX_CLUSTER_NODES 256
00383 
00384   typedef struct TSClusterRPCHandle
00385   {
00386     int opaque[2];
00387   } TSClusterRPCHandle_t;
00388 
00389   typedef int TSClusterStatusHandle_t;
00390   typedef int TSNodeHandle_t;
00391 
00392   typedef struct TSClusterRPCMsg
00393   {
00394     TSClusterRPCHandle_t m_handle;
00395     char m_data[4];
00396   } TSClusterRPCMsg_t;
00397 
00398   typedef enum
00399     {
00400       NODE_ONLINE = 1,
00401       NODE_OFFLINE
00402     } TSNodeStatus_t;
00403 
00404   typedef enum
00405     {
00406       RPC_API_WIRELESS_F01 = 51,
00407       RPC_API_WIRELESS_F02,
00408       RPC_API_WIRELESS_F03,
00409       RPC_API_WIRELESS_F04,
00410       RPC_API_WIRELESS_F05,
00411       RPC_API_WIRELESS_F06,
00412       RPC_API_WIRELESS_F07,
00413       RPC_API_WIRELESS_F08,
00414       RPC_API_WIRELESS_F09,
00415       RPC_API_WIRELESS_F10
00416     } TSClusterRPCKey_t;
00417 
00418   typedef void (*TSClusterRPCFunction) (TSNodeHandle_t *node, TSClusterRPCMsg_t *msg, int msg_data_len);
00419   typedef void (*TSClusterStatusFunction) (TSNodeHandle_t *node, TSNodeStatus_t s);
00420 
00421   /****************************************************************************
00422    *  Subscribe to node up/down status notification.                        *
00423    *    Return == 0 Success                                                 *
00424    *    Return != 0 Failure                                                 *
00425    * contact: OXY, DY
00426    ****************************************************************************/
00427   tsapi int TSAddClusterStatusFunction(TSClusterStatusFunction Status_Function, TSMutex m, TSClusterStatusHandle_t *h);
00428   /****************************************************************************
00429    *  Cancel subscription to node up/down status notification.              *
00430    *    Return == 0 Success                                                 *
00431    *    Return != 0 Failure                                                 *
00432    * contact: OXY, DY
00433    ****************************************************************************/
00434   tsapi int TSDeleteClusterStatusFunction(TSClusterStatusHandle_t *h);
00435 
00436   /****************************************************************************
00437    *  Get the struct in_addr associated with the TSNodeHandle_t.            *
00438    *    Return == 0 Success                                                 *
00439    *    Return != 0 Failure                                                 *
00440    * contact: OXY, DY
00441    ****************************************************************************/
00442   tsapi int TSNodeHandleToIPAddr(TSNodeHandle_t *h, struct in_addr *in);
00443 
00444   /****************************************************************************
00445    *  Get the TSNodeHandle_t for the local node.                            *
00446    *  contact: OXY, DY
00447    ****************************************************************************/
00448   tsapi void TSGetMyNodeHandle(TSNodeHandle_t *h);
00449 
00450   /****************************************************************************
00451    *  Enable node up/down notification for subscription added via           *
00452    *  TSAddClusterStatusFunction().                                         *
00453    *  contact: OXY, DY
00454    ****************************************************************************/
00455   tsapi void TSEnableClusterStatusCallout(TSClusterStatusHandle_t *h);
00456 
00457   /****************************************************************************
00458    *  Associate the given key with the given RPC function.                  *
00459    *    Return == 0 Success                                                 *
00460    *    Return != 0 Failure                                                 *
00461    *  contact: OXY, DY
00462    ****************************************************************************/
00463   tsapi int TSAddClusterRPCFunction(TSClusterRPCKey_t k, TSClusterRPCFunction RPC_Function, TSClusterRPCHandle_t *h);
00464 
00465   /****************************************************************************
00466    *  Delete the key to function association created via                    *
00467    *  TSAddClusterRPCFunction().                                            *
00468    *    Return == 0 Success                                                 *
00469    *    Return != 0 Failure                                                 *
00470    *  contact: OXY, DY
00471    ****************************************************************************/
00472   tsapi int TSDeleteClusterRPCFunction(TSClusterRPCHandle_t *h);
00473 
00474   /****************************************************************************
00475    *  Free TSClusterRPCMsg_t received via RPC function                      *
00476    *  contact: OXY, DY
00477    ****************************************************************************/
00478   tsapi void TSFreeRPCMsg(TSClusterRPCMsg_t *msg, int msg_data_len);
00479 
00480   /****************************************************************************
00481    *  Allocate TSClusterRPCMsg_t for use in TSSendClusterRPC()              *
00482    *    Return != 0 Success                                                 *
00483    *    Return == 0 Allocation failed                                       *
00484    *  contact: OXY, DY
00485    ****************************************************************************/
00486   tsapi TSClusterRPCMsg_t *TSAllocClusterRPCMsg(TSClusterRPCHandle_t *h, int data_size);
00487 
00488   /****************************************************************************
00489    *  Send the RPC message to the specified node.                           *
00490    *    Cluster frees the given memory on send.                             *
00491    *    RPC function frees memory on receive.                               *
00492    *    Return == 0 Success                                                 *
00493    *    Return != 0 Failure                                                 *
00494    *  contact: OXY, DY
00495    ****************************************************************************/
00496   tsapi int TSSendClusterRPC(TSNodeHandle_t *nh, TSClusterRPCMsg_t *msg);
00497 
00498 
00499 
00500   /*
00501     This is for the prefetch APIs, this really has to be cleaned out. This is
00502     some pretty seriously broken stuff, and we should decide whether it should
00503     die and be redone properly. A few of the issues include:
00504 
00505        * The hooks are not normal ATS continuations, just plain callbacks.
00506        * The hooks are therefore not registered the normal way either...
00507        * And thusly, there can only be one callback for each of the three
00508          Prefetch "hooks".
00509        * The example plugins don't compile, there are old / missing pieces.
00510   */
00511 
00512   typedef enum
00513   {
00514     TS_PREFETCH_UDP_BLAST = 0,
00515     TS_PREFETCH_TCP_BLAST,
00516     TS_PREFETCH_MULTICAST_BLAST
00517   } TSPrefetchBlastType;
00518 
00519   typedef struct
00520   {
00521     TSPrefetchBlastType type;
00522     struct sockaddr_storage ip;
00523   } TSPrefetchBlastData;
00524 
00525   typedef enum
00526   {
00527     TS_PREFETCH_OBJ_BUF_NOT_NEEDED = 0,
00528     TS_PREFETCH_OBJ_BUF_NEEDED,  /* The user wants the buffer but does not
00529                                     want it to be transmitted to the child */
00530     TS_PREFETCH_OBJ_BUF_NEEDED_N_TRANSMITTED     /* The object should
00531                                                     be transmitted as well */
00532   } TSPrefetchStatus;
00533 
00534   /* return type for TSPrefetchHook */
00535   typedef enum
00536     {
00537       TS_PREFETCH_CONTINUE,
00538       TS_PREFETCH_DISCONTINUE
00539     } TSPrefetchReturnCode;
00540 
00541 
00542   /* prefetch hooks, which are *not* normal hooks (no continuations) */
00543   typedef enum
00544   {
00545     TS_PREFETCH_PRE_PARSE_HOOK,
00546     /* This hook is invoked just before we begin to parse a document
00547        request and response headers are available.
00548        Return value: TS_PREFETCH_CONTINUE  :continue parsing
00549        TS_PREFETCH_DISCONTIUE: don't bother parser
00550     */
00551 
00552     TS_PREFETCH_EMBEDDED_URL_HOOK,
00553     /* This hook is invoked when a URL is extracted.
00554        url_proto and url_response_proto contain the default protocols used
00555        for sending the url and actual url object respectively to the child.
00556        The hook can change thes to one of the 3 methods mentioned above.
00557        Return value: TS_PREFETCH_CONTINUE  : prefetch this url.
00558        TS_PREFETCH_DISCONTIUE: don't bother prefetching this
00559        url
00560     */
00561 
00562     TS_PREFETCH_EMBEDDED_OBJECT_HOOK
00563     /* This hook is invoked when the user wants to have access to the buffer
00564        of the embedded object we prefetched. We pass in the buffer reader.
00565        The reader contains the data in the format specified in the Prefetch
00566        document (with 12 byte header etc).
00567        It is the users responsibility to free the reader.
00568        The only valid field in the PrefetchInfo structure object_buf_reader.
00569        embedded_url, object_buf, object_buf_reader, and object_buf_status are
00570        set in TSPrefetchInfo passed as arguments
00571     */
00572   } TSPrefetchHookID;
00573 
00574 
00575   /* This holds the main Prefetch information as used by the hook callbacks. */
00576   typedef struct
00577   {
00578     /*request header */
00579     TSMBuffer request_buf;
00580     TSMLoc request_loc;
00581 
00582     /*response header */
00583     TSMBuffer response_buf;
00584     TSMLoc response_loc;
00585 
00586     /*child ip addr in network order */
00587     struct sockaddr_storage client_ip;
00588 
00589     /*the embedded url parsed by the parser */
00590     const char *embedded_url;
00591 
00592     /* flag which says if a perticular embedded url is present in the cache */
00593     int present_in_cache;
00594 
00595     /* Reader for the buffer which contains the prefetched object */
00596     TSIOBuffer object_buf;
00597     TSIOBufferReader object_buf_reader;
00598 
00599     /* This specifies if we need to invoke the OBJECT_HOOK and whether we
00600        need to send the buffer to child as well
00601        This should set inside EMBEDDED_URL_HOOK by the user
00602     */
00603     int object_buf_status;
00604 
00605     /** Method of sending data to child.
00606 
00607         If set to @c MULTICAST_BLAST then the corresponding address
00608         value must be set to a multicast address to use.
00609     */
00610     TSPrefetchBlastData url_blast;
00611     TSPrefetchBlastData url_response_blast;
00612 
00613   } TSPrefetchInfo;
00614 
00615   typedef TSPrefetchReturnCode (*TSPrefetchHook) (TSPrefetchHookID hook, TSPrefetchInfo* prefetch_info);
00616 
00617   /* Registers a hook for the given hook_no.
00618      A hook is already present, it is replace by hook_fn
00619      return value 0 indicates success */
00620   tsapi int TSPrefetchHookSet(int hook_no, TSPrefetchHook hook_fn);
00621 
00622 
00623   /**
00624    * Extended FetchSM's AIPs
00625    */
00626 
00627   /*
00628    * Create FetchSM, this API will enable stream IO automatically.
00629    *
00630    * @param contp: continuation to be callbacked.
00631    * @param method: request method.
00632    * @param url: scheme://host[:port]/path.
00633    * @param version: client http version, eg: "HTTP/1.1".
00634    * @param client_addr: client addr sent to log.
00635    * @param flags: can be bitwise OR of several TSFetchFlags.
00636    *
00637    * return TSFetchSM which should be destroyed by TSFetchDestroy().
00638    */
00639   tsapi TSFetchSM TSFetchCreate(TSCont contp, const char *method,
00640                                 const char *url, const char *version,
00641                                 struct sockaddr const* client_addr, int flags);
00642 
00643   /*
00644    * Create FetchSM, this API will enable stream IO automatically.
00645    *
00646    * @param fetch_sm: returned value of TSFetchCreate().
00647    * @param name: name of header.
00648    * @param name_len: len of name.
00649    * @param value: value of header.
00650    * @param name_len: len of value.
00651    *
00652    * return TSFetchSM which should be destroyed by TSFetchDestroy().
00653    */
00654   tsapi void TSFetchHeaderAdd(TSFetchSM fetch_sm,
00655                               const char *name, int name_len,
00656                               const char *value, int value_len);
00657 
00658   /*
00659    * Write data to FetchSM
00660    *
00661    * @param fetch_sm: returned value of TSFetchCreate().
00662    * @param data/len: data to be written to fetch sm.
00663    */
00664   tsapi void TSFetchWriteData(TSFetchSM fetch_sm, const void *data, size_t len);
00665 
00666   /*
00667    * Read up to *len* bytes from FetchSM into *buf*.
00668    *
00669    * @param fetch_sm: returned value of TSFetchCreate().
00670    * @param buf/len: buffer to contain data from fetch sm.
00671    */
00672   tsapi ssize_t TSFetchReadData(TSFetchSM fetch_sm, void *buf, size_t len);
00673 
00674   /*
00675    * Lanuch FetchSM to do http request, before calling this API,
00676    * you should append http request header into fetch sm through
00677    * TSFetchWriteData() API
00678    *
00679    * @param fetch_sm: comes from returned value of TSFetchCreate().
00680    */
00681   tsapi void TSFetchLaunch(TSFetchSM fetch_sm);
00682 
00683   /*
00684    * Destroy FetchSM
00685    *
00686    * @param fetch_sm: returned value of TSFetchCreate().
00687    */
00688   tsapi void TSFetchDestroy(TSFetchSM fetch_sm);
00689 
00690   /*
00691    * Set user-defined data in FetchSM
00692    */
00693   tsapi void TSFetchUserDataSet(TSFetchSM fetch_sm, void *data);
00694 
00695   /*
00696    * Get user-defined data in FetchSM
00697    */
00698   tsapi void* TSFetchUserDataGet(TSFetchSM fetch_sm);
00699 
00700   /*
00701    * Get client response hdr mbuffer
00702    */
00703   tsapi TSMBuffer TSFetchRespHdrMBufGet(TSFetchSM fetch_sm);
00704 
00705   /*
00706    * Get client response hdr mloc
00707    */
00708   tsapi TSMLoc TSFetchRespHdrMLocGet(TSFetchSM fetch_sm);
00709 
00710 #ifdef __cplusplus
00711 }
00712 #endif                          /* __cplusplus */
00713 #endif                          /* __TS_API_EXPERIMENTAL_H__ */

Generated by  doxygen 1.7.1