summaryrefslogtreecommitdiff
path: root/usr/src/cmd/connstat/connstat.h
blob: a50049b3c7ca61a2aad382b8685d167286cd9b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * CDDL HEADER START
 *
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2015, 2016 by Delphix. All rights reserved.
 */

#ifndef	_CONNSTAT_H
#define	_CONNSTAT_H

#include <sys/types.h>
#include <sys/socket.h>
#include <ofmt.h>
#include <sys/stropts.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct connstat_conn_attr_s {
	struct sockaddr_storage	ca_laddr;
	struct sockaddr_storage	ca_raddr;
	int			ca_lport;
	int			ca_rport;
	int			ca_state;
} connstat_conn_attr_t;

typedef struct conn_walk_state_s {
	ofmt_handle_t		cws_ofmt;
	uint_t			cws_flags;
	connstat_conn_attr_t	cws_filter;
} conn_walk_state_t;

/* cws_flags */
#define	CS_LOOPBACK	0x0001	/* Include loopback connections */
#define	CS_IPV4		0x0002	/* Show only IPv4 connections */
#define	CS_IPV6		0x0004	/* Show only IPv6 connections */
#define	CS_LADDR	0x0008	/* Filter by laddr in cws_filter */
#define	CS_RADDR	0x0010	/* Filter by raddr in cws_filter */
#define	CS_LPORT	0x0020	/* Filter by lport in cws_filter */
#define	CS_RPORT	0x0040	/* Filter by rport in cws_filter */
#define	CS_STATE	0x0080	/* Filter by state in cws_filter */
#define	CS_PARSABLE	0x0100	/* Parsable output */

typedef ofmt_field_t *connstat_getfieldsfunc_t(void);
typedef void connstat_walkfunc_t(struct strbuf *, conn_walk_state_t *);

typedef struct connstat_proto_s {
	char	*csp_proto;
	char	*csp_default_fields;
	int	csp_miblevel;
	int	csp_mibv4name;
	int	csp_mibv6name;
	connstat_getfieldsfunc_t *csp_getfields;
	connstat_walkfunc_t *csp_v4walk;
	connstat_walkfunc_t *csp_v6walk;
} connstat_proto_t;

boolean_t print_string(ofmt_arg_t *, char *, uint_t);
boolean_t print_uint16(ofmt_arg_t *, char *, uint_t);
boolean_t print_uint32(ofmt_arg_t *, char *, uint_t);
boolean_t print_uint64(ofmt_arg_t *, char *, uint_t);

#ifdef	__cplusplus
}
#endif

#endif	/* _CONNSTAT_H */