Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Replace PF_* constants with AF_*
Browse files Browse the repository at this point in the history
AF_* constants appear to be more standardized, and in practice there's
always a one to one relationship between AF_* and PF_*, so let's
use AF_* instead of PF_*.

* xlat/domains.in: Remove.
* net.c: Do not define PF_UNSPEC.  Stop including "xlat/domains.h".
Replace PF_* with AF_*.  Replace domains with addrfams.
* tests/inet-cmsg.c: Replace PF_INET with AF_INET.
* tests/net-yy-inet.c: Likewise.
* tests/netlink_inet_diag.c: Likewise.
* tests/net-accept-connect.c: Replace PF_LOCAL with AF_LOCAL.
* tests/net-y-unix.c: Likewise.
* tests/net-yy-unix.c: Likewise.
* tests/netlink_unix_diag.c: Likewise.
* tests/net.expected: Replace PF_ with AF_.
  • Loading branch information
ldv-alt committed Apr 4, 2016
1 parent 2aa9b32 commit 71fe62e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 87 deletions.
32 changes: 14 additions & 18 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@
# include <bluetooth/rfcomm.h>
# include <bluetooth/sco.h>
#endif
#ifndef PF_UNSPEC
# define PF_UNSPEC AF_UNSPEC
#endif

#include "xlat/domains.h"
#include "xlat/addrfams.h"
#include "xlat/socktypes.h"
#include "xlat/sock_type_flags.h"
Expand All @@ -99,7 +95,7 @@

#include "xlat/inet_protocols.h"

#ifdef PF_NETLINK
#ifdef AF_NETLINK
# if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
# endif
Expand Down Expand Up @@ -790,32 +786,32 @@ tprint_sock_type(int flags)

