Index: plugins/ilo2_ribcl/ilo2_ribcl_xml.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_xml.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_xml.c	(working copy)
@@ -77,6 +77,7 @@
 static int ir_xml_insert_logininfo( char *, int, char *, char *, char *);
 static int ir_xml_extract_index( char *, char *, int);
 static int ir_xml_replacestr( char **, char *);
+extern int ir_xml_insert_headerinfo( char *, int, char *, char *, char *);
 
 /* Error return values for ir_xml_extract_index */
 #define IR_NO_PREFIX	-1
@@ -107,7 +108,6 @@
 	[IR_CMD_SERVER_AUTO_PWR_60]	ILO2_RIBCL_SERVER_AUTO_PWR_60,
 	[IR_CMD_SERVER_AUTO_PWR_RANDOM]	ILO2_RIBCL_SERVER_AUTO_PWR_RANDOM
 		};
-
 /**
  * ir_xml_parse_status
  * @ribcl_outbuf: Ptr to a buffer containing the raw output from any RIBCL cmd.
@@ -915,7 +915,7 @@
 	for( i =0; i < IR_NUM_COMMANDS; i++){
 		handler->ribcl_xml_cmd[i] = NULL;
 	}
-	
+
 	login = handler->user_name;
 	password = handler->password;
 
@@ -1047,7 +1047,108 @@
 
 } /* end ir_xml_insert_logininfo() */
 
+
 /**
+ * ir_xml_insert_headerinfo
+ * @dest - ptr to destination buffer for the customized HTTP header.
+ * @dsize - size of the dest buffer, including the terminating null.
+ * @format - A *printf format string containing at least two %s substitutions.
+ * @h_name  - the hostname string
+ * @c_length - Content length in decimal characters.
+ *
+ * This is a stripped down version of the standard snprintf() routine.
+ * It is designed to insert the hostname and content-length
+ * strings into a HTTP header template given by the *'format' parameter.
+ * The resulting customized header string is written to the null 
+ * terminated buffer 'dest'.
+ *
+ * Return value: The number of characters written to the dest buffer, not
+ *               including the terminating null (just like snprintf()) if
+ *               success, -1 if failure.
+ **/
+int ir_xml_insert_headerinfo( char *dest, int dsize, char *format,
+		 char *h_name, char *c_length)
+{
+	enum istates { COPY, INSERT_H_NAME, INSERT_C_LENGTH, COPY_POST };
+	int dcount = 0;
+	enum istates state;
+	char ch;
+	int header_entered = 0;
+	if( dest == NULL || h_name == NULL || c_length == NULL)
+		return -1;
+	state = COPY;
+
+	while( dcount < dsize)
+	{
+		switch( state){
+
+		case COPY:
+			if( (*format == '%') && ( (*(format +1)) == 's')){
+				format += 2;
+				if( header_entered){
+					state = INSERT_C_LENGTH;
+				} else {
+					state = INSERT_H_NAME;
+				}
+			} else {
+				/* Copy from format to dest */
+				ch = *dest++ = *format++;
+				if( ch == '\0'){
+					/* We're done */
+					return( dcount);
+				}
+				dcount++;
+			}
+			break;
+
+		case INSERT_H_NAME:
+			header_entered = 1;
+			if( *h_name != '\0'){
+				*dest++ = *h_name++;
+				dcount++;
+			} else {
+				state = COPY;
+			}
+			break;
+
+                case INSERT_C_LENGTH:
+			if( *c_length != '\0'){
+				*dest++ = *c_length++;
+				dcount++;
+			} else {
+				state = COPY_POST;
+			}
+			break;
+
+                case COPY_POST:
+			/* Copy from format to dest */
+			ch = *dest++ = *format++;
+			if( ch == '\0'){
+				/* We're done */
+				return( dcount);
+			}
+			dcount++;
+			break;
+
+		default:
+			err("ir_xml_insert_logininfo(): Illegal state.");
+			return ( -1);
+			break;
+
+		} /* end switch state */
+
+	} /* end while dcount < dsize */
+
+        /* If we make it here, then we've run out of destination buffer space,
+         * so force a null termination to the destination buffer and return the
+         * number of non-null chars.
+         */
+
+	*(dest -1) = '\0';
+	return( dcount - 1);
+
+} /* end ir_xml_insert_headerinfo() */
+/**
  * ir_xml_free_cmdbufs
  * @handler:  ptr to the ilo2_ribcl plugin private handler.
  *
@@ -1697,7 +1798,11 @@
 
 			/* XXX REVISIT - confirm that "Not Installed" is the
 			 * correct string when the power supply is removed. */
