Background Introduction ======== ipmi (Intelligent Platform Management Interface) is a set of specifications / interfaces for hardware platform management. Official Website: http://www.intel.com/design/servers/ipmi/index.htm and ipmitool are tools for managing and configuring support for IPMI specification hardware. Official Website http://ipmitool.sourceforge.net/
IPMitool architecture ============== The source code directory is -contrib // used to establish the Shell script for the web management page --- Control // contains some installation, configuration information --- debian // Contains information of Changelog and other information - DOC // Man Help information --- include | / --- ipmitool // header file definition --- lib // correspond to IPMI specifications If IPMI_SESSION.C Processing Session / --- SRC // This directory is IPMitool's three main programs / --- plugins // ipmi_intf.c interface Some universal features Implementation --- BMC // ipmitool and BMC The interface between Kernel Driver --- IMB // Intel IMB Interface --- Lan // IPMI V1.5 LAN Interface --- LANPLUS // IPMI V2.0 RMCP LAN Interface --- Lipmi // Solaris x86 lipmi interface / --- open // linux openipmi interface [default]
The factory mode under C language ================= From the above directory structure, it is not difficult to see that an important feature of IPMitool design is to see different interface as Plugin. This makes the system have a clear structure and good expansion.
The entities defined in the IPMI specification, such as session, FRU, SDR, CHASSIS, SENSOR, etc., all in the LIB. This part is separated from the specific interface phase. The general interface of Interface is defined in include / ipmitool / ipmi_intf.h; Interface's general function implementation, in /src/plugins/ipmi_intf.c. It is worth noting that Interface is the concept defined in the IPMI specification, and the Chinese "interface" is used in the communication interface.
This way to separate universal interfaces and specific implementations is unbelourtion is a simple factory model.
Practice ==== So how is the interface implementation as Plugin? You can take a look at a specific example.
IPMI_INTF {... strunt ipmi_intf {... struct ipmi_inter {... strunt ipmi_ness * session; struct ipmi_oem_handdr; uint32_t timget_addr; uint32_t timget_addr; UINT32_T TARGET_ADDR;
INT (* setup); int (* open) (struct IPMI_INTF * INTF); void (* close) (Struct ipmi_intf * intf); ...}; similar to the olance, Struct is inside the Struct Data and methods. Different, the method uses the function of the function pointer. Because there is no THIS pointer, the function of the function is pointing to the pointer to its own STRUCT. Such as setup.
In the specific implementation, specific functions are given in SRC / PLUGINS / LAN / LAN.C. Such as IPMI_LAN_SETUP. In IPMI_LAN_SETUP, the INTF pointer that can be used can be used to implement the operation of the corresponding data in the IPMI_INTF structure.
struct ipmi_intf ipmi_lan_intf = {name: "lan", desc: "IPMI v1.5 LAN Interface", setup: ipmi_lan_setup, open: ipmi_lan_open, close: ipmi_lan_close, sendrecv: ipmi_lan_send_cmd, sendrsp: ipmi_lan_send_rsp, keepalive: ipmi_lan_keepalive, target_addr: IPMI_BMC_SLAVE_ADDR, }
The will be is not difficult, the difficulties will not, 嘿嘿