xref: /titanic_52/usr/src/uts/common/sys/hook_event.h (revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * This file include definition of message passed from hook provider
28  * to hook consumer.  If necessary, each hook provider can add its
29  * own message definition here.
30  */
31 
32 #ifndef _SYS_HOOK_EVENT_H
33 #define	_SYS_HOOK_EVENT_H
34 
35 #include <sys/neti.h>
36 #include <sys/hook.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * The hook_pkt_event_t structure is supplied with packet events on
44  * associated network interfaces.
45  *
46  * The members of this structure are defined as follows:
47  * hpe_protocol - protocol identifier that indicates which protocol the
48  *                header data is associated with.
49  * hpe_ifp - "in" interface for packets coming into the system or forwarded
50  * hpe_ofp - "out" interface for packets being transmitted or forwarded
51  * hpe_hdr - pointer to protocol header within the packet
52  * hpe_mp  - pointer to the mblk pointer starting the chain for this packet
53  * hpe_mb  - pointer to the mblk that contains hpe_hdr
54  */
55 typedef struct hook_pkt_event {
56 	net_handle_t		hpe_protocol;
57 	phy_if_t		hpe_ifp;
58 	phy_if_t		hpe_ofp;
59 	void			*hpe_hdr;
60 	mblk_t			**hpe_mp;
61 	mblk_t			*hpe_mb;
62 	int			hpe_flags;
63 	void			*hpe_reserved[2];
64 } hook_pkt_event_t;
65 
66 #define	HPE_MULTICAST	0x01
67 #define	HPE_BROADCAST	0x02
68 
69 /*
70  * NIC events hook provider
71  */
72 typedef enum nic_event {
73 	NE_PLUMB = 1,
74 	NE_UNPLUMB,
75 	NE_UP,
76 	NE_DOWN,
77 	NE_ADDRESS_CHANGE,
78 	NE_LIF_UP,
79 	NE_LIF_DOWN
80 } nic_event_t;
81 
82 typedef void *nic_event_data_t;
83 
84 /*
85  * The hook_nic_event data structure is provided with all network interface
86  * events.
87  *
88  * hne_protocol- network protocol for events, returned from net_lookup
89  * hne_nic     - physical interface associated with event
90  * hne_lif     - logical interface (if any) associated with event
91  * hne_event   - type of event occuring
92  * hne_data    - pointer to extra data about event or NULL if none
93  * hne_datalen - size of data pointed to by hne_data (can be 0)
94  */
95 typedef struct hook_nic_event {
96 	net_handle_t		hne_protocol;
97 	phy_if_t		hne_nic;
98 	lif_if_t		hne_lif;
99 	nic_event_t		hne_event;
100 	nic_event_data_t	hne_data;
101 	size_t			hne_datalen;
102 } hook_nic_event_t;
103 
104 /*
105  * This structure is used internally by ip to queue events.
106  */
107 struct hook_nic_event_int {
108 	netstackid_t		hnei_stackid;
109 	hook_nic_event_t	hnei_event;
110 };
111 typedef struct hook_nic_event_int hook_nic_event_int_t;
112 
113 /*
114  * This structure holds the data passed back from the ip module to
115  * observability consumers.
116  *
117  * Externally exposed fields, that must match the order and size of
118  * dl_ipnetinfo_t in <sys/dlpi.h> are:
119  * hpo_version    Version number for this header
120  * hpo_family     Address family of the attached packet
121  * hpo_htype      IPobs hook type
122  * hpo_pktlen     Length of the attached packet
123  * hpo_ifindex    Interface index that the packet was received/sent over.
124  *                For local packets, this is the index of the interface
125  *                associated with the local destination address.
126  * hpo_grifindex  IPMP group interface index (zero unless ihd_ifindex
127  *                is an IPMP underlying interface).
128  * hpo_zsrc       Source zoneid; set to ALL_ZONES when unknown.
129  * hpo_zdst       Destination zoneid; set to ALL_ZONES when unknown.
130  *
131  * Fields used internally are:
132  * hpo_pkt        Pointer to the mblk_t containig this structure with
133  *                the real packet found at b_cont
134  */
135 typedef struct hook_pkt_observe_s {
136 	uint8_t		hpo_version;
137 	uint8_t		hpo_family;
138 	uint16_t	hpo_htype;
139 	uint32_t	hpo_pktlen;
140 	uint32_t	hpo_ifindex;
141 	uint32_t	hpo_grifindex;
142 	uint32_t	hpo_zsrc;
143 	uint32_t	hpo_zdst;
144 	/*
145 	 * Fields used internally are below.
146 	 */
147 	mblk_t		*hpo_pkt;
148 	void		*hpo_ctx;
149 } hook_pkt_observe_t;
150 
151 /*
152  * ipobs_hooktype_t describes the hook types supported
153  * by the ip module. IPOBS_HOOK_LOCAL refers to packets
154  * which are looped back internally within the ip module.
155  */
156 
157 typedef enum ipobs_hook_type {
158 	IPOBS_HOOK_INBOUND = 0,
159 	IPOBS_HOOK_OUTBOUND = 1,
160 	IPOBS_HOOK_LOCAL = 2
161 } ipobs_hook_type_t;
162 
163 
164 #ifdef	__cplusplus
165 }
166 #endif
167 
168 #endif /* _SYS_HOOK_EVENT_H */
169