xref: /illumos-gate/usr/src/uts/common/sys/hook_event.h (revision eda50310abb3984bab11856a2aca8936d26881cb)
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 2006 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <sys/neti.h>
38 #include <sys/hook.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * The hook_pkt_event_t structure is supplied with packet events on
46  * associated network interfaces.
47  *
48  * The members of this structure are defined as follows:
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 	phy_if_t		hpe_ifp;
57 	phy_if_t		hpe_ofp;
58 	void			*hpe_hdr;
59 	mblk_t			**hpe_mp;
60 	mblk_t			*hpe_mb;
61 } hook_pkt_event_t;
62 
63 /*
64  * NIC events hook provider
65  */
66 typedef enum nic_event {
67 	NE_PLUMB = 1,
68 	NE_UNPLUMB,
69 	NE_UP,
70 	NE_DOWN,
71 	NE_ADDRESS_CHANGE
72 } nic_event_t;
73 
74 typedef void *nic_event_data_t;
75 
76 /*
77  * The hook_nic_event data structure is provided with all network interface
78  * events.
79  *
80  * hne_family  - network family of events, returned from net_lookup
81  * hne_nic     - physical interface associated with event
82  * hne_lif     - logical interface (if any) associated with event
83  * hne_event   - type of event occuring
84  * hne_data    - pointer to extra data about event or NULL if none
85  * hne_datalen - size of data pointed to by hne_data (can be 0)
86  */
87 typedef struct hook_nic_event {
88 	net_data_t		hne_family;
89 	phy_if_t		hne_nic;
90 	lif_if_t		hne_lif;
91 	nic_event_t		hne_event;
92 	nic_event_data_t	hne_data;
93 	size_t			hne_datalen;
94 } hook_nic_event_t;
95 
96 #ifdef	__cplusplus
97 }
98 #endif
99 
100 #endif /* _SYS_HOOK_EVENT_H */
101