mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 19:17:22 +00:00
initial checkin
This commit is contained in:
parent
31b25430c1
commit
39167b6ae8
55
ipmitool/include/ipmitool/ipmi_constants.h
Normal file
55
ipmitool/include/ipmitool/ipmi_constants.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPMI_CONSTANTS_H
|
||||||
|
#define IPMI_CONSTANTS_H
|
||||||
|
|
||||||
|
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_NONE 0x0
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_MD2 0x1
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_MD5 0x2
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_KEY 0x4
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_OEM 0x5
|
||||||
|
#define IPMI_SESSION_AUTHTYPE_RMCP_PLUS 0x6
|
||||||
|
|
||||||
|
#define IPMI_SESSION_PRIV_CALLBACK 0x1
|
||||||
|
#define IPMI_SESSION_PRIV_USER 0x2
|
||||||
|
#define IPMI_SESSION_PRIV_OPERATOR 0x3
|
||||||
|
#define IPMI_SESSION_PRIV_ADMIN 0x4
|
||||||
|
#define IPMI_SESSION_PRIV_OEM 0x5
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*IPMI_CONSTANTS_H*/
|
129
ipmitool/include/ipmitool/ipmi_session.h
Normal file
129
ipmitool/include/ipmitool/ipmi_session.h
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPMI_SESSION_H
|
||||||
|
#define IPMI_SESSION_H
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
#include <ipmitool/ipmi.h>
|
||||||
|
|
||||||
|
#define IPMI_GET_SESSION_INFO 0x3D
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From table 22.25 of the IPMIv2 specification
|
||||||
|
*/
|
||||||
|
struct get_session_info_rsp
|
||||||
|
{
|
||||||
|
unsigned char session_handle;
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char __reserved1 : 2;
|
||||||
|
unsigned char session_slot_count : 6; /* 1-based */
|
||||||
|
#else
|
||||||
|
unsigned char session_slot_count : 6; /* 1-based */
|
||||||
|
unsigned char __reserved1 : 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char __reserved2 : 2;
|
||||||
|
unsigned char active_session_count : 6; /* 1-based */
|
||||||
|
#else
|
||||||
|
unsigned char active_session_count : 6; /* 1-based */
|
||||||
|
unsigned char __reserved2 : 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char __reserved3 : 2;
|
||||||
|
unsigned char user_id : 6;
|
||||||
|
#else
|
||||||
|
unsigned char user_id : 6;
|
||||||
|
unsigned char __reserved3 : 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char __reserved4 : 4;
|
||||||
|
unsigned char privilege_level : 4;
|
||||||
|
#else
|
||||||
|
unsigned char privilege_level : 4;
|
||||||
|
unsigned char __reserved4 : 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char auxiliary_data : 4;
|
||||||
|
unsigned char channel_number : 4;
|
||||||
|
#else
|
||||||
|
unsigned char channel_number : 4;
|
||||||
|
unsigned char auxiliary_data : 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/* Only exists if channel type is 802.3 LAN */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char console_ip[4]; /* MSBF */
|
||||||
|
unsigned char console_mac[6]; /* MSBF */
|
||||||
|
uint16_t console_port; /* LSBF */
|
||||||
|
} lan_data;
|
||||||
|
|
||||||
|
/* Only exists if channel type is async. serial modem */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned char session_channel_activity_type;
|
||||||
|
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
unsigned char __reserved5 : 4;
|
||||||
|
unsigned char destination_selector : 4;
|
||||||
|
#else
|
||||||
|
unsigned char destination_selector : 4;
|
||||||
|
unsigned char __reserved5 : 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned char console_ip[4]; /* MSBF */
|
||||||
|
|
||||||
|
/* Only exists if session is PPP */
|
||||||
|
uint16_t console_port; /* LSBF */
|
||||||
|
} modem_data;
|
||||||
|
} channel_data;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int ipmi_session_main(struct ipmi_intf *, int, char **);
|
||||||
|
|
||||||
|
#endif /*IPMI_CHANNEL_H*/
|
46
ipmitool/include/ipmitool/ipmi_strings.h
Normal file
46
ipmitool/include/ipmitool/ipmi_strings.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPMI_STRINGS_H
|
||||||
|
#define IPMI_STRINGS_H
|
||||||
|
|
||||||
|
#include <ipmitool/helper.h>
|
||||||
|
|
||||||
|
extern const struct valstr ipmi_channel_activity_type_vals[];
|
||||||
|
extern const struct valstr ipmi_privlvl_vals[];
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*IPMI_STRINGS_H*/
|
425
ipmitool/lib/ipmi_session.c
Normal file
425
ipmitool/lib/ipmi_session.c
Normal file
@ -0,0 +1,425 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <ipmitool/ipmi.h>
|
||||||
|
#include <ipmitool/ipmi_intf.h>
|
||||||
|
#include <ipmitool/helper.h>
|
||||||
|
#include <ipmitool/ipmi_lanp.h>
|
||||||
|
#include <ipmitool/ipmi_session.h>
|
||||||
|
#include <ipmitool/ipmi_strings.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IPMI_SESSION_REQUEST_CURRENT = 0,
|
||||||
|
IPMI_SESSION_REQUEST_ALL,
|
||||||
|
IPMI_SESSION_REQUEST_BY_ID,
|
||||||
|
IPMI_SESSION_REQUEST_BY_HANDLE
|
||||||
|
} Ipmi_Session_Request_Type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print_session_info_csv
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_session_info_csv(const struct get_session_info_rsp * session_info,
|
||||||
|
int data_len)
|
||||||
|
{
|
||||||
|
char buffer[18];
|
||||||
|
uint16_t console_port_tmp;
|
||||||
|
|
||||||
|
printf("%d", session_info->session_handle);
|
||||||
|
printf(",%d", session_info->session_slot_count);
|
||||||
|
printf(",%d", session_info->active_session_count);
|
||||||
|
|
||||||
|
if (data_len == 3)
|
||||||
|
{
|
||||||
|
/* There is no session data here*/
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(",%d", session_info->user_id);
|
||||||
|
printf(",%s", val2str(session_info->privilege_level, ipmi_privlvl_vals));
|
||||||
|
|
||||||
|
printf(",%s", session_info->auxiliary_data?
|
||||||
|
"IPMIv2/RMCP+" : "IPMIv1.5");
|
||||||
|
|
||||||
|
printf(",0x%02x", session_info->channel_number);
|
||||||
|
|
||||||
|
if (data_len == 18)
|
||||||
|
{
|
||||||
|
/* We have 802.3 LAN data */
|
||||||
|
printf(",%s",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&(session_info->channel_data.lan_data.console_ip),
|
||||||
|
buffer,
|
||||||
|
16));
|
||||||
|
|
||||||
|
printf(",%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
|
session_info->channel_data.lan_data.console_mac[0],
|
||||||
|
session_info->channel_data.lan_data.console_mac[1],
|
||||||
|
session_info->channel_data.lan_data.console_mac[2],
|
||||||
|
session_info->channel_data.lan_data.console_mac[3],
|
||||||
|
session_info->channel_data.lan_data.console_mac[4],
|
||||||
|
session_info->channel_data.lan_data.console_mac[5]);
|
||||||
|
|
||||||
|
console_port_tmp = session_info->channel_data.lan_data.console_port;
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
console_port_tmp = BSWAP_16(console_port_tmp);
|
||||||
|
#endif
|
||||||
|
printf(",%d", console_port_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if ((data_len == 12) || (data_len == 14))
|
||||||
|
{
|
||||||
|
/* Channel async serial/modem */
|
||||||
|
printf(",%s",
|
||||||
|
val2str(session_info->channel_data.modem_data.session_channel_activity_type,
|
||||||
|
ipmi_channel_activity_type_vals));
|
||||||
|
|
||||||
|
printf(",%d",
|
||||||
|
session_info->channel_data.modem_data.destination_selector);
|
||||||
|
|
||||||
|
printf(",%s",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&(session_info->channel_data.modem_data.console_ip),
|
||||||
|
buffer,
|
||||||
|
16));
|
||||||
|
|
||||||
|
if (data_len == 14)
|
||||||
|
{
|
||||||
|
/* Connection is PPP */
|
||||||
|
console_port_tmp = session_info->channel_data.lan_data.console_port;
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
console_port_tmp = BSWAP_16(console_port_tmp);
|
||||||
|
#endif
|
||||||
|
printf(",%d", console_port_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print_session_info_verbose
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_session_info_verbose(const struct get_session_info_rsp * session_info,
|
||||||
|
int data_len)
|
||||||
|
{
|
||||||
|
char buffer[18];
|
||||||
|
uint16_t console_port_tmp;
|
||||||
|
|
||||||
|
printf("session handle : %d\n", session_info->session_handle);
|
||||||
|
printf("slot count : %d\n", session_info->session_slot_count);
|
||||||
|
printf("active sessions : %d\n", session_info->active_session_count);
|
||||||
|
|
||||||
|
if (data_len == 3)
|
||||||
|
{
|
||||||
|
/* There is no session data here */
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("user id : %d\n", session_info->user_id);
|
||||||
|
printf("privilege level : %s\n",
|
||||||
|
val2str(session_info->privilege_level, ipmi_privlvl_vals));
|
||||||
|
|
||||||
|
printf("session type : %s\n", session_info->auxiliary_data?
|
||||||
|
"IPMIv2/RMCP+" : "IPMIv1.5");
|
||||||
|
|
||||||
|
printf("channel number : 0x%02x\n", session_info->channel_number);
|
||||||
|
|
||||||
|
|
||||||
|
if (data_len == 18)
|
||||||
|
{
|
||||||
|
/* We have 802.3 LAN data */
|
||||||
|
printf("console ip : %s\n",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&(session_info->channel_data.lan_data.console_ip),
|
||||||
|
buffer,
|
||||||
|
16));
|
||||||
|
|
||||||
|
printf("console mac : %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
session_info->channel_data.lan_data.console_mac[0],
|
||||||
|
session_info->channel_data.lan_data.console_mac[1],
|
||||||
|
session_info->channel_data.lan_data.console_mac[2],
|
||||||
|
session_info->channel_data.lan_data.console_mac[3],
|
||||||
|
session_info->channel_data.lan_data.console_mac[4],
|
||||||
|
session_info->channel_data.lan_data.console_mac[5]);
|
||||||
|
|
||||||
|
console_port_tmp = session_info->channel_data.lan_data.console_port;
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
console_port_tmp = BSWAP_16(console_port_tmp);
|
||||||
|
#endif
|
||||||
|
printf("console port : %d\n", console_port_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if ((data_len == 12) || (data_len == 14))
|
||||||
|
{
|
||||||
|
/* Channel async serial/modem */
|
||||||
|
printf("Session/Channel Activity Type : %s\n",
|
||||||
|
val2str(session_info->channel_data.modem_data.session_channel_activity_type,
|
||||||
|
ipmi_channel_activity_type_vals));
|
||||||
|
|
||||||
|
printf("Destination selector : %d\n",
|
||||||
|
session_info->channel_data.modem_data.destination_selector);
|
||||||
|
|
||||||
|
printf("console ip : %s\n",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&(session_info->channel_data.modem_data.console_ip),
|
||||||
|
buffer,
|
||||||
|
16));
|
||||||
|
|
||||||
|
if (data_len == 14)
|
||||||
|
{
|
||||||
|
/* Connection is PPP */
|
||||||
|
console_port_tmp = session_info->channel_data.lan_data.console_port;
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
console_port_tmp = BSWAP_16(console_port_tmp);
|
||||||
|
#endif
|
||||||
|
printf("console port : %d\n", console_port_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void print_session_info(const struct get_session_info_rsp * session_info,
|
||||||
|
int data_len)
|
||||||
|
{
|
||||||
|
if (csv_output)
|
||||||
|
print_session_info_csv(session_info, data_len);
|
||||||
|
else
|
||||||
|
print_session_info_verbose(session_info, data_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ipmi_get_session_info
|
||||||
|
*
|
||||||
|
* returns 0 on success
|
||||||
|
* -1 on error
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ipmi_get_session_info(struct ipmi_intf * intf,
|
||||||
|
Ipmi_Session_Request_Type session_request_type,
|
||||||
|
uint32_t id_or_handle)
|
||||||
|
{
|
||||||
|
int i, retval = 0;
|
||||||
|
|
||||||
|
struct ipmi_rs * rsp;
|
||||||
|
struct ipmi_rq req;
|
||||||
|
unsigned char rqdata[5]; // max length of the variable length request
|
||||||
|
struct get_session_info_rsp session_info;
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&session_info, 0, sizeof(session_info));
|
||||||
|
req.msg.netfn = IPMI_NETFN_APP; // 0x06
|
||||||
|
req.msg.cmd = IPMI_GET_SESSION_INFO; // 0x3D
|
||||||
|
req.msg.data = rqdata;
|
||||||
|
|
||||||
|
switch (session_request_type)
|
||||||
|
{
|
||||||
|
|
||||||
|
case IPMI_SESSION_REQUEST_CURRENT:
|
||||||
|
case IPMI_SESSION_REQUEST_BY_ID:
|
||||||
|
case IPMI_SESSION_REQUEST_BY_HANDLE:
|
||||||
|
switch (session_request_type)
|
||||||
|
{
|
||||||
|
case IPMI_SESSION_REQUEST_CURRENT:
|
||||||
|
rqdata[0] = 0x00;
|
||||||
|
req.msg.data_len = 1;
|
||||||
|
break;
|
||||||
|
case IPMI_SESSION_REQUEST_BY_ID:
|
||||||
|
rqdata[0] = 0xFF;
|
||||||
|
rqdata[1] = id_or_handle & 0x000000FF;
|
||||||
|
rqdata[2] = (id_or_handle >> 8) & 0x000000FF;
|
||||||
|
rqdata[3] = (id_or_handle >> 16) & 0x000000FF;
|
||||||
|
rqdata[4] = (id_or_handle >> 24) & 0x000000FF;
|
||||||
|
req.msg.data_len = 5;
|
||||||
|
break;
|
||||||
|
case IPMI_SESSION_REQUEST_BY_HANDLE:
|
||||||
|
rqdata[0] = 0xFE;
|
||||||
|
rqdata[1] = (unsigned char)id_or_handle;
|
||||||
|
req.msg.data_len = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rsp = intf->sendrecv(intf, &req);
|
||||||
|
if (!rsp || rsp->ccode) {
|
||||||
|
printf("Error:%x Get Session Info Command\n", rsp ? rsp->ccode : 0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&session_info, rsp->data, rsp->data_len);
|
||||||
|
print_session_info(&session_info, rsp->data_len);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IPMI_SESSION_REQUEST_ALL:
|
||||||
|
req.msg.data_len = 1;
|
||||||
|
i = 1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
rqdata[0] = i++;
|
||||||
|
rsp = intf->sendrecv(intf, &req);
|
||||||
|
|
||||||
|
if (!rsp || rsp->ccode || (rsp->data_len < 3))
|
||||||
|
{
|
||||||
|
printf("Error retrieving session info for session %d\n", i);
|
||||||
|
retval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&session_info, rsp->data, rsp->data_len);
|
||||||
|
print_session_info(&session_info, rsp->data_len);
|
||||||
|
|
||||||
|
} while (i <= session_info.session_slot_count);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
printf_session_usage()
|
||||||
|
{
|
||||||
|
printf("Session Commands: info <active | all | id 0xnnnnnnnn | handle 0xnn>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ipmi_session_main(struct ipmi_intf * intf, int argc, char ** argv)
|
||||||
|
{
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
if (!argc || !strncmp(argv[0], "help", 4))
|
||||||
|
{
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
else if (!strncmp(argv[0], "info", 4))
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((argc < 2) || !strncmp(argv[1], "help", 4))
|
||||||
|
{
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Ipmi_Session_Request_Type session_request_type;
|
||||||
|
uint32_t id_or_handle;
|
||||||
|
|
||||||
|
if (!strncmp(argv[1], "active", 6))
|
||||||
|
session_request_type = IPMI_SESSION_REQUEST_CURRENT;
|
||||||
|
else if (!strncmp(argv[1], "all", 3))
|
||||||
|
session_request_type = IPMI_SESSION_REQUEST_ALL;
|
||||||
|
|
||||||
|
else if (!strncmp(argv[1], "id", 2))
|
||||||
|
{
|
||||||
|
if (argc >= 3)
|
||||||
|
{
|
||||||
|
session_request_type = IPMI_SESSION_REQUEST_BY_ID;
|
||||||
|
id_or_handle = strtol(argv[2], NULL, 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Missing id argument\n");
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strncmp(argv[1], "handle", 6))
|
||||||
|
{
|
||||||
|
if (argc >= 3)
|
||||||
|
{
|
||||||
|
session_request_type = IPMI_SESSION_REQUEST_BY_HANDLE;
|
||||||
|
id_or_handle = strtol(argv[2], NULL, 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Missing handle argument\n");
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Invalid SESSION info parameter: %s\n", argv[1]);
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (! retval)
|
||||||
|
retval = ipmi_get_session_info(intf,
|
||||||
|
session_request_type,
|
||||||
|
id_or_handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Invalid SESSION command: %s\n", argv[0]);
|
||||||
|
printf_session_usage();
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
60
ipmitool/lib/ipmi_strings.c
Normal file
60
ipmitool/lib/ipmi_strings.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
||||||
|
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <ipmitool/ipmi_strings.h>
|
||||||
|
#include <ipmitool/ipmi_constants.h>
|
||||||
|
|
||||||
|
|
||||||
|
const struct valstr ipmi_channel_activity_type_vals[] = {
|
||||||
|
{ 0, "IPMI Messaging session active" },
|
||||||
|
{ 1, "Callback Messaging session active" },
|
||||||
|
{ 2, "Dial-out Alert active" },
|
||||||
|
{ 3, "TAP Page Active" },
|
||||||
|
{ 0x00, NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const struct valstr ipmi_privlvl_vals[] = {
|
||||||
|
{ IPMI_SESSION_PRIV_CALLBACK, "CALLBACK" },
|
||||||
|
{ IPMI_SESSION_PRIV_USER, "USER" },
|
||||||
|
{ IPMI_SESSION_PRIV_OPERATOR, "OPERATOR" },
|
||||||
|
{ IPMI_SESSION_PRIV_ADMIN, "ADMINISTRATOR" },
|
||||||
|
{ IPMI_SESSION_PRIV_OEM, "OEM" },
|
||||||
|
{ 0xF, "NO ACCESS" },
|
||||||
|
{ 0, NULL },
|
||||||
|
};
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user