4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <assert.h>
29 #include <inttypes.h>
30 #include <string.h>
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
35 #include <errno.h>
36 #include <unistd.h>
37 #include <netdb.h>
38 #include <fcntl.h>
39
40 #include "libipmi.h"
41 #include "ipmi_lan.h"
42 #include "ipmi_impl.h"
43
461 sizeof (uint32_t));
462
463 (void) memcpy(msg + off, &session_hdr, sizeof (session_hdr));
464 off += sizeof (session_hdr);
465
466 /* IPMI session authcode */
467 if (ilp->il_send_authcode && ilp->il_authtype) {
468 (void) memcpy(msg + off, ilp->il_authcode, 16);
469 off += 16;
470 }
471
472 /* message length */
473 msg[off++] = req->ic_dlen + 7;
474 cs = off;
475
476 /* IPMI message header */
477 (void) memset(&msg_hdr, 0, sizeof (msg_hdr));
478 msg_hdr.imh_addr1 = IPMI_BMC_SLAVE_ADDR;
479 msg_hdr.imh_lun = req->ic_lun;
480 msg_hdr.imh_netfn = req->ic_netfn;
481 tmp = off - cs;
482 msg_hdr.imh_csum = ipmi_csum(msg + cs, tmp);
483 cs = off;
484 msg_hdr.imh_addr2 = IPMI_BMC_SLAVE_ADDR;
485 entry->ire_rq_seq = curr_seq++;
486 msg_hdr.imh_seq = entry->ire_rq_seq << 2;
487 msg_hdr.imh_cmd = req->ic_cmd;
488 (void) memcpy(msg + off, &msg_hdr, sizeof (msg_hdr));
489 off += sizeof (msg_hdr);
490
491 /* message data */
492 if (req->ic_dlen != 0) {
493 (void) memcpy(msg + off, req->ic_data, req->ic_dlen);
494 off += req->ic_dlen;
495 }
496
497 /* message data checksum */
498 tmp = off - cs;
499 msg[off++] = ipmi_csum(msg + cs, tmp);
500
501 if (ilp->il_in_seq) {
502 ilp->il_in_seq++;
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <assert.h>
30 #include <inttypes.h>
31 #include <string.h>
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
35 #include <arpa/inet.h>
36 #include <errno.h>
37 #include <unistd.h>
38 #include <netdb.h>
39 #include <fcntl.h>
40
41 #include "libipmi.h"
42 #include "ipmi_lan.h"
43 #include "ipmi_impl.h"
44
462 sizeof (uint32_t));
463
464 (void) memcpy(msg + off, &session_hdr, sizeof (session_hdr));
465 off += sizeof (session_hdr);
466
467 /* IPMI session authcode */
468 if (ilp->il_send_authcode && ilp->il_authtype) {
469 (void) memcpy(msg + off, ilp->il_authcode, 16);
470 off += 16;
471 }
472
473 /* message length */
474 msg[off++] = req->ic_dlen + 7;
475 cs = off;
476
477 /* IPMI message header */
478 (void) memset(&msg_hdr, 0, sizeof (msg_hdr));
479 msg_hdr.imh_addr1 = IPMI_BMC_SLAVE_ADDR;
480 msg_hdr.imh_lun = req->ic_lun;
481 msg_hdr.imh_netfn = req->ic_netfn;
482 msg_hdr.imh_csum = ipmi_csum((uint8_t *)&msg_hdr, sizeof (msg_hdr));
483 cs = off;
484 msg_hdr.imh_addr2 = IPMI_BMC_SLAVE_ADDR;
485 entry->ire_rq_seq = curr_seq++;
486 msg_hdr.imh_seq = entry->ire_rq_seq << 2;
487 msg_hdr.imh_cmd = req->ic_cmd;
488 (void) memcpy(msg + off, &msg_hdr, sizeof (msg_hdr));
489 off += sizeof (msg_hdr);
490
491 /* message data */
492 if (req->ic_dlen != 0) {
493 (void) memcpy(msg + off, req->ic_data, req->ic_dlen);
494 off += req->ic_dlen;
495 }
496
497 /* message data checksum */
498 tmp = off - cs;
499 msg[off++] = ipmi_csum(msg + cs, tmp);
500
501 if (ilp->il_in_seq) {
502 ilp->il_in_seq++;
|