From 56c495455cf1385640b872a9e7071efef8c41850 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Sun, 19 Mar 2006 18:37:16 +0000 Subject: [PATCH] Add support for setting VLAN id and priority --- ipmitool/ChangeLog | 1 + ipmitool/doc/ipmitool.1 | 14 +++++++ ipmitool/lib/ipmi_lanp.c | 88 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/ipmitool/ChangeLog b/ipmitool/ChangeLog index 64562da..72a57d7 100644 --- a/ipmitool/ChangeLog +++ b/ipmitool/ChangeLog @@ -8,6 +8,7 @@ version 1.8.7 * Disable file paranoia checks on read files by default * Support IPMIv2 SOL on older Intel boxes * Display message and exit if keepalive fails during SOL + * Add support for setting VLAN id and priority version 1.8.6 * Fix memory corruption when sending encrypted SOL traffic diff --git a/ipmitool/doc/ipmitool.1 b/ipmitool/doc/ipmitool.1 index 425dd0a..78e3a1f 100644 --- a/ipmitool/doc/ipmitool.1 +++ b/ipmitool/doc/ipmitool.1 @@ -750,6 +750,20 @@ Set BMC generated gratuitous ARPs. Set BMC generated gratuitous ARP interval. .TP +\fIvlan id\fP <\fBoff\fR|\fBid\fR> +.br + +Disable VLAN operation or enable VLAN and set the ID. +.br +ID: value of the virtual lan identifier between 1 and 4094 inclusive. +.TP +\fIvlan priority\fP <\fBpriority\fR> +.br + +Set the priority associated with VLAN frames. +.br +ID: priority of the virtual lan frames between 0 and 7 inclusive. +.TP \fIauth\fP <\fBlevel\fR,\fB...\fR> <\fBtype\fR,\fB...\fR> .br diff --git a/ipmitool/lib/ipmi_lanp.c b/ipmitool/lib/ipmi_lanp.c index 5acdeaf..8ef2696 100644 --- a/ipmitool/lib/ipmi_lanp.c +++ b/ipmitool/lib/ipmi_lanp.c @@ -733,6 +733,19 @@ ipmi_lan_print(struct ipmi_intf * intf, uint8_t chan) printf("%-24s: %02x:%02x:%02x:%02x:%02x:%02x\n", p->desc, p->data[0], p->data[1], p->data[2], p->data[3], p->data[4], p->data[5]); + p = get_lan_param(intf, chan, IPMI_LANP_VLAN_ID); + if (p != NULL && p->data != NULL) { + int id = ((p->data[1] & 0x0f) << 8) + p->data[0]; + if (p->data[1] & 0x80) + printf("%-24s: %d\n", p->desc, id); + else + printf("%-24s: Disabled\n", p->desc); + } + + p = get_lan_param(intf, chan, IPMI_LANP_VLAN_PRIORITY); + if (p != NULL && p->data != NULL) + printf("%-24s: %d\n", p->desc, p->data[0] & 0x07); + /* Determine supported Cipher Suites -- Requires two calls */ p = get_lan_param(intf, chan, IPMI_LANP_RMCP_CIPHER_SUPPORT); if (p == NULL) @@ -1205,9 +1218,11 @@ static void ipmi_lan_set_usage(void) lprintf(LOG_NOTICE, " user Enable default user for this channel"); lprintf(LOG_NOTICE, " access Enable or disable access to this channel"); lprintf(LOG_NOTICE, " alert Enable or disable PEF alerting for this channel"); - lprintf(LOG_NOTICE, " arp response Enable or disable BMC ARP responding"); + lprintf(LOG_NOTICE, " arp respond Enable or disable BMC ARP responding"); lprintf(LOG_NOTICE, " arp generate Enable or disable BMC gratuitous ARP generation"); lprintf(LOG_NOTICE, " arp interval Set gratuitous ARP generation interval"); + lprintf(LOG_NOTICE, " vlan id > Disable or enable VLAN and set ID (1-4094)"); + lprintf(LOG_NOTICE, " vlan priority Set vlan priority (0-7)"); lprintf(LOG_NOTICE, " auth Set channel authentication types"); lprintf(LOG_NOTICE, " level = CALLBACK, USER, OPERATOR, ADMIN"); lprintf(LOG_NOTICE, " type = NONE, MD2, MD5, PASSWORD, OEM"); @@ -1225,6 +1240,57 @@ static void ipmi_lan_set_usage(void) lprintf(LOG_NOTICE, " O = OEM\n"); } +static void +ipmi_lan_set_vlan_usage(void) +{ + lprintf(LOG_NOTICE, + "lan set vlan id \n" + "lan set vlan id off\n" + "lan set vlan priority \n"); +} + +static int +ipmi_lan_set_vlan_id(struct ipmi_intf * intf, uint8_t chan, char *string) +{ + uint8_t data[2]; + int rc; + + if (string == NULL) { + data[0] = 0; + data[1] = 0; + } + else { + int id = atoi(string); + + if (id < 1 || id > 4094) { + lprintf(LOG_NOTICE, "vlan id must be between 1 and 4094."); + return -1; + } + else { + data[0] = (uint8_t)id; + data[1] = (uint8_t)(id >> 8) | 0x80; + } + } + rc = set_lan_param(intf, chan, IPMI_LANP_VLAN_ID, data, 2); + return rc; +} + +static int +ipmi_lan_set_vlan_priority(struct ipmi_intf * intf, uint8_t chan, char *string) +{ + uint8_t data; + int rc; + int priority = atoi(string); + + if (priority < 0 || priority > 7) { + lprintf(LOG_NOTICE, "vlan priority must be between 0 and 7."); + return -1; + } + data = (uint8_t)priority; + rc = set_lan_param(intf, chan, IPMI_LANP_VLAN_PRIORITY, &data, 1); + return rc; +} + static int ipmi_lan_set(struct ipmi_intf * intf, int argc, char ** argv) { @@ -1333,6 +1399,7 @@ ipmi_lan_set(struct ipmi_intf * intf, int argc, char ** argv) " static = static address (manually configured)\n" " dhcp = address obtained by BMC running DHCP\n" " bios = address loaded by BIOS or system software\n"); + return 0; } else if (strncmp(argv[2], "none", 4) == 0) data[0] = 0; @@ -1433,6 +1500,25 @@ ipmi_lan_set(struct ipmi_intf * intf, int argc, char ** argv) rc = set_lan_param(intf, chan, IPMI_LANP_BAK_GATEWAY_MAC, data, 6); } } + else if (strncasecmp(argv[1], "vlan", 4) == 0) { + if (argc < 4 || strncmp(argv[2], "help", 4) == 0) { + ipmi_lan_set_vlan_usage(); + } + else if (strncasecmp(argv[2], "id", 2) == 0) { + if (strncasecmp(argv[3], "off", 3) == 0) { + ipmi_lan_set_vlan_id(intf, chan, NULL); + } + else { + ipmi_lan_set_vlan_id(intf, chan, argv[3]); + } + } + else if (strncasecmp(argv[2], "priority", 8) == 0) { + ipmi_lan_set_vlan_priority(intf, chan, argv[3]); + } + else { + ipmi_lan_set_vlan_usage(); + } + } /* set PEF alerting on or off */ else if (strncasecmp(argv[1], "alert", 5) == 0) { if (argc < 3) {