17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*e11c3f44Smeem * Common Development and Distribution License (the "License"). 6*e11c3f44Smeem * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 20*e11c3f44Smeem * 21*e11c3f44Smeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 227c478bd9Sstevel@tonic-gate * Use is subject to license terms. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _IPMP_MPATHD_H 267c478bd9Sstevel@tonic-gate #define _IPMP_MPATHD_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * Definitions for the messaging protocol between in.mpathd and libipmp. 30*e11c3f44Smeem * This interface is project-private to the IPMP subsystem. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/types.h> 347c478bd9Sstevel@tonic-gate #include <sys/socket.h> /* needed for <net/if.h> */ 357c478bd9Sstevel@tonic-gate #include <net/if.h> /* needed for LIFNAMSIZ */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define MPATHD_PORT 5999 42*e11c3f44Smeem #define MPATHD_PATH "/lib/inet/in.mpathd" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * Supported commands. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate enum { 48*e11c3f44Smeem MI_PING = 0, /* ping in.mpathd */ 497c478bd9Sstevel@tonic-gate MI_OFFLINE = 1, /* offline the interface */ 507c478bd9Sstevel@tonic-gate MI_UNDO_OFFLINE = 2, /* undo the offline */ 51*e11c3f44Smeem MI_QUERY = 3, /* query ipmp-related information */ 527c478bd9Sstevel@tonic-gate MI_NCMD /* total number of commands */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Types of information which can be requested and received (except for 57*e11c3f44Smeem * IPMP_IFLIST and IPMP_ADDRLIST, which can only be received). 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate typedef enum { 607c478bd9Sstevel@tonic-gate IPMP_GROUPLIST = 1, 617c478bd9Sstevel@tonic-gate IPMP_GROUPINFO = 2, 627c478bd9Sstevel@tonic-gate IPMP_IFINFO = 3, 637c478bd9Sstevel@tonic-gate IPMP_IFLIST = 4, 64*e11c3f44Smeem IPMP_SNAP = 5, 65*e11c3f44Smeem IPMP_ADDRLIST = 6, 66*e11c3f44Smeem IPMP_ADDRINFO = 7 677c478bd9Sstevel@tonic-gate } ipmp_infotype_t; 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* 70*e11c3f44Smeem * Daemon ping request. 71*e11c3f44Smeem */ 72*e11c3f44Smeem typedef struct mi_ping { 73*e11c3f44Smeem uint32_t mip_command; 74*e11c3f44Smeem } mi_ping_t; 75*e11c3f44Smeem 76*e11c3f44Smeem /* 777c478bd9Sstevel@tonic-gate * Interface offline request; `mio_ifname' is the interface to offline; 787c478bd9Sstevel@tonic-gate * `mio_min_redundancy' is the minimum amount of usable interfaces after 797c478bd9Sstevel@tonic-gate * offline that must exist for the operation to succeed. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate typedef struct mi_offline { 827c478bd9Sstevel@tonic-gate uint32_t mio_command; 837c478bd9Sstevel@tonic-gate char mio_ifname[LIFNAMSIZ]; 847c478bd9Sstevel@tonic-gate uint32_t mio_min_redundancy; 857c478bd9Sstevel@tonic-gate } mi_offline_t; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * Interface undo-offline request; `miu_uname' is the interface to 897c478bd9Sstevel@tonic-gate * undo-offline. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate typedef struct mi_undo_offline { 927c478bd9Sstevel@tonic-gate uint32_t miu_command; 937c478bd9Sstevel@tonic-gate char miu_ifname[LIFNAMSIZ]; 947c478bd9Sstevel@tonic-gate } mi_undo_offline_t; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Retrieve IPMP-related information: `miq_inforeq' is the type of information 98*e11c3f44Smeem * being request (see above for the list of types). If the request type is 99*e11c3f44Smeem * IPMP_GROUPINFO, then `miq_grname' indicates the group. If the request type 100*e11c3f44Smeem * is IPMP_IFINFO, then `miq_ifname' indicates the interface. If the request 101*e11c3f44Smeem * type is IPMP_ADDRINFO then `miq_grname' indicates the group and `miq_addr' 102*e11c3f44Smeem * indicates the address. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate typedef struct mi_query { 1057c478bd9Sstevel@tonic-gate uint32_t miq_command; 1067c478bd9Sstevel@tonic-gate ipmp_infotype_t miq_inforeq; 1077c478bd9Sstevel@tonic-gate union { 1087c478bd9Sstevel@tonic-gate char miqu_ifname[LIFNAMSIZ]; 1097c478bd9Sstevel@tonic-gate char miqu_grname[LIFGRNAMSIZ]; 1107c478bd9Sstevel@tonic-gate } miq_infodata; 111*e11c3f44Smeem struct sockaddr_storage miq_addr; 1127c478bd9Sstevel@tonic-gate } mi_query_t; 1137c478bd9Sstevel@tonic-gate #define miq_ifname miq_infodata.miqu_ifname 1147c478bd9Sstevel@tonic-gate #define miq_grname miq_infodata.miqu_grname 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * Union of all commands. Can be used to estimate the maximum buffer size 1187c478bd9Sstevel@tonic-gate * requirement for receiving any command. 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate union mi_commands { 1217c478bd9Sstevel@tonic-gate uint32_t mi_command; 122*e11c3f44Smeem mi_ping_t mi_pcmd; 1237c478bd9Sstevel@tonic-gate mi_offline_t mi_ocmd; 1247c478bd9Sstevel@tonic-gate mi_undo_offline_t mi_ucmd; 1257c478bd9Sstevel@tonic-gate mi_query_t mi_qcmd; 1267c478bd9Sstevel@tonic-gate }; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1297c478bd9Sstevel@tonic-gate * Result structure returned by in.mpathd. 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate typedef struct mi_result { 1327c478bd9Sstevel@tonic-gate uint32_t me_sys_error; /* System error (errno.h) */ 1337c478bd9Sstevel@tonic-gate uint32_t me_mpathd_error; /* Mpathd error */ 1347c478bd9Sstevel@tonic-gate } mi_result_t; 1357c478bd9Sstevel@tonic-gate 136*e11c3f44Smeem #define IPMP_REQTIMEOUT 5 /* seconds */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate extern int ipmp_connect(int *); 1397c478bd9Sstevel@tonic-gate extern int ipmp_read(int, void *, size_t, const struct timeval *); 1407c478bd9Sstevel@tonic-gate extern int ipmp_write(int, const void *, size_t); 1417c478bd9Sstevel@tonic-gate extern int ipmp_writetlv(int, ipmp_infotype_t, size_t, void *); 1427c478bd9Sstevel@tonic-gate extern int ipmp_readtlv(int, ipmp_infotype_t *, size_t *, void **, 1437c478bd9Sstevel@tonic-gate const struct timeval *); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate #endif 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #endif /* _IPMP_MPATHD_H */ 150