xref: /illumos-gate/usr/src/uts/common/sys/hook_event.h (revision 33697085)
1381a2a9aSdr /*
2381a2a9aSdr  * CDDL HEADER START
3381a2a9aSdr  *
4381a2a9aSdr  * The contents of this file are subject to the terms of the
5381a2a9aSdr  * Common Development and Distribution License (the "License").
6381a2a9aSdr  * You may not use this file except in compliance with the License.
7381a2a9aSdr  *
8381a2a9aSdr  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9381a2a9aSdr  * or http://www.opensolaris.org/os/licensing.
10381a2a9aSdr  * See the License for the specific language governing permissions
11381a2a9aSdr  * and limitations under the License.
12381a2a9aSdr  *
13381a2a9aSdr  * When distributing Covered Code, include this CDDL HEADER in each
14381a2a9aSdr  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15381a2a9aSdr  * If applicable, add the following below this CDDL HEADER, with the
16381a2a9aSdr  * fields enclosed by brackets "[]" replaced with your own identifying
17381a2a9aSdr  * information: Portions Copyright [yyyy] [name of copyright owner]
18381a2a9aSdr  *
19381a2a9aSdr  * CDDL HEADER END
20381a2a9aSdr  */
21381a2a9aSdr /*
220a0e9771SDarren Reed  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23381a2a9aSdr  * Use is subject to license terms.
24381a2a9aSdr  */
25381a2a9aSdr 
26381a2a9aSdr /*
27381a2a9aSdr  * This file include definition of message passed from hook provider
28381a2a9aSdr  * to hook consumer.  If necessary, each hook provider can add its
29381a2a9aSdr  * own message definition here.
30381a2a9aSdr  */
31381a2a9aSdr 
32381a2a9aSdr #ifndef _SYS_HOOK_EVENT_H
33381a2a9aSdr #define	_SYS_HOOK_EVENT_H
34381a2a9aSdr 
35381a2a9aSdr #include <sys/neti.h>
36381a2a9aSdr #include <sys/hook.h>
37381a2a9aSdr 
38381a2a9aSdr #ifdef	__cplusplus
39381a2a9aSdr extern "C" {
40381a2a9aSdr #endif
41381a2a9aSdr 
42*33697085SGordon Ross struct msgb;	/* avoiding sys/stream.h here */
43*33697085SGordon Ross 
44381a2a9aSdr /*
45381a2a9aSdr  * The hook_pkt_event_t structure is supplied with packet events on
46381a2a9aSdr  * associated network interfaces.
47381a2a9aSdr  *
48381a2a9aSdr  * The members of this structure are defined as follows:
497ddc9b1aSDarren Reed  * hpe_protocol - protocol identifier that indicates which protocol the
507ddc9b1aSDarren Reed  *                header data is associated with.
51381a2a9aSdr  * hpe_ifp - "in" interface for packets coming into the system or forwarded
52381a2a9aSdr  * hpe_ofp - "out" interface for packets being transmitted or forwarded
53381a2a9aSdr  * hpe_hdr - pointer to protocol header within the packet
54381a2a9aSdr  * hpe_mp  - pointer to the mblk pointer starting the chain for this packet
55381a2a9aSdr  * hpe_mb  - pointer to the mblk that contains hpe_hdr
56381a2a9aSdr  */
57381a2a9aSdr typedef struct hook_pkt_event {
587ddc9b1aSDarren Reed 	net_handle_t		hpe_protocol;
59381a2a9aSdr 	phy_if_t		hpe_ifp;
60381a2a9aSdr 	phy_if_t		hpe_ofp;
61381a2a9aSdr 	void			*hpe_hdr;
62*33697085SGordon Ross 	struct msgb		**hpe_mp;
63*33697085SGordon Ross 	struct msgb		*hpe_mb;
641b47e080Sdr 	int			hpe_flags;
657ddc9b1aSDarren Reed 	void			*hpe_reserved[2];
66381a2a9aSdr } hook_pkt_event_t;
67381a2a9aSdr 
681b47e080Sdr #define	HPE_MULTICAST	0x01
691b47e080Sdr #define	HPE_BROADCAST	0x02
701b47e080Sdr 
71381a2a9aSdr /*
72381a2a9aSdr  * NIC events hook provider
73381a2a9aSdr  */
74381a2a9aSdr typedef enum nic_event {
75381a2a9aSdr 	NE_PLUMB = 1,
76381a2a9aSdr 	NE_UNPLUMB,
77381a2a9aSdr 	NE_UP,
78381a2a9aSdr 	NE_DOWN,
79b127ac41SPhilip Kirk 	NE_ADDRESS_CHANGE,
80b127ac41SPhilip Kirk 	NE_LIF_UP,
8132af2ca0SAlexandr Nedvedicky 	NE_LIF_DOWN,
8232af2ca0SAlexandr Nedvedicky 	NE_IFINDEX_CHANGE
83381a2a9aSdr } nic_event_t;
84381a2a9aSdr 
85381a2a9aSdr typedef void *nic_event_data_t;
86381a2a9aSdr 
87381a2a9aSdr /*
88381a2a9aSdr  * The hook_nic_event data structure is provided with all network interface
89381a2a9aSdr  * events.
90381a2a9aSdr  *
917ddc9b1aSDarren Reed  * hne_protocol- network protocol for events, returned from net_lookup
92381a2a9aSdr  * hne_nic     - physical interface associated with event
93381a2a9aSdr  * hne_lif     - logical interface (if any) associated with event
94381a2a9aSdr  * hne_event   - type of event occuring
95381a2a9aSdr  * hne_data    - pointer to extra data about event or NULL if none
96381a2a9aSdr  * hne_datalen - size of data pointed to by hne_data (can be 0)
97381a2a9aSdr  */
98381a2a9aSdr typedef struct hook_nic_event {
997ddc9b1aSDarren Reed 	net_handle_t		hne_protocol;
100381a2a9aSdr 	phy_if_t		hne_nic;
101381a2a9aSdr 	lif_if_t		hne_lif;
102381a2a9aSdr 	nic_event_t		hne_event;
103381a2a9aSdr 	nic_event_data_t	hne_data;
104381a2a9aSdr 	size_t			hne_datalen;
105381a2a9aSdr } hook_nic_event_t;
106381a2a9aSdr 
1077ddc9b1aSDarren Reed /*
1087ddc9b1aSDarren Reed  * This structure is used internally by ip to queue events.
1097ddc9b1aSDarren Reed  */
1107ddc9b1aSDarren Reed struct hook_nic_event_int {
1117ddc9b1aSDarren Reed 	netstackid_t		hnei_stackid;
1127ddc9b1aSDarren Reed 	hook_nic_event_t	hnei_event;
1137ddc9b1aSDarren Reed };
1147ddc9b1aSDarren Reed typedef struct hook_nic_event_int hook_nic_event_int_t;
1157ddc9b1aSDarren Reed 
1160a0e9771SDarren Reed /*
1170a0e9771SDarren Reed  * This structure holds the data passed back from the ip module to
1180a0e9771SDarren Reed  * observability consumers.
1190a0e9771SDarren Reed  *
1200a0e9771SDarren Reed  * Externally exposed fields, that must match the order and size of
1210a0e9771SDarren Reed  * dl_ipnetinfo_t in <sys/dlpi.h> are:
1220a0e9771SDarren Reed  * hpo_version    Version number for this header
1230a0e9771SDarren Reed  * hpo_family     Address family of the attached packet
1240a0e9771SDarren Reed  * hpo_htype      IPobs hook type
1250a0e9771SDarren Reed  * hpo_pktlen     Length of the attached packet
1260a0e9771SDarren Reed  * hpo_ifindex    Interface index that the packet was received/sent over.
1270a0e9771SDarren Reed  *                For local packets, this is the index of the interface
1280a0e9771SDarren Reed  *                associated with the local destination address.
1290a0e9771SDarren Reed  * hpo_grifindex  IPMP group interface index (zero unless ihd_ifindex
1300a0e9771SDarren Reed  *                is an IPMP underlying interface).
1310a0e9771SDarren Reed  * hpo_zsrc       Source zoneid; set to ALL_ZONES when unknown.
1320a0e9771SDarren Reed  * hpo_zdst       Destination zoneid; set to ALL_ZONES when unknown.
1330a0e9771SDarren Reed  *
1340a0e9771SDarren Reed  * Fields used internally are:
1350a0e9771SDarren Reed  * hpo_pkt        Pointer to the mblk_t containig this structure with
1360a0e9771SDarren Reed  *                the real packet found at b_cont
1370a0e9771SDarren Reed  */
1380a0e9771SDarren Reed typedef struct hook_pkt_observe_s {
1390a0e9771SDarren Reed 	uint8_t		hpo_version;
1400a0e9771SDarren Reed 	uint8_t		hpo_family;
1410a0e9771SDarren Reed 	uint16_t	hpo_htype;
1420a0e9771SDarren Reed 	uint32_t	hpo_pktlen;
1430a0e9771SDarren Reed 	uint32_t	hpo_ifindex;
1440a0e9771SDarren Reed 	uint32_t	hpo_grifindex;
1450a0e9771SDarren Reed 	uint32_t	hpo_zsrc;
1460a0e9771SDarren Reed 	uint32_t	hpo_zdst;
1470a0e9771SDarren Reed 	/*
1480a0e9771SDarren Reed 	 * Fields used internally are below.
1490a0e9771SDarren Reed 	 */
150*33697085SGordon Ross 	struct msgb	*hpo_pkt;
1510a0e9771SDarren Reed 	void		*hpo_ctx;
1520a0e9771SDarren Reed } hook_pkt_observe_t;
1530a0e9771SDarren Reed 
1540a0e9771SDarren Reed /*
1550a0e9771SDarren Reed  * ipobs_hooktype_t describes the hook types supported
1560a0e9771SDarren Reed  * by the ip module. IPOBS_HOOK_LOCAL refers to packets
1570a0e9771SDarren Reed  * which are looped back internally within the ip module.
1580a0e9771SDarren Reed  */
1590a0e9771SDarren Reed 
1600a0e9771SDarren Reed typedef enum ipobs_hook_type {
1610a0e9771SDarren Reed 	IPOBS_HOOK_INBOUND = 0,
1620a0e9771SDarren Reed 	IPOBS_HOOK_OUTBOUND = 1,
1630a0e9771SDarren Reed 	IPOBS_HOOK_LOCAL = 2
1640a0e9771SDarren Reed } ipobs_hook_type_t;
1650a0e9771SDarren Reed 
1660a0e9771SDarren Reed 
167381a2a9aSdr #ifdef	__cplusplus
168381a2a9aSdr }
169381a2a9aSdr #endif
170381a2a9aSdr 
171381a2a9aSdr #endif /* _SYS_HOOK_EVENT_H */
172