1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  14  */
  15 
  16 #ifndef _LIBAOE_H
  17 #define _LIBAOE_H
  18 
  19 #include <sys/aoe.h>
  20 #include <sys/ioctl.h>
  21 #include <sys/list.h>
  22 #include <sys/param.h>
  23 #include <sys/stat.h>
  24 #include <sys/types.h>
  25 
  26 #include <assert.h>
  27 #include <ctype.h>
  28 #include <errno.h>
  29 #include <fcntl.h>
  30 #include <inttypes.h>
  31 #include <libdllink.h>
  32 #include <libintl.h>
  33 #include <libscf.h>
  34 #include <locale.h>
  35 #include <stddef.h>
  36 #include <stdint.h>
  37 #include <stdio.h>
  38 #include <stdlib.h>
  39 #include <string.h>
  40 #include <strings.h>
  41 #include <syslog.h>
  42 #include <unistd.h>
  43 #include <wchar.h>
  44 
  45 #ifdef  __cplusplus
  46 extern "C" {
  47 #endif
  48 
  49 /*
  50  * AoE Port Type
  51  */
  52 #define AOE_PORTTYPE_INITIATOR          0
  53 #define AOE_PORTTYPE_TARGET             1
  54 
  55 typedef int AOE_STATUS;
  56 
  57 #define AOE_STATUS_OK                           0
  58 #define AOE_STATUS_ERROR                        1
  59 #define AOE_STATUS_ERROR_INVAL_ARG              2
  60 #define AOE_STATUS_ERROR_BUSY                   3
  61 #define AOE_STATUS_ERROR_ALREADY                4
  62 #define AOE_STATUS_ERROR_PERM                   5
  63 #define AOE_STATUS_ERROR_OPEN_DEV               6
  64 #define AOE_STATUS_ERROR_MAC_LEN                8
  65 #define AOE_STATUS_ERROR_CREATE_MAC             12
  66 #define AOE_STATUS_ERROR_OPEN_MAC               13
  67 #define AOE_STATUS_ERROR_CREATE_PORT            14
  68 #define AOE_STATUS_ERROR_MAC_NOT_FOUND          15
  69 #define AOE_STATUS_ERROR_OFFLINE_DEV            16
  70 #define AOE_STATUS_ERROR_MORE_DATA              17
  71 #define AOE_STATUS_ERROR_GET_LINKINFO           19
  72 #define AOE_STATUS_ERROR_EXISTS                 20
  73 #define AOE_STATUS_ERROR_SERVICE_NOT_FOUND      21
  74 #define AOE_STATUS_ERROR_NOMEM                  22
  75 #define AOE_STATUS_ERROR_MEMBER_NOT_FOUND       23
  76 
  77 
  78 /*
  79  * Define commonly used constants
  80  */
  81 #define AOE_MAX_MAC_NAMES_LEN   256
  82 #define AOE_MAX_PORTID_LEN      8
  83 #define AOE_PORT_LIST_LEN       255
  84 
  85 #define AOE_SCF_ADD             0
  86 #define AOE_SCF_REMOVE          1
  87 
  88 #define AOE_INITIATOR_SERVICE   "network/aoe/initiator"
  89 #define AOE_TARGET_SERVICE      "network/aoe/target"
  90 #define AOE_PG_NAME             "aoe-port-list-pg"
  91 #define AOE_PORT_LIST_PROP      "port_list_p"
  92 
  93 #define DBUS_HAL_DESTINATION    "org.freedesktop.Hal"
  94 #define DBUS_HAL_PATH           "/org/freedesktop/Hal/Manager"
  95 #define DBUS_HAL_INTERFACE      "org.freedesktop.Hal.Manager"
  96 #define DBUS_HAL_COM_DEV_LIST   "GetAllDevices"
  97 #define DBUS_HAL_COM_DEV_REM    "Remove"
  98 
  99 /*
 100  * AoE port instance in smf repository
 101  */
 102 typedef struct aoe_smf_port_instance {
 103         int             id;
 104         char            linknames[MAXLINKNAMELEN];
 105         int             promisc;
 106         aoe_cli_type_t  type;
 107         aoe_cli_policy_t policy;
 108         char            module[AOE_ACP_MODLEN];
 109 } AOE_SMF_PORT_INSTANCE, *PAOE_SMF_PORT_INSTANCE;
 110 
 111 /*
 112  * AoE port instance list
 113  */
 114 typedef struct aoe_smf_port_list {
 115         uint32_t                port_num;
 116         AOE_SMF_PORT_INSTANCE   ports[1];
 117 } AOE_SMF_PORT_LIST, *PAOE_SMF_PORT_LIST;
 118 
 119 AOE_STATUS      aoe_create_port(int portid, char *ifnames, int promisc,
 120                     aoe_cli_type_t type, aoe_cli_policy_t policy, char *module);
 121 AOE_STATUS      aoe_delete_port(int portid);
 122 AOE_STATUS      aoe_get_port_list(uint32_t *port_num, aoe_port_list_t **ports);
 123 AOE_STATUS      aoe_load_config(uint32_t port_type,
 124                     AOE_SMF_PORT_LIST **portlist);
 125 const char      *aoe_strerror(AOE_STATUS error);
 126 
 127 #ifdef  __cplusplus
 128 }
 129 #endif
 130 
 131 #endif  /* _LIBAOE_H */