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

ipmi_solparm.h

Go to the documentation of this file.
00001 /*
00002  * ipmi_solparm.h
00003  *
00004  * Routines for configuring IPMI SoL data.
00005  *
00006  * Author: MontaVista Software, Inc.
00007  *         Corey Minyard <minyard@mvista.com>
00008  *         source@mvista.com
00009  *
00010  * Copyright 2006 MontaVista Software Inc.
00011  *
00012  *  This program is free software; you can redistribute it and/or
00013  *  modify it under the terms of the GNU Lesser General Public License
00014  *  as published by the Free Software Foundation; either version 2 of
00015  *  the License, or (at your option) any later version.
00016  *
00017  *
00018  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00019  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00020  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00021  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00023  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00024  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00025  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00026  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00027  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  *
00029  *  You should have received a copy of the GNU Lesser General Public
00030  *  License along with this program; if not, write to the Free
00031  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00032  */
00033 
00034 #ifndef _IPMI_SOLPARM_H
00035 #define _IPMI_SOLPARM_H
00036 
00037 #include <OpenIPMI/ipmi_types.h>
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 /* The abstract type for solparm. */
00044 typedef struct ipmi_solparm_s ipmi_solparm_t;
00045 
00046 
00047 /* Generic callback used to tell when a SOLPARM operation is done. */
00048 typedef void (*ipmi_solparm_done_cb)(ipmi_solparm_t *solparm,
00049                                      int            err,
00050                                      void           *cb_data);
00051 
00052 /* Generic callback for iterating. */
00053 typedef void (*ipmi_solparm_ptr_cb)(ipmi_solparm_t *solparm,
00054                                     void           *cb_data);
00055 
00056 /* Allocate a SOLPARM. */
00057 int ipmi_solparm_alloc(ipmi_mc_t      *mc,
00058                        unsigned int   channel,
00059                        ipmi_solparm_t **new_solparm);
00060 
00061 /* Destroy a SOLPARM. */
00062 int ipmi_solparm_destroy(ipmi_solparm_t       *solparm,
00063                          ipmi_solparm_done_cb handler,
00064                          void                 *cb_data);
00065 
00066 /* Used to track references to a solparm.  You can use this instead of
00067    ipmi_solparm_destroy, but use of the destroy function is
00068    recommended.  This is primarily here to help reference-tracking
00069    garbage collection systems like what is in Perl to be able to
00070    automatically destroy solparms when they are done. */
00071 void ipmi_solparm_ref(ipmi_solparm_t *solparm);
00072 void ipmi_solparm_deref(ipmi_solparm_t *solparm);
00073 
00074 void ipmi_solparm_iterate_solparms(ipmi_domain_t       *domain,
00075                                    ipmi_solparm_ptr_cb handler,
00076                                    void                *cb_data);
00077 
00078 ipmi_mcid_t ipmi_solparm_get_mc_id(ipmi_solparm_t *solparm);
00079 unsigned int ipmi_solparm_get_channel(ipmi_solparm_t *solparm);
00080 
00081 #define IPMI_SOLPARM_NAME_LEN 64
00082 int ipmi_solparm_get_name(ipmi_solparm_t *solparm, char *name, int length);
00083 
00084 
00085 
00086 /* Fetch a parameter value from the SOLPARM.  The "set" and "block"
00087    parameters are the set selector and block selectors.  If those are
00088    not relevant for the given parm, then set them to zero.  Note that
00089    on the return data, the first byte (byte 0) is the revision number,
00090    the data starts in the second byte. */
00091 typedef void (*ipmi_solparm_get_cb)(ipmi_solparm_t    *solparm,
00092                                     int               err,
00093                                     unsigned char     *data,
00094                                     unsigned int      data_len,
00095                                     void              *cb_data);
00096 int ipmi_solparm_get_parm(ipmi_solparm_t      *solparm,
00097                           unsigned int        parm,
00098                           unsigned int        set,
00099                           unsigned int        block,
00100                           ipmi_solparm_get_cb done,
00101                           void                *cb_data);
00102 
00103 /* Set the parameter value in the SOLPARM to the given data. */
00104 int ipmi_solparm_set_parm(ipmi_solparm_t       *solparm,
00105                           unsigned int         parm,
00106                           unsigned char        *data,
00107                           unsigned int         data_len,
00108                           ipmi_solparm_done_cb done,
00109                           void                 *cb_data);
00110 
00111 /* The various SoL config parms. */
00112 #define IPMI_SOLPARM_SET_IN_PROGRESS            0
00113 #define IPMI_SOLPARM_ENABLE                     1
00114 #define IPMI_SOLPARM_AUTHENTICATION             2
00115 #define IPMI_SOLPARM_CHAR_SETTINGS              3
00116 #define IPMI_SOLPARM_RETRY                      4
00117 #define IPMI_SOLPARM_NONVOLATILE_BITRATE        5
00118 #define IPMI_SOLPARM_VOLATILE_BITRATE           6
00119 #define IPMI_SOLPARM_PAYLOAD_CHANNEL            7
00120 #define IPMI_SOLPARM_PAYLOAD_PORT_NUMBER        8
00121 
00122 /* A full SoL configuration.  Note that you cannot allocate one of
00123    these, you can only fetch them, modify them, set them, and free
00124    them. */
00125 typedef struct ipmi_sol_config_s ipmi_sol_config_t;
00126 
00127 /* Get the full SOL configuration and lock the SOL.  Note that if the
00128    SOL is locked by another, you will get an EAGAIN error in the
00129    callback.  You can retry the operation, or if you are sure that it
00130    is free, you can call ipmi_sol_clear_lock() before retrying.  Note
00131    that the config in the callback *must* be freed by you. */
00132 typedef void (*ipmi_sol_get_config_cb)(ipmi_solparm_t    *solparm,
00133                                        int               err,
00134                                        ipmi_sol_config_t *config,
00135                                        void              *cb_data);
00136 int ipmi_sol_get_config(ipmi_solparm_t         *solparm,
00137                         ipmi_sol_get_config_cb done,
00138                         void                   *cb_data);
00139 
00140 /* Set the full SOL configuration.  The config *MUST* be locked and
00141    the solparm must match the SOL that it was fetched with.  Note that
00142    a copy is made of the configuration, so you are free to do whatever
00143    you like with it after this.  Note that this unlocks the config, so
00144    it cannot be used for future set operations. */
00145 int ipmi_sol_set_config(ipmi_solparm_t       *solparm,
00146                         ipmi_sol_config_t    *config,
00147                         ipmi_solparm_done_cb done,
00148                         void                 *cb_data);
00149 
00150 /* Clear the lock on a SOL.  If the SOL config is non-NULL, then it's
00151    lock is also cleared. */
00152 int ipmi_sol_clear_lock(ipmi_solparm_t       *solparm,
00153                         ipmi_sol_config_t    *solc,
00154                         ipmi_solparm_done_cb done,
00155                         void                 *cb_data);
00156 
00157 /* Free a SOL config. */
00158 void ipmi_sol_free_config(ipmi_sol_config_t *config);
00159 
00160 /*
00161  * Boatloads of data from the SOL config.  Note that all IP addresses,
00162  * ports, etc. are in network order.
00163  */
00164 
00165 /* This interface lets you fetch and set the data values by parm
00166    num. Note that the parm nums *DO NOT* correspond to the
00167    IPMI_SOLPARM_xxx values above. */
00168 
00169 enum ipmi_solconf_val_type_e { IPMI_SOLCONFIG_INT, IPMI_SOLCONFIG_BOOL,
00170                                IPMI_SOLCONFIG_DATA,
00171                                IPMI_SOLCONFIG_IP, IPMI_SOLCONFIG_MAC };
00172 /* When getting the value, the valtype will be set to int or data.  If
00173    it is int or bool, the value is returned in ival and the dval is
00174    not used.  If it is data, ip, or mac, the data will be returned in
00175    an allocated array in dval and the length set in dval_len.  The
00176    data must be freed with ipmi_solconfig_data_free().  The is used
00177    for some data items (the priv level for authentication type, the
00178    destination for alerts and destination addresses); for other items
00179    it is ignored.  The index should point to the value to fetch
00180    (starting at zero), it will be updated to the next value or -1 if
00181    no more are left.  The index will be unchanged if the parm does not
00182    support an index.
00183 
00184    The string name is returned in the name field, if it is not NULL.
00185 
00186    Note that when fetching a value, if the passed in pointer is NULL
00187    the data will not be filled in (except for index, which must always
00188    be present).  That lets you get the value type without getting the
00189    data, for instance. */
00190 int ipmi_solconfig_get_val(ipmi_sol_config_t *solc,
00191                            unsigned int      parm,
00192                            const char        **name,
00193                            int               *index,
00194                            enum ipmi_solconf_val_type_e *valtype,
00195                            unsigned int      *ival,
00196                            unsigned char     **dval,
00197                            unsigned int      *dval_len);
00198   /* Set a value in the sol config.  You must know ahead of time the
00199      actual value type and set the proper one. */
00200 int ipmi_solconfig_set_val(ipmi_sol_config_t *solc,
00201                            unsigned int      parm,
00202                            int               index,
00203                            unsigned int      ival,
00204                            unsigned char     *dval,
00205                            unsigned int      dval_len);
00206 /* If the value is an integer, this can be used to determine if it is
00207    an enumeration and what the values are.  If the parm is not an
00208    enumeration, this will return ENOSYS for the parm.  Otherwise, if
00209    you pass in zero, you will get either the first enumeration value,
00210    or EINVAL if zero is not a valid enumeration, but there are others.
00211    If this returns EINVAL or 0, nval will be set to the next valid
00212    enumeration value, or -1 if val is the last or past the last
00213    enumeration value.  If this returns 0, val will be set to the
00214    string value for the enumeration. */
00215 int ipmi_solconfig_enum_val(unsigned int parm, int val, int *nval,
00216                             const char **sval);
00217 /* Sometimes array indexes may be enumerations.  This allows the user
00218    to detect if a specific parm's array index is an enumeration, and
00219    to get the enumeration values.  */
00220 int ipmi_solconfig_enum_idx(unsigned int parm, int idx, const char **sval);
00221 /* Free data from ipmi_solconfig_get_val(). */
00222 void ipmi_solconfig_data_free(void *data);
00223 /* Convert a string to a solconfig parm number.  Returns -1 if the
00224    string is invalid. */
00225 unsigned int ipmi_solconfig_str_to_parm(char *name);
00226 /* Convert the parm to a string name. */
00227 const char *ipmi_solconfig_parm_to_str(unsigned int parm);
00228 /* Get the type of a specific parm. */
00229 int ipmi_solconfig_parm_to_type(unsigned int                 parm,
00230                                 enum ipmi_solconf_val_type_e *valtype);
00231 
00232 
00233 /* Settings for getting at individual parameters directly. */
00234 
00235 unsigned int
00236 ipmi_solconfig_get_enable(ipmi_sol_config_t *solc);
00237 int
00238 ipmi_solconfig_set_enable(ipmi_sol_config_t *solc,
00239                           unsigned int      val);
00240 
00241 unsigned int
00242 ipmi_solconfig_get_force_payload_encryption(ipmi_sol_config_t *solc);
00243 int
00244 ipmi_solconfig_set_force_payload_encryption(ipmi_sol_config_t *solc,
00245                                             unsigned int      val);
00246 
00247 unsigned int
00248 ipmi_solconfig_get_force_payload_authentication(ipmi_sol_config_t *solc);
00249 int
00250 ipmi_solconfig_set_force_payload_authentication(ipmi_sol_config_t *solc,
00251                                                 unsigned int      val);
00252 
00253 unsigned int
00254 ipmi_solconfig_get_privilege_level(ipmi_sol_config_t *solc);
00255 int
00256 ipmi_solconfig_set_privilege_level(ipmi_sol_config_t *solc,
00257                                    unsigned int      val);
00258 
00259 unsigned int
00260 ipmi_solconfig_get_char_accumulation_interval(ipmi_sol_config_t *solc);
00261 int
00262 ipmi_solconfig_set_char_accumulation_interval(ipmi_sol_config_t *solc,
00263                                               unsigned int      val);
00264 
00265 unsigned int
00266 ipmi_solconfig_get_char_send_threshold(ipmi_sol_config_t *solc);
00267 int
00268 ipmi_solconfig_set_char_send_threshold(ipmi_sol_config_t *solc,
00269                                        unsigned int      val);
00270 
00271 unsigned int
00272 ipmi_solconfig_get_retry_count(ipmi_sol_config_t *solc);
00273 int
00274 ipmi_solconfig_set_retry_count(ipmi_sol_config_t *solc,
00275                                unsigned int      val);
00276 
00277 unsigned int
00278 ipmi_solconfig_get_retry_interval(ipmi_sol_config_t *solc);
00279 int
00280 ipmi_solconfig_set_retry_interval(ipmi_sol_config_t *solc,
00281                                   unsigned int      val);
00282 
00283 unsigned int
00284 ipmi_solconfig_get_non_volatile_bitrate(ipmi_sol_config_t *solc);
00285 int
00286 ipmi_solconfig_set_non_volatile_bitrate(ipmi_sol_config_t *solc,
00287                                         unsigned int      val);
00288 
00289 unsigned int
00290 ipmi_solconfig_get_volatile_bitrate(ipmi_sol_config_t *solc);
00291 int
00292 ipmi_solconfig_set_volatile_bitrate(ipmi_sol_config_t *solc,
00293                                    unsigned int      val);
00294 
00295 int
00296 ipmi_solconfig_get_port_number(ipmi_sol_config_t *solc,
00297                                unsigned int      *data);
00298 int
00299 ipmi_solconfig_set_port_number(ipmi_sol_config_t *solc,
00300                                unsigned int      val);
00301 
00302 int
00303 ipmi_solconfig_get_payload_channel(ipmi_sol_config_t *solc,
00304                                    unsigned int      *data);
00305 
00306 #ifdef __cplusplus
00307 }
00308 #endif
00309 
00310 #endif /* _IPMI_SOLPARM_H */

© sourcejam.com 2005-2008