summaryrefslogtreecommitdiff
path: root/debian/patches/20_ipmi_isol
blob: 85e684f6cf9882d51f6b393858c5640095451663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
## 20_ipmi_isol.dpatch by  <mjj29@debian.org>
##
## 20_ipmi_isol, closes #412816
Index: ipmitool-1.8.11/include/ipmitool/ipmi_isol.h.orig
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ ipmitool-1.8.11/include/ipmitool/ipmi_isol.h.orig	2009-03-22 16:48:34.633972562 +0000
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+#ifndef IPMI_ISOL_H
+#define IPMI_ISOL_H
+
+#include <ipmitool/ipmi.h>
+
+#define ACTIVATE_ISOL			0x01
+#define SET_ISOL_CONFIG			0x03
+#define GET_ISOL_CONFIG			0x04
+
+#define ISOL_ENABLE_PARAM		0x01
+#define ISOL_AUTHENTICATION_PARAM	0x02
+#define ISOL_ENABLE_FLAG			0x01
+#define ISOL_PRIVILEGE_LEVEL_USER	0x02
+#define ISOL_BAUD_RATE_PARAM		0x05
+#define ISOL_BAUD_RATE_9600		0x06
+#define ISOL_BAUD_RATE_19200		0x07
+#define ISOL_BAUD_RATE_38400		0x08
+#define ISOL_BAUD_RATE_57600		0x09
+#define ISOL_BAUD_RATE_115200		0x0A
+#define ISOL_PREFERRED_BAUD_RATE		0x07
+
+int ipmi_isol_main(struct ipmi_intf *, int, char **);
+
+#endif /* IPMI_SOL_H */
Index: ipmitool-1.8.11/lib/ipmi_isol.c.orig
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ ipmitool-1.8.11/lib/ipmi_isol.c.orig	2009-03-22 16:48:34.661974936 +0000
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <ipmitool/helper.h>
+#include <ipmitool/log.h>
+#include <ipmitool/ipmi.h>
+#include <ipmitool/ipmi_strings.h>
+#include <ipmitool/ipmi_intf.h>
+#include <ipmitool/ipmi_isol.h>
+
+const struct valstr ipmi_isol_baud_vals[] = {
+	{ ISOL_BAUD_RATE_9600,   "9600" },
+	{ ISOL_BAUD_RATE_19200,  "19200" },
+	{ ISOL_BAUD_RATE_38400,  "38400" },
+	{ ISOL_BAUD_RATE_57600,  "57600" },
+	{ ISOL_BAUD_RATE_115200, "115200" },
+	{ 0x00, NULL }
+};
+
+extern int verbose;
+
+static int ipmi_isol_setup(struct ipmi_intf * intf, char baudsetting)
+{
+	struct ipmi_rs * rsp;
+	struct ipmi_rq req;
+	unsigned char data[6];	
+
+	/* TEST FOR AVAILABILITY */
+
+	memset(data, 0, 6);
+	data[0] = 0x00;
+	data[1] = ISOL_ENABLE_PARAM;
+	data[2] = ISOL_ENABLE_FLAG;
+
+	memset(&req, 0, sizeof(req));
+	req.msg.netfn = IPMI_NETFN_ISOL;
+	req.msg.cmd = SET_ISOL_CONFIG;
+	req.msg.data = data;
+	req.msg.data_len = 3;
+
+	rsp = intf->sendrecv(intf, &req);
+	if (rsp == NULL) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config Command");
+		return -1;
+	}
+	if (rsp->ccode == 0xc1) {
+		lprintf(LOG_ERR, "IPMI v1.5 Serial Over Lan (ISOL) not supported!");
+		return -1;
+	}
+	if (rsp->ccode > 0) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config Command: %s",
+			val2str(rsp->ccode, completion_code_vals));
+		return -1;
+	}
+
+	/* GET ISOL CONFIG */
+
+	memset(data, 0, 6);
+	data[0] = 0x00;
+	data[1] = ISOL_AUTHENTICATION_PARAM;
+	data[2] = 0x00;		/* block */
+	data[3] = 0x00;		/* selector */
+	req.msg.cmd = GET_ISOL_CONFIG;
+	req.msg.data_len = 4;
+
+	rsp = intf->sendrecv(intf, &req);
+	if (rsp == NULL) {
+		lprintf(LOG_ERR, "Error in Get ISOL Config Command");
+		return -1;
+	}
+	if (rsp->ccode > 0) {
+		lprintf(LOG_ERR, "Error in Get ISOL Config Command: %s",
+			val2str(rsp->ccode, completion_code_vals));
+		return -1;
+	}
+
+	if (verbose > 1)
+		printbuf(rsp->data, rsp->data_len, "ISOL Config");
+
+	/* SET ISOL CONFIG - AUTHENTICATION */
+
+	memset(data, 0, 6);
+	data[0] = 0x00;
+	data[1] = ISOL_AUTHENTICATION_PARAM;
+	data[2] = ISOL_PRIVILEGE_LEVEL_USER | (rsp->data[1] & 0x80);
+	req.msg.cmd = SET_ISOL_CONFIG;
+	req.msg.data_len = 3;
+
+	rsp = intf->sendrecv(intf, &req);
+	if (rsp == NULL) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config (Authentication) Command");
+		return -1;
+	}
+	if (rsp->ccode > 0) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config (Authentication) Command: %s",
+			val2str(rsp->ccode, completion_code_vals));
+		return -1;
+	}
+
+	/* SET ISOL CONFIG - BAUD RATE */
+
+	memset(data, 0, 6);
+	data[0] = 0x00;
+	data[1] = ISOL_BAUD_RATE_PARAM;
+	data[2] = baudsetting;
+	req.msg.cmd = SET_ISOL_CONFIG;
+	req.msg.data_len = 3;
+
+	rsp = intf->sendrecv(intf, &req);
+	if (rsp == NULL) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config (Baud Rate) Command");
+		return -1;
+	}
+	if (rsp->ccode > 0) {
+		lprintf(LOG_ERR, "Error in Set ISOL Config (Baud Rate) Command: %s",
+			val2str(rsp->ccode, completion_code_vals));
+		return -1;
+	}
+
+	printf("Set ISOL Baud Rate to %s\n",
+	       val2str(baudsetting, ipmi_isol_baud_vals));
+
+	return 0;
+}
+
+int ipmi_isol_main(struct ipmi_intf * intf, int argc, char ** argv)
+{
+	int ret = 0;
+
+	if (argc < 2 || strncmp(argv[0], "help", 4) == 0) {
+		lprintf(LOG_NOTICE, "ISOL Commands: setup <baud>");
+		lprintf(LOG_NOTICE, "ISOL Baud Rates:  9600, 19200, 38400, 57600, 115200");
+		return 0;
+	}
+		
+	if (strncmp(argv[0], "setup", 5) == 0) {
+		if (strncmp(argv[1], "9600", 4) == 0) {
+			ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_9600);
+		}
+		else if (strncmp(argv[1], "19200", 5) == 0) {
+			ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_19200);
+		}
+		else if (strncmp(argv[1], "38400", 5) == 0) {
+			ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_38400);
+		}
+		else if (strncmp(argv[1], "57600", 5) == 0) {
+			ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_57600);
+		}
+		else if (strncmp(argv[1], "115200", 6) == 0) {
+			ret = ipmi_isol_setup(intf, ISOL_BAUD_RATE_115200);
+		}
+		else {
+			lprintf(LOG_ERR, "ISOL - Unsupported baud rate: %s", argv[1]);
+			ret = -1;
+		}
+	}
+	return ret;
+}
Index: ipmitool-1.8.11/src/plugins/lan/lan.c
===================================================================
--- ipmitool-1.8.11.orig/src/plugins/lan/lan.c	2009-02-25 20:38:53.000000000 +0000
+++ ipmitool-1.8.11/src/plugins/lan/lan.c	2009-03-22 16:48:34.681976632 +0000
@@ -1448,6 +1448,430 @@
 	return rsp;
 }
 
