lanplus.c (70984dcad503a28baed2a269aa725b4cfb19251e) | lanplus.c (eb54136775f63a6a159f3c55ee4772d7aa363cc4) |
---|---|
1/* 2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistribution of source code must retain the above copyright --- 2114 unchanged lines hidden (view full) --- 2123 if (!intf->opened && intf->open && intf->open(intf) < 0) 2124 return NULL; 2125 2126 /* 2127 * The session timeout is initialized in the above interface open, 2128 * so it will only be valid after the open completes. 2129 */ 2130 saved_timeout = session->timeout; | 1/* 2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistribution of source code must retain the above copyright --- 2114 unchanged lines hidden (view full) --- 2123 if (!intf->opened && intf->open && intf->open(intf) < 0) 2124 return NULL; 2125 2126 /* 2127 * The session timeout is initialized in the above interface open, 2128 * so it will only be valid after the open completes. 2129 */ 2130 saved_timeout = session->timeout; |
2131 while (try < session->retry) { | 2131 while (try < intf->ssn_params.retry) { |
2132 //ltime = time(NULL); 2133 2134 if (xmit) { 2135 ltime = time(NULL); 2136 2137 if (payload->payload_type == IPMI_PAYLOAD_TYPE_IPMI) 2138 { 2139 /* --- 121 unchanged lines hidden (view full) --- 2261 usleep(100); /* Not sure what this is for */ 2262 2263 /* Remember our connection state */ 2264 switch (payload->payload_type) 2265 { 2266 case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: 2267 session->v2_data.session_state = LANPLUS_STATE_OPEN_SESSION_SENT; 2268 /* not retryable for timeouts, force no retry */ | 2132 //ltime = time(NULL); 2133 2134 if (xmit) { 2135 ltime = time(NULL); 2136 2137 if (payload->payload_type == IPMI_PAYLOAD_TYPE_IPMI) 2138 { 2139 /* --- 121 unchanged lines hidden (view full) --- 2261 usleep(100); /* Not sure what this is for */ 2262 2263 /* Remember our connection state */ 2264 switch (payload->payload_type) 2265 { 2266 case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST: 2267 session->v2_data.session_state = LANPLUS_STATE_OPEN_SESSION_SENT; 2268 /* not retryable for timeouts, force no retry */ |
2269 try = session->retry; | 2269 try = intf->ssn_params.retry; |
2270 break; 2271 case IPMI_PAYLOAD_TYPE_RAKP_1: 2272 session->v2_data.session_state = LANPLUS_STATE_RAKP_1_SENT; 2273 /* not retryable for timeouts, force no retry */ | 2270 break; 2271 case IPMI_PAYLOAD_TYPE_RAKP_1: 2272 session->v2_data.session_state = LANPLUS_STATE_RAKP_1_SENT; 2273 /* not retryable for timeouts, force no retry */ |
2274 try = session->retry; | 2274 try = intf->ssn_params.retry; |
2275 break; 2276 case IPMI_PAYLOAD_TYPE_RAKP_3: 2277 /* not retryable for timeouts, force no retry */ | 2275 break; 2276 case IPMI_PAYLOAD_TYPE_RAKP_3: 2277 /* not retryable for timeouts, force no retry */ |
2278 try = session->retry; | 2278 try = intf->ssn_params.retry; |
2279 session->v2_data.session_state = LANPLUS_STATE_RAKP_3_SENT; 2280 break; 2281 } 2282 2283 2284 /* 2285 * Special case for SOL outbound packets. 2286 */ --- 388 unchanged lines hidden (view full) --- 2675 uint8_t msg_data[2]; 2676 uint8_t backupBridgePossible; 2677 2678 backupBridgePossible = bridgePossible; 2679 2680 bridgePossible = 0; 2681 2682 msg_data[0] = IPMI_LAN_CHANNEL_E | 0x80; // Ask for IPMI v2 data as well | 2279 session->v2_data.session_state = LANPLUS_STATE_RAKP_3_SENT; 2280 break; 2281 } 2282 2283 2284 /* 2285 * Special case for SOL outbound packets. 2286 */ --- 388 unchanged lines hidden (view full) --- 2675 uint8_t msg_data[2]; 2676 uint8_t backupBridgePossible; 2677 2678 backupBridgePossible = bridgePossible; 2679 2680 bridgePossible = 0; 2681 2682 msg_data[0] = IPMI_LAN_CHANNEL_E | 0x80; // Ask for IPMI v2 data as well |
2683 msg_data[1] = intf->session->privlvl; | 2683 msg_data[1] = intf->ssn_params.privlvl; |
2684 2685 memset(&req, 0, sizeof(req)); 2686 req.msg.netfn = IPMI_NETFN_APP; // 0x06 2687 req.msg.cmd = IPMI_GET_CHANNEL_AUTH_CAP; // 0x38 2688 req.msg.data = msg_data; 2689 req.msg.data_len = 2; 2690 2691 rsp = intf->sendrecv(intf, &req); --- 34 unchanged lines hidden (view full) --- 2726ipmi_close_session_cmd(struct ipmi_intf * intf) 2727{ 2728 struct ipmi_rs * rsp; 2729 struct ipmi_rq req; 2730 uint8_t msg_data[4]; 2731 uint32_t bmc_session_lsbf; 2732 uint8_t backupBridgePossible; 2733 | 2684 2685 memset(&req, 0, sizeof(req)); 2686 req.msg.netfn = IPMI_NETFN_APP; // 0x06 2687 req.msg.cmd = IPMI_GET_CHANNEL_AUTH_CAP; // 0x38 2688 req.msg.data = msg_data; 2689 req.msg.data_len = 2; 2690 2691 rsp = intf->sendrecv(intf, &req); --- 34 unchanged lines hidden (view full) --- 2726ipmi_close_session_cmd(struct ipmi_intf * intf) 2727{ 2728 struct ipmi_rs * rsp; 2729 struct ipmi_rq req; 2730 uint8_t msg_data[4]; 2731 uint32_t bmc_session_lsbf; 2732 uint8_t backupBridgePossible; 2733 |
2734 if (intf->session->v2_data.session_state != LANPLUS_STATE_ACTIVE) | 2734 if (intf->session == NULL 2735 || intf->session->v2_data.session_state != LANPLUS_STATE_ACTIVE) |
2735 return -1; 2736 2737 backupBridgePossible = bridgePossible; 2738 2739 intf->target_addr = IPMI_BMC_SLAVE_ADDR; 2740 bridgePossible = 0; 2741 2742 bmc_session_lsbf = intf->session->v2_data.bmc_id; --- 64 unchanged lines hidden (view full) --- 2807 if (msg == NULL) { 2808 lprintf(LOG_ERR, "ipmitool: malloc failure"); 2809 return 1; 2810 } 2811 2812 memset(msg, 0, IPMI_OPEN_SESSION_REQUEST_SIZE); 2813 2814 msg[0] = 0; /* Message tag */ | 2736 return -1; 2737 2738 backupBridgePossible = bridgePossible; 2739 2740 intf->target_addr = IPMI_BMC_SLAVE_ADDR; 2741 bridgePossible = 0; 2742 2743 bmc_session_lsbf = intf->session->v2_data.bmc_id; --- 64 unchanged lines hidden (view full) --- 2808 if (msg == NULL) { 2809 lprintf(LOG_ERR, "ipmitool: malloc failure"); 2810 return 1; 2811 } 2812 2813 memset(msg, 0, IPMI_OPEN_SESSION_REQUEST_SIZE); 2814 2815 msg[0] = 0; /* Message tag */ |
2815 if (ipmi_oem_active(intf, "intelplus") || session->privlvl != IPMI_SESSION_PRIV_ADMIN) 2816 msg[1] = session->privlvl; | 2816 if (ipmi_oem_active(intf, "intelplus") || intf->ssn_params.privlvl != IPMI_SESSION_PRIV_ADMIN) 2817 msg[1] = intf->ssn_params.privlvl; |
2817 else 2818 msg[1] = 0; /* Give us highest privlg level based on supported algorithms */ 2819 msg[2] = 0; /* reserved */ 2820 msg[3] = 0; /* reserved */ 2821 2822 /* Choose our session ID for easy recognition in the packet dump */ 2823 session->v2_data.console_id = 0xA0A2A3A4; 2824 msg[4] = session->v2_data.console_id & 0xff; 2825 msg[5] = (session->v2_data.console_id >> 8) & 0xff; 2826 msg[6] = (session->v2_data.console_id >> 16) & 0xff; 2827 msg[7] = (session->v2_data.console_id >> 24) & 0xff; 2828 2829 | 2818 else 2819 msg[1] = 0; /* Give us highest privlg level based on supported algorithms */ 2820 msg[2] = 0; /* reserved */ 2821 msg[3] = 0; /* reserved */ 2822 2823 /* Choose our session ID for easy recognition in the packet dump */ 2824 session->v2_data.console_id = 0xA0A2A3A4; 2825 msg[4] = session->v2_data.console_id & 0xff; 2826 msg[5] = (session->v2_data.console_id >> 8) & 0xff; 2827 msg[6] = (session->v2_data.console_id >> 16) & 0xff; 2828 msg[7] = (session->v2_data.console_id >> 24) & 0xff; 2829 2830 |
2830 if (lanplus_get_requested_ciphers(session->cipher_suite_id, | 2831 if (lanplus_get_requested_ciphers(intf->ssn_params.cipher_suite_id, |
2831 &(session->v2_data.requested_auth_alg), 2832 &(session->v2_data.requested_integrity_alg), 2833 &(session->v2_data.requested_crypt_alg))) 2834 { 2835 lprintf(LOG_WARNING, "Unsupported cipher suite ID : %d\n", | 2832 &(session->v2_data.requested_auth_alg), 2833 &(session->v2_data.requested_integrity_alg), 2834 &(session->v2_data.requested_crypt_alg))) 2835 { 2836 lprintf(LOG_WARNING, "Unsupported cipher suite ID : %d\n", |
2836 session->cipher_suite_id); | 2837 intf->ssn_params.cipher_suite_id); |
2837 free(msg); 2838 msg = NULL; 2839 return 1; 2840 } 2841 2842 2843 /* 2844 * Authentication payload --- 183 unchanged lines hidden (view full) --- 3028 if (verbose > 1) 3029 printbuf(session->v2_data.console_rand, 16, 3030 ">> Console generated random number"); 3031 3032 3033 /* 3034 * Requested maximum privilege level. 3035 */ | 2838 free(msg); 2839 msg = NULL; 2840 return 1; 2841 } 2842 2843 2844 /* 2845 * Authentication payload --- 183 unchanged lines hidden (view full) --- 3029 if (verbose > 1) 3030 printbuf(session->v2_data.console_rand, 16, 3031 ">> Console generated random number"); 3032 3033 3034 /* 3035 * Requested maximum privilege level. 3036 */ |
3036 msg[24] = session->privlvl | session->v2_data.lookupbit; | 3037 msg[24] = intf->ssn_params.privlvl | intf->ssn_params.lookupbit; |
3037 session->v2_data.requested_role = msg[24]; 3038 msg[25] = 0; /* reserved */ 3039 msg[26] = 0; /* reserved */ 3040 3041 3042 /* Username specification */ | 3038 session->v2_data.requested_role = msg[24]; 3039 msg[25] = 0; /* reserved */ 3040 msg[26] = 0; /* reserved */ 3041 3042 3043 /* Username specification */ |
3043 msg[27] = strlen((const char *)session->username); | 3044 msg[27] = strlen((const char *)intf->ssn_params.username); |
3044 if (msg[27] > IPMI_MAX_USER_NAME_LENGTH) 3045 { 3046 lprintf(LOG_ERR, "ERROR: user name too long. " 3047 "(Exceeds %d characters)", 3048 IPMI_MAX_USER_NAME_LENGTH); 3049 free(msg); 3050 msg = NULL; 3051 return 1; 3052 } | 3045 if (msg[27] > IPMI_MAX_USER_NAME_LENGTH) 3046 { 3047 lprintf(LOG_ERR, "ERROR: user name too long. " 3048 "(Exceeds %d characters)", 3049 IPMI_MAX_USER_NAME_LENGTH); 3050 free(msg); 3051 msg = NULL; 3052 return 1; 3053 } |
3053 memcpy(msg + 28, session->username, msg[27]); | 3054 memcpy(msg + 28, intf->ssn_params.username, msg[27]); |
3054 3055 v2_payload.payload_type = IPMI_PAYLOAD_TYPE_RAKP_1; 3056 if (ipmi_oem_active(intf, "i82571spt")) { 3057 /* 3058 * The IPMI v2.0 spec hints on that all user name bytes 3059 * must be occupied (29:44). The Intel 82571 GbE refuses 3060 * to establish a session if this field is shorter. 3061 */ --- 229 unchanged lines hidden (view full) --- 3291 3292 3293/** 3294 * ipmi_lan_close 3295 */ 3296void 3297ipmi_lanplus_close(struct ipmi_intf * intf) 3298{ | 3055 3056 v2_payload.payload_type = IPMI_PAYLOAD_TYPE_RAKP_1; 3057 if (ipmi_oem_active(intf, "i82571spt")) { 3058 /* 3059 * The IPMI v2.0 spec hints on that all user name bytes 3060 * must be occupied (29:44). The Intel 82571 GbE refuses 3061 * to establish a session if this field is shorter. 3062 */ --- 229 unchanged lines hidden (view full) --- 3292 3293 3294/** 3295 * ipmi_lan_close 3296 */ 3297void 3298ipmi_lanplus_close(struct ipmi_intf * intf) 3299{ |
3299 if (!intf->abort) | 3300 if (!intf->abort && intf->session) |
3300 ipmi_close_session_cmd(intf); 3301 | 3301 ipmi_close_session_cmd(intf); 3302 |
3302 if (intf->fd >= 0) | 3303 if (intf->fd >= 0) { |
3303 close(intf->fd); | 3304 close(intf->fd); |
3305 intf->fd = -1; 3306 } |
|
3304 3305 ipmi_req_clear_entries(); 3306 ipmi_intf_session_cleanup(intf); | 3307 3308 ipmi_req_clear_entries(); 3309 ipmi_intf_session_cleanup(intf); |
3307 intf->session = NULL; | |
3308 intf->opened = 0; 3309 intf->manufacturer_id = IPMI_OEM_UNKNOWN; 3310 intf = NULL; 3311} 3312 3313 3314 3315static int 3316ipmi_set_session_privlvl_cmd(struct ipmi_intf * intf) 3317{ 3318 struct ipmi_rs * rsp; 3319 struct ipmi_rq req; 3320 uint8_t backupBridgePossible; | 3310 intf->opened = 0; 3311 intf->manufacturer_id = IPMI_OEM_UNKNOWN; 3312 intf = NULL; 3313} 3314 3315 3316 3317static int 3318ipmi_set_session_privlvl_cmd(struct ipmi_intf * intf) 3319{ 3320 struct ipmi_rs * rsp; 3321 struct ipmi_rq req; 3322 uint8_t backupBridgePossible; |
3321 uint8_t privlvl = intf->session->privlvl; | 3323 uint8_t privlvl = intf->ssn_params.privlvl; |
3322 3323 if (privlvl <= IPMI_SESSION_PRIV_USER) 3324 return 0; /* no need to set higher */ 3325 3326 backupBridgePossible = bridgePossible; 3327 3328 bridgePossible = 0; 3329 --- 33 unchanged lines hidden (view full) --- 3363 * ipmi_lanplus_open 3364 */ 3365int 3366ipmi_lanplus_open(struct ipmi_intf * intf) 3367{ 3368 int rc; 3369 int retry; 3370 struct get_channel_auth_cap_rsp auth_cap; | 3324 3325 if (privlvl <= IPMI_SESSION_PRIV_USER) 3326 return 0; /* no need to set higher */ 3327 3328 backupBridgePossible = bridgePossible; 3329 3330 bridgePossible = 0; 3331 --- 33 unchanged lines hidden (view full) --- 3365 * ipmi_lanplus_open 3366 */ 3367int 3368ipmi_lanplus_open(struct ipmi_intf * intf) 3369{ 3370 int rc; 3371 int retry; 3372 struct get_channel_auth_cap_rsp auth_cap; |
3373 struct ipmi_session_params *params; |
|
3371 struct ipmi_session *session; 3372 | 3374 struct ipmi_session *session; 3375 |
3373 if (!intf || !intf->session) | 3376 if (!intf) |
3374 return -1; | 3377 return -1; |
3375 session = intf->session; | |
3376 | 3378 |
3377 if (!session->port) 3378 session->port = IPMI_LANPLUS_PORT; 3379 if (!session->privlvl) 3380 session->privlvl = IPMI_SESSION_PRIV_ADMIN; 3381 if (!session->timeout) 3382 session->timeout = IPMI_LAN_TIMEOUT; 3383 if (!session->retry) 3384 session->retry = IPMI_LAN_RETRY; | 3379 if (intf->opened) 3380 return intf->fd; |
3385 | 3381 |
3386 if (session->hostname == NULL || strlen((const char *)session->hostname) == 0) { | 3382 params = &intf->ssn_params; 3383 3384 if (!params->port) 3385 params->port = IPMI_LANPLUS_PORT; 3386 if (!params->privlvl) 3387 params->privlvl = IPMI_SESSION_PRIV_ADMIN; 3388 if (!params->timeout) 3389 params->timeout = IPMI_LAN_TIMEOUT; 3390 if (!params->retry) 3391 params->retry = IPMI_LAN_RETRY; 3392 3393 if (params->hostname == NULL || strlen((const char *)params->hostname) == 0) { |
3387 lprintf(LOG_ERR, "No hostname specified!"); 3388 return -1; 3389 } 3390 | 3394 lprintf(LOG_ERR, "No hostname specified!"); 3395 return -1; 3396 } 3397 |
3391 intf->abort = 1; | 3398 if (ipmi_intf_socket_connect(intf) == -1) { 3399 lprintf(LOG_ERR, "Could not open socket!"); 3400 goto fail; 3401 } |
3392 | 3402 |
3403 session = (struct ipmi_session *)malloc(sizeof (struct ipmi_session)); 3404 if (!session) { 3405 lprintf(LOG_ERR, "ipmitool: malloc failure"); 3406 goto fail; 3407 } |
|
3393 | 3408 |
3409 intf->session = session; 3410 |
|
3394 /* Setup our lanplus session state */ | 3411 /* Setup our lanplus session state */ |
3412 memset(session, 0, sizeof(struct ipmi_session)); 3413 session->timeout = params->timeout; 3414 memcpy(&session->authcode, ¶ms->authcode_set, sizeof(session->authcode)); |
|
3395 session->v2_data.auth_alg = IPMI_AUTH_RAKP_NONE; 3396 session->v2_data.crypt_alg = IPMI_CRYPT_NONE; | 3415 session->v2_data.auth_alg = IPMI_AUTH_RAKP_NONE; 3416 session->v2_data.crypt_alg = IPMI_CRYPT_NONE; |
3397 session->v2_data.console_id = 0x00; 3398 session->v2_data.bmc_id = 0x00; | |
3399 session->sol_data.sequence_number = 1; | 3417 session->sol_data.sequence_number = 1; |
3400 //session->sol_data.last_received_sequence_number = 0; 3401 //session->sol_data.last_received_byte_count = 0; 3402 memset(session->v2_data.sik, 0, IPMI_SIK_BUFFER_SIZE); | |
3403 | 3418 |
3404 /* Kg is set in ipmi_intf */ 3405 //memset(session->v2_data.kg, 0, IPMI_KG_BUFFER_SIZE); 3406 3407 if (ipmi_intf_socket_connect (intf) == -1) { 3408 lprintf(LOG_ERR, "Could not open socket!"); 3409 return -1; 3410 } 3411 3412 if (intf->fd < 0) { 3413 lperror(LOG_ERR, "Connect to %s failed", 3414 session->hostname); 3415 intf->close(intf); 3416 return -1; 3417 } 3418 | |
3419 intf->opened = 1; | 3419 intf->opened = 1; |
3420 intf->abort = 1; |
|
3420 3421 /* 3422 * 3423 * Make sure the BMC supports IPMI v2 / RMCP+ 3424 */ 3425 if (!ipmi_oem_active(intf, "i82571spt") && 3426 ipmi_get_auth_capabilities_cmd(intf, &auth_cap)) { 3427 lprintf(LOG_INFO, "Error issuing Get Channel " --- 12 unchanged lines hidden (view full) --- 3440 * as the session state is advancing. 3441 */ 3442 for (retry = 0; retry < IPMI_LAN_RETRY; retry++) { 3443 session->v2_data.session_state = LANPLUS_STATE_PRESESSION; 3444 /* 3445 * Open session 3446 */ 3447 if ((rc = ipmi_lanplus_open_session(intf)) == 1) { | 3421 3422 /* 3423 * 3424 * Make sure the BMC supports IPMI v2 / RMCP+ 3425 */ 3426 if (!ipmi_oem_active(intf, "i82571spt") && 3427 ipmi_get_auth_capabilities_cmd(intf, &auth_cap)) { 3428 lprintf(LOG_INFO, "Error issuing Get Channel " --- 12 unchanged lines hidden (view full) --- 3441 * as the session state is advancing. 3442 */ 3443 for (retry = 0; retry < IPMI_LAN_RETRY; retry++) { 3444 session->v2_data.session_state = LANPLUS_STATE_PRESESSION; 3445 /* 3446 * Open session 3447 */ 3448 if ((rc = ipmi_lanplus_open_session(intf)) == 1) { |
3448 intf->close(intf); | |
3449 goto fail; 3450 } 3451 if (rc == 2) { 3452 lprintf(LOG_DEBUG, "Retry lanplus open session, %d", retry); 3453 continue; 3454 } 3455 /* 3456 * RAKP 1 3457 */ 3458 if ((rc = ipmi_lanplus_rakp1(intf)) == 1) { | 3449 goto fail; 3450 } 3451 if (rc == 2) { 3452 lprintf(LOG_DEBUG, "Retry lanplus open session, %d", retry); 3453 continue; 3454 } 3455 /* 3456 * RAKP 1 3457 */ 3458 if ((rc = ipmi_lanplus_rakp1(intf)) == 1) { |
3459 intf->close(intf); | |
3460 goto fail; 3461 } 3462 if (rc == 2) { 3463 lprintf(LOG_DEBUG, "Retry lanplus rakp1, %d", retry); 3464 continue; 3465 } 3466 /* 3467 * RAKP 3 3468 */ 3469 if ((rc = ipmi_lanplus_rakp3(intf)) == 1) { | 3459 goto fail; 3460 } 3461 if (rc == 2) { 3462 lprintf(LOG_DEBUG, "Retry lanplus rakp1, %d", retry); 3463 continue; 3464 } 3465 /* 3466 * RAKP 3 3467 */ 3468 if ((rc = ipmi_lanplus_rakp3(intf)) == 1) { |
3470 intf->close(intf); | |
3471 goto fail; 3472 } 3473 if (rc == 0) break; 3474 lprintf(LOG_DEBUG,"Retry lanplus rakp3, %d", retry); 3475 } 3476 3477 lprintf(LOG_DEBUG, "IPMIv2 / RMCP+ SESSION OPENED SUCCESSFULLY\n"); 3478 | 3469 goto fail; 3470 } 3471 if (rc == 0) break; 3472 lprintf(LOG_DEBUG,"Retry lanplus rakp3, %d", retry); 3473 } 3474 3475 lprintf(LOG_DEBUG, "IPMIv2 / RMCP+ SESSION OPENED SUCCESSFULLY\n"); 3476 |
3477 intf->abort = 0; 3478 |
|
3479 if (!ipmi_oem_active(intf, "i82571spt")) { 3480 rc = ipmi_set_session_privlvl_cmd(intf); 3481 if (rc < 0) { | 3479 if (!ipmi_oem_active(intf, "i82571spt")) { 3480 rc = ipmi_set_session_privlvl_cmd(intf); 3481 if (rc < 0) { |
3482 intf->close(intf); | |
3483 goto fail; 3484 } 3485 } 3486 intf->manufacturer_id = ipmi_get_oem(intf); | 3482 goto fail; 3483 } 3484 } 3485 intf->manufacturer_id = ipmi_get_oem(intf); |
3487 bridgePossible = 1; | |
3488 3489 /* automatically detect interface request and response sizes */ 3490 hpm2_detect_max_payload_size(intf); 3491 | 3486 3487 /* automatically detect interface request and response sizes */ 3488 hpm2_detect_max_payload_size(intf); 3489 |
3490 bridgePossible = 1; |
|
3492 return intf->fd; 3493 3494 fail: 3495 lprintf(LOG_ERR, "Error: Unable to establish IPMI v2 / RMCP+ session"); | 3491 return intf->fd; 3492 3493 fail: 3494 lprintf(LOG_ERR, "Error: Unable to establish IPMI v2 / RMCP+ session"); |
3496 intf->opened = 0; | 3495 intf->close(intf); |
3497 return -1; 3498} 3499 3500 3501 3502void test_crypt1(void) 3503{ 3504 uint8_t key[] = --- 126 unchanged lines hidden (view full) --- 3631static int ipmi_lanplus_setup(struct ipmi_intf * intf) 3632{ 3633 //test_crypt1(); 3634 assert("ipmi_lanplus_setup"); 3635 3636 if (lanplus_seed_prng(16)) 3637 return -1; 3638 | 3496 return -1; 3497} 3498 3499 3500 3501void test_crypt1(void) 3502{ 3503 uint8_t key[] = --- 126 unchanged lines hidden (view full) --- 3630static int ipmi_lanplus_setup(struct ipmi_intf * intf) 3631{ 3632 //test_crypt1(); 3633 assert("ipmi_lanplus_setup"); 3634 3635 if (lanplus_seed_prng(16)) 3636 return -1; 3637 |
3639 intf->session = malloc(sizeof(struct ipmi_session)); 3640 if (intf->session == NULL) { 3641 lprintf(LOG_ERR, "ipmitool: malloc failure"); 3642 return -1; 3643 } 3644 memset(intf->session, 0, sizeof(struct ipmi_session)); 3645 | |
3646 /* setup default LAN maximum request and response sizes */ 3647 intf->max_request_data_size = IPMI_LAN_MAX_REQUEST_SIZE; 3648 intf->max_response_data_size = IPMI_LAN_MAX_RESPONSE_SIZE; 3649 3650 return 0; 3651} 3652 3653static void ipmi_lanp_set_max_rq_data_size(struct ipmi_intf * intf, uint16_t size) 3654{ | 3638 /* setup default LAN maximum request and response sizes */ 3639 intf->max_request_data_size = IPMI_LAN_MAX_REQUEST_SIZE; 3640 intf->max_response_data_size = IPMI_LAN_MAX_RESPONSE_SIZE; 3641 3642 return 0; 3643} 3644 3645static void ipmi_lanp_set_max_rq_data_size(struct ipmi_intf * intf, uint16_t size) 3646{ |
3655 if (intf->session->cipher_suite_id == 3) { | 3647 if (intf->ssn_params.cipher_suite_id == 3) { |
3656 /* 3657 * encrypted payload can only be multiple of 16 bytes 3658 */ 3659 size &= ~15; 3660 3661 /* 3662 * decrement payload size on confidentiality header size 3663 * plus minimal confidentiality trailer size 3664 */ 3665 size -= (16 + 1); 3666 } 3667 3668 intf->max_request_data_size = size; 3669} 3670 3671static void ipmi_lanp_set_max_rp_data_size(struct ipmi_intf * intf, uint16_t size) 3672{ | 3648 /* 3649 * encrypted payload can only be multiple of 16 bytes 3650 */ 3651 size &= ~15; 3652 3653 /* 3654 * decrement payload size on confidentiality header size 3655 * plus minimal confidentiality trailer size 3656 */ 3657 size -= (16 + 1); 3658 } 3659 3660 intf->max_request_data_size = size; 3661} 3662 3663static void ipmi_lanp_set_max_rp_data_size(struct ipmi_intf * intf, uint16_t size) 3664{ |
3673 if (intf->session->cipher_suite_id == 3) { | 3665 if (intf->ssn_params.cipher_suite_id == 3) { |
3674 /* 3675 * encrypted payload can only be multiple of 16 bytes 3676 */ 3677 size &= ~15; 3678 3679 /* 3680 * decrement payload size on confidentiality header size 3681 * plus minimal confidentiality trailer size 3682 */ 3683 size -= (16 + 1); 3684 } 3685 3686 intf->max_response_data_size = size; 3687} | 3666 /* 3667 * encrypted payload can only be multiple of 16 bytes 3668 */ 3669 size &= ~15; 3670 3671 /* 3672 * decrement payload size on confidentiality header size 3673 * plus minimal confidentiality trailer size 3674 */ 3675 size -= (16 + 1); 3676 } 3677 3678 intf->max_response_data_size = size; 3679} |