The activate payload takes and instance, and there may be times when the instance is not one. Is this patch acceptable for setting the instance for SOL sessions?

Thanks,

-corey
Index: doc/ipmitool.1
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/doc/ipmitool.1,v
retrieving revision 1.50
diff -u -r1.50 ipmitool.1
--- doc/ipmitool.1	5 Sep 2012 14:22:36 -0000	1.50
+++ doc/ipmitool.1	12 Sep 2012 19:06:48 -0000
@@ -2586,7 +2586,7 @@
 by the IPMI over serial channel.
 .RE
 .TP 
-\fIactivate\fP [\fIusesolkeepalive\fP | \fInokeepalive\fP]
+\fIactivate\fP [\fIusesolkeepalive\fP | \fInokeepalive\fP] [\fIinstance=<number>\fP]
 .br 
 
 Causes ipmitool to enter Serial Over LAN
@@ -2596,6 +2596,9 @@
 sent to the serial console on the remote server.
 On exit,the the SOL payload mode is deactivated and
 the terminal is reset to its original settings.
+
+If the instance is given, it will activate using the given instance
+number.  The default is 1.
 .RS
 
 Special escape sequences are provided to control the SOL session:
@@ -2617,7 +2620,7 @@
 Note that escapes are only recognized immediately after newline.
 .RE
 .TP 
-\fIdeactivate\fP
+\fIdeactivate\fP [\fIinstance=<number>\fP]
 .br 
 
 Deactivates Serial Over LAN mode on the BMC.
@@ -2625,6 +2628,9 @@
 this command to be sent to the BMC, but in the case of an
 unintentional exit from SOL mode, this command may be
 necessary to reset the state of the BMC.
+
+If the instance is given, it will deactivate the given instance
+number.  The default is 1.
 .RE
 .TP 
 \fIspd\fP <\fBi2cbus\fR> <\fBi2caddr\fR> [<\fBchannel\fR>] [<\fmaxread\fR>]
Index: lib/ipmi_sol.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/lib/ipmi_sol.c,v
retrieving revision 1.57
diff -u -r1.57 ipmi_sol.c
--- lib/ipmi_sol.c	21 Jan 2012 05:27:14 -0000	1.57
+++ lib/ipmi_sol.c	12 Sep 2012 19:06:49 -0000
@@ -1283,7 +1283,7 @@
  * ipmi_sol_deactivate
  */
 static int
-ipmi_sol_deactivate(struct ipmi_intf * intf)
+ipmi_sol_deactivate(struct ipmi_intf * intf, int instance)
 {
 	struct ipmi_rs * rsp;
 	struct ipmi_rq   req;
@@ -1296,8 +1296,8 @@
 	req.msg.data     = data;
 
 	bzero(data, sizeof(data));
-	data[0] = IPMI_PAYLOAD_TYPE_SOL;  /* payload type              */
-	data[1] = 1;                      /* payload instance.  Guess! */
+	data[0] = IPMI_PAYLOAD_TYPE_SOL;  /* payload type      */
+	data[1] = instance;               /* payload instance. */
 
 	/* Lots of important data */
 	data[2] = 0;
@@ -1524,7 +1524,7 @@
  * ipmi_sol_red_pill
  */
 static int
-ipmi_sol_red_pill(struct ipmi_intf * intf)
+ipmi_sol_red_pill(struct ipmi_intf * intf, int instance)
 {
 	char   * buffer;
 	int    numRead;
@@ -1670,7 +1670,7 @@
 	{
 		lprintf(LOG_ERR, "Error: No response to keepalive - Terminating session");
 		/* attempt to clean up anyway */
-		ipmi_sol_deactivate(intf);
+		ipmi_sol_deactivate(intf, instance);
 		exit(1);
 	}
 
@@ -1680,7 +1680,7 @@
 		exit(1);
 	}
 	else
-		ipmi_sol_deactivate(intf);
+		ipmi_sol_deactivate(intf, instance);
 
 	return 0;
 }
@@ -1692,7 +1692,8 @@
  * ipmi_sol_activate
  */
 static int
