Re: prefer AF_* over PF_*

2016-05-29 Thread Martin Natano
On Sat, May 28, 2016 at 07:55:00PM -0700, Philip Guenther wrote:
> 
> About the only place userland code should use PF_* socket constants is 
> with sysctl(3)'s CTL_NET hierarchy.  All the standardized functions are 
> defined as taking AF_* values.  Let's use the preferred names in the 
> getaddrinfo(3) and socketpair(2) manpages.
> 
> ok?

POSIX only mentions AF_*. ok natano@


> 
> Philip Guenther
> 
> Index: net/getaddrinfo.3
> ===
> RCS file: /data/src/openbsd/src/lib/libc/net/getaddrinfo.3,v
> retrieving revision 1.57
> diff -u -p -r1.57 getaddrinfo.3
> --- net/getaddrinfo.3 16 Feb 2015 18:26:56 -  1.57
> +++ net/getaddrinfo.3 20 May 2016 00:06:21 -
> @@ -94,7 +94,7 @@ The protocol family that should be used.
>  When
>  .Fa ai_family
>  is set to
> -.Dv PF_UNSPEC ,
> +.Dv AF_UNSPEC ,
>  it means the caller will accept any protocol family supported by the
>  operating system.
>  .It Fa ai_socktype
> @@ -229,7 +229,7 @@ behaves as if the caller provided a
>  with
>  .Fa ai_family
>  set to
> -.Dv PF_UNSPEC ,
> +.Dv AF_UNSPEC ,
>  .Fa ai_flags
>  set to
>  .Dv AI_ADDRCONFIG ,
> @@ -351,7 +351,7 @@ int s;
>  const char *cause = NULL;
>  
>  memset(, 0, sizeof(hints));
> -hints.ai_family = PF_UNSPEC;
> +hints.ai_family = AF_UNSPEC;
>  hints.ai_socktype = SOCK_STREAM;
>  error = getaddrinfo("www.kame.net", "www", , );
>  if (error)
> @@ -393,7 +393,7 @@ int nsock;
>  const char *cause = NULL;
>  
>  memset(, 0, sizeof(hints));
> -hints.ai_family = PF_UNSPEC;
> +hints.ai_family = AF_UNSPEC;
>  hints.ai_socktype = SOCK_STREAM;
>  hints.ai_flags = AI_PASSIVE;
>  error = getaddrinfo(NULL, "www", , );
> Index: sys/socketpair.2
> ===
> RCS file: /data/src/openbsd/src/lib/libc/sys/socketpair.2,v
> retrieving revision 1.19
> diff -u -p -r1.19 socketpair.2
> --- sys/socketpair.2  19 Mar 2016 22:10:49 -  1.19
> +++ sys/socketpair.2  20 May 2016 00:05:48 -
> @@ -124,7 +124,7 @@ This call is currently implemented only 
>  Many operating systems only accept a
>  .Fa protocol
>  of
> -.Dv PF_UNSPEC ,
> +.Dv AF_UNSPEC ,
>  so that should be used instead of
> -.Dv PF_LOCAL
> +.Dv AF_LOCAL
>  for maximal portability.
> 



prefer AF_* over PF_*

2016-05-28 Thread Philip Guenther

About the only place userland code should use PF_* socket constants is 
with sysctl(3)'s CTL_NET hierarchy.  All the standardized functions are 
defined as taking AF_* values.  Let's use the preferred names in the 
getaddrinfo(3) and socketpair(2) manpages.

ok?

Philip Guenther

Index: net/getaddrinfo.3
===
RCS file: /data/src/openbsd/src/lib/libc/net/getaddrinfo.3,v
retrieving revision 1.57
diff -u -p -r1.57 getaddrinfo.3
--- net/getaddrinfo.3   16 Feb 2015 18:26:56 -  1.57
+++ net/getaddrinfo.3   20 May 2016 00:06:21 -
@@ -94,7 +94,7 @@ The protocol family that should be used.
 When
 .Fa ai_family
 is set to
-.Dv PF_UNSPEC ,
+.Dv AF_UNSPEC ,
 it means the caller will accept any protocol family supported by the
 operating system.
 .It Fa ai_socktype
@@ -229,7 +229,7 @@ behaves as if the caller provided a
 with
 .Fa ai_family
 set to
-.Dv PF_UNSPEC ,
+.Dv AF_UNSPEC ,
 .Fa ai_flags
 set to
 .Dv AI_ADDRCONFIG ,
@@ -351,7 +351,7 @@ int s;
 const char *cause = NULL;
 
 memset(, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
+hints.ai_family = AF_UNSPEC;
 hints.ai_socktype = SOCK_STREAM;
 error = getaddrinfo("www.kame.net", "www", , );
 if (error)
@@ -393,7 +393,7 @@ int nsock;
 const char *cause = NULL;
 
 memset(, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
+hints.ai_family = AF_UNSPEC;
 hints.ai_socktype = SOCK_STREAM;
 hints.ai_flags = AI_PASSIVE;
 error = getaddrinfo(NULL, "www", , );
Index: sys/socketpair.2
===
RCS file: /data/src/openbsd/src/lib/libc/sys/socketpair.2,v
retrieving revision 1.19
diff -u -p -r1.19 socketpair.2
--- sys/socketpair.219 Mar 2016 22:10:49 -  1.19
+++ sys/socketpair.220 May 2016 00:05:48 -
@@ -124,7 +124,7 @@ This call is currently implemented only 
 Many operating systems only accept a
 .Fa protocol
 of
-.Dv PF_UNSPEC ,
+.Dv AF_UNSPEC ,
 so that should be used instead of
-.Dv PF_LOCAL
+.Dv AF_LOCAL
 for maximal portability.