diff --git a/src/common/pack.c b/src/common/pack.c
index 976a11efde6f1cf5607424192d6e15e93bea7dd7..b1a07fc8f119ceb47f35fd69c2e8ac245f7c89b6 100644
--- a/src/common/pack.c
+++ b/src/common/pack.c
@@ -162,6 +162,33 @@ _unpackmem_ptr(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
 }
 	
 
+/*
+ * Given 'bufp' pointing to a network byte order 32-bit integer
+ * (size) and an arbitrary data string, return a pointer to the 
+ * data string in 'valp'.  Also return the sizes of 'valp' in bytes. 
+ * Advance bufp and decrement lenp by 4 bytes (size of memory 
+ * size records) plus the actual buffer size.
+ */
+void
+_unpackmem(char *valp, uint16_t *size_valp, void **bufp, int *lenp)
+{
+	uint16_t nl;
+
+	memcpy(&nl, *bufp, sizeof(nl));
+	*size_valp = ntohs(nl);
+	(size_t)*bufp += sizeof(nl);
+	*lenp -= sizeof(nl);
+
+	if (*size_valp > 0) {
+		memcpy ( valp, *bufp, *size_valp);
+		(size_t)*bufp += *size_valp;
+		*lenp -= *size_valp;
+	}
+	else
+		*valp = 0 ;
+
+}
+
 /*
  * Given 'bufp' pointing to a network byte order 32-bit integer
  * (size) and an arbitrary data string, return a pointer to the 
diff --git a/src/common/pack.h b/src/common/pack.h
index 40b4449a39e39e78a8e6dce073bdb8a8e9e4fae4..5f6b4a8c968cf4fc18ae5c4335f30d682a8ba481 100644
--- a/src/common/pack.h
+++ b/src/common/pack.h
@@ -32,6 +32,7 @@ void	_packstrarray(char **valp, uint16_t size_val, void **bufp, int *lenp);
 void	_unpackstrarray(char ***valp, uint16_t* size_val, void **bufp, int *lenp);
 
 void	_packmem(char *valp, uint16_t size_val, void **bufp, int *lenp);
+void	_unpackmem(char *valp, uint16_t *size_valp, void **bufp, int *lenp);
 void	_unpackmem_ptr(char **valp, uint16_t *size_valp, void **bufp, int *lenp);
 void	_unpackmem_xmalloc(char **valp, uint16_t *size_valp, void **bufp, int *lenp);
 void	_unpackmem_malloc(char **valp, uint16_t *size_valp, void **bufp, int *lenp);
@@ -78,6 +79,15 @@ void	_unpackmem_malloc(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
 	_packmem(valp,(uint16_t)size_val,bufp,lenp);	\
 } while (0)
 
+#define unpackmem(valp,size_valp,bufp,lenp) do {		\
+	assert(valp != NULL);		\
+	assert(sizeof(size_valp) == sizeof(uint16_t *));\
+	assert((bufp) != NULL && *(bufp) != NULL);	\
+        assert((lenp) != NULL);				\
+        assert(*(lenp) >= sizeof(uint16_t));		\
+	_unpackmem(valp,(uint16_t *)size_valp,bufp,lenp);	\
+} while (0)
+
 #define packstr(str,bufp,lenp) do {			\
 	uint32_t _size;					\
 	_size = (uint32_t)(str ? strlen(str)+1 : 0);	\