SYS_FUNC(socket)
{
printxval(domains, tcp->u_arg[0], "PF_???");
printxval(addrfams, tcp->u_arg[0], "AF_???");
tprints(", ");
tprint_sock_type(tcp->u_arg[1]);
tprints(", ");
switch (tcp->u_arg[0]) {
case PF_INET:
#ifdef PF_INET6
case PF_INET6:
case AF_INET:
#ifdef AF_INET6
case AF_INET6:
#endif
printxval(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
break;
#ifdef PF_IPX
case PF_IPX:
#ifdef AF_IPX
case AF_IPX:
/* BTW: I don't believe this.. */
tprints("[");
printxval(domains, tcp->u_arg[2], "PF_???");
printxval(addrfams, tcp->u_arg[2], "AF_???");
tprints("]");
break;
#endif /* PF_IPX */
#ifdef PF_NETLINK
case PF_NETLINK:
#endif /* AF_IPX */
#ifdef AF_NETLINK
case AF_NETLINK:
printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
break;
#endif
#if defined(PF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
case PF_BLUETOOTH:
#if defined(AF_BLUETOOTH) && defined(HAVE_BLUETOOTH_BLUETOOTH_H)
case AF_BLUETOOTH:
printxval(bt_protocols, tcp->u_arg[2], "BTPROTO_???");
break;
#endif
Expand Down Expand Up @@ -1126,7 +1122,7 @@ SYS_FUNC(pipe2)
SYS_FUNC(socketpair)
{
if (entering(tcp)) {
printxval(domains, tcp->u_arg[0], "PF_???");
printxval(addrfams, tcp->u_arg[0], "AF_???");
tprints(", ");
tprint_sock_type(tcp->u_arg[1]);
tprintf(", %lu", tcp->u_arg[2]);
Expand Down
4 changes: 2 additions & 2 deletions tests/inet-cmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ main(void)
assert(!close(0));
assert(!close(3));

if (socket(PF_INET, SOCK_DGRAM, 0))
if (socket(AF_INET, SOCK_DGRAM, 0))
perror_msg_and_skip("socket");
struct sockaddr_in addr = {
.sin_family = AF_INET,
Expand All @@ -106,7 +106,7 @@ main(void)
perror_msg_and_skip("bind");
assert(!getsockname(0, (struct sockaddr *) &addr, &len));

assert(socket(PF_INET, SOCK_DGRAM, 0) == 3);
assert(socket(AF_INET, SOCK_DGRAM, 0) == 3);
assert(!connect(3, (struct sockaddr *) &addr, len));

const int opt_1 = htonl(0x01000000);
Expand Down
4 changes: 2 additions & 2 deletions tests/net-accept-connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main(int ac, const char **av)
close(0);
close(1);

if (socket(PF_LOCAL, SOCK_STREAM, 0))
if (socket(AF_LOCAL, SOCK_STREAM, 0))
perror_msg_and_skip("socket");
if (bind(0, (struct sockaddr *) &addr, len))
perror_msg_and_skip("bind");
Expand Down Expand Up @@ -93,7 +93,7 @@ main(int ac, const char **av)

assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0);
assert(signal(SIGUSR1, handler) != SIG_ERR);
assert(socket(PF_LOCAL, SOCK_STREAM, 0) == 1);
assert(socket(AF_LOCAL, SOCK_STREAM, 0) == 1);
assert(close(0) == 0);
assert(connect(1, (struct sockaddr *) &addr, len) == 0);
assert(sigprocmask(SIG_UNBLOCK, &set, NULL) == 0);
Expand Down
12 changes: 6 additions & 6 deletions tests/net-y-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ main(int ac, const char **av)
if (*len > sizeof(addr))
*len = sizeof(addr);

int listen_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
int listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (listen_fd < 0)
perror_msg_and_skip("socket");
unsigned long listen_inode = inode_of_sockfd(listen_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
listen_fd, listen_inode);

(void) unlink(av[1]);
Expand Down Expand Up @@ -87,11 +87,11 @@ main(int ac, const char **av)
", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode,
av[1], (unsigned) *len);

int connect_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
int connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (connect_fd < 0)
perror_msg_and_fail("socket");
unsigned long connect_inode = inode_of_sockfd(connect_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
connect_fd, connect_inode);

if (connect(connect_fd, listen_sa, *len))
Expand Down Expand Up @@ -141,11 +141,11 @@ main(int ac, const char **av)
assert(close(accept_fd) == 0);
printf("close(%d<socket:[%lu]>) = 0\n", accept_fd, accept_inode);

connect_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (connect_fd < 0)
perror_msg_and_fail("socket");
connect_inode = inode_of_sockfd(connect_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<socket:[%lu]>\n",
connect_fd, connect_inode);

*optval = 1;
Expand Down
8 changes: 4 additions & 4 deletions tests/net-yy-inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ main(void)
socklen_t * const len = tail_alloc(sizeof(socklen_t));
*len = sizeof(addr);

const int listen_fd = socket(PF_INET, SOCK_STREAM, 0);
const int listen_fd = socket(AF_INET, SOCK_STREAM, 0);
if (listen_fd < 0)
perror_msg_and_skip("socket");
const unsigned long listen_inode = inode_of_sockfd(listen_fd);
printf("socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = %d<TCP:[%lu]>\n",
printf("socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = %d<TCP:[%lu]>\n",
listen_fd, listen_inode);

if (bind(listen_fd, listen_sa, *len))
Expand Down Expand Up @@ -85,11 +85,11 @@ main(void)
", [%u], [%u]) = 0\n",
listen_fd, listen_port, *optval, (unsigned) *len);

const int connect_fd = socket(PF_INET, SOCK_STREAM, 0);
const int connect_fd = socket(AF_INET, SOCK_STREAM, 0);
if (connect_fd < 0)
perror_msg_and_fail("socket");
const unsigned long connect_inode = inode_of_sockfd(connect_fd);
printf("socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = %d<TCP:[%lu]>\n",
printf("socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = %d<TCP:[%lu]>\n",
connect_fd, connect_inode);

*len = sizeof(addr);
Expand Down
12 changes: 6 additions & 6 deletions tests/net-yy-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ main(int ac, const char **av)
if (*len > sizeof(addr))
*len = sizeof(addr);

int listen_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
int listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (listen_fd < 0)
perror_msg_and_skip("socket");
unsigned long listen_inode = inode_of_sockfd(listen_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
listen_fd, listen_inode);

(void) unlink(av[1]);
Expand Down Expand Up @@ -88,11 +88,11 @@ main(int ac, const char **av)
", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode,
av[1], av[1], (unsigned) *len);

int connect_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
int connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (connect_fd < 0)
perror_msg_and_fail("socket");
unsigned long connect_inode = inode_of_sockfd(connect_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
connect_fd, connect_inode);

if (connect(connect_fd, listen_sa, *len))
Expand Down Expand Up @@ -144,11 +144,11 @@ main(int ac, const char **av)
printf("close(%d<UNIX:[%lu->%lu,\"%s\"]>) = 0\n",
accept_fd, accept_inode, connect_inode, av[1]);

connect_fd = socket(PF_LOCAL, SOCK_STREAM, 0);
connect_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (connect_fd < 0)
perror_msg_and_fail("socket");
connect_inode = inode_of_sockfd(connect_fd);
printf("socket(PF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
printf("socket(AF_LOCAL, SOCK_STREAM, 0) = %d<UNIX:[%lu]>\n",
connect_fd, connect_inode);

*optval = 1;
Expand Down
4 changes: 2 additions & 2 deletions tests/net.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 1
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +socket\(AF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +socket\(AF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 1
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +bind\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, 19\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +listen\(0, 5\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +getsockname\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, \[19\]\) += 0
Expand Down
4 changes: 2 additions & 2 deletions tests/netlink_inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ int main(void)
close(0);
close(1);

if (socket(PF_INET, SOCK_STREAM, 0))
perror_msg_and_skip("socket PF_INET");
if (socket(AF_INET, SOCK_STREAM, 0))
perror_msg_and_skip("socket AF_INET");
if (bind(0, (struct sockaddr *) &addr, len))
perror_msg_and_skip("bind");
if (listen(0, 5))
Expand Down
4 changes: 2 additions & 2 deletions tests/netlink_unix_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ int main(void)
close(1);

(void) unlink(SUN_PATH);
if (socket(PF_LOCAL, SOCK_STREAM, 0))
perror_msg_and_skip("socket PF_LOCAL");
if (socket(AF_LOCAL, SOCK_STREAM, 0))
perror_msg_and_skip("socket AF_LOCAL");
if (bind(0, (struct sockaddr *) &addr, len))
perror_msg_and_skip("bind");
if (listen(0, 5))
Expand Down
43 changes: 0 additions & 43 deletions xlat/domains.in

This file was deleted.

0 comments on commit 71fe62e

Please sign in to comment.