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