xref: /aosp_15_r20/external/bcc/libbpf-tools/tcptracer.h (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2022 Microsoft Corporation
3 //
4 // Based on tcptracer(8) from BCC by Kinvolk GmbH and
5 // tcpconnect(8) by Anton Protopopov
6 
7 #ifndef __TCPTRACER_H
8 #define __TCPTRACER_H
9 
10 /* The maximum number of items in maps */
11 #define MAX_ENTRIES 8192
12 
13 #define TASK_COMM_LEN 16
14 
15 enum event_type {
16 	TCP_EVENT_TYPE_CONNECT,
17 	TCP_EVENT_TYPE_ACCEPT,
18 	TCP_EVENT_TYPE_CLOSE,
19 };
20 
21 struct event {
22 	union {
23 		__u32 saddr_v4;
24 		unsigned __int128 saddr_v6;
25 	};
26 	union {
27 		__u32 daddr_v4;
28 		unsigned __int128 daddr_v6;
29 	};
30 	char task[TASK_COMM_LEN];
31 	__u64 ts_us;
32 	__u32 af; /* AF_INET or AF_INET6 */
33 	__u32 pid;
34 	__u32 uid;
35 	__u32 netns;
36 	__u16 dport;
37 	__u16 sport;
38 	__u8 type;
39 };
40 
41 
42 #endif /* __TCPTRACER_H */
43