-
+			/*The iLO3 output for the power supply has
+			 *a "Power Supplies" label that we don't care
+			 *about, the same is filtered-out here
+			 */
+			if( xmlStrcmp( lbl, (xmlChar *)"Power Supplies") != 0)
 			if( xmlStrcmp( stat, (xmlChar *)"Not Installed") != 0 ){	
 				ret = ir_xml_record_psdata( ir_handler,
 						(char *)lbl, (char *)stat);
@@ -2742,7 +2847,89 @@
 	
 } /* end ir_xml_replacestr() */
 
+/**
+ * ir_xml_decode_chunked
+ * @d_response: Pointer to the raw output from RIBCL command.
+ *
+ * Converts a buffer containing the raw output from a RIBCL command
+ * that contains HTTP header and response in 'chunked' transfer encoding
+ * into plain text that can be fed into the parser.
+ * Return value: Ptr to the new buffer on success, or NULL if failure.
+ **/
+char* ir_xml_decode_chunked(char *d_response)
+{
+	int hide = 1;
+	int issizeofchunk = 1;
+	char temp_line[ILO2_RIBCL_HTTP_LINE_MAX];
+	int chunksize;
+	int line_length;
+	int i;
+	int j;
+	char *new_buffer;
+	new_buffer = malloc(ILO2_RIBCL_DISCOVER_RESP_MAX);
+	memset( new_buffer, '\0', ILO2_RIBCL_DISCOVER_RESP_MAX);
+	if( new_buffer == NULL){
+		err("ir_xml_decode_chunked():"
+			"failed to allocate resp buffer.");
+		return NULL;
+	}
+	j = 0;
+	i = 0;
+	while(1){
+		i=0;
+		memset( temp_line,'\0', ILO2_RIBCL_HTTP_LINE_MAX);
+		while(( temp_line[i++] = *d_response++)!='\n');
+		line_length = strlen( temp_line);
+		if( line_length == 0){
+			return NULL;
+		}
+		if( hide){
+			if( line_length <= 2){
+				hide=0;
+			}
+		} else {
+			if( issizeofchunk){
+                        	        chunksize = hextodec(temp_line);
+                                	issizeofchunk = 0;
+	                                continue;
+                	}
+	                if( chunksize == 0){
+				break;
+			}
+			if( chunksize == line_length){
+				issizeofchunk = 1;
+				hide = 1;
+			} else {
+				if( chunksize > line_length){
+					chunksize -= line_length;
+				} else {
+					issizeofchunk = 1;
+					for( i = 0; i < chunksize ; i++, j++)
+						new_buffer[j] = temp_line[i];
+					continue;
+				}
+			}
+			i = 0;
+			for(i = 0; i < line_length; i++, j++){
+				new_buffer[j] = temp_line[i];
+			}
+		}
+	}
+	return new_buffer;
+} /* end ir_xml_decode_chunked() */
 
