ipmi_lancfg.c revision 81d9f076db88c1f40c85831ce1ebb444a209c5a8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Query and configure LAN interfaces over IPMI. This is done through the
* sets the parameters one per command in series. We hide this implementation
* detail and instead export a single structure to consumers.
*/
#include <stddef.h>
#include <strings.h>
#include <libipmi.h>
#include "ipmi_impl.h"
typedef struct ipmi_cmd_lan_get_config {
ilgc_number :4,
__reserved :3,
ilgc_revonly :1);
typedef struct ipmi_cmd_lan_set_config {
ilsc_number :4,
__reserved :4);
#define IPMI_LAN_SET_LEN(dlen) \
#define IPMI_LAN_PARAM_SET_IN_PROGRESS 0
#define IPMI_LAN_PARAM_IP_ADDR 3
#define IPMI_LAN_PARAM_IP_SOURCE 4
#define IPMI_LAN_PARAM_MAC_ADDR 5
#define IPMI_LAN_PARAM_SUBNET_MASK 6
#define IPMI_LAN_PARAM_GATEWAY_ADDR 12
#define IPMI_LAN_SET_COMPLETE 0x0
#define IPMI_LAN_SET_INPROGRESS 0x1
#define IPMI_LAN_SET_COMMIT 0x2
typedef struct ipmi_lan_entry {
int ile_param;
int ile_mask;
int ile_set;
int ile_block;
static ipmi_lan_entry_t ipmi_lan_table[] = {
{ IPMI_LAN_PARAM_IP_ADDR, IPMI_LAN_SET_IPADDR, 0, 0,
{ IPMI_LAN_PARAM_MAC_ADDR, IPMI_LAN_SET_MACADDR, 0, 0,
};
#define IPMI_LAN_NENTRIES \
(sizeof (ipmi_lan_table) / sizeof (ipmi_lan_table[0]))
static int
{
ipmi_cmd_lan_get_config_t lcmd = { 0 };
switch (ihp->ih_completion) {
case 0x80:
break;
}
return (-1);
}
return (0);
}
int
{
int i;
return (-1);
if (set & IPMI_LAN_SET_INPROGRESS)
else
for (i = 0; i < IPMI_LAN_NENTRIES; i++) {
lep = &ipmi_lan_table[i];
return (-1);
}
return (0);
}
static int
{
ipmi_cmd_lan_set_config_t lcmd = { 0 };
switch (ihp->ih_completion) {
case 0x80:
break;
case 0x81:
break;
case 0x82:
break;
case 0x83:
break;
}
return (-1);
}
return (0);
}
int
int mask)
{
int i;
/*
* Cancel any pending transaction, then open a new transaction.
*/
return (-1);
return (-1);
/*
* Iterate over all parameters and set them.
*/
for (i = 0; i < IPMI_LAN_NENTRIES; i++) {
lep = &ipmi_lan_table[i];
continue;
/*
* On some systems, setting the mode to DHCP may cause
* the command to timeout, presumably because it is
* waiting for the setting to take effect. If we see
* completion code 0xc3 (command timeout) while setting
* the DHCP value, just ignore it.
*/
if (mask != IPMI_LAN_SET_IPADDR_SOURCE ||
return (-1);
}
}
/*
* Commit the transaction.
*/
return (-1);
return (0);
}