1 /** @file
2 
3   A brief file description
4 
5   @section license License
6 
7   Licensed to the Apache Software Foundation (ASF) under one
8   or more contributor license agreements.  See the NOTICE file
9   distributed with this work for additional information
10   regarding copyright ownership.  The ASF licenses this file
11   to you under the Apache License, Version 2.0 (the
12   "License"); you may not use this file except in compliance
13   with the License.  You may obtain a copy of the License at
14 
15       http://www.apache.org/licenses/LICENSE-2.0
16 
17   Unless required by applicable law or agreed to in writing, software
18   distributed under the License is distributed on an "AS IS" BASIS,
19   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   See the License for the specific language governing permissions and
21   limitations under the License.
22  */
23 
24 #include "HttpDebugNames.h"
25 #include "P_EventSystem.h"
26 #include "StatPages.h"
27 #include "HttpTunnel.h"
28 #include "Transform.h"
29 #include "HttpSM.h"
30 #include "HttpUpdateSM.h"
31 #include <ts/apidefs.h>
32 #include <I_Event.h>
33 
34 //----------------------------------------------------------------------------
35 const char *
get_server_state_name(HttpTransact::ServerState_t state)36 HttpDebugNames::get_server_state_name(HttpTransact::ServerState_t state)
37 {
38   switch (state) {
39   case HttpTransact::STATE_UNDEFINED:
40     return "STATE_UNDEFINED";
41   case HttpTransact::ACTIVE_TIMEOUT:
42     return "ACTIVE_TIMEOUT";
43   case HttpTransact::BAD_INCOMING_RESPONSE:
44     return "BAD_INCOMING_RESPONSE";
45   case HttpTransact::CONNECTION_ALIVE:
46     return "CONNECTION_ALIVE";
47   case HttpTransact::CONNECTION_CLOSED:
48     return "CONNECTION_CLOSED";
49   case HttpTransact::CONNECTION_ERROR:
50     return "CONNECTION_ERROR";
51   case HttpTransact::INACTIVE_TIMEOUT:
52     return "INACTIVE_TIMEOUT";
53   case HttpTransact::OPEN_RAW_ERROR:
54     return "OPEN_RAW_ERROR";
55   case HttpTransact::PARSE_ERROR:
56     return "PARSE_ERROR";
57   case HttpTransact::TRANSACTION_COMPLETE:
58     return "TRANSACTION_COMPLETE";
59   case HttpTransact::PARENT_RETRY:
60     return "PARENT_RETRY";
61   case HttpTransact::OUTBOUND_CONGESTION:
62     return "OUTBOUND_CONGESTION";
63   }
64 
65   return ("unknown state name");
66 }
67 
68 //////////////////////////////////////////////////////////////////
69 //
70 //  HttpDebugNames::get_method_name()
71 //
72 //////////////////////////////////////////////////////////////////
73 const char *
get_method_name(const char * method)74 HttpDebugNames::get_method_name(const char *method)
75 {
76   if (method == HTTP_METHOD_CONNECT) {
77     return ("HTTP_METHOD_CONNECT");
78   } else if (method == HTTP_METHOD_DELETE) {
79     return ("HTTP_METHOD_DELETE");
80   } else if (method == HTTP_METHOD_GET) {
81     return ("HTTP_METHOD_GET");
82   } else if (method == HTTP_METHOD_HEAD) {
83     return ("HTTP_METHOD_HEAD");
84   } else if (method == HTTP_METHOD_OPTIONS) {
85     return ("HTTP_METHOD_OPTIONS");
86   } else if (method == HTTP_METHOD_POST) {
87     return ("HTTP_METHOD_POST");
88   } else if (method == HTTP_METHOD_PURGE) {
89     return ("HTTP_METHOD_PURGE");
90   } else if (method == HTTP_METHOD_PUT) {
91     return ("HTTP_METHOD_PUT");
92   } else if (method == HTTP_METHOD_TRACE) {
93     return ("HTTP_METHOD_TRACE");
94   } else {
95     return ("HTTP_METHOD_UNKNOWN");
96   }
97 }
98 
99 //////////////////////////////////////////////////////////////////
100 //
101 //  HttpDebugNames::get_event_name()
102 //
103 //////////////////////////////////////////////////////////////////
104 const char *
get_event_name(int event)105 HttpDebugNames::get_event_name(int event)
106 {
107   switch (event) {
108   case EVENT_NONE:
109     static_assert(static_cast<int>(EVENT_NONE) == static_cast<int>(VC_EVENT_NONE));
110     return "EVENT_NONE/VC_EVENT_NONE";
111   case EVENT_IMMEDIATE:
112     static_assert(static_cast<int>(EVENT_IMMEDIATE) == static_cast<int>(TS_EVENT_IMMEDIATE));
113     static_assert(static_cast<int>(EVENT_IMMEDIATE) == static_cast<int>(VC_EVENT_IMMEDIATE));
114     return "EVENT_IMMEDIATE/TS_EVENT_IMMEDIATE/VC_EVENT_IMMEDIATE";
115   case EVENT_ERROR:
116     static_assert(static_cast<int>(EVENT_ERROR) == static_cast<int>(TS_EVENT_ERROR));
117     static_assert(static_cast<int>(EVENT_ERROR) == static_cast<int>(VC_EVENT_ERROR));
118     return "EVENT_ERROR/TS_EVENT_ERROR/VC_EVENT_ERROR";
119   case EVENT_INTERVAL:
120     return "EVENT_INTERVAL";
121   case VC_EVENT_READ_READY:
122     static_assert(static_cast<int>(VC_EVENT_READ_READY) == static_cast<int>(TS_EVENT_VCONN_READ_READY));
123     return "VC_EVENT_READ_READY/TS_EVENT_VCONN_READ_READY";
124   case VC_EVENT_WRITE_READY:
125     static_assert(static_cast<int>(VC_EVENT_WRITE_READY) == static_cast<int>(TS_EVENT_VCONN_WRITE_READY));
126     return "VC_EVENT_WRITE_READY/TS_EVENT_VCONN_WRITE_READY";
127   case VC_EVENT_READ_COMPLETE:
128     static_assert(static_cast<int>(VC_EVENT_READ_COMPLETE) == static_cast<int>(TS_EVENT_VCONN_READ_COMPLETE));
129     return "VC_EVENT_READ_COMPLETE/TS_EVENT_VCONN_READ_COMPLETE";
130   case VC_EVENT_WRITE_COMPLETE:
131     static_assert(static_cast<int>(VC_EVENT_WRITE_COMPLETE) == static_cast<int>(TS_EVENT_VCONN_WRITE_COMPLETE));
132     return "VC_EVENT_WRITE_COMPLETE/TS_EVENT_VCONN_WRITE_COMPLETE";
133   case VC_EVENT_EOS:
134     static_assert(static_cast<int>(VC_EVENT_EOS) == static_cast<int>(TS_EVENT_VCONN_EOS));
135     return "VC_EVENT_EOS/TS_EVENT_VCONN_EOS";
136   case VC_EVENT_INACTIVITY_TIMEOUT:
137     static_assert(static_cast<int>(VC_EVENT_INACTIVITY_TIMEOUT) == static_cast<int>(TS_EVENT_VCONN_INACTIVITY_TIMEOUT));
138     return "VC_EVENT_INACTIVITY_TIMEOUT/TS_EVENT_VCONN_INACTIVITY_TIMEOUT";
139   case VC_EVENT_ACTIVE_TIMEOUT:
140     static_assert(static_cast<int>(VC_EVENT_ACTIVE_TIMEOUT) == static_cast<int>(TS_EVENT_VCONN_ACTIVE_TIMEOUT));
141     return "VC_EVENT_ACTIVE_TIMEOUT/TS_EVENT_VCONN_ACTIVE_TIMEOUT";
142 
143   /////////////////
144   // NET  EVENTS //
145   /////////////////
146   case NET_EVENT_OPEN:
147     static_assert(static_cast<int>(NET_EVENT_OPEN) == static_cast<int>(TS_EVENT_NET_CONNECT));
148     return "NET_EVENT_OPEN/TS_EVENT_NET_CONNECT";
149   case NET_EVENT_ACCEPT:
150     static_assert(static_cast<int>(NET_EVENT_ACCEPT) == static_cast<int>(TS_EVENT_NET_ACCEPT));
151     return "NET_EVENT_ACCEPT/TS_EVENT_NET_ACCEPT";
152   case NET_EVENT_OPEN_FAILED:
153     static_assert(static_cast<int>(NET_EVENT_OPEN_FAILED) == static_cast<int>(TS_EVENT_NET_CONNECT_FAILED));
154     return "NET_EVENT_OPEN_FAILED/TS_EVENT_NET_CONNECT_FAILED";
155 
156   ////////////////////
157   // HOSTDB  EVENTS //
158   ////////////////////
159   case EVENT_HOST_DB_LOOKUP:
160     static_assert(static_cast<int>(EVENT_HOST_DB_LOOKUP) == static_cast<int>(TS_EVENT_HOST_LOOKUP));
161     return "EVENT_HOST_DB_LOOKUP/TS_EVENT_HOST_LOOKUP";
162   case EVENT_HOST_DB_GET_RESPONSE:
163     return "EVENT_HOST_DB_GET_RESPONSE";
164   case EVENT_SRV_LOOKUP:
165     return "EVENT_SRV_LOOKUP";
166   case EVENT_SRV_IP_REMOVED:
167     return "EVENT_SRV_IP_REMOVED";
168   case EVENT_SRV_GET_RESPONSE:
169     return "EVENT_SRV_GET_RESPONSE";
170 
171   ////////////////////
172   // DNS     EVENTS //
173   ////////////////////
174   case DNS_EVENT_LOOKUP:
175     return "DNS_EVENT_LOOKUP";
176 
177   ////////////////////
178   // CACHE   EVENTS //
179   ////////////////////
180   case CACHE_EVENT_LOOKUP_FAILED:
181     return "CACHE_EVENT_LOOKUP_FAILED";
182   case CACHE_EVENT_OPEN_READ:
183     static_assert(static_cast<int>(CACHE_EVENT_OPEN_READ) == static_cast<int>(TS_EVENT_CACHE_OPEN_READ));
184     return "CACHE_EVENT_OPEN_READ/TS_EVENT_CACHE_OPEN_READ";
185   case CACHE_EVENT_OPEN_READ_FAILED:
186     static_assert(static_cast<int>(CACHE_EVENT_OPEN_READ_FAILED) == static_cast<int>(TS_EVENT_CACHE_OPEN_READ_FAILED));
187     return "CACHE_EVENT_OPEN_READ_FAILED/TS_EVENT_CACHE_OPEN_READ_FAILED";
188   case CACHE_EVENT_OPEN_WRITE:
189     static_assert(static_cast<int>(CACHE_EVENT_OPEN_WRITE) == static_cast<int>(TS_EVENT_CACHE_OPEN_WRITE));
190     return "CACHE_EVENT_OPEN_WRITE/TS_EVENT_CACHE_OPEN_WRITE";
191   case CACHE_EVENT_OPEN_WRITE_FAILED:
192     static_assert(static_cast<int>(CACHE_EVENT_OPEN_WRITE_FAILED) == static_cast<int>(TS_EVENT_CACHE_OPEN_WRITE_FAILED));
193     return "CACHE_EVENT_OPEN_WRITE_FAILED/TS_EVENT_CACHE_OPEN_WRITE_FAILED";
194   case CACHE_EVENT_REMOVE:
195     static_assert(static_cast<int>(CACHE_EVENT_REMOVE) == static_cast<int>(TS_EVENT_CACHE_REMOVE));
196     return "CACHE_EVENT_REMOVE/TS_EVENT_CACHE_REMOVE";
197   case CACHE_EVENT_REMOVE_FAILED:
198     static_assert(static_cast<int>(CACHE_EVENT_REMOVE_FAILED) == static_cast<int>(TS_EVENT_CACHE_REMOVE_FAILED));
199     return "CACHE_EVENT_REMOVE_FAILED/TS_EVENT_CACHE_REMOVE_FAILED";
200   case CACHE_EVENT_UPDATE:
201     return "CACHE_EVENT_UPDATE";
202   case CACHE_EVENT_UPDATE_FAILED:
203     return "CACHE_EVENT_UPDATE_FAILED";
204 
205   case STAT_PAGE_SUCCESS:
206     return "STAT_PAGE_SUCCESS";
207   case STAT_PAGE_FAILURE:
208     return "STAT_PAGE_FAILURE";
209 
210   case TRANSFORM_READ_READY:
211     static_assert(static_cast<int>(TRANSFORM_READ_READY) == static_cast<int>(TS_EVENT_SSL_SESSION_GET));
212     return "TRANSFORM_READ_READY/TS_EVENT_SSL_SESSION_GET";
213 
214   /////////////////////////
215   //  HttpTunnel Events  //
216   /////////////////////////
217   case HTTP_TUNNEL_EVENT_DONE:
218     return "HTTP_TUNNEL_EVENT_DONE";
219   case HTTP_TUNNEL_EVENT_PRECOMPLETE:
220     return "HTTP_TUNNEL_EVENT_PRECOMPLETE";
221   case HTTP_TUNNEL_EVENT_CONSUMER_DETACH:
222     return "HTTP_TUNNEL_EVENT_CONSUMER_DETACH";
223 
224   /////////////////////////////
225   //  Plugin Events
226   /////////////////////////////
227   case HTTP_API_CONTINUE:
228     static_assert(static_cast<int>(HTTP_API_CONTINUE) == static_cast<int>(TS_EVENT_HTTP_CONTINUE));
229     return "HTTP_API_CONTINUE/TS_EVENT_HTTP_CONTINUE";
230   case HTTP_API_ERROR:
231     static_assert(static_cast<int>(HTTP_API_ERROR) == static_cast<int>(TS_EVENT_HTTP_ERROR));
232     return "HTTP_API_ERROR/TS_EVENT_HTTP_ERROR";
233 
234   ///////////////////////////////
235   //  Scheduled Update Events
236   ///////////////////////////////
237   case HTTP_SCH_UPDATE_EVENT_WRITTEN:
238     return "HTTP_SCH_UPDATE_EVENT_WRITTEN";
239   case HTTP_SCH_UPDATE_EVENT_UPDATED:
240     return "HTTP_SCH_UPDATE_EVENT_UPDATED";
241   case HTTP_SCH_UPDATE_EVENT_DELETED:
242     return "HTTP_SCH_UPDATE_EVENT_DELETED";
243   case HTTP_SCH_UPDATE_EVENT_NOT_CACHED:
244     return "HTTP_SCH_UPDATE_EVENT_NOT_CACHED";
245   case HTTP_SCH_UPDATE_EVENT_ERROR:
246     return "HTTP_SCH_UPDATE_EVENT_ERROR";
247   case HTTP_SCH_UPDATE_EVENT_NO_ACTION:
248     return "HTTP_SCH_UPDATE_EVENT_NO_ACTION";
249 
250   case TS_EVENT_NET_ACCEPT_FAILED:
251     return "TS_EVENT_NET_ACCEPT_FAILED";
252   case TS_EVENT_INTERNAL_206:
253     return "TS_EVENT_INTERNAL_206";
254   case TS_EVENT_INTERNAL_207:
255     return "TS_EVENT_INTERNAL_207";
256   case TS_EVENT_INTERNAL_208:
257     return "TS_EVENT_INTERNAL_208";
258   case TS_EVENT_INTERNAL_209:
259     return "TS_EVENT_INTERNAL_209";
260   case TS_EVENT_INTERNAL_210:
261     return "TS_EVENT_INTERNAL_210";
262   case TS_EVENT_INTERNAL_211:
263     return "TS_EVENT_INTERNAL_211";
264   case TS_EVENT_INTERNAL_212:
265     return "TS_EVENT_INTERNAL_212";
266   case TS_EVENT_CACHE_SCAN:
267     return "TS_EVENT_CACHE_SCAN";
268   case TS_EVENT_CACHE_SCAN_FAILED:
269     return "TS_EVENT_CACHE_SCAN_FAILED";
270   case TS_EVENT_CACHE_SCAN_OBJECT:
271     return "TS_EVENT_CACHE_SCAN_OBJECT";
272   case TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED:
273     return "TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED";
274   case TS_EVENT_CACHE_SCAN_OPERATION_FAILED:
275     return "TS_EVENT_CACHE_SCAN_OPERATION_FAILED";
276   case TS_EVENT_CACHE_SCAN_DONE:
277     return "TS_EVENT_CACHE_SCAN_DONE";
278   case TS_EVENT_CACHE_LOOKUP:
279     return "TS_EVENT_CACHE_LOOKUP";
280   case TS_EVENT_CACHE_READ:
281     return "TS_EVENT_CACHE_READ";
282   case TS_EVENT_CACHE_DELETE:
283     return "TS_EVENT_CACHE_DELETE";
284   case TS_EVENT_CACHE_WRITE:
285     return "TS_EVENT_CACHE_WRITE";
286   case TS_EVENT_CACHE_WRITE_HEADER:
287     return "TS_EVENT_CACHE_WRITE_HEADER";
288   case TS_EVENT_CACHE_CLOSE:
289     return "TS_EVENT_CACHE_CLOSE";
290   case TS_EVENT_CACHE_LOOKUP_READY:
291     return "TS_EVENT_CACHE_LOOKUP_READY";
292   case TS_EVENT_CACHE_LOOKUP_COMPLETE:
293     return "TS_EVENT_CACHE_LOOKUP_COMPLETE";
294   case TS_EVENT_CACHE_READ_READY:
295     return "TS_EVENT_CACHE_READ_READY";
296   case TS_EVENT_CACHE_READ_COMPLETE:
297     return "TS_EVENT_CACHE_READ_COMPLETE";
298   case TS_EVENT_INTERNAL_1200:
299     return "TS_EVENT_INTERNAL_1200";
300   case TS_EVENT_SSL_SESSION_NEW:
301     return "TS_EVENT_SSL_SESSION_NEW";
302   case TS_EVENT_SSL_SESSION_REMOVE:
303     return "TS_EVENT_SSL_SESSION_REMOVE";
304   case TS_EVENT_AIO_DONE:
305     return "TS_EVENT_AIO_DONE";
306   case TS_EVENT_HTTP_READ_REQUEST_HDR:
307     return "TS_EVENT_HTTP_READ_REQUEST_HDR";
308   case TS_EVENT_HTTP_OS_DNS:
309     return "TS_EVENT_HTTP_OS_DNS";
310   case TS_EVENT_HTTP_SEND_REQUEST_HDR:
311     return "TS_EVENT_HTTP_SEND_REQUEST_HDR";
312   case TS_EVENT_HTTP_READ_CACHE_HDR:
313     return "TS_EVENT_HTTP_READ_CACHE_HDR";
314   case TS_EVENT_HTTP_READ_RESPONSE_HDR:
315     return "TS_EVENT_HTTP_READ_RESPONSE_HDR";
316   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
317     return "TS_EVENT_HTTP_SEND_RESPONSE_HDR";
318   case TS_EVENT_HTTP_REQUEST_TRANSFORM:
319     return "TS_EVENT_HTTP_REQUEST_TRANSFORM";
320   case TS_EVENT_HTTP_RESPONSE_TRANSFORM:
321     return "TS_EVENT_HTTP_RESPONSE_TRANSFORM";
322   case TS_EVENT_HTTP_SELECT_ALT:
323     return "TS_EVENT_HTTP_SELECT_ALT";
324   case TS_EVENT_HTTP_TXN_START:
325     return "TS_EVENT_HTTP_TXN_START";
326   case TS_EVENT_HTTP_TXN_CLOSE:
327     return "TS_EVENT_HTTP_TXN_CLOSE";
328   case TS_EVENT_HTTP_SSN_START:
329     return "TS_EVENT_HTTP_SSN_START";
330   case TS_EVENT_HTTP_SSN_CLOSE:
331     return "TS_EVENT_HTTP_SSN_CLOSE";
332   case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
333     return "TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE";
334   case TS_EVENT_HTTP_PRE_REMAP:
335     return "TS_EVENT_HTTP_PRE_REMAP";
336   case TS_EVENT_HTTP_POST_REMAP:
337     return "TS_EVENT_HTTP_POST_REMAP";
338   case TS_EVENT_LIFECYCLE_PORTS_INITIALIZED:
339     return "TS_EVENT_LIFECYCLE_PORTS_INITIALIZED";
340   case TS_EVENT_LIFECYCLE_PORTS_READY:
341     return "TS_EVENT_LIFECYCLE_PORTS_READY";
342   case TS_EVENT_LIFECYCLE_CACHE_READY:
343     return "TS_EVENT_LIFECYCLE_CACHE_READY";
344   case TS_EVENT_LIFECYCLE_SERVER_SSL_CTX_INITIALIZED:
345     return "TS_EVENT_LIFECYCLE_SERVER_SSL_CTX_INITIALIZED";
346   case TS_EVENT_LIFECYCLE_CLIENT_SSL_CTX_INITIALIZED:
347     return "TS_EVENT_LIFECYCLE_CLIENT_SSL_CTX_INITIALIZED";
348   case TS_EVENT_LIFECYCLE_TASK_THREADS_READY:
349     return "TS_EVENT_LIFECYCLE_TASK_THREADS_READY";
350   case TS_EVENT_LIFECYCLE_SHUTDOWN:
351     return "TS_EVENT_LIFECYCLE_SHUTDOWN";
352   case TS_EVENT_VCONN_START:
353     return "TS_EVENT_VCONN_START";
354   case TS_EVENT_VCONN_CLOSE:
355     return "TS_EVENT_VCONN_CLOSE";
356   case TS_EVENT_LIFECYCLE_MSG:
357     return "TS_EVENT_LIFECYCLE_MSG";
358   case TS_EVENT_HTTP_REQUEST_BUFFER_COMPLETE:
359     return "TS_EVENT_HTTP_REQUEST_BUFFER_COMPLETE";
360   case TS_EVENT_MGMT_UPDATE:
361     return "TS_EVENT_MGMT_UPDATE";
362   case TS_EVENT_INTERNAL_60200:
363     return "TS_EVENT_INTERNAL_60200";
364   case TS_EVENT_INTERNAL_60201:
365     return "TS_EVENT_INTERNAL_60201";
366   case TS_EVENT_INTERNAL_60202:
367     return "TS_EVENT_INTERNAL_60202";
368   case TS_EVENT_SSL_CLIENT_HELLO:
369     return "TS_EVENT_SSL_CLIENT_HELLO";
370   case TS_EVENT_SSL_CERT:
371     return "TS_EVENT_SSL_CERT";
372   case TS_EVENT_SSL_SERVERNAME:
373     return "TS_EVENT_SSL_SERVERNAME";
374   case TS_EVENT_SSL_VERIFY_SERVER:
375     return "TS_EVENT_SSL_VERIFY_SERVER";
376   case TS_EVENT_SSL_VERIFY_CLIENT:
377     return "TS_EVENT_SSL_VERIFY_CLIENT";
378   case TS_EVENT_VCONN_OUTBOUND_START:
379     return "TS_EVENT_VCONN_OUTBOUND_START";
380   case TS_EVENT_VCONN_OUTBOUND_CLOSE:
381     return "TS_EVENT_VCONN_OUTBOUND_CLOSE";
382   }
383 
384   return ("unknown event");
385 }
386 
387 //////////////////////////////////////////////////////////////////
388 //
389 //  HttpDebugNames::get_action_name()
390 //
391 //////////////////////////////////////////////////////////////////
392 const char *
get_action_name(HttpTransact::StateMachineAction_t e)393 HttpDebugNames::get_action_name(HttpTransact::StateMachineAction_t e)
394 {
395   switch (e) {
396   case HttpTransact::SM_ACTION_UNDEFINED:
397     return ("SM_ACTION_UNDEFINED");
398 
399   case HttpTransact::SM_ACTION_CACHE_ISSUE_WRITE:
400     return ("SM_ACTION_CACHE_ISSUE_WRITE");
401 
402   case HttpTransact::SM_ACTION_CACHE_ISSUE_WRITE_TRANSFORM:
403     return ("SM_ACTION_CACHE_ISSUE_WRITE_TRANSFORM");
404 
405   case HttpTransact::SM_ACTION_CACHE_LOOKUP:
406     return ("SM_ACTION_CACHE_LOOKUP");
407 
408   case HttpTransact::SM_ACTION_DNS_LOOKUP:
409     return ("SM_ACTION_DNS_LOOKUP");
410 
411   case HttpTransact::SM_ACTION_DNS_REVERSE_LOOKUP:
412     return ("SM_ACTION_DNS_REVERSE_LOOKUP");
413 
414   case HttpTransact::SM_ACTION_CACHE_PREPARE_UPDATE:
415     return ("SM_ACTION_CACHE_PREPARE_UPDATE");
416 
417   case HttpTransact::SM_ACTION_CACHE_ISSUE_UPDATE:
418     return ("SM_ACTION_CACHE_ISSUE_UPDATE");
419 
420   case HttpTransact::SM_ACTION_ORIGIN_SERVER_OPEN:
421     return ("SM_ACTION_ORIGIN_SERVER_OPEN");
422 
423   case HttpTransact::SM_ACTION_ORIGIN_SERVER_RAW_OPEN:
424     return ("SM_ACTION_ORIGIN_SERVER_RAW_OPEN");
425 
426   case HttpTransact::SM_ACTION_ORIGIN_SERVER_RR_MARK_DOWN:
427     return ("SM_ACTION_ORIGIN_SERVER_RR_MARK_DOWN");
428 
429   case HttpTransact::SM_ACTION_READ_PUSH_HDR:
430     return ("SM_ACTION_READ_PUSH_HDR");
431 
432   case HttpTransact::SM_ACTION_STORE_PUSH_BODY:
433     return ("SM_ACTION_STORE_PUSH_BODY");
434 
435   case HttpTransact::SM_ACTION_INTERNAL_CACHE_WRITE:
436     return ("SM_ACTION_INTERNAL_CACHE_WRITE");
437 
438   case HttpTransact::SM_ACTION_INTERNAL_CACHE_DELETE:
439     return ("SM_ACTION_INTERNAL_CACHE_DELETE");
440 
441   case HttpTransact::SM_ACTION_INTERNAL_CACHE_NOOP:
442     return ("SM_ACTION_INTERNAL_CACHE_NOOP");
443 
444   case HttpTransact::SM_ACTION_INTERNAL_CACHE_UPDATE_HEADERS:
445     return ("SM_ACTION_INTERNAL_CACHE_UPDATE_HEADERS");
446 
447   case HttpTransact::SM_ACTION_INTERNAL_REQUEST:
448     return ("SM_ACTION_INTERNAL_REQUEST");
449 
450   case HttpTransact::SM_ACTION_SEND_ERROR_CACHE_NOOP:
451     return ("SM_ACTION_SEND_ERROR_CACHE_NOOP");
452 
453   case HttpTransact::SM_ACTION_SERVE_FROM_CACHE:
454     return ("SM_ACTION_SERVE_FROM_CACHE");
455 
456   case HttpTransact::SM_ACTION_SERVER_READ:
457     return ("SM_ACTION_SERVER_READ");
458 
459   case HttpTransact::SM_ACTION_SSL_TUNNEL:
460     return ("SM_ACTION_SSL_TUNNEL");
461 
462   case HttpTransact::SM_ACTION_CONTINUE:
463     return ("SM_ACTION_CONTINUE");
464 
465   case HttpTransact::SM_ACTION_API_READ_REQUEST_HDR:
466     return ("SM_ACTION_API_READ_REQUEST_HDR");
467 
468   case HttpTransact::SM_ACTION_API_OS_DNS:
469     return ("SM_ACTION_API_OS_DNS");
470 
471   case HttpTransact::SM_ACTION_API_SEND_REQUEST_HDR:
472     return ("SM_ACTION_API_SEND_REQUEST_HDR");
473 
474   case HttpTransact::SM_ACTION_API_READ_CACHE_HDR:
475     return ("SM_ACTION_API_READ_CACHE_HDR");
476 
477   case HttpTransact::SM_ACTION_API_CACHE_LOOKUP_COMPLETE:
478     return ("SM_ACTION_API_CACHE_LOOKUP_COMPLETE");
479 
480   case HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR:
481     return ("SM_ACTION_API_READ_RESPONSE_HDR");
482 
483   case HttpTransact::SM_ACTION_API_SEND_RESPONSE_HDR:
484     return ("SM_ACTION_API_SEND_RESPONSE_HDR");
485 
486   case HttpTransact::SM_ACTION_INTERNAL_100_RESPONSE:
487     return ("SM_ACTION_INTERNAL_100_RESPONSE");
488 
489   case HttpTransact::SM_ACTION_SERVER_PARSE_NEXT_HDR:
490     return ("SM_ACTION_SERVER_PARSE_NEXT_HDR");
491 
492   case HttpTransact::SM_ACTION_TRANSFORM_READ:
493     return ("SM_ACTION_TRANSFORM_READ");
494 
495   case HttpTransact::SM_ACTION_WAIT_FOR_FULL_BODY:
496     return ("SM_ACTION_WAIT_FOR_FULL_BODY");
497 
498   case HttpTransact::SM_ACTION_REQUEST_BUFFER_READ_COMPLETE:
499     return ("SM_ACTION_REQUEST_BUFFER_READ_COMPLETE");
500   case HttpTransact::SM_ACTION_API_SM_START:
501     return ("SM_ACTION_API_SM_START");
502   case HttpTransact::SM_ACTION_REDIRECT_READ:
503     return ("SM_ACTION_REDIRECT_READ");
504   case HttpTransact::SM_ACTION_API_SM_SHUTDOWN:
505     return ("SM_ACTION_API_SM_SHUTDOWN");
506   case HttpTransact::SM_ACTION_REMAP_REQUEST:
507     return ("SM_ACTION_REMAP_REQUEST");
508   case HttpTransact::SM_ACTION_API_PRE_REMAP:
509     return ("SM_ACTION_API_PRE_REMAP");
510   case HttpTransact::SM_ACTION_API_POST_REMAP:
511     return ("SM_ACTION_API_POST_REMAP");
512   case HttpTransact::SM_ACTION_POST_REMAP_SKIP:
513     return ("SM_ACTION_POST_REMAP_SKIP");
514   }
515 
516   return ("unknown state name");
517 }
518 
519 //////////////////////////////////////////////////////////////////
520 //
521 //  HttpDebugNames::get_cache_action_name()
522 //
523 //////////////////////////////////////////////////////////////////
524 const char *
get_cache_action_name(HttpTransact::CacheAction_t t)525 HttpDebugNames::get_cache_action_name(HttpTransact::CacheAction_t t)
526 {
527   switch (t) {
528   case HttpTransact::CACHE_DO_UNDEFINED:
529     return ("CACHE_DO_UNDEFINED");
530   case HttpTransact::CACHE_DO_NO_ACTION:
531     return ("CACHE_DO_NO_ACTION");
532   case HttpTransact::CACHE_DO_DELETE:
533     return ("CACHE_DO_DELETE");
534   case HttpTransact::CACHE_DO_LOOKUP:
535     return ("CACHE_DO_LOOKUP");
536   case HttpTransact::CACHE_DO_REPLACE:
537     return ("CACHE_DO_REPLACE");
538   case HttpTransact::CACHE_DO_SERVE:
539     return ("CACHE_DO_SERVE");
540   case HttpTransact::CACHE_DO_SERVE_AND_DELETE:
541     return ("CACHE_DO_SERVE_AND_DELETE");
542   case HttpTransact::CACHE_DO_SERVE_AND_UPDATE:
543     return ("CACHE_DO_SERVE_AND_UPDATE");
544   case HttpTransact::CACHE_DO_UPDATE:
545     return ("CACHE_DO_UPDATE");
546   case HttpTransact::CACHE_DO_WRITE:
547     return ("CACHE_DO_WRITE");
548   case HttpTransact::CACHE_PREPARE_TO_DELETE:
549     return ("CACHE_PREPARE_TO_DELETE");
550   case HttpTransact::CACHE_PREPARE_TO_UPDATE:
551     return ("CACHE_PREPARE_TO_UPDATE");
552   case HttpTransact::CACHE_PREPARE_TO_WRITE:
553     return ("CACHE_PREPARE_TO_WRITE");
554   case HttpTransact::TOTAL_CACHE_ACTION_TYPES:
555     return ("TOTAL_CACHE_ACTION_TYPES");
556   }
557 
558   return ("unknown cache action");
559 }
560 
561 //////////////////////////////////////////////////////////////////
562 //
563 //  HttpDebugNames::get_api_hook_name()
564 //
565 //////////////////////////////////////////////////////////////////
566 const char *
get_api_hook_name(TSHttpHookID t)567 HttpDebugNames::get_api_hook_name(TSHttpHookID t)
568 {
569   switch (t) {
570   case TS_HTTP_READ_REQUEST_HDR_HOOK:
571     return "TS_HTTP_READ_REQUEST_HDR_HOOK";
572   case TS_HTTP_OS_DNS_HOOK:
573     return "TS_HTTP_OS_DNS_HOOK";
574   case TS_HTTP_SEND_REQUEST_HDR_HOOK:
575     return "TS_HTTP_SEND_REQUEST_HDR_HOOK";
576   case TS_HTTP_READ_CACHE_HDR_HOOK:
577     return "TS_HTTP_READ_CACHE_HDR_HOOK";
578   case TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK:
579     return "TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK";
580   case TS_HTTP_READ_RESPONSE_HDR_HOOK:
581     return "TS_HTTP_READ_RESPONSE_HDR_HOOK";
582   case TS_HTTP_SEND_RESPONSE_HDR_HOOK:
583     return "TS_HTTP_SEND_RESPONSE_HDR_HOOK";
584   case TS_HTTP_REQUEST_TRANSFORM_HOOK:
585     return "TS_HTTP_REQUEST_TRANSFORM_HOOK";
586   case TS_HTTP_REQUEST_BUFFER_READ_COMPLETE_HOOK:
587     return "TS_HTTP_REQUEST_BUFFER_READ_COMPLETE_HOOK";
588   case TS_HTTP_RESPONSE_TRANSFORM_HOOK:
589     return "TS_HTTP_RESPONSE_TRANSFORM_HOOK";
590   case TS_HTTP_SELECT_ALT_HOOK:
591     return "TS_HTTP_SELECT_ALT_HOOK";
592   case TS_HTTP_TXN_START_HOOK:
593     return "TS_HTTP_TXN_START_HOOK";
594   case TS_HTTP_TXN_CLOSE_HOOK:
595     return "TS_HTTP_TXN_CLOSE_HOOK";
596   case TS_HTTP_SSN_START_HOOK:
597     return "TS_HTTP_SSN_START_HOOK";
598   case TS_HTTP_SSN_CLOSE_HOOK:
599     return "TS_HTTP_SSN_CLOSE_HOOK";
600   case TS_HTTP_PRE_REMAP_HOOK:
601     return "TS_HTTP_PRE_REMAP_HOOK";
602   case TS_HTTP_POST_REMAP_HOOK:
603     return "TS_HTTP_POST_REMAP_HOOK";
604   case TS_HTTP_RESPONSE_CLIENT_HOOK:
605     return "TS_HTTP_RESPONSE_CLIENT_HOOK";
606   case TS_HTTP_LAST_HOOK:
607     return "TS_HTTP_LAST_HOOK";
608   case TS_VCONN_START_HOOK:
609     return "TS_VCONN_START_HOOK";
610   case TS_VCONN_CLOSE_HOOK:
611     return "TS_VCONN_CLOSE_HOOK";
612   case TS_SSL_CLIENT_HELLO_HOOK:
613     return "TS_SSL_CLIENT_HELLO_HOOK";
614   case TS_SSL_CERT_HOOK:
615     return "TS_SSL_CERT_HOOK";
616   case TS_SSL_SERVERNAME_HOOK:
617     return "TS_SSL_SERVERNAME_HOOK";
618   case TS_SSL_VERIFY_SERVER_HOOK:
619     return "TS_SSL_VERIFY_SERVER_HOOK";
620   case TS_SSL_VERIFY_CLIENT_HOOK:
621     return "TS_SSL_VERIFY_CLIENT_HOOK";
622   case TS_SSL_SESSION_HOOK:
623     return "TS_SSL_SESSION_HOOK";
624   case TS_VCONN_OUTBOUND_START_HOOK:
625     return "TS_VCONN_OUTBOUND_START_HOOK";
626   case TS_VCONN_OUTBOUND_CLOSE_HOOK:
627     return "TS_VCONN_OUTBOUND_CLOSE_HOOK";
628   }
629 
630   return "unknown hook";
631 }
632 
633 ts::BufferWriter &
bwformat(ts::BufferWriter & w,ts::BWFSpec const & spec,HttpTransact::ServerState_t state)634 bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::ServerState_t state)
635 {
636   if (spec.has_numeric_type()) {
637     return bwformat(w, spec, static_cast<uintmax_t>(state));
638   } else {
639     return bwformat(w, spec, HttpDebugNames::get_server_state_name(state));
640   }
641 }
642 
643 ts::BufferWriter &
bwformat(ts::BufferWriter & w,ts::BWFSpec const & spec,HttpTransact::CacheAction_t state)644 bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::CacheAction_t state)
645 {
646   if (spec.has_numeric_type()) {
647     return bwformat(w, spec, static_cast<uintmax_t>(state));
648   } else {
649     return bwformat(w, spec, HttpDebugNames::get_cache_action_name(state));
650   }
651 }
652 
653 ts::BufferWriter &
bwformat(ts::BufferWriter & w,ts::BWFSpec const & spec,HttpTransact::StateMachineAction_t state)654 bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::StateMachineAction_t state)
655 {
656   if (spec.has_numeric_type()) {
657     return bwformat(w, spec, static_cast<uintmax_t>(state));
658   } else {
659     return bwformat(w, spec, HttpDebugNames::get_action_name(state));
660   }
661 }
662 
663 ts::BufferWriter &
bwformat(ts::BufferWriter & w,ts::BWFSpec const & spec,TSHttpHookID id)664 bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, TSHttpHookID id)
665 {
666   if (spec.has_numeric_type()) {
667     return bwformat(w, spec, static_cast<uintmax_t>(id));
668   } else {
669     return bwformat(w, spec, HttpDebugNames::get_api_hook_name(id));
670   }
671 }
672