[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/06: Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] 04/06: Define IN6ADDR_ANY and IN6ADDR_LOOPBACK. |
Date: |
Mon, 4 Jul 2022 05:52:41 -0400 (EDT) |
civodul pushed a commit to branch main
in repository guile.
commit 6da4be170ac40c8e86123d0e0d0907cb61e64872
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jul 4 11:39:14 2022 +0200
Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
* libguile/socket.c (scm_init_socket): Define IN6ADDR_ANY and
IN6ADDR_LOOPBACK.
* doc/ref/posix.texi (Network Address Conversion): Document them.
---
doc/ref/posix.texi | 17 ++++++++++++++++-
libguile/socket.c | 2 ++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 7633bd5a3..50085cd80 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -2524,7 +2524,22 @@ Make an IPv4 Internet address by combining the network
number
@cindex IPv6
An IPv6 Internet address is a 16-byte value, represented in Guile as
-an integer in host byte order, so that say ``::1'' is 1.
+an integer in host byte order, so that say ``::1'' is 1. The following
+constants are defined for convenience.
+
+@defvar IN6ADDR_ANY
+For a server, this can be used with @code{bind} (@pxref{Network Sockets
+and Communication}) to allow connections from any IPv6 interface on the
+machine.
+@end defvar
+
+@defvar IN6ADDR_LOOPBACK
+The address of the local host using the loopback device, ie.@:
+@samp{::1}.
+@end defvar
+
+The procedures below convert an IPv6 @emph{or} an IPv4 address to and
+from its textual representation.
@deffn {Scheme Procedure} inet-ntop family address
@deffnx {C Function} scm_inet_ntop (family, address)
diff --git a/libguile/socket.c b/libguile/socket.c
index 4818d62bd..3d5b89e63 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -1656,6 +1656,7 @@ scm_init_socket ()
/* standard addresses. */
#ifdef INADDR_ANY
scm_c_define ("INADDR_ANY", scm_from_ulong (INADDR_ANY));
+ scm_c_define ("IN6ADDR_ANY", scm_from_ulong (0));
#endif
#ifdef INADDR_BROADCAST
scm_c_define ("INADDR_BROADCAST", scm_from_ulong (INADDR_BROADCAST));
@@ -1665,6 +1666,7 @@ scm_init_socket ()
#endif
#ifdef INADDR_LOOPBACK
scm_c_define ("INADDR_LOOPBACK", scm_from_ulong (INADDR_LOOPBACK));
+ scm_c_define ("IN6ADDR_LOOPBACK", scm_from_ulong (1));
#endif
/* socket types.
- [Guile-commits] branch main updated (7e048c6c5 -> 8c976c6a1), Ludovic Courtès, 2022/07/04
- [Guile-commits] 02/06: web: Handle ending CRLF (\r\n) for chunked input and output ports., Ludovic Courtès, 2022/07/04
- [Guile-commits] 04/06: Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.,
Ludovic Courtès <=
- [Guile-commits] 03/06: web: Don't hide missing data in the chunked input port., Ludovic Courtès, 2022/07/04
- [Guile-commits] 05/06: Define IPPROTO_IPV6 and IPV6_V6ONLY., Ludovic Courtès, 2022/07/04
- [Guile-commits] 06/06: Update NEWS., Ludovic Courtès, 2022/07/04
- [Guile-commits] 01/06: web: send capitalized authorization header scheme, Ludovic Courtès, 2022/07/04