xref: /aosp_15_r20/external/perfetto/src/trace_processor/types/tcp_state.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
18 #define SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
19 
20 namespace perfetto {
21 namespace trace_processor {
22 
23 // Sock IPV4 Protocol Definition, from include/uapi/linux/in.h.
24 constexpr int kAfNet = 2;
25 // Sock IPV6 Protocol Definition, from include/uapi/linux/in.h.
26 constexpr int kAfNet6 = 10;
27 // Sock TCP protocol Definition, from include/uapi/linux/in.h.
28 constexpr int kIpprotoTcp = 6;
29 // Sock UDP protocol Definition, from include/uapi/linux/in.h.
30 constexpr int kIpprotoUdp = 17;
31 // Sock ICMP protocol Definition, from include/uapi/linux/in.h.
32 constexpr int kIpprotoIcmp = 1;
33 // Sock ICMPV6 protocol Definition, from include/uapi/linux/in.h.
34 constexpr int kIpprotoIcmpv6 = 58;
35 // Skb IPV4 Protocol Definition, from include/uapi/linux/if_ether.h.
36 constexpr int kEthPIp = 0x800;
37 // Skb IPV6 Protocol Definition, from include/uapi/linux/if_ether.h.
38 constexpr int kEthPIp6 = 0x86DD;
39 // TCP protocol states, from include/net/tcp_states.h.
40 enum {
41   TCP_ESTABLISHED = 1,
42   TCP_SYN_SENT,
43   TCP_SYN_RECV,
44   TCP_FIN_WAIT1,
45   TCP_FIN_WAIT2,
46   TCP_TIME_WAIT,
47   TCP_CLOSE,
48   TCP_CLOSE_WAIT,
49   TCP_LAST_ACK,
50   TCP_LISTEN,
51   TCP_CLOSING,
52   TCP_NEW_SYN_RECV,
53   TCP_MAX_STATES
54 };
55 // TCP protocol state to string mapping.
56 static constexpr const char* const kTcpStateNames[] = {
57     "TCP_UNKNOWN",      "TCP_ESTABLISHED", "TCP_SYN_SENT",  "TCP_SYN_RECV",
58     "TCP_FIN_WAIT1",    "TCP_FIN_WAIT2",   "TCP_TIME_WAIT", "TCP_CLOSE",
59     "TCP_CLOSE_WAIT",   "TCP_LAST_ACK",    "TCP_LISTEN",    "TCP_CLOSING",
60     "TCP_NEW_SYN_RECV", "TCP_MAX_STATES"};
61 
62 }  // namespace trace_processor
63 }  // namespace perfetto
64 
65 #endif  // SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
66