+/**
+ * hextodec
+ * @hex: string containing hex values.
+ * 
+ * convert the hex ascii charecters to integer value
+ * 
+ * Return value: a long containing the Decimal value
+ **/
+long hextodec(char hex[])
+{
+	return( strtol(hex, NULL, 16));
+}/* end hextodec() */
 
 #ifdef ILO2_RIBCL_DEBUG_SENSORS
 static char *ilo2_ribcl_sval2string[] = {
Index: plugins/ilo2_ribcl/ilo2_ribcl_ssl.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_ssl.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_ssl.c	(working copy)
@@ -73,24 +73,93 @@
 	void *ssl_handler = NULL;
 	int in_index;
 	int ret;
+	int ilo_header_len;
+	char *hostname;
+	char cmnd_bufsize[ILO2_RIBCL_CMD_MAX_LEN];
 
 	/* Zero out the response buffer */
 	memset( resp_buf, 0, resp_size);
-
+	ir_handler->ribcl_xml_ilo3_hdr = NULL;
 	ssl_handler = oh_ssl_connect( ir_handler->ilo2_hostport,
 				ir_handler->ssl_ctx, 0);
-
 	if( ssl_handler == NULL){
 		err("ilo2_ribcl_ssl_send_command(): "
 		    "oh_ssl_connect returned NULL.");
 		return( -1);
 	}
-
 	/* Send the XML header. iLO2 requires the header to be sent ahead 
 	   separately from the buffer containing the command. */
-
-	ret = oh_ssl_write(ssl_handler, ILO2_RIBCL_XML_HDR,
-				sizeof(ILO2_RIBCL_XML_HDR), 0);
+	/*
+	 * the following is added to send different header info
+	 * for iLO2 and iLO3. based on the ilo_type, header is 
+	 * choosen, if the ilo_type is 0(zero ). then a test header
+	 * is sent to identify if that is ilo2 or ilo3.
+	 */
+	memset(cmnd_bufsize, '\0', ILO2_RIBCL_CMD_MAX_LEN);
+	switch(ir_handler->ilo_type)
+	{
+		case ILO:
+		case ILO2:
+		        ret = oh_ssl_write(ssl_handler, ILO2_RIBCL_XML_HDR,
+						sizeof(ILO2_RIBCL_XML_HDR), 0);
+			break;
+		case ILO3:
+			hostname = ir_handler->ir_hostname;
+			itoascii(cmnd_bufsize, strlen(cmnd_buf));
+			ilo_header_len = strlen( ILO3_RIBCL_XML_HDR)\
+					+ strlen(hostname)\
+					+ strlen(cmnd_bufsize);
+			ir_handler->ribcl_xml_ilo3_hdr = malloc( ilo_header_len);
+			if( ir_handler->ribcl_xml_ilo3_hdr == NULL){
+				err("ilo2_ribcl_ssl_send_command():"
+					"unable to allocate memory");
+				return -1;
+			}
+			memset( ir_handler->ribcl_xml_ilo3_hdr,
+				'\0', ilo_header_len);
+			ir_xml_insert_headerinfo(ir_handler->ribcl_xml_ilo3_hdr,
+				 ilo_header_len, ILO3_RIBCL_XML_HDR,
+				ir_handler->ir_hostname, cmnd_bufsize);
+			ret = oh_ssl_write(ssl_handler,
+					ir_handler->ribcl_xml_ilo3_hdr,
+					strlen(ir_handler->ribcl_xml_ilo3_hdr),
+					0);
+			/*
+			 * Free up the allocated memory
+			 */
+			free( ir_handler->ribcl_xml_ilo3_hdr);
+			break;
+		case NO_ILO:
+			hostname = ir_handler->ir_hostname;
+			itoascii(cmnd_bufsize, strlen(ILO_RIBCL_TEST_ILO)-1);
+			ilo_header_len = strlen( ILO_RIBCL_XML_TEST_HDR)\
+					+ strlen(hostname)\
+					+ strlen(cmnd_bufsize);
+			ir_handler->ribcl_xml_test_hdr = malloc( ilo_header_len);
+			if( ir_handler->ribcl_xml_test_hdr == NULL){
+				err("ilo2_ribcl_ssl_send_command():"
+					"unable to allocate memory");
+				return -1;
+			}
+			memset( ir_handler->ribcl_xml_test_hdr,
+				'\0', ilo_header_len);
+			ir_xml_insert_headerinfo(ir_handler->ribcl_xml_test_hdr,
+				ilo_header_len, ILO_RIBCL_XML_TEST_HDR,
+				ir_handler->ir_hostname, cmnd_bufsize);
+			ret = oh_ssl_write(ssl_handler,
+					ir_handler->ribcl_xml_test_hdr,
+					strlen(ir_handler->ribcl_xml_test_hdr),
+					0);
+			/*
+			 * Free up the allocated memory
+			 */
+			free( ir_handler->ribcl_xml_test_hdr);
+			break;
+		default:
+			err("ilo2_ribcl_ssl_send_command(): "
+				"could not find iLO type.");
+			ret = -1;
+	}
 	if( ret < 0){
 		err("ilo2_ribcl_ssl_send_command(): "
 		    "write of xml header to socket failed.");
@@ -99,7 +168,14 @@
 	}
 
 	/* Send the command buffer. */
-	ret = oh_ssl_write(ssl_handler, cmnd_buf, strlen(cmnd_buf), 0);
+	/*
+	 * REVISIT: this can be 'switched' later
+	 */
+	if( ir_handler->ilo_type != NO_ILO)
+		ret = oh_ssl_write(ssl_handler, cmnd_buf, strlen(cmnd_buf), 0);
+	else
+		ret = oh_ssl_write(ssl_handler, ILO_RIBCL_TEST_ILO,
+					 strlen(ILO_RIBCL_TEST_ILO), 0);
 	if( ret < 0){
 		err("ilo2_ribcl_ssl_send_command(): "
 		    "write of xml command to socket failed.");
@@ -127,3 +203,83 @@
 	return( 0);
 
 } /* end ilo2_ribcl_ssl_send_command */
+
+
+/**
+ * ilo_ribcl_detect_ilo_type
+ * @ir_handler: Pointer to the ilo handler.
+ *
+ * Detects if the current ilo is ilo2/ilo3
+ *
+ * Return value: returns either ILO2 or ILO3
+ *
+ **/
+int ilo_ribcl_detect_ilo_type(ilo2_ribcl_handler_t *ir_handler)
+{
+	char *detect_cmd;
+	char *d_response;
+	char firstline[ILO2_RIBCL_HTTP_LINE_MAX];
+	int index;
+	int ret;
+
+	d_response = malloc(ILO_RIBCL_TEST_ILO_RESPONSE_MAX);
+	if(!d_response){
+		err("ilo_ribcl_detect_ilo_type():"
+			"unable to allocate memory");
+		return( -1);
+	}
+	detect_cmd = ir_handler->ribcl_xml_test_hdr;
+	ret = ilo2_ribcl_ssl_send_command( ir_handler, detect_cmd, 
+				d_response, ILO_RIBCL_TEST_ILO_RESPONSE_MAX);
+	if( ret < 0){
+                err("ilo2_ribcl_ssl_send_command(): "
+                    "write of xml header to socket failed.");
+		free( d_response);
+                return( -1);
+        }
+	index = 0;
+	while(d_response[index]!='\n'){
+		firstline[index]=d_response[index];
+		index++;
+	}
+	firstline[index++] = '\n';
+	firstline[index] = '\0';
+	/*
+	 *We can now free up the d_response
+	 *pointer
+	 */
+	free( d_response);
+	if(strcmp(ILO_RIBCL_TEST_RESPONSE, firstline)==0){
+		dbg("Found iLO3 MP");
+		return ILO3;
+	} else {
+		dbg("Found iLO2 MP");
+		return ILO2;
+	}
+} /* end ilo_ribcl_detect_ilo_type() */
+
+/**
+ * itoascii
+ * @cmnd_size: Pointer to the converted string.
+ * @decimal: integer value.
+ *
+ * Converts a integer value to ascii string.
+ *
+ * Return value: none.
+ *
+ **/
+void itoascii(char cmnd_size[], int decimal)
+{
+	int i;
+	int j;
+	int temp;
+	i = 0;
+	do{
+		cmnd_size[i++] = decimal % 10 + '0';
+	}while((decimal /= 10) > 0);
+	for(i = 0, j = strlen(cmnd_size)-1; i < j; i++, j--){
+		temp = cmnd_size[i];
+		cmnd_size[i] = cmnd_size[j];
+		cmnd_size[j] = temp;
+	}
+} /* end itoascii() */
Index: plugins/ilo2_ribcl/ilo2_ribcl_xml.h
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_xml.h	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_xml.h	(working copy)
@@ -52,5 +52,6 @@
 extern int ir_xml_parse_discoveryinfo( ilo2_ribcl_handler_t *, char *);
 extern void ir_xml_free_cmdbufs( ilo2_ribcl_handler_t *);
 extern int ir_xml_build_cmdbufs( ilo2_ribcl_handler_t *);
- 
+extern char* ir_xml_decode_chunked( char *);
+extern long hextodec(char *); 
 #endif /* _INC_ILO2_RIBCL_XML_H_ */
Index: plugins/ilo2_ribcl/ilo2_ribcl_ssl.h
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_ssl.h	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_ssl.h	(working copy)
@@ -35,13 +35,14 @@
 #ifndef _INC_ILO2_RIBCL_SSL_H_
 #define _INC_ILO2_RIBCL_SSL_H_
 
+#define ILO_RIBCL_TEST_ILO_RESPONSE_MAX 1024
 #include <ilo2_ribcl.h>
-
 /*
  * This file defines prototypes for the iLO2 RIBCL plug-in iLO2 SSL connection
  * management functions implemented in ilo2_ribcl_ssl.c
  */
-extern int ilo2_ribcl_ssl_send_command(ilo2_ribcl_handler_t *, char *,
+extern int ilo_ribcl_ssl_send_command(ilo2_ribcl_handler_t *, char *,
 	char *, int);
-
+extern int ilo_ribcl_detect_ilo_type(ilo2_ribcl_handler_t *);
+void itoascii(char *, int);
 #endif /* _INC_ILO2_RIBCL_SSL_H_ */
Index: plugins/ilo2_ribcl/ilo2_ribcl_cmnds.h
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_cmnds.h	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_cmnds.h	(working copy)
@@ -45,6 +45,13 @@
  */
 #define ILO2_RIBCL_XML_HDR      "<?xml version=\"1.0\"?>\r\n"
 
+#define ILO3_RIBCL_XML_HDR	"POST /ribcl HTTP/1.1\r\nHOST: %s\r\n\
+TE: chunked\r\nConnection: Close\r\nContent-length: %s\r\n\r\n"
+#define ILO_RIBCL_XML_TEST_HDR  ILO3_RIBCL_XML_HDR
+
+#define ILO_RIBCL_TEST_ILO	"<RIBCL VERSION=\"2.0\"></RIBCL>\r\n"
+#define ILO_RIBCL_TEST_RESPONSE	"HTTP/1.1 200 OK\r\n"
+
 /* Here are all the RIBCL xml templates for the commands. For each command,
  * we have a format specification string that allows us to insert the
  * login and password strings for individual systems. Also, each command
Index: plugins/ilo2_ribcl/ilo2_ribcl_discover.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_discover.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_discover.c	(working copy)
@@ -259,6 +259,7 @@
 	char *discover_cmd;
 	char *d_response;	/* command response buffer */
 	int ret;
+	char *new_buffer=NULL;
 
 	/* Allocate a temporary response buffer. Since the discover
 	 * command should be infrequently run, we dynamically allocate
@@ -294,7 +295,19 @@
 		ret = ilo2_ribcl_getfile( ir_handler->discovery_responsefile,
 			d_response, ILO2_RIBCL_DISCOVER_RESP_MAX);
 	} else {
-
+		if(ir_handler->ilo_type == NO_ILO){
+			ret = ilo_ribcl_detect_ilo_type(ir_handler);
+			if( ret <0){
+				err("ilo2_ribcl_do_discovery():"
+					"could not detect iLO type.");
+				return( SA_ERR_HPI_INTERNAL_ERROR);
+			}
+			/*
+			 *We found the ilo_type in ret
+			 *assigne it to the handler here
+			 */
+			ir_handler->ilo_type = ret;
+		}
 		/* Send the command to iLO2 and get the response. */
 		ret = ilo2_ribcl_ssl_send_command( ir_handler, discover_cmd,
 				d_response, ILO2_RIBCL_DISCOVER_RESP_MAX);
@@ -302,6 +315,19 @@
 
 #else /* ILO2_RIBCL_SIMULATE_iLO2_RESPONSE not defined. This the the
 	 normal use, non-testing case. */
+	if(ir_handler->ilo_type == NO_ILO){
+		ret = ilo_ribcl_detect_ilo_type(ir_handler);
+		if( ret <0){
+			err("ilo2_ribcl_do_discovery():"
+				"could not detect iLO type.");
+			return( SA_ERR_HPI_INTERNAL_ERROR);
+		}
+		/*
+		 *We found the ilo_type in ret
+		 *assign it to the handler here
+		 */
+		ir_handler->ilo_type = ret;
+	}
 
 	/* Send the command to iLO2 and get the response. */
 	ret = ilo2_ribcl_ssl_send_command( ir_handler, discover_cmd,
@@ -318,16 +344,39 @@
 	/* Now, parse the response. The information we extract will be
 	 * written into the DiscoveryData element in our private handler
 	 */
+	/*
+	 *switch based on ilo
+	 *
+	 */
+	switch(ir_handler->ilo_type){
 
-	ret = ir_xml_parse_discoveryinfo( ir_handler, d_response);
+		case ILO:
+		case ILO2:
+			ret = ir_xml_parse_discoveryinfo( ir_handler, 
+							d_response);
+			break;
+		case ILO3:
+			new_buffer = ir_xml_decode_chunked(d_response);
+			ret = ir_xml_parse_discoveryinfo( ir_handler, 
+							new_buffer);
+			break;
+		default:
+			err("ilo2_ribcl_do_discovery():"
+				"failed to detect ilo type.");
+	}
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_do_discovery(): response parse failed.");
-		free( d_response); 
+		free( d_response);
+		free( new_buffer);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
-
 	/* We're finished. Free up the temporary response buffer */
 	free( d_response);
+	/*
+	 * new_buffer will be NULL for ILO2
+	 * it is absolutely fine to free NULL
+	 */
+	free( new_buffer);
 	return( SA_OK);
 	
 } /* end ilo2_ribcl_do_discovery() */
Index: plugins/ilo2_ribcl/ilo2_ribcl_idr.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_idr.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_idr.c	(working copy)
@@ -897,7 +897,7 @@
  *	Field 1: SAHPI_IDR_FIELDTYPE_PRODUCT_NAME "<system product number>"
  *	Field 2: SAHPI_IDR_FIELDTYPE_SERIAL_NUMBER "<system serial numner>" 
  *	Field 3: SAHPI_IDR_FIELDTYPE_MANUFACTURER "Hewlett Packard"
- *	Field 4: SAHPI_IDR_FIELDTYPE_CUSTOM "iLo2_Firmware: <firmware version>"
+ *	Field 4: SAHPI_IDR_FIELDTYPE_CUSTOM "iLO_Firmware: <firmware version>"
  *
  * Return values:
  * None
@@ -929,7 +929,7 @@
 
 	field = &(idr_info->idr_areas[0].area_fields[I2R_CHASSIS_IF_ILO2VERS]);
 	field->field_type = SAHPI_IDR_FIELDTYPE_CUSTOM;
-	ilo2_ribcl_field_catstring( field, "iLo2_Firmware: ");
+	ilo2_ribcl_field_catstring( field, "iLO_Firmware: ");
 	ilo2_ribcl_field_catstring( field, ddata->fwdata.version_string);
 	
 } /* end ilo2_ribcl_build_chassis_idr() */ 
