xref: /illumos-gate/usr/src/cmd/connstat/connstat.h (revision a2f04351)
1*a2f04351SSebastien Roy /*
2*a2f04351SSebastien Roy  * CDDL HEADER START
3*a2f04351SSebastien Roy  *
4*a2f04351SSebastien Roy  * This file and its contents are supplied under the terms of the
5*a2f04351SSebastien Roy  * Common Development and Distribution License ("CDDL"), version 1.0.
6*a2f04351SSebastien Roy  * You may only use this file in accordance with the terms of version
7*a2f04351SSebastien Roy  * 1.0 of the CDDL.
8*a2f04351SSebastien Roy  *
9*a2f04351SSebastien Roy  * A full copy of the text of the CDDL should have accompanied this
10*a2f04351SSebastien Roy  * source.  A copy of the CDDL is also available via the Internet at
11*a2f04351SSebastien Roy  * http://www.illumos.org/license/CDDL.
12*a2f04351SSebastien Roy  *
13*a2f04351SSebastien Roy  * CDDL HEADER END
14*a2f04351SSebastien Roy  */
15*a2f04351SSebastien Roy /*
16*a2f04351SSebastien Roy  * Copyright (c) 2015, 2016 by Delphix. All rights reserved.
17*a2f04351SSebastien Roy  */
18*a2f04351SSebastien Roy 
19*a2f04351SSebastien Roy #ifndef	_CONNSTAT_H
20*a2f04351SSebastien Roy #define	_CONNSTAT_H
21*a2f04351SSebastien Roy 
22*a2f04351SSebastien Roy #include <sys/types.h>
23*a2f04351SSebastien Roy #include <sys/socket.h>
24*a2f04351SSebastien Roy #include <ofmt.h>
25*a2f04351SSebastien Roy #include <sys/stropts.h>
26*a2f04351SSebastien Roy 
27*a2f04351SSebastien Roy #ifdef	__cplusplus
28*a2f04351SSebastien Roy extern "C" {
29*a2f04351SSebastien Roy #endif
30*a2f04351SSebastien Roy 
31*a2f04351SSebastien Roy typedef struct connstat_conn_attr_s {
32*a2f04351SSebastien Roy 	struct sockaddr_storage	ca_laddr;
33*a2f04351SSebastien Roy 	struct sockaddr_storage	ca_raddr;
34*a2f04351SSebastien Roy 	int			ca_lport;
35*a2f04351SSebastien Roy 	int			ca_rport;
36*a2f04351SSebastien Roy 	int			ca_state;
37*a2f04351SSebastien Roy } connstat_conn_attr_t;
38*a2f04351SSebastien Roy 
39*a2f04351SSebastien Roy typedef struct conn_walk_state_s {
40*a2f04351SSebastien Roy 	ofmt_handle_t		cws_ofmt;
41*a2f04351SSebastien Roy 	uint_t			cws_flags;
42*a2f04351SSebastien Roy 	connstat_conn_attr_t	cws_filter;
43*a2f04351SSebastien Roy } conn_walk_state_t;
44*a2f04351SSebastien Roy 
45*a2f04351SSebastien Roy /* cws_flags */
46*a2f04351SSebastien Roy #define	CS_LOOPBACK	0x0001	/* Include loopback connections */
47*a2f04351SSebastien Roy #define	CS_IPV4		0x0002	/* Show only IPv4 connections */
48*a2f04351SSebastien Roy #define	CS_IPV6		0x0004	/* Show only IPv6 connections */
49*a2f04351SSebastien Roy #define	CS_LADDR	0x0008	/* Filter by laddr in cws_filter */
50*a2f04351SSebastien Roy #define	CS_RADDR	0x0010	/* Filter by raddr in cws_filter */
51*a2f04351SSebastien Roy #define	CS_LPORT	0x0020	/* Filter by lport in cws_filter */
52*a2f04351SSebastien Roy #define	CS_RPORT	0x0040	/* Filter by rport in cws_filter */
53*a2f04351SSebastien Roy #define	CS_STATE	0x0080	/* Filter by state in cws_filter */
54*a2f04351SSebastien Roy #define	CS_PARSABLE	0x0100	/* Parsable output */
55*a2f04351SSebastien Roy 
56*a2f04351SSebastien Roy typedef ofmt_field_t *connstat_getfieldsfunc_t(void);
57*a2f04351SSebastien Roy typedef void connstat_walkfunc_t(struct strbuf *, conn_walk_state_t *);
58*a2f04351SSebastien Roy 
59*a2f04351SSebastien Roy typedef struct connstat_proto_s {
60*a2f04351SSebastien Roy 	char	*csp_proto;
61*a2f04351SSebastien Roy 	char	*csp_default_fields;
62*a2f04351SSebastien Roy 	int	csp_miblevel;
63*a2f04351SSebastien Roy 	int	csp_mibv4name;
64*a2f04351SSebastien Roy 	int	csp_mibv6name;
65*a2f04351SSebastien Roy 	connstat_getfieldsfunc_t *csp_getfields;
66*a2f04351SSebastien Roy 	connstat_walkfunc_t *csp_v4walk;
67*a2f04351SSebastien Roy 	connstat_walkfunc_t *csp_v6walk;
68*a2f04351SSebastien Roy } connstat_proto_t;
69*a2f04351SSebastien Roy 
70*a2f04351SSebastien Roy boolean_t print_string(ofmt_arg_t *, char *, uint_t);
71*a2f04351SSebastien Roy boolean_t print_uint16(ofmt_arg_t *, char *, uint_t);
72*a2f04351SSebastien Roy boolean_t print_uint32(ofmt_arg_t *, char *, uint_t);
73*a2f04351SSebastien Roy boolean_t print_uint64(ofmt_arg_t *, char *, uint_t);
74*a2f04351SSebastien Roy 
75*a2f04351SSebastien Roy #ifdef	__cplusplus
76*a2f04351SSebastien Roy }
77*a2f04351SSebastien Roy #endif
78*a2f04351SSebastien Roy 
79*a2f04351SSebastien Roy #endif	/* _CONNSTAT_H */
80