Index: libfdproto/dictionary_functions.c
===================================================================
--- libfdproto/dictionary_functions.c	(revision 1093)
+++ libfdproto/dictionary_functions.c	(revision 1122)
@@ -74,4 +74,8 @@
 				AddressType = 1;/* see http://www.iana.org/assignments/address-family-numbers/ */
 				size = 6;	/* 2 for AddressType + 4 for data */
+				#ifdef ADDRESS_AVP_INCLUDE_PORT
+				if (sin->sin_port != 0)
+					size += 2;
+				#endif /* ADDRESS_AVP_INCLUDE_PORT */
 				
 				CHECK_MALLOC(  buf = malloc(size)  );
@@ -79,4 +83,9 @@
 				/* may not work because of alignment: *(uint32_t *)(buf+2) = htonl(sin->sin_addr.s_addr); */
 				memcpy(buf + 2, &sin->sin_addr.s_addr, 4);
+				
+				#ifdef ADDRESS_AVP_INCLUDE_PORT
+				if (sin->sin_port != 0)
+					memcpy(buf + 6, &sin->sin_port, 2);
+				#endif /* ADDRESS_AVP_INCLUDE_PORT */
 			}
 			break;
@@ -89,4 +98,8 @@
 				AddressType = 2;/* see http://www.iana.org/assignments/address-family-numbers/ */
 				size = 18;	/* 2 for AddressType + 16 for data */
+				#ifdef ADDRESS_AVP_INCLUDE_PORT
+				if (sin6->sin6_port != 0)
+					size += 2;
+				#endif /* ADDRESS_AVP_INCLUDE_PORT */
 				
 				CHECK_MALLOC(  buf = malloc(size)  );
@@ -94,4 +107,9 @@
 				/* The order is already good here */
 				memcpy(buf + 2, &sin6->sin6_addr.s6_addr, 16);
+				
+				#ifdef ADDRESS_AVP_INCLUDE_PORT
+				if (sin6->sin6_port != 0)
+					memcpy(buf + 18, &sin6->sin6_port, 2);
+				#endif /* ADDRESS_AVP_INCLUDE_PORT */
 			}
 			break;
@@ -126,9 +144,12 @@
 				sSA4 * sin = (sSA4 *)interpreted;
 				
-				CHECK_PARAMS(  avp_value->os.len == 6  );
+				CHECK_PARAMS(  avp_value->os.len >= 6  );
 				
 				sin->sin_family = AF_INET;
 				/* sin->sin_addr.s_addr = ntohl( * (uint32_t *) buf); -- may not work because of bad alignment */
 				memcpy(&sin->sin_addr.s_addr, buf, 4);
+				
+				if (avp_value->os.len == 8)
+					memcpy(&sin->sin_port, buf + 4, 2);
 			}
 			break;
@@ -138,8 +159,12 @@
 				sSA6 * sin6 = (sSA6 *)interpreted;
 				
-				CHECK_PARAMS(  avp_value->os.len == 18  );
+				CHECK_PARAMS(  avp_value->os.len >= 18  );
 				
 				sin6->sin6_family = AF_INET6;
 				memcpy(&sin6->sin6_addr.s6_addr, buf, 16);
+				
+				if (avp_value->os.len == 20)
+					memcpy(&sin6->sin6_port, buf + 16, 2);
+				
 			}
 			break;
@@ -179,18 +204,22 @@
 			/* IP */
 			s.sa.sa_family = AF_INET;
-			if (avp_value->os.len != 6) {
+			if ((avp_value->os.len != 6) && (avp_value->os.len != 8)) {
 				CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "[invalid IP length: %zd]", avp_value->os.len), return NULL);
 				return *buf;
 			}
 			memcpy(&s.sin.sin_addr.s_addr, avp_value->os.data + 2, 4);
+			if (avp_value->os.len == 8)
+				memcpy(&s.sin.sin_port, avp_value->os.data + 6, 2);
 			break;
 		case 2:
 			/* IP6 */
 			s.sa.sa_family = AF_INET6;
-			if (avp_value->os.len != 18) {
+			if ((avp_value->os.len != 18) && (avp_value->os.len != 20)) {
 				CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "[invalid IP6 length: %zd]", avp_value->os.len), return NULL);
 				return *buf;
 			}
 			memcpy(&s.sin6.sin6_addr.s6_addr, avp_value->os.data + 2, 16);
+			if (avp_value->os.len == 20)
+				memcpy(&s.sin6.sin6_port, avp_value->os.data + 18, 2);
 			break;
 		default:
@@ -199,5 +228,5 @@
 	}
 	
-	return fd_sa_dump_node(FD_DUMP_STD_PARAMS, &s.sa, NI_NUMERICHOST);
+	return fd_sa_dump(FD_DUMP_STD_PARAMS, &s.sa, NI_NUMERICHOST);
 }
 
Index: libfdproto/utils.c
===================================================================
--- libfdproto/utils.c	(revision 1119)
+++ libfdproto/utils.c	(revision 1122)
@@ -36,35 +36,27 @@
 #include "fdproto-internal.h"
 
-DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump_node, sSA * sa, int flags)
+DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump, sSA * sa, int flags) 
 {
 	char addrbuf[INET6_ADDRSTRLEN];
+	char servbuf[32];
+	int rc;
 	FD_DUMP_HANDLE_OFFSET();
 	
+	servbuf[0] = 0;
+	
 	if (sa) {
-		int rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), NULL, 0, flags);
+		if (sSAport(sa)) {
+			rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), servbuf, sizeof(servbuf), flags);
+		} else {
+			rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), NULL, 0, flags);
+		}
 		if (rc) {
 			CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", gai_strerror(rc)), return NULL);
 		} else {
-			CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", &addrbuf[0]), return NULL);
-		}
-	} else {
-		CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(NULL / ANY)"), return NULL);
-	}
-	
-	return *buf;
-}
-
-DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump_node_serv, sSA * sa, int flags) 
-{
-	char addrbuf[INET6_ADDRSTRLEN];
-	char servbuf[32];
-	FD_DUMP_HANDLE_OFFSET();
-	
-	if (sa) {
-		int rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), servbuf, sizeof(servbuf), flags);
-		if (rc) {
-			CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", gai_strerror(rc)), return NULL);
-		} else {
-			CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s(%s)", &addrbuf[0], &servbuf[0]), return NULL);
+			if (servbuf[0]) {
+				CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s(%s)", &addrbuf[0], &servbuf[0]), return NULL);
+			} else {
+				CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", &addrbuf[0]), return NULL);
+			}
 		}
 	} else {
