]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-addr.c
Merge changes from CUPS 1.4svn-r7874.
[thirdparty/cups.git] / cups / http-addr.c
index 58504ca1df68c0a6e48649cf6773fbc3f649b39e..0bc71f6fa711f08e172bd68cfd5a0127bef06672 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: http-addr.c 6816 2007-08-20 20:16:00Z mike $"
+ * "$Id: http-addr.c 6814 2007-08-20 20:09:25Z mike $"
  *
  *   HTTP address routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -18,6 +18,7 @@
  *   httpAddrEqual()     - Compare two addresses.
  *   httpAddrLocalhost() - Check for the local loopback address.
  *   httpAddrLookup()    - Lookup the hostname associated with the address.
+ *   _httpAddrPort()     - Get the port number associated with an address.
  *   httpAddrString()    - Convert an IP address to a dotted string.
  *   httpGetHostByName() - Lookup a hostname or IP address, and return
  *                         address records for the specified name.
@@ -241,6 +242,26 @@ httpAddrLookup(
 }
 
 
+/*
+ * '_httpAddrPort()' - Get the port number associated with an address.
+ */
+
+int                                    /* O - Port number */
+_httpAddrPort(http_addr_t *addr)       /* I - Address */
+{
+  if (!addr)
+    return (ippPort());
+#ifdef AF_INET6
+  else if (addr->addr.sa_family == AF_INET6)
+    return (ntohs(addr->ipv6.sin6_port));
+#endif /* AF_INET6 */
+  else if (addr->addr.sa_family == AF_INET)
+    return (ntohs(addr->ipv4.sin_port));
+  else
+    return (ippPort());
+}
+
+
 /*
  * 'httpAddrString()' - Convert an address to a numeric string.
  *
@@ -552,5 +573,5 @@ httpGetHostname(http_t *http,               /* I - HTTP connection or NULL */
 
 
 /*
- * End of "$Id: http-addr.c 6816 2007-08-20 20:16:00Z mike $".
+ * End of "$Id: http-addr.c 6814 2007-08-20 20:09:25Z mike $".
  */