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 "tscore/ink_config.h"
25 #include <cstdio>
26 #include <cstring>
27 
28 #include "P_EventSystem.h"
29 #include "I_Cache.h"
30 #include "I_Net.h"
31 #include "I_HostDB.h"
32 #include "BaseManager.h"
33 #include "P_RefCountCache.h"
34 
35 /*-------------------------------------------------------------------------
36   event_int_to_string
37 
38   This routine will translate an integer event number to a string
39   identifier based on a brute-force search of a switch tag.  If the event
40   cannot be located in the switch table, the routine will construct and
41   return a string of the integer identifier.
42   -------------------------------------------------------------------------*/
43 
44 const char *
event_int_to_string(int event,int blen,char * buffer)45 event_int_to_string(int event, int blen, char *buffer)
46 {
47   switch (event) {
48   case -1:
49     return "<no event>";
50   case VC_EVENT_READ_READY:
51     return "VC_EVENT_READ_READY";
52   case VC_EVENT_WRITE_READY:
53     return "VC_EVENT_WRITE_READY";
54   case VC_EVENT_READ_COMPLETE:
55     return "VC_EVENT_READ_COMPLETE";
56   case VC_EVENT_WRITE_COMPLETE:
57     return "VC_EVENT_WRITE_COMPLETE";
58   case VC_EVENT_EOS:
59     return "VC_EVENT_EOS";
60   case VC_EVENT_INACTIVITY_TIMEOUT:
61     return "VC_EVENT_INACTIVITY_TIMEOUT";
62   case VC_EVENT_ACTIVE_TIMEOUT:
63     return "VC_EVENT_ACTIVE_TIMEOUT";
64 
65   case NET_EVENT_OPEN:
66     return "NET_EVENT_OPEN";
67   case NET_EVENT_OPEN_FAILED:
68     return "NET_EVENT_OPEN_FAILED";
69   case NET_EVENT_ACCEPT:
70     return "NET_EVENT_ACCEPT";
71   case NET_EVENT_ACCEPT_SUCCEED:
72     return "NET_EVENT_ACCEPT_SUCCEED";
73   case NET_EVENT_ACCEPT_FAILED:
74     return "NET_EVENT_ACCEPT_FAILED";
75 
76   case EVENT_HOST_DB_LOOKUP:
77     return "EVENT_HOST_DB_LOOKUP";
78   case EVENT_HOST_DB_GET_RESPONSE:
79     return "EVENT_HOST_DB_GET_RESPONSE";
80 
81   case DNS_EVENT_EVENTS_START:
82     return "DNS_EVENT_EVENTS_START";
83 
84   case REFCOUNT_CACHE_EVENT_SYNC:
85     return "REFCOUNT_CACHE_EVENT_SYNC";
86 
87   case CACHE_EVENT_LOOKUP:
88     return "CACHE_EVENT_LOOKUP";
89   case CACHE_EVENT_LOOKUP_FAILED:
90     return "CACHE_EVENT_LOOKUP_FAILED";
91   case CACHE_EVENT_OPEN_READ:
92     return "CACHE_EVENT_OPEN_READ";
93   case CACHE_EVENT_OPEN_READ_FAILED:
94     return "CACHE_EVENT_OPEN_READ_FAILED";
95   case CACHE_EVENT_OPEN_WRITE:
96     return "CACHE_EVENT_OPEN_WRITE";
97   case CACHE_EVENT_OPEN_WRITE_FAILED:
98     return "CACHE_EVENT_OPEN_WRITE_FAILED";
99   case CACHE_EVENT_REMOVE:
100     return "CACHE_EVENT_REMOVE";
101   case CACHE_EVENT_REMOVE_FAILED:
102     return "CACHE_EVENT_REMOVE_FAILED";
103   case CACHE_EVENT_UPDATE:
104     return "CACHE_EVENT_UPDATE";
105   case CACHE_EVENT_UPDATE_FAILED:
106     return "CACHE_EVENT_UPDATE_FAILED";
107   case CACHE_EVENT_LINK:
108     return "CACHE_EVENT_LINK";
109   case CACHE_EVENT_LINK_FAILED:
110     return "CACHE_EVENT_LINK_FAILED";
111   case CACHE_EVENT_DEREF:
112     return "CACHE_EVENT_DEREF";
113   case CACHE_EVENT_DEREF_FAILED:
114     return "CACHE_EVENT_DEREF_FAILED";
115   case CACHE_EVENT_RESPONSE:
116     return "CACHE_EVENT_RESPONSE";
117   case CACHE_EVENT_RESPONSE_MSG:
118     return "CACHE_EVENT_RESPONSE_MSG";
119 
120   case MGMT_EVENT_SHUTDOWN:
121     return "MGMT_EVENT_SHUTDOWN";
122   case MGMT_EVENT_RESTART:
123     return "MGMT_EVENT_RESTART";
124   case MGMT_EVENT_BOUNCE:
125     return "MGMT_EVENT_BOUNCE";
126   case MGMT_EVENT_CONFIG_FILE_UPDATE:
127     return "MGMT_EVENT_CONFIG_FILE_UPDATE";
128   case MGMT_EVENT_CLEAR_STATS:
129     return "MGMT_EVENT_CLEAR_STATS";
130   case MGMT_EVENT_HOST_STATUS_UP:
131     return "MGMT_EVENT_HOST_STATUS_UP";
132   case MGMT_EVENT_HOST_STATUS_DOWN:
133     return "MGMT_EVENT_HOST_STATUS_DOWN";
134 
135   default:
136     if (buffer != nullptr) {
137       snprintf(buffer, blen, "%d", event);
138       return buffer;
139     } else {
140       return "UNKNOWN_EVENT";
141     }
142   }
143 }
144