+
+#ifdef ENABLE_IPV6
+static void
+ip_address_to_lprt_repr (const ip_address *addr, int port, char *buf,
+ size_t buflen)
+{
+ unsigned char *ptr;
+
+ assert (addr != NULL);
+ assert (addr->type == IPV4_ADDRESS || addr->type == IPV6_ADDRESS);
+ assert (buf != NULL);
+ /* buf must contain the argument of LPRT (of the form af,n,h1,h2,...,hn,p1,p2). */
+ assert (buflen >= 21 * 4);
+
+ /* Construct the argument of LPRT (of the form af,n,h1,h2,...,hn,p1,p2). */
+ switch (addr->type)
+ {
+ case IPV4_ADDRESS:
+ ptr = ADDRESS_IPV4_DATA (addr);
+ snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d,%d,%d,%d", 4, 4,
+ ptr[0], ptr[1], ptr[2], ptr[3], 2,
+ (port & 0xff00) >> 8, port & 0xff);
+ buf[buflen - 1] = '\0';
+ break;
+ case IPV6_ADDRESS:
+ ptr = ADDRESS_IPV6_DATA (addr);
+ snprintf (buf, buflen, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+ 6, 16, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7],
+ ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15], 2,
+ (port & 0xff00) >> 8, port & 0xff);
+ buf[buflen - 1] = '\0';
+ break;
+ }
+}