-ipmi_sol_activate(struct ipmi_intf * intf, int looptest, int interval)
+ipmi_sol_activate(struct ipmi_intf * intf, int looptest, int interval,
+		  int instance)
 {
 	struct ipmi_rs * rsp;
 	struct ipmi_rq   req;
@@ -1728,7 +1729,7 @@
 	req.msg.data     = data;
 
 	data[0] = IPMI_PAYLOAD_TYPE_SOL;  /* payload type     */
-	data[1] = 1;                      /* payload instance */
+	data[1] = instance;               /* payload instance */
 
 	/* Lots of important data.  Most is default */
 	data[2]  = bSolEncryption?     0x80 : 0;
@@ -1834,7 +1835,7 @@
 
 	if(looptest == 1)
 	{
-		ipmi_sol_deactivate(intf);
+		ipmi_sol_deactivate(intf, instance);
 		usleep(interval*1000);
 		return 0;
 	}
@@ -1845,7 +1846,7 @@
 	 * 1) STDIN for user input
 	 * 2) The FD for incoming SOL packets
 	 */
-	if (ipmi_sol_red_pill(intf))
+	if (ipmi_sol_red_pill(intf, instance))
 	{
 		lprintf(LOG_ERR, "Error in SOL session");
 		return -1;
@@ -1865,8 +1866,8 @@
 	lprintf(LOG_NOTICE, "SOL Commands: info [<channel number>]");
 	lprintf(LOG_NOTICE, "              set <parameter> <value> [channel]");
 	lprintf(LOG_NOTICE, "              payload <enable|disable|status> [channel] [userid]");
-	lprintf(LOG_NOTICE, "              activate [<usesolkeepalive|nokeepalive>]");
-	lprintf(LOG_NOTICE, "              deactivate");
+	lprintf(LOG_NOTICE, "              activate [<usesolkeepalive|nokeepalive>] [instance=<number>]");
+	lprintf(LOG_NOTICE, "              deactivate [instance=<number>]");
 	lprintf(LOG_NOTICE, "              looptest [<loop times>] [<loop interval(in ms)>]");
 }
 
@@ -2020,32 +2021,60 @@
 	 * Activate
 	 */
  	else if (!strncmp(argv[0], "activate", 8)) {
+		int i;
+		unsigned int instance = 1;
 
-		if (argc > 2) {
-			print_sol_usage();
-			return -1;
-		}
-
-		if (argc == 2) {
-			if (!strncmp(argv[1], "usesolkeepalive", 15))
+		for (i = 1; i < argc; i++) {
+			if (!strncmp(argv[i], "usesolkeepalive", 15))
 				_use_sol_for_keepalive = 1;
-			else if (!strncmp(argv[1], "nokeepalive", 11))
+			else if (!strncmp(argv[i], "nokeepalive", 11))
 				_disable_keepalive = 1;
-			else {
+			else if (!strncmp(argv[i], "instance=", 9)) {
+				char *end;
+				instance = strtoul(argv[i] + 9, &end, 0);
+				if (*end != 0 || instance == 0 || instance > 15)
+				{
+					lprintf(LOG_ERR,
+						"instance invalid: '%s'",
+						argv[i] + 9);
+					print_sol_usage();
+					return -1;
+				}
+			} else {
 				print_sol_usage();
 				return -1;
 			}
 		}
-		retval = ipmi_sol_activate(intf, 0, 0);
+		retval = ipmi_sol_activate(intf, 0, 0, instance);
 	}
 
 
 	/*
 	 * Dectivate
 	 */
-	else if (!strncmp(argv[0], "deactivate", 10))
-		retval = ipmi_sol_deactivate(intf);
-
+	else if (!strncmp(argv[0], "deactivate", 10)) {
+		int i;
+		unsigned int instance = 1;
+
+		for (i = 1; i < argc; i++) {
+			if (!strncmp(argv[i], "instance=", 9)) {
+				char *end;
+				instance = strtoul(argv[i] + 9, &end, 0);
+				if (*end != 0 || instance == 0 || instance > 15)
+				{
+					lprintf(LOG_ERR,
+						"instance invalid: '%s'",
+						argv[i] + 9);
+					print_sol_usage();
+					return -1;
+				}
+			} else {
+				print_sol_usage();
+				return -1;
+			}
+		}
+		retval = ipmi_sol_deactivate(intf, instance);
+	}
 
 	/*
 	 * SOL loop test: Activate and then Dectivate
@@ -2074,7 +2103,7 @@
 		while (cnt > 0)
 		{
 			printf("remain loop test counter: %d\n", cnt);
-			retval = ipmi_sol_activate(intf, 1, interval);
+			retval = ipmi_sol_activate(intf, 1, interval, 1);
 			if (retval)
 			{
 				printf("SOL looptest failed: %d\n", retval);
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to