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

ipmi_pet.h

Go to the documentation of this file.
00001 /*
00002  * ipmi_pet.h
00003  *
00004  * MontaVista IPMI interface for setting up and handling platform event
00005  * traps.
00006  *
00007  * Author: MontaVista Software, Inc.
00008  *         Corey Minyard <minyard@mvista.com>
00009  *         source@mvista.com
00010  *
00011  * Copyright 2004 MontaVista Software Inc.
00012  *
00013  *  This program is free software; you can redistribute it and/or
00014  *  modify it under the terms of the GNU Lesser General Public License
00015  *  as published by the Free Software Foundation; either version 2 of
00016  *  the License, or (at your option) any later version.
00017  *
00018  *
00019  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00022  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00025  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00027  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00028  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  *  You should have received a copy of the GNU Lesser General Public
00031  *  License along with this program; if not, write to the Free
00032  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00033  */
00034 
00035 #ifndef _IPMI_PET_H
00036 #define _IPMI_PET_H
00037 
00038 #include <OpenIPMI/ipmi_types.h>
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 typedef struct ipmi_pet_s ipmi_pet_t;
00045 
00046 typedef void (*ipmi_pet_done_cb)(ipmi_pet_t *pet, int err, void *cb_data);
00047 
00048 /* Create and configure a Platform Event Trap handler for the given
00049  * channel in the given domain.  Parameters are: 
00050  *
00051  *  channel - The specific channel to configure.  There is not real
00052  *      way to know all the channels and what IP addresses should
00053  *      be used for each.
00054  *  ip_addr - The IP address to tell the PET to send messages to, if
00055  *      applicable for this domain.
00056  *  mac_addr - The MAC address to tell the PET to send messages to,
00057  *      if applicable for this domain.
00058  *  eft_sel - the Event Filter selector to use for this PET destination.
00059  *      Note that this does *not* need to be unique for different OpenIPMI
00060  *      instances that are using the same channel, since the configuration
00061  *      will be exactly the same for all EFT entries using the same
00062  *      channel, assuming they share the same policy number.
00063  *  policy_num - The policy number to use for the alert policy.  This
00064  *      should be the same for all users of a domain.
00065  *  apt_sel - The Alert Policy selector to use for this PET destination.
00066  *      Note that as eft_sel, this needs to be unique for each different
00067  *      OpenIPMI instance on the same channel, as it specifies the
00068  *      destination to use.
00069  *  lan_dest_sel - The LAN configuration destination selector for this PET
00070  *      destination.  Unlike eft_sel and apt_sel, this *must* be unique
00071  *      for each OpenIPMI instance on the same channel.
00072  *
00073  * Creating one of these in a domain will cause event traps to be received
00074  * and handled as standard events in OpenIPMI.
00075  *
00076  * Note that this uses the standard SNMP trap port (162), so you
00077  * cannot run SNMP software that receives traps and an IPMI PET at
00078  * the same time on the same machine.
00079  */
00080 int ipmi_pet_create(ipmi_domain_t    *domain,
00081                     unsigned int     connection,
00082                     unsigned int     channel,
00083                     struct in_addr   ip_addr,
00084                     unsigned char    mac_addr[6],
00085                     unsigned int     eft_sel,
00086                     unsigned int     policy_num,
00087                     unsigned int     apt_sel,
00088                     unsigned int     lan_dest_sel,
00089                     ipmi_pet_done_cb done,
00090                     void             *cb_data,
00091                     ipmi_pet_t       **pet);
00092 
00093 /*
00094  * Like the previous call, but takes an MC instead of a domain and
00095  * channel.
00096  */
00097 int ipmi_pet_create_mc(ipmi_mc_t        *mc,
00098                        unsigned int     channel,
00099                        struct in_addr   ip_addr,
00100                        unsigned char    mac_addr[6],
00101                        unsigned int     eft_sel,
00102                        unsigned int     policy_num,
00103                        unsigned int     apt_sel,
00104                        unsigned int     lan_dest_sel,
00105                        ipmi_pet_done_cb done,
00106                        void             *cb_data,
00107                        ipmi_pet_t       **ret_pet);
00108 
00109 /* Destroy a PET.  Note that if you destroy all PETs, this will result
00110    in the SNMP trap UDP port being closed. */
00111 int ipmi_pet_destroy(ipmi_pet_t       *pet,
00112                      ipmi_pet_done_cb done,
00113                      void             *cb_data);
00114 
00115 /* Used to track references to a pet.  You can use this instead of
00116    ipmi_pet_destroy, but use of the destroy function is
00117    recommended.  This is primarily here to help reference-tracking
00118    garbage collection systems like what is in Perl to be able to
00119    automatically destroy pets when they are done. */
00120 void ipmi_pet_ref(ipmi_pet_t *pet);
00121 void ipmi_pet_deref(ipmi_pet_t *pet);
00122 
00123 /* Get the "name" for the PET.  Returns the length of the string
00124    (minus the closing \0).  PET names are auto-assigned. */
00125 #define IPMI_PET_NAME_LEN 64
00126 int ipmi_pet_get_name(ipmi_pet_t *pet, char *name, int len);
00127 
00128 /* Iterate through all the PETs. */
00129 typedef void (*ipmi_pet_ptr_cb)(ipmi_pet_t *pet, void *cb_data);
00130 void ipmi_pet_iterate_pets(ipmi_domain_t   *domain,
00131                            ipmi_pet_ptr_cb handler,
00132                            void            *cb_data);
00133 
00134 ipmi_mcid_t ipmi_pet_get_mc_id(ipmi_pet_t *pet);
00135 unsigned int ipmi_pet_get_channel(ipmi_pet_t *pet);
00136 struct in_addr *ipmi_pet_get_ip_addr(ipmi_pet_t *pet, struct in_addr *ip_addr);
00137 unsigned char *ipmi_pet_get_mac_addr(ipmi_pet_t    *pet,
00138                                      unsigned char mac_addr[6]);
00139 unsigned int ipmi_pet_get_eft_sel(ipmi_pet_t *pet);
00140 unsigned int ipmi_pet_get_policy_num(ipmi_pet_t *pet);
00141 unsigned int ipmi_pet_get_apt_sel(ipmi_pet_t *pet);
00142 unsigned int ipmi_pet_get_lan_dest_sel(ipmi_pet_t *pet);
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #endif /* _IPMI_PET_H */

© sourcejam.com 2005-2008