1 /* 2 * Redistribution and use in source and binary forms, with or without 3 * modification, are permitted provided that the following conditions 4 * are met: 5 * 6 * Redistribution of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * 9 * Redistribution in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * Neither the name of Sun Microsystems, Inc. or the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * This software is provided "AS IS," without a warranty of any kind. 18 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, 19 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A 20 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. 21 * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE 22 * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING 23 * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL 24 * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, 25 * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR 26 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF 27 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 28 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 29 */ 30 31 #include <string.h> 32 33 #include <ipmitool/ipmi.h> 34 #include <ipmitool/ipmi_intf.h> 35 #include <ipmitool/ipmi_constants.h> 36 #include <ipmitool/log.h> 37 #include <ipmitool/helper.h> 38 #include <ipmitool/ipmi_sel.h> 39 40 static int ipmi_oem_supermicro(struct ipmi_intf * intf); 41 static int ipmi_oem_ibm(struct ipmi_intf * intf); 42 43 static struct ipmi_oem_handle ipmi_oem_list[] = { 44 { 45 name: "supermicro", 46 desc: "Supermicro IPMIv1.5 BMC with OEM LAN authentication support", 47 setup: ipmi_oem_supermicro, 48 }, 49 { 50 name: "intelwv2", 51 desc: "Intel SE7501WV2 IPMIv1.5 BMC with extra LAN communication support", 52 }, 53 { 54 name: "intelplus", 55 desc: "Intel IPMI 2.0 BMC with RMCP+ communication support", 56 }, 57 { 58 name: "icts", 59 desc: "IPMI 2.0 ICTS compliance support", 60 }, 61 { 62 name: "ibm", 63 desc: "IBM OEM support", 64 setup: ipmi_oem_ibm, 65 }, 66 { 67 name: "i82571spt", 68 desc: "Intel 82571 MAC with integrated RMCP+ support in super pass-through mode", 69 }, 70 { 71 name: "kontron", 72 desc: "Kontron OEM big buffer support" 73 }, 74 { 0 } 75 }; 76 77 /* Supermicro IPMIv2 BMCs use OEM authtype */ 78 static int 79 ipmi_oem_supermicro(struct ipmi_intf * intf) 80 { 81 ipmi_intf_session_set_authtype(intf, IPMI_SESSION_AUTHTYPE_OEM); 82 return 0; 83 } 84 85 static int 86 ipmi_oem_ibm(struct ipmi_intf * intf) 87 { 88 char * filename; 89 if ((filename = getenv("IPMI_OEM_IBM_DATAFILE")) == NULL) { 90 lprintf(LOG_ERR, "Unable to read IPMI_OEM_IBM_DATAFILE from environment"); 91 return -1; 92 } 93 return ipmi_sel_oem_init((const char *)filename); 94 } 95 96 /* ipmi_oem_print - print list of OEM handles 97 */ 98 void 99 ipmi_oem_print(void) 100 { 101 struct ipmi_oem_handle * oem; 102 lprintf(LOG_NOTICE, "\nOEM Support:"); 103 for (oem=ipmi_oem_list; oem->name != NULL && oem->desc != NULL; oem++) { 104 lprintf(LOG_NOTICE, "\t%-12s %s", oem->name, oem->desc); 105 } 106 lprintf(LOG_NOTICE, ""); 107 } 108 109 /* ipmi_oem_setup - do initial setup of OEM handle 110 * 111 * @intf: ipmi interface 112 * @oemtype: OEM handle name 113 * 114 * returns 0 on success 115 * returns -1 on error 116 */ 117 int 118 ipmi_oem_setup(struct ipmi_intf * intf, char * oemtype) 119 { 120 struct ipmi_oem_handle * oem; 121 int rc = 0; 122 123 if (oemtype == NULL || 124 strncmp(oemtype, "help", 4) == 0 || 125 strncmp(oemtype, "list", 4) == 0) { 126 ipmi_oem_print(); 127 return -1; 128 } 129 130 for (oem=ipmi_oem_list; oem->name != NULL; oem++) { 131 if (strncmp(oemtype, oem->name, strlen(oem->name)) == 0) 132 break; 133 } 134 135 if (oem->name == NULL) 136 return -1; 137 138 /* save pointer for later use */ 139 intf->oem = oem; 140 141 /* run optional setup function if it is defined */ 142 if (oem->setup != NULL) { 143 lprintf(LOG_DEBUG, "Running OEM setup for \"%s\"", oem->desc); 144 rc = oem->setup(intf); 145 } 146 147 return rc; 148 } 149 150 /* ipmi_oem_active - used to determine if a particular OEM type is set 151 * 152 * @intf: ipmi interface 153 * @oemtype: string containing name of ipmi handle to check 154 * 155 * returns 1 if requested ipmi handle is active 156 * returns 0 otherwise 157 */ 158 int 159 ipmi_oem_active(struct ipmi_intf * intf, const char * oemtype) 160 { 161 if (intf->oem == NULL) 162 return 0; 163 164 if (strncmp(intf->oem->name, oemtype, strlen(oemtype)) == 0) 165 return 1; 166 167 return 0; 168 } 169