]> git.ipfire.org Git - thirdparty/util-linux.git/blame - misc-utils/lsfd-sock.h
Merge branch 'PR/libmount-utab-event' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / misc-utils / lsfd-sock.h
CommitLineData
0ee16e43
MY
1/*
2 * lsfd(1) - list file descriptors
3 *
4 * Copyright (C) 2022 Red Hat, Inc. All rights reserved.
5 * Written by Masatake YAMATO <yamato@redhat.com>
6 *
7 * Very generally based on lsof(8) by Victor A. Abell <abe@purdue.edu>
8 * It supports multiple OSes. lsfd specializes to Linux.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it would be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24#ifndef UTIL_LINUX_LSFD_SOCK_H
25#define UTIL_LINUX_LSFD_SOCK_H
26
7b50bd25 27#include <stdbool.h>
0ee16e43
MY
28#include <sys/stat.h>
29
7b50bd25
MY
30#include "libsmartcols.h"
31
0ee16e43
MY
32/*
33 * xinfo: eXtra inforation about sockets
34 */
35struct sock_xinfo {
36 ino_t inode; /* inode in sockfs */
37 ino_t netns_inode; /* inode of netns where
38 the socket belongs to */
39 const struct sock_xinfo_class *class;
40};
41
7b50bd25
MY
42struct sock {
43 struct file file;
44 char *protoname;
45 struct sock_xinfo *xinfo;
046c5d5a 46 struct ipc_endpoint endpoint;
7b50bd25
MY
47};
48
0ee16e43 49struct sock_xinfo_class {
7b50bd25
MY
50 /* Methods for filling socket related columns */
51 char * (*get_name)(struct sock_xinfo *, struct sock *);
52 char * (*get_type)(struct sock_xinfo *, struct sock *);
53 char * (*get_state)(struct sock_xinfo *, struct sock *);
45d61bff 54 bool (*get_listening)(struct sock_xinfo *, struct sock *);
7b50bd25
MY
55 /* Method for class specific columns.
56 * Return true when the method fills the column. */
57 bool (*fill_column)(struct proc *,
58 struct sock_xinfo *,
59 struct sock *,
60 struct libscols_line *,
61 int,
62 size_t,
63 char **str);
046c5d5a 64 struct ipc_class *(*get_ipc_class)(struct sock_xinfo *, struct sock *);
7b50bd25 65
0ee16e43
MY
66 void (*free)(struct sock_xinfo *);
67};
68
69void initialize_sock_xinfos(void);
70void finalize_sock_xinfos(void);
71
b8bcca67 72struct sock_xinfo *get_sock_xinfo(ino_t inode);
0ee16e43
MY
73
74#endif /* UTIL_LINUX_LSFD_SOCK_H */