1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _IPMP_MPATHD_H 28*0Sstevel@tonic-gate #define _IPMP_MPATHD_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Definitions for the messaging protocol between in.mpathd and libipmp. 34*0Sstevel@tonic-gate * This interface is loosely documented in PSARC/2000/306. 35*0Sstevel@tonic-gate * 36*0Sstevel@tonic-gate * PLEASE NOTE: Although this interface is officially consolidation-private, 37*0Sstevel@tonic-gate * we will be reclassifying it as project-private in the future, and 38*0Sstevel@tonic-gate * transitioning any existing consumers to use higher-level libipmp routines. 39*0Sstevel@tonic-gate * 40*0Sstevel@tonic-gate * Put another way: treat this as if it was project-private! 41*0Sstevel@tonic-gate */ 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #include <sys/types.h> 44*0Sstevel@tonic-gate #include <sys/socket.h> /* needed for <net/if.h> */ 45*0Sstevel@tonic-gate #include <net/if.h> /* needed for LIFNAMSIZ */ 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate #ifdef __cplusplus 48*0Sstevel@tonic-gate extern "C" { 49*0Sstevel@tonic-gate #endif 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #define MPATHD_PORT 5999 52*0Sstevel@tonic-gate #define MPATHD_PATH "/usr/lib/inet/in.mpathd" 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate /* 55*0Sstevel@tonic-gate * Supported commands. 56*0Sstevel@tonic-gate */ 57*0Sstevel@tonic-gate enum { 58*0Sstevel@tonic-gate MI_PING = 0, /* sanity test */ 59*0Sstevel@tonic-gate MI_OFFLINE = 1, /* offline the interface */ 60*0Sstevel@tonic-gate MI_UNDO_OFFLINE = 2, /* undo the offline */ 61*0Sstevel@tonic-gate MI_SETOINDEX = 3, /* set original interface index */ 62*0Sstevel@tonic-gate MI_QUERY = 4, /* query ipmp-related information */ 63*0Sstevel@tonic-gate MI_NCMD /* total number of commands */ 64*0Sstevel@tonic-gate }; 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate /* 67*0Sstevel@tonic-gate * Types of information which can be requested and received (except for 68*0Sstevel@tonic-gate * IPMP_IFLIST, which can only be received). 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate typedef enum { 71*0Sstevel@tonic-gate IPMP_GROUPLIST = 1, 72*0Sstevel@tonic-gate IPMP_GROUPINFO = 2, 73*0Sstevel@tonic-gate IPMP_IFINFO = 3, 74*0Sstevel@tonic-gate IPMP_IFLIST = 4, 75*0Sstevel@tonic-gate IPMP_SNAP = 5 76*0Sstevel@tonic-gate } ipmp_infotype_t; 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* 79*0Sstevel@tonic-gate * Interface offline request; `mio_ifname' is the interface to offline; 80*0Sstevel@tonic-gate * `mio_min_redundancy' is the minimum amount of usable interfaces after 81*0Sstevel@tonic-gate * offline that must exist for the operation to succeed. 82*0Sstevel@tonic-gate */ 83*0Sstevel@tonic-gate typedef struct mi_offline { 84*0Sstevel@tonic-gate uint32_t mio_command; 85*0Sstevel@tonic-gate char mio_ifname[LIFNAMSIZ]; 86*0Sstevel@tonic-gate char mio_move_to_if[LIFNAMSIZ]; /* currently unused */ 87*0Sstevel@tonic-gate uint32_t mio_min_redundancy; 88*0Sstevel@tonic-gate } mi_offline_t; 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate /* 91*0Sstevel@tonic-gate * Interface undo-offline request; `miu_uname' is the interface to 92*0Sstevel@tonic-gate * undo-offline. 93*0Sstevel@tonic-gate */ 94*0Sstevel@tonic-gate typedef struct mi_undo_offline { 95*0Sstevel@tonic-gate uint32_t miu_command; 96*0Sstevel@tonic-gate char miu_ifname[LIFNAMSIZ]; 97*0Sstevel@tonic-gate } mi_undo_offline_t; 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate /* 100*0Sstevel@tonic-gate * Set original interface index request: `mis_lifname' is the name of the 101*0Sstevel@tonic-gate * logical interface that is having its index reset; `mis_new_pifname' is the 102*0Sstevel@tonic-gate * name of the interface whose index will be associated with `mis_lifname'; 103*0Sstevel@tonic-gate * `mis_iftype' is the interface type. 104*0Sstevel@tonic-gate */ 105*0Sstevel@tonic-gate typedef struct mi_setoindex { 106*0Sstevel@tonic-gate uint32_t mis_command; 107*0Sstevel@tonic-gate char mis_lifname[LIFNAMSIZ]; 108*0Sstevel@tonic-gate char mis_new_pifname[LIFNAMSIZ]; 109*0Sstevel@tonic-gate uint32_t mis_iftype; 110*0Sstevel@tonic-gate } mi_setoindex_t; 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate /* 113*0Sstevel@tonic-gate * Retrieve IPMP-related information: `miq_inforeq' is the type of information 114*0Sstevel@tonic-gate * being request (see above for the list of types). If the request is for 115*0Sstevel@tonic-gate * either IPMP_GROUPINFO or IPMP_IFINFO, then either `miq_grname' or 116*0Sstevel@tonic-gate * `miq_ifname' should be set (respectively) to indicate the name of the 117*0Sstevel@tonic-gate * group or interface to retrieve the information for. 118*0Sstevel@tonic-gate */ 119*0Sstevel@tonic-gate typedef struct mi_query { 120*0Sstevel@tonic-gate uint32_t miq_command; 121*0Sstevel@tonic-gate ipmp_infotype_t miq_inforeq; 122*0Sstevel@tonic-gate union { 123*0Sstevel@tonic-gate char miqu_ifname[LIFNAMSIZ]; 124*0Sstevel@tonic-gate char miqu_grname[LIFGRNAMSIZ]; 125*0Sstevel@tonic-gate } miq_infodata; 126*0Sstevel@tonic-gate } mi_query_t; 127*0Sstevel@tonic-gate #define miq_ifname miq_infodata.miqu_ifname 128*0Sstevel@tonic-gate #define miq_grname miq_infodata.miqu_grname 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * Union of all commands. Can be used to estimate the maximum buffer size 132*0Sstevel@tonic-gate * requirement for receiving any command. 133*0Sstevel@tonic-gate */ 134*0Sstevel@tonic-gate union mi_commands { 135*0Sstevel@tonic-gate uint32_t mi_command; 136*0Sstevel@tonic-gate mi_offline_t mi_ocmd; 137*0Sstevel@tonic-gate mi_undo_offline_t mi_ucmd; 138*0Sstevel@tonic-gate mi_setoindex_t mi_scmd; 139*0Sstevel@tonic-gate mi_query_t mi_qcmd; 140*0Sstevel@tonic-gate }; 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate /* 143*0Sstevel@tonic-gate * Result structure returned by in.mpathd. 144*0Sstevel@tonic-gate */ 145*0Sstevel@tonic-gate typedef struct mi_result { 146*0Sstevel@tonic-gate uint32_t me_sys_error; /* System error (errno.h) */ 147*0Sstevel@tonic-gate uint32_t me_mpathd_error; /* Mpathd error */ 148*0Sstevel@tonic-gate } mi_result_t; 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate /* 151*0Sstevel@tonic-gate * Legacy values for me_mpathd_error; the daemon now returns the IPMP 152*0Sstevel@tonic-gate * error codes defined in <ipmp.h>, which are compatible with these error 153*0Sstevel@tonic-gate * codes. These will be removed in the future. 154*0Sstevel@tonic-gate */ 155*0Sstevel@tonic-gate enum { 156*0Sstevel@tonic-gate MPATHD_SUCCESS = 0, /* operation succeeded */ 157*0Sstevel@tonic-gate MPATHD_SYS_ERROR = 1, /* check me_sys_error for the errno */ 158*0Sstevel@tonic-gate MPATHD_MIN_RED_ERROR = 2, /* minimum redundancy not met */ 159*0Sstevel@tonic-gate MPATHD_FAILBACK_DISABLED = 3, /* failback administratively disabled */ 160*0Sstevel@tonic-gate MPATHD_FAILBACK_PARTIAL = 4 /* unable to completely failback */ 161*0Sstevel@tonic-gate }; 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate extern int ipmp_connect(int *); 164*0Sstevel@tonic-gate extern int ipmp_read(int, void *, size_t, const struct timeval *); 165*0Sstevel@tonic-gate extern int ipmp_write(int, const void *, size_t); 166*0Sstevel@tonic-gate extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *); 167*0Sstevel@tonic-gate extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **, 168*0Sstevel@tonic-gate const struct timeval *); 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate #ifdef __cplusplus 171*0Sstevel@tonic-gate } 172*0Sstevel@tonic-gate #endif 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate #endif /* _IPMP_MPATHD_H */ 175