X hits on this document

PDF document

February 10, 2006 - page 42 / 238

937 views

0 shares

0 downloads

0 comments

42 / 238

30

CHAPTER 3. IPMI INTERFACES

req.addr = (void *) &si; req.addr_len = sizeof(si); req.msgid = 0x1234; req.msg.netfn = 0x04; /* Sensor/Event netfn */ req.msg.cmd = 0x2d; /* Get sensor reading */ req.msg.data = data; req.msg.data_len = 1; data[0] = 10; /* Read sensor 10 */

rv = ioctl(fd, IPMICTL_SEND_COMMAND, &req);

Note that sending the command is asyncronous; you will not immediately get the response. Instead, the response comes back later and can be received at that point in time. This is what makes the msgid important.

The following example shows sending a get device id request to IPMB address 0xb2.

s t r u c t i p m i _ r e q

req;

struct ipmi_ipmb_addr si;

/* Format the address. */ s i . a d d r _ t y p e = I P M I _ I P M B _ A D D R _ T Y P E si.channel = 0; si.lun = 0; ; s i . s l a v e _ a d d r = 0 x b 2 ;

req.addr = (void *) &si; req.addr_len = sizeof(si); req.msgid = 0x1234; req.msg.netfn = 0x06; /* App netfn */ req.msg.cmd = 0x01; /* Get device id */ req.msg.data = NULL; req.msg.data_len = 0;

r v = i o c t l ( f d , I P M I C T L _ S E N D _ C O M M A N D , & r e q ) ;

Receiving Responses and Events

As mentioned before, the responses to commands come back in later. You can use standard select and poll calls to wait for messages to come in. However, you cannot use read to get the message. The following data structure is used to receive messages:

int

recv_type;

unsigned char

*addr;

unsigned int

addr_len;

long

msgid;

s t r u c t i p m i _ r e c { v

Document info
Document views937
Page views937
Page last viewedSun Dec 11 06:19:37 UTC 2016
Pages238
Paragraphs8090
Words85809

Comments