Index: plugins/ilo2_ribcl/ilo2_ribcl.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl.c	(working copy)
@@ -45,7 +45,6 @@
 #include <ilo2_ribcl_xml.h>
 #include <ilo2_ribcl_discover.h>
 #include <ilo2_ribcl_sensor.h>
-
 static SaHpiEntityPathT g_epbase; /* root entity path (from config) */
 
 /*****************************
@@ -218,11 +217,31 @@
 	ilo2_ribcl_handler->user_name = ilo2_user_name;
 	ilo2_ribcl_handler->password = ilo2_password;
 
+	/*initialize the ilo_type to NO_ILO*/
+	ilo2_ribcl_handler->ilo_type = NO_ILO;
+
+	/*hostname is needed for the HTTP 1.1 header
+	 *that will be sent to iLO3 prior to RIBCL command
+	 *submission. The max length of the hostname is 
+	 *limited by HOST_NAME_MAX, the gethostname always have a '\0'
+	 *at the end of the name, if hostname exceeds the HOST_NAME_MAX,
+	 *the string is truncated. So it is always made
+	 *sure that the last character is '\0'. Achieved by the following
+	 *statement of the gethostname.
+	 */
+	gethostname(ilo2_ribcl_handler->ir_hostname, HOST_NAME_MAX-1);
+	ilo2_ribcl_handler->ir_hostname[HOST_NAME_MAX] = '\0';
+	
+
+	/*Initialize the test and the iLO3 header pointer to NULL*/
+	ilo2_ribcl_handler->ribcl_xml_test_hdr = NULL;
+	ilo2_ribcl_handler->ribcl_xml_ilo3_hdr = NULL;
+	
 	/* Build the customized RIBCL command strings containing the
 	 * login and password for this ilo2 host */
