Constant correctness: socket(PF_*, ...) -> socket(AF_*, ...)

This commit is contained in:
Nicholas J. Kain 2011-06-25 11:11:48 -04:00
parent e50c429235
commit 7ee0001e97
5 changed files with 11 additions and 11 deletions

View File

@ -527,7 +527,7 @@ static int get_listen(void)
.sun_path = "/var/state/ifchange" .sun_path = "/var/state/ifchange"
}; };
lsock = socket(PF_UNIX, SOCK_STREAM, 0); lsock = socket(AF_UNIX, SOCK_STREAM, 0);
if (lsock == -1) if (lsock == -1)
suicide("dispatch_work - failed to create socket"); suicide("dispatch_work - failed to create socket");

View File

@ -132,7 +132,7 @@ static int set_if_flag(int idx, short flag)
if (!is_permitted(ifnam[idx])) if (!is_permitted(ifnam[idx]))
goto out0; goto out0;
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (set_if_flag) failed to open interface socket: %s\n", log_line("%s: (set_if_flag) failed to open interface socket: %s\n",
ifnam[idx], strerror(errno)); ifnam[idx], strerror(errno));
@ -184,7 +184,7 @@ void perform_ip(int idx, char *str)
sin.sin_addr = ipaddr; sin.sin_addr = ipaddr;
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr)); memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (perform_ip) failed to open interface socket: %s\n", log_line("%s: (perform_ip) failed to open interface socket: %s\n",
ifnam[idx], strerror(errno)); ifnam[idx], strerror(errno));
@ -217,7 +217,7 @@ void perform_subnet(int idx, char *str)
sin.sin_addr = subnet; sin.sin_addr = subnet;
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr)); memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (perform_ip) failed to open interface socket: %s\n", log_line("%s: (perform_ip) failed to open interface socket: %s\n",
ifnam[idx], strerror(errno)); ifnam[idx], strerror(errno));
@ -264,7 +264,7 @@ void perform_router(int idx, char *str)
rt.rt_dev = ifnam[idx]; rt.rt_dev = ifnam[idx];
rt.rt_metric = 1; rt.rt_metric = 1;
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (perform_router) failed to open interface socket: %s\n", log_line("%s: (perform_router) failed to open interface socket: %s\n",
ifnam[idx], strerror(errno)); ifnam[idx], strerror(errno));
@ -293,7 +293,7 @@ void perform_mtu(int idx, char *str)
ifrt.ifr_mtu = mtu; ifrt.ifr_mtu = mtu;
strlcpy(ifrt.ifr_name, ifnam[idx], IFNAMSIZ); strlcpy(ifrt.ifr_name, ifnam[idx], IFNAMSIZ);
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (perform_mtu) failed to open interface socket: %s\n", log_line("%s: (perform_mtu) failed to open interface socket: %s\n",
ifnam[idx], strerror(errno)); ifnam[idx], strerror(errno));
@ -325,7 +325,7 @@ void perform_broadcast(int idx, char *str)
sin.sin_addr = broadcast; sin.sin_addr = broadcast;
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr)); memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
fd = socket(PF_INET, SOCK_DGRAM, 0); fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) { if (fd == -1) {
log_line("%s: (perform_broadcast) failed to open interface socket: %s\n", ifnam[idx], strerror(errno)); log_line("%s: (perform_broadcast) failed to open interface socket: %s\n", ifnam[idx], strerror(errno));
return; return;

View File

@ -69,7 +69,7 @@ static int arpping(struct client_state_t *cs, uint32_t test_ip,
struct arpMsg arp; struct arpMsg arp;
if (cs->arpFd == -1) { if (cs->arpFd == -1) {
int arpfd = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)); int arpfd = socket(AF_PACKET, SOCK_PACKET, htons(ETH_P_ARP));
if (arpfd == -1) { if (arpfd == -1) {
log_error("arp: failed to create socket: %s", strerror(errno)); log_error("arp: failed to create socket: %s", strerror(errno));
return -1; return -1;

View File

@ -64,7 +64,7 @@ int nl_open(struct client_state_t *cs)
assert(cs->nlFd == -1); assert(cs->nlFd == -1);
cs->nlFd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); cs->nlFd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (cs->nlFd == -1) if (cs->nlFd == -1)
return -1; return -1;

View File

@ -56,7 +56,7 @@ static int create_udp_listen_socket(unsigned int ip, int port, char *inf)
int opt = 1; int opt = 1;
log_line("Opening listen socket on 0x%08x:%d %s", ip, port, inf); log_line("Opening listen socket on 0x%08x:%d %s", ip, port, inf);
if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
log_error("create_udp_listen_socket: socket failed: %s", log_error("create_udp_listen_socket: socket failed: %s",
strerror(errno)); strerror(errno));
goto out; goto out;
@ -364,7 +364,7 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip,
int opt = 1, fd, result = -1; int opt = 1, fd, result = -1;
unsigned int padding; unsigned int padding;
if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
goto out; goto out;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) == -1) if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) == -1)