Main Page | Class List | Directories | File List | Class Members | File Members

ipmi_addr.h

Go to the documentation of this file.
00001 /*
00002  * ipmi_addr.h
00003  *
00004  * Addressing information for IPMI interfaces.
00005  *
00006  * Author: MontaVista Software, Inc.
00007  *         Corey Minyard <minyard@mvista.com>
00008  *         source@mvista.com
00009  *
00010  * Copyright 2002,2003,2004,2005 MontaVista Software Inc.
00011  *
00012  * This software is available to you under a choice of one of two
00013  * licenses.  You may choose to be licensed under the terms of the GNU
00014  * Lesser General Public License (GPL) Version 2 or the modified BSD
00015  * license below.  The following disclamer applies to both licenses:
00016  *
00017  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00018  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00022  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00023  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00025  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00026  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  *
00028  * GNU Lesser General Public Licence
00029  *
00030  *  This program is free software; you can redistribute it and/or
00031  *  modify it under the terms of the GNU Lesser General Public License
00032  *  as published by the Free Software Foundation; either version 2 of
00033  *  the License, or (at your option) any later version.
00034  *
00035  *  You should have received a copy of the GNU Lesser General Public
00036  *  License along with this program; if not, write to the Free
00037  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00038  *
00039  * Modified BSD Licence
00040  *
00041  * Redistribution and use in source and binary forms, with or without
00042  * modification, are permitted provided that the following conditions
00043  * are met:
00044  *
00045  *   1. Redistributions of source code must retain the above copyright
00046  *      notice, this list of conditions and the following disclaimer.
00047  *   2. Redistributions in binary form must reproduce the above
00048  *      copyright notice, this list of conditions and the following
00049  *      disclaimer in the documentation and/or other materials provided
00050  *      with the distribution.
00051  *   3. The name of the author may not be used to endorse or promote
00052  *      products derived from this software without specific prior
00053  *      written permission.
00054  */
00055 
00056 #ifndef __IPMI_ADDR_H
00057 #define __IPMI_ADDR_H
00058 
00059 /* To get a socket. */
00060 #include <netinet/in.h>
00061 
00062 #ifdef __cplusplus
00063 extern "C" {
00064 #endif
00065 
00066 /* The formats of these MUST match the formats for the kernel. */
00067 
00068 #ifndef __LINUX_IPMI_H /* Don't include this if we are including the kernel */
00069 
00070 /* This is an overlay for all the address types, so it's easy to
00071    determine the actual address type.  This is kind of like addresses
00072    work for sockets. */
00073 #define IPMI_MAX_ADDR_SIZE 32
00074 struct ipmi_addr
00075 {
00076          /* Try to take these from the "Channel Medium Type" table
00077             in section 6.5 of the IPMI 1.5 manual. */
00078         int   addr_type;
00079         short channel;
00080         char  data[IPMI_MAX_ADDR_SIZE];
00081 };
00082 
00083 /* When the address is not used, the type will be set to this value.
00084    The channel is the BMC's channel number for the channel (usually
00085    0), or IPMC_BMC_CHANNEL if communicating directly with the BMC. */
00086 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0xc
00087 struct ipmi_system_interface_addr
00088 {
00089         int           addr_type;
00090         short         channel;
00091         unsigned char lun;
00092 };
00093 
00094 /* An IPMB Address. */
00095 #define IPMI_IPMB_ADDR_TYPE     1
00096 /* Used for broadcast get device id as described in section 17.9 of the
00097    IPMI 1.5 manual. */
00098 #define IPMI_IPMB_BROADCAST_ADDR_TYPE   0x41
00099 struct ipmi_ipmb_addr
00100 {
00101         int           addr_type;
00102         short         channel;
00103         unsigned char slave_addr;
00104         unsigned char lun;
00105 };
00106 
00107 /*
00108  * A LAN Address.  This is an address to/from a LAN interface bridged
00109  * by the BMC, not an address actually out on the LAN.
00110  *
00111  * A concious decision was made here to deviate slightly from the IPMI
00112  * spec.  We do not use rqSWID and rsSWID like it shows in the
00113  * message.  Instead, we use remote_SWID and local_SWID.  This means
00114  * that any message (a request or response) from another device will
00115  * always have exactly the same address.  If you didn't do this,
00116  * requests and responses from the same device would have different
00117  * addresses, and that's not too cool.
00118  *
00119  * In this address, the remote_SWID is always the SWID the remote
00120  * message came from, or the SWID we are sending the message to.
00121  * local_SWID is always our SWID.  Note that having our SWID in the
00122  * message is a little wierd, but this is required.
00123  */
00124 #define IPMI_LAN_ADDR_TYPE              0x04
00125 struct ipmi_lan_addr
00126 {
00127         int           addr_type;
00128         short         channel;
00129         unsigned char privilege;
00130         unsigned char session_handle;
00131         unsigned char remote_SWID;
00132         unsigned char local_SWID;
00133         unsigned char lun;
00134 };
00135 
00136 /* Channel for talking directly with the BMC.  When using this
00137    channel, This is for the system interface address type only.
00138    FIXME - is this right, or should we use -1? */
00139 #define IPMI_BMC_CHANNEL  0xf
00140 
00141 /* The channel that means "The channel we are talking on". */
00142 #define IPMI_SELF_CHANNEL 0xe
00143 
00144 #define IPMI_NUM_CHANNELS 0x10
00145 
00146 #endif /* _LINUX_IPMI_H */
00147 
00148 /* RMCP+ address types are in this range.  These map to payloads.  Note
00149    that 0x100 is specially used; it would be IPMI if there was no
00150    special handling, but it is used for RMCP messages outside the
00151    session. */
00152 #define IPMI_RMCPP_ADDR_START           0x100
00153 #define IPMI_RMCPP_ADDR_END             0x13f
00154 typedef struct ipmi_rmcpp_addr
00155 {
00156         int           addr_type;
00157 
00158         /* These fields are only used if this is a type 2 payload
00159            (0x102 for the addr_type).  The IANA comes from the lan
00160            challenge for the other oem payload types (0x20-0x27) */
00161         unsigned char oem_iana[3];
00162         uint16_t      oem_payload_id;
00163 } ipmi_rmcpp_addr_t;
00164 
00165 /* This is outside the range of normal NETFNs, it is used for
00166    registering for RMCP things. */
00167 #define IPMI_RMCPP_DUMMY_NETFN          0x40
00168 
00169 /* Generate types for the kernel versions of these. */
00170 typedef struct ipmi_addr ipmi_addr_t;
00171 typedef struct ipmi_system_interface_addr ipmi_system_interface_addr_t;
00172 typedef struct ipmi_ipmb_addr ipmi_ipmb_addr_t;
00173 typedef struct ipmi_lan_addr ipmi_lan_addr_t;
00174 
00175 /* An 802.3 LAN address */
00176 #define IPMI_802_3_ADDR_TYPE 4
00177 typedef struct ipmi_802_3_addr_s
00178 {
00179         int            addr_type;
00180         short          channel;
00181         struct in_addr addr;
00182         unsigned short port;
00183 } ipmi_802_3_addr_t;
00184 
00185 /* Compare two IPMI addresses, and return false if they are equal and
00186    true if they are not. */
00187 int ipmi_addr_equal(const ipmi_addr_t *addr1,
00188                     int               addr1_len,
00189                     const ipmi_addr_t *addr2,
00190                     int               addr2_len);
00191 unsigned int ipmi_addr_get_lun(const ipmi_addr_t *addr);
00192 int ipmi_addr_set_lun(ipmi_addr_t *addr, unsigned int lun);
00193 
00194 /* Like the above, but do not use the LUN in the comparison. */
00195 int ipmi_addr_equal_nolun(const ipmi_addr_t *addr1,
00196                           int               addr1_len,
00197                           const ipmi_addr_t *addr2,
00198                           int               addr2_len);
00199 
00200 /* Get the slave address from the address, returns 0 if the address
00201    does not have a slave address. */
00202 unsigned int ipmi_addr_get_slave_addr(const ipmi_addr_t *addr);
00203 
00204 #ifdef __cplusplus
00205 }
00206 #endif
00207 
00208 #endif /* __IPMI_ADDR_H */

© sourcejam.com 2005-2008