Index: src/lib/radius.c
===================================================================
RCS file: /source/radiusd/src/lib/radius.c,v
retrieving revision 1.161
diff -u -r1.161 radius.c
--- src/lib/radius.c	1 Sep 2005 21:50:56 -0000	1.161
+++ src/lib/radius.c	13 Sep 2005 17:09:52 -0000
@@ -589,6 +589,46 @@
 		}
 
 		switch(reply->type) {
+		case PW_TYPE_INTEGER:
+		case PW_TYPE_IPADDR:
+			*length_ptr += 4;
+			if (vsa_length_ptr) *vsa_length_ptr += 4;
+			
+			if (reply->type == PW_TYPE_INTEGER ) {
+				/*  If tagged, the tag becomes the MSB of the value */
+				if(reply->flags.has_tag) {
+					/*  Tag must be ( 0x01 -> 0x1F ) OR 0x00  */
+					if(!TAG_VALID(reply->flags.tag)) {
+						reply->flags.tag = 0x00;
+					}
+					lvalue = htonl((reply->lvalue & 0xffffff) |
+						       ((reply->flags.tag & 0xff) << 24));
+				} else {
+					lvalue = htonl(reply->lvalue);
+				}
+			} else {
+				/*
+				 *	IP address is already in
+				 *	network byte order.
+				 */
+				lvalue = reply->lvalue;
+			}
+
+			len = 4;
+				  
+			if (reply->flags.encrypt == 0) {
+				memcpy(ptr, &lvalue, len);
+				*length_ptr += len;
+				if (vsa_length_ptr) *vsa_length_ptr += len;
+				ptr += len;
+				total_length += len;
+				break;
+			} else {
+				memcpy(reply->vp_strvalue, &lvalue, len); /* NOTE: destroys the original text attribute */
+				reply->length = len;
+				/* FALL-THROUGH */
+			}
+			
 		case PW_TYPE_STRING:
 		case PW_TYPE_OCTETS:
 			/*
@@ -694,35 +734,6 @@
 			total_length += len;
 			break;
 			
-		case PW_TYPE_INTEGER:
-		case PW_TYPE_IPADDR:
-			*length_ptr += 4;
-			if (vsa_length_ptr) *vsa_length_ptr += 4;
-			
-			if (reply->type == PW_TYPE_INTEGER ) {
-				/*  If tagged, the tag becomes the MSB of the value */
-				if(reply->flags.has_tag) {
-					/*  Tag must be ( 0x01 -> 0x1F ) OR 0x00  */
-					if(!TAG_VALID(reply->flags.tag)) {
-						reply->flags.tag = 0x00;
-					}
-					lvalue = htonl((reply->lvalue & 0xffffff) |
-						       ((reply->flags.tag & 0xff) << 24));
-				} else {
-					lvalue = htonl(reply->lvalue);
-				}
-			} else {
-				/*
-				 *	IP address is already in
-				 *	network byte order.
-				 */
-				lvalue = reply->lvalue;
-			}
-			memcpy(ptr, &lvalue, 4);
-			ptr += 4;
-			total_length += 4;
-			break;
-			
 			/*
 			 *  There are no tagged date attributes.
 			 */