-
 	if (ir_xml_build_cmdbufs( ilo2_ribcl_handler) != RIBCL_SUCCESS){
-		err("ilo2_ribcl_open(): ir_xml_build_cmdbufs failed to build buffers.");
+		err("ilo2_ribcl_open(): ir_xml_build_cmdbufs"
+				"failed to build buffers.");
 		free(ilo2_ribcl_handler->ilo2_hostport);
 		free(ilo2_ribcl_handler);
 		free(oh_handler->rptcache);
@@ -264,7 +283,6 @@
 		free(oh_handler);
 		return(NULL);
 	}
-
 	/* Initialize sensor data */
 	ilo2_ribcl_init_sensor_data( ilo2_ribcl_handler);
 
Index: plugins/ilo2_ribcl/ilo2_ribcl_control.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_control.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_control.c	(working copy)
@@ -396,6 +396,7 @@
 {
 	char *uid_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 	int uid_status = -1;
 
@@ -424,17 +425,36 @@
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_uid_status( response, &uid_status,
+					hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_uid_status(new_response, &uid_status,
+					hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_get_uid_status():"
+				"failed to detect ilo type.");
+        }
 	/* Now, parse the response. */
-	ret = ir_xml_parse_uid_status(response, &uid_status,
-			hnd->ilo2_hostport);
+	/*ret = ir_xml_parse_uid_status(new_response, &uid_status,
+			hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_get_uid_status: response parse failed.");
-		free( response); 
+		free( response);
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 
 	if(uid_status == ILO2_RIBCL_UID_ON) {
 		*status = SAHPI_CTRL_STATE_ON;
@@ -466,6 +486,7 @@
 {
 	char *uid_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 
 	if((status != SAHPI_CTRL_STATE_OFF) &&
@@ -503,16 +524,35 @@
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status( response,
+						hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status(new_response,
+						hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_set_uid_status():"
+				"failed to detect ilo type.");
+        }
 	/* Now, parse the response. */
-	ret = ir_xml_parse_status(response, hnd->ilo2_hostport);
+	/*ret = ir_xml_parse_status(new_response, hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_set_uid_status: response parse failed.");
-		free( response); 
+		free( response);
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 	return(SA_OK);
 }
 
@@ -534,6 +574,7 @@
 {
 	char *ps_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 	int ps_status = -1;
 
@@ -562,17 +603,38 @@
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_power_saver_status( response, 
+					&ps_status,
+					hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_power_saver_status(new_response, 
+					&ps_status,
+					hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_get_power_saver_status():"
+					"failed to detect ilo type.");
+        }
 	/* Now, parse the response. */
-	ret = ir_xml_parse_power_saver_status(response, &ps_status,
-			hnd->ilo2_hostport);
+	/*ret = ir_xml_parse_power_saver_status(new_response, &ps_status,
+			hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS) {
 		err("ilo2_ribcl_get_power_saver_status: response parse failed.");
 		free( response); 
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 
 	if (ps_status >= ILO2_RIBCL_MANUAL_OS_CONTROL_MODE && 
 		ps_status <= ILO2_RIBCL_MANUAL_HIGH_PERF_MODE) {
@@ -603,6 +665,7 @@
 {
 	char *ps_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 
 	if((status < ILO2_RIBCL_MANUAL_OS_CONTROL_MODE) ||
@@ -647,11 +710,27 @@
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
-	/* Now, parse the response. */
-	ret = ir_xml_parse_status(response, hnd->ilo2_hostport);
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status(response, hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status(new_response,
+						hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_set_power_saver_status():"
+					"failed to detect ilo type.");
+        }
+	/*ret = ir_xml_parse_status(new_response, hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_set_power_saver_status: response parse failed.");
 		free( response);
+		free( new_response);
 		/* DL365 G1 doesn't support Power Saver Feature and DL385 G2
 		   supports just the ILO2_RIBCL_MANUAL_LOW_POWER_MODE */  
 		if(ret == RIBCL_UNSUPPORTED) {
@@ -662,6 +741,7 @@
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 	return(SA_OK);
 }
 
@@ -683,6 +763,7 @@
 {
 	char *ps_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 	int ps_status = -1;
 
@@ -710,18 +791,39 @@
 		free( response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_auto_power_status(response, 
+					&ps_status,
+					hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_auto_power_status(new_response, 
+					&ps_status,
+					hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_get_auto_power_status():"
+					"failed to detect ilo type.");
+        }
 
 	/* Now, parse the response. */
-	ret = ir_xml_parse_auto_power_status(response, &ps_status,
-			hnd->ilo2_hostport);
+	/*ret = ir_xml_parse_auto_power_status(new_response, &ps_status,
+			hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS) {
 		err("ilo2_ribcl_get_auto_power_status: response parse failed.");
 		free( response); 
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 
 	if (ps_status >= ILO2_RIBCL_AUTO_POWER_ENABLED && 
 		ps_status <= ILO2_RIBCL_AUTO_POWER_DELAY_60) {
@@ -752,6 +854,7 @@
 {
 	char *ps_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 
 	if((status != ILO2_RIBCL_AUTO_POWER_ENABLED) &&
@@ -807,16 +910,34 @@
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
+	switch(hnd->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status(response, hnd->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_status(new_response, 
+						hnd->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_set_auto_power_status():"
+					"failed to detect ilo type.");
+        }
 	/* Now, parse the response. */
-	ret = ir_xml_parse_status(response, hnd->ilo2_hostport);
+	/*ret = ir_xml_parse_status(new_response, hnd->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_set_auto_power_status: response parse failed.");
 		free( response);
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 	return(SA_OK);
 }
 
Index: plugins/ilo2_ribcl/ilo2_ribcl_reset.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_reset.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_reset.c	(working copy)
@@ -137,6 +137,7 @@
 	SaHpiRptEntryT *rpt;
 	char *srs_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 
 	if (!hnd || NULL == oh_lookup_resetaction(act)){
@@ -210,14 +211,30 @@
 		free( response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
+	switch(ilo2_ribcl_handler->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now parse the response.*/
+			ret = ir_xml_parse_reset_server(response,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			ret = ir_xml_parse_reset_server(new_response,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_do_discovery():"
+				"failed to detect ilo type.");
+	}
 
-	/* Now, parse the response.
-	 */
+	/* Now parse the response.*/
 
-	ret = ir_xml_parse_reset_server(response,
-			ilo2_ribcl_handler->ilo2_hostport);
+	/*ret = ir_xml_parse_reset_server(new_response,
+			ilo2_ribcl_handler->ilo2_hostport);*/
 
 	free( response);
+	free( new_response);
 
 	if(ret == -1) {
 		err("ilo2_ribcl_set_reset_state: iLO2 returned error.");
Index: plugins/ilo2_ribcl/ilo2_ribcl.h
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl.h	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl.h	(working copy)
@@ -44,6 +44,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <bits/local_lim.h>
 
 #include <SaHpi.h>
 #include <oh_utils.h>
@@ -99,7 +100,7 @@
  * Change to dynamic if need be.
  */
 #define ILO2_RIBCL_BUFFER_LEN	4096 
-
+#define ILO2_RIBCL_HTTP_LINE_MAX 1024
 /*
  * Power and reset status definitions
 */
@@ -107,8 +108,12 @@
 #define ILO2_RIBCL_POWER_ON	1
 #define ILO2_RIBCL_RESET_SUCCESS	1	
 #define ILO2_RIBCL_RESET_FAILED	0	
-
 /*
+ *Moving this definition to this file
+ *from ilo2_ribcl_discover.h file
+ */
+#define ILO2_RIBCL_DISCOVER_RESP_MAX 1024*48
+/*
  * For a oh_set_power_state() call with a state parameter of
  * SAHPI_POWER_CYCLE, we must wait until the server actually powers off
  * before powering it back on again. 
@@ -131,7 +136,11 @@
 */
 #define ILO2_RIBCL_MANAGED_HOTSWAP_CAP_FALSE	0
 
-
+#define NO_ILO	0
+#define ILO	1
+#define ILO2	2
+#define ILO3	3
+#define ILO2_RIBCL_CMD_MAX_LEN 5
 /******************************************************************************
  * The following data structures and macros are used for our implementation
  * of Inventory Data Repositories.
@@ -372,7 +381,8 @@
 typedef struct ilo2_ribcl_handler {
 	char *entity_root;
 	int first_discovery_done;
-
+	int ilo_type;
+	char ir_hostname[HOST_NAME_MAX];
 	/* Storehouse for data obtained during discovery */
 	ilo2_ribcl_DiscoveryData_t DiscoveryData;
 
@@ -396,6 +406,9 @@
 	/* Commands customized with the login and password for this system */
 	char *ribcl_xml_cmd[ IR_NUM_COMMANDS];
 
+	char *ribcl_xml_test_hdr;
+	char *ribcl_xml_ilo3_hdr;
+
 	GSList *eventq;                 /* Event queue cache */
 
 	/* During discovery, soem routines need a temporary buffer for
Index: plugins/ilo2_ribcl/ilo2_ribcl_power.c
===================================================================
--- plugins/ilo2_ribcl/ilo2_ribcl_power.c	(revision 7296)
+++ plugins/ilo2_ribcl/ilo2_ribcl_power.c	(working copy)
@@ -72,6 +72,7 @@
 	SaHpiRptEntryT *rpt;
 	char *grs_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 	int power_status = -1;
 	ilo2_ribcl_resource_info_t *res_info = NULL;
@@ -131,20 +132,38 @@
 		free( response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
+	switch(ilo2_ribcl_handler->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response.*/
+			ret = ir_xml_parse_host_power_status(response, 
+					&power_status,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response.*/
+			ret = ir_xml_parse_host_power_status(new_response, 
+					&power_status,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_do_discovery():"
+				"failed to detect ilo type.");
+	}
 
-	/* Now, parse the response.
-	 */
-
-	ret = ir_xml_parse_host_power_status(response, &power_status,
-			ilo2_ribcl_handler->ilo2_hostport);
+	/*ret = ir_xml_parse_host_power_status(new_response, &power_status,
+			ilo2_ribcl_handler->ilo2_hostport);*/
 	if( ret != RIBCL_SUCCESS){
 		err("ilo2_ribcl_get_power_state: response parse failed.");
 		free( response); 
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
 	/* We're finished. Free up the temporary response buffer */
 	free( response);
+	free( new_response);
 
 	if(power_status == ILO2_RIBCL_POWER_ON) {
 		*state = SAHPI_POWER_ON;
@@ -191,6 +210,7 @@
 	SaHpiRptEntryT *rpt;
 	char *sps_cmd;
 	char *response;	/* command response buffer */
+	char *new_response = NULL;
 	int ret;
 	ilo2_ribcl_resource_info_t *res_info = NULL;
 
@@ -265,15 +285,29 @@
 		free( response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
-
-	/* Now, parse the response. */
-
-	ret = ir_xml_parse_set_host_power(response,
-			ilo2_ribcl_handler->ilo2_hostport);
-
+	switch(ilo2_ribcl_handler->ilo_type){
+		case ILO:
+		case ILO2:
+			/* Now, parse the response. */
+			ret = ir_xml_parse_set_host_power(response,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		case ILO3:
+			new_response = ir_xml_decode_chunked(response);
+			/* Now, parse the response. */
+			ret = ir_xml_parse_set_host_power(new_response,
+					ilo2_ribcl_handler->ilo2_hostport);
+			break;
+		default:
+			err("ilo2_ribcl_do_discovery():"
+					"failed to detect ilo type.");
+	}
+	/*ret = ir_xml_parse_set_host_power(new_response,
+			ilo2_ribcl_handler->ilo2_hostport);*/
 	if(ret == -1) {
 		err("ilo2_ribcl_set_power_state: iLO2 returned error.");
 		free( response);
+		free( new_response);
 		return( SA_ERR_HPI_INTERNAL_ERROR);
 	}
 
@@ -333,13 +367,29 @@
 			free( response);
 			return( SA_ERR_HPI_INTERNAL_ERROR);
 		}
+		switch(ilo2_ribcl_handler->ilo_type){
+			case ILO:
+			case ILO2:
+				/* Now, parse the response. */
+				ret = ir_xml_parse_set_host_power(response,
+					ilo2_ribcl_handler->ilo2_hostport);
+				break;
+			case ILO3:
+				new_response = ir_xml_decode_chunked(response);
+				/* Now, parse the response. */
+				ret = ir_xml_parse_set_host_power(new_response,
+					ilo2_ribcl_handler->ilo2_hostport);
+				break;
+			default:
+				err("ilo2_ribcl_do_discovery():"
+					"failed to detect ilo type.");
+		}
 
 		/* Now, parse the response. */
-
-		ret = ir_xml_parse_set_host_power(response,
-				ilo2_ribcl_handler->ilo2_hostport);
-
+		/*ret = ir_xml_parse_set_host_power(new_response,
+				ilo2_ribcl_handler->ilo2_hostport);*/
 		free( response);
+		free( new_response);
 
 		if(ret == -1) {
 			err("ilo2_ribcl_set_power_state: iLO2 returned error.");