+/*
+ * IPMI SOL Payload Format
+ * +--------------------+
+ * |  rmcp.ver          | 4 bytes
+ * |  rmcp.__reserved   |
+ * |  rmcp.seq          |
+ * |  rmcp.class        |
+ * +--------------------+
+ * |  session.authtype  | 9 bytes
+ * |  session.seq       |
+ * |  session.id        |
+ * +--------------------+
+ * |  message length    | 1 byte
+ * +--------------------+
+ * |  sol.seq           | 5 bytes
+ * |  sol.ack_seq       |
+ * |  sol.acc_count     |
+ * |  sol.control       |
+ * |  sol.__reserved    |
+ * +--------------------+
+ * | [request data]     | data_len bytes
+ * +--------------------+
+ */
+uint8_t * ipmi_lan_build_sol_msg(struct ipmi_intf * intf,
+				 struct ipmi_v2_payload * payload,
+				 int * llen)
+{
+	struct rmcp_hdr rmcp = {
+		.ver		= RMCP_VERSION_1,
+		.class		= RMCP_CLASS_IPMI,
+		.seq		= 0xff,
+	};
+	struct ipmi_session * session = intf->session;
+
+	/* msg will hold the entire message to be sent */
+	uint8_t * msg;
+
+	int len = 0;
+
+	len =	sizeof(rmcp)                                 +  // RMCP Header (4)
+		10                                           +  // IPMI Session Header
+		5                                            +  // SOL header
+		payload->payload.sol_packet.character_count;    // The actual payload
+
+	msg = malloc(len);
+	if (msg == NULL) {
+		lprintf(LOG_ERR, "ipmitool: malloc failure");
+		return;
+	}
+	memset(msg, 0, len);
+
+	/* rmcp header */
+	memcpy(msg, &rmcp, sizeof(rmcp));
+	len = sizeof(rmcp);
+
+	/* ipmi session header */
+	msg[len++] = 0; /* SOL is always authtype = NONE */
+	msg[len++] = session->in_seq & 0xff;
+	msg[len++] = (session->in_seq >> 8) & 0xff;
+	msg[len++] = (session->in_seq >> 16) & 0xff;
+	msg[len++] = (session->in_seq >> 24) & 0xff;
+
+	msg[len++] = session->session_id & 0xff;
+	msg[len++] = (session->session_id >> 8) & 0xff;
+	msg[len++] = (session->session_id >> 16) & 0xff;
+	msg[len++] = ((session->session_id >> 24) + 0x10) & 0xff; /* Add 0x10 to MSB for SOL */
+
+	msg[len++] = payload->payload.sol_packet.character_count + 5;
+	
+	/* sol header */
+	msg[len++] = payload->payload.sol_packet.packet_sequence_number;
+	msg[len++] = payload->payload.sol_packet.acked_packet_number;
+	msg[len++] = payload->payload.sol_packet.accepted_character_count;
+	msg[len]    = payload->payload.sol_packet.is_nack           ? 0x40 : 0;
+	msg[len]   |= payload->payload.sol_packet.assert_ring_wor   ? 0x20 : 0;
+	msg[len]   |= payload->payload.sol_packet.generate_break    ? 0x10 : 0;
+	msg[len]   |= payload->payload.sol_packet.deassert_cts      ? 0x08 : 0;
+	msg[len]   |= payload->payload.sol_packet.deassert_dcd_dsr  ? 0x04 : 0;
+	msg[len]   |= payload->payload.sol_packet.flush_inbound     ? 0x02 : 0;
+	msg[len++] |= payload->payload.sol_packet.flush_outbound    ? 0x01 : 0;
+
+	len++; /* On SOL there's and additional fifth byte before the data starts */
+
+	if (payload->payload.sol_packet.character_count) {
+		/* We may have data to add */
+		memcpy(msg + len,
+		       payload->payload.sol_packet.data,
+		       payload->payload.sol_packet.character_count);
+		len += payload->payload.sol_packet.character_count;		
+	}
+
+	session->in_seq++;
+	if (session->in_seq == 0)
+		session->in_seq++;
+	
+	*llen = len;
+	return msg;
+}
+
+/*
+ * is_sol_packet
+ */
+static int
+is_sol_packet(struct ipmi_rs * rsp)
+{
+	return (rsp                                                           &&
+		(rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL));
+}
+
+
+
+/*
+ * sol_response_acks_packet
+ */
+static int
+sol_response_acks_packet(struct ipmi_rs         * rsp,
+			 struct ipmi_v2_payload * payload)
+{
+	return (is_sol_packet(rsp)                                            &&
+		payload                                                       &&
+		(payload->payload_type    == IPMI_PAYLOAD_TYPE_SOL)           && 
+		(rsp->payload.sol_packet.acked_packet_number ==
+		 payload->payload.sol_packet.packet_sequence_number));
+}
+
+/*
+ * ipmi_lan_send_sol_payload
+ *
+ */
+static struct ipmi_rs *
+ipmi_lan_send_sol_payload(struct ipmi_intf * intf,
+			  struct ipmi_v2_payload * payload)
+{
+	struct ipmi_rs      * rsp = NULL;
+	uint8_t             * msg;
+	int                   len;
+	int                   try = 0;
+
+	if (intf->opened == 0 && intf->open != NULL) {
+		if (intf->open(intf) < 0)
+			return NULL;
+	}
+
+	msg = ipmi_lan_build_sol_msg(intf, payload, &len);
+	if (len <= 0 || msg == NULL) {
+		lprintf(LOG_ERR, "Invalid SOL payload packet");
+		if (msg != NULL)
+			free(msg);
+		return NULL;
+	}
+
+	lprintf(LOG_DEBUG, ">> SENDING A SOL MESSAGE\n");
+
+	for (;;) {
+		if (ipmi_lan_send_packet(intf, msg, len) < 0) {
+			try++;
+			usleep(5000);
+			continue;
+		}
+
+		/* if we are set to noanswer we do not expect response */
+		if (intf->noanswer)
+			break;
+		
+		if (payload->payload.sol_packet.packet_sequence_number == 0) {
+			/* We're just sending an ACK.  No need to retry. */
+			break;
+		}
+
+		usleep(100);
+		
+		rsp = ipmi_lan_recv_sol(intf); /* Grab the next packet */
+
+		if (sol_response_acks_packet(rsp, payload))
+			break;
+
+		else if (is_sol_packet(rsp) && rsp->data_len)
+		{
+			/*
+			 * We're still waiting for our ACK, but we more data from
+			 * the BMC
+			 */
+			intf->session->sol_data.sol_input_handler(rsp);
+		}
+
+		usleep(5000);
+		if (++try >= intf->session->retry) {
+			lprintf(LOG_DEBUG, "  No response from remote controller");
+			break;
+		}
+	}
+
+	return rsp;
+}
+
+/*
+ * is_sol_partial_ack
+ *
+ * Determine if the response is a partial ACK/NACK that indicates
+ * we need to resend part of our packet.
+ *
+ * returns the number of characters we need to resend, or
+ *         0 if this isn't an ACK or we don't need to resend anything
+ */
+static int is_sol_partial_ack(struct ipmi_v2_payload * v2_payload,
+			      struct ipmi_rs         * rsp)
+{
+	int chars_to_resend = 0;
+
+	if (v2_payload                                &&
+	    rsp                                       &&
+	    is_sol_packet(rsp)                        &&
+	    sol_response_acks_packet(rsp, v2_payload) &&
+	    (rsp->payload.sol_packet.accepted_character_count <
+	     v2_payload->payload.sol_packet.character_count))
+	{
+		if (rsp->payload.sol_packet.accepted_character_count == 0) {
+			/* We should not resend data */
+			chars_to_resend = 0;
+		}
+		else
+		{
+			chars_to_resend =
+				v2_payload->payload.sol_packet.character_count -
+				rsp->payload.sol_packet.accepted_character_count;
+		}
+	}
+
+	return chars_to_resend;
+}
+
+/*
+ * set_sol_packet_sequence_number
+ */
+static void set_sol_packet_sequence_number(struct ipmi_intf * intf,
+					   struct ipmi_v2_payload * v2_payload)
+{
+	/* Keep our sequence number sane */
+	if (intf->session->sol_data.sequence_number > 0x0F)
+		intf->session->sol_data.sequence_number = 1;
+
+	v2_payload->payload.sol_packet.packet_sequence_number =
+		intf->session->sol_data.sequence_number++;
+}
+
+/*
+ * ipmi_lan_send_sol
+ *
+ * Sends a SOL packet..  We handle partial ACK/NACKs from the BMC here.
+ *
+ * Returns a pointer to the SOL ACK we received, or
+ *         0 on failure
+ * 
+ */
+struct ipmi_rs *
+ipmi_lan_send_sol(struct ipmi_intf * intf,
+		  struct ipmi_v2_payload * v2_payload)
+{
+	struct ipmi_rs * rsp;
+	int chars_to_resend = 0;
+
+	v2_payload->payload_type   = IPMI_PAYLOAD_TYPE_SOL;
+
+	/*
+	 * Payload length is just the length of the character
+	 * data here.
+	 */
+	v2_payload->payload.sol_packet.acked_packet_number = 0; /* NA */
+
+	set_sol_packet_sequence_number(intf, v2_payload);
+	
+	v2_payload->payload.sol_packet.accepted_character_count = 0; /* NA */
+
+	rsp = ipmi_lan_send_sol_payload(intf, v2_payload);
+
+	/* Determine if we need to resend some of our data */
+	chars_to_resend = is_sol_partial_ack(v2_payload, rsp);
+
+	while (chars_to_resend)
+	{
+		/*
+		 * We first need to handle any new data we might have
+		 * received in our NACK
+		 */
+		if (rsp->data_len)
+			intf->session->sol_data.sol_input_handler(rsp);
+
+		set_sol_packet_sequence_number(intf, v2_payload);
+		
+		/* Just send the required data */
+		memmove(v2_payload->payload.sol_packet.data,
+			v2_payload->payload.sol_packet.data +
+			rsp->payload.sol_packet.accepted_character_count,
+			chars_to_resend);
+
+		v2_payload->payload.sol_packet.character_count = chars_to_resend;
+
+		rsp = ipmi_lan_send_sol_payload(intf, v2_payload);
+
+		chars_to_resend = is_sol_partial_ack(v2_payload, rsp);
+	}
+
+	return rsp;
+}
+
+/*
+ * check_sol_packet_for_new_data
+ *
+ * Determine whether the SOL packet has already been seen
+ * and whether the packet has new data for us.
+ *
+ * This function has the side effect of removing an previously
+ * seen data, and moving new data to the front.
+ *
+ * It also "Remembers" the data so we don't get repeats.
+ *
+ */
+static int
+check_sol_packet_for_new_data(struct ipmi_intf * intf,
+			      struct ipmi_rs *rsp)
+{
+	static uint8_t last_received_sequence_number = 0;
+	static uint8_t last_received_byte_count      = 0;
+	int new_data_size                            = 0;
+
+	if (rsp &&
+	    (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL))
+	    
+	{
+		uint8_t unaltered_data_len = rsp->data_len;
+		if (rsp->payload.sol_packet.packet_sequence_number ==
+		    last_received_sequence_number)
+		{
+			/*
+			 * This is the same as the last packet, but may include
+			 * extra data
+			 */
+			new_data_size = rsp->data_len - last_received_byte_count;
+			
+			if (new_data_size > 0)
+			{
+				/* We have more data to process */
+				memmove(rsp->data,
+					rsp->data +
+					rsp->data_len - new_data_size,
+					new_data_size);
+			}
+			
+			rsp->data_len = new_data_size;
+		}
+	
+		/*
+		 *Rember the data for next round
+		 */
+		if (rsp && rsp->payload.sol_packet.packet_sequence_number)
+		{
+			last_received_sequence_number =
+				rsp->payload.sol_packet.packet_sequence_number;
+			last_received_byte_count = unaltered_data_len;
+		}
+	}
+
+	return new_data_size;
+}
+
+/*
+ * ack_sol_packet
+ *
+ * Provided the specified packet looks reasonable, ACK it.
+ */
+static void
+ack_sol_packet(struct ipmi_intf * intf,
+	       struct ipmi_rs * rsp)
+{
+	if (rsp &&
+	    (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) &&
+	    (rsp->payload.sol_packet.packet_sequence_number))
+	{
+		struct ipmi_v2_payload ack;
+
+		memset(&ack, 0, sizeof(struct ipmi_v2_payload));
+
+		ack.payload_type = IPMI_PAYLOAD_TYPE_SOL;
+
+		/*
+		 * Payload length is just the length of the character
+		 * data here.
+		 */
+		ack.payload_length = 0;
+
+		/* ACK packets have sequence numbers of 0 */
+		ack.payload.sol_packet.packet_sequence_number = 0;
+
+		ack.payload.sol_packet.acked_packet_number =
+			rsp->payload.sol_packet.packet_sequence_number;
+
+		ack.payload.sol_packet.accepted_character_count = rsp->data_len;
+		
+		ipmi_lan_send_sol_payload(intf, &ack);
+	}
+}
+
+/*
+ * ipmi_recv_sol
+ *
+ * Receive a SOL packet and send an ACK in response.
+ *
+ */
+struct ipmi_rs *
+ipmi_lan_recv_sol(struct ipmi_intf * intf)
+{
+	struct ipmi_rs * rsp = ipmi_lan_poll_recv(intf);
+
+	ack_sol_packet(intf, rsp);              
+
+	/*
+	 * Remembers the data sent, and alters the data to just
+	 * include the new stuff.
+	 */
+	check_sol_packet_for_new_data(intf, rsp);
+
+	return rsp;
+}
+
 /* send a get device id command to keep session active */
 static int
 ipmi_lan_keepalive(struct ipmi_intf * intf)