From 4f4fe40bc9d06de09f4af934b87299ab1ee3cc66 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 21 Aug 2024 15:18:00 +0000 Subject: [PATCH] Mechanically replace inet_aton with inet_pton. OK claudio, deraadt --- usr.sbin/ospfd/database.c | 4 ++-- usr.sbin/ospfd/hello.c | 4 ++-- usr.sbin/ospfd/interface.c | 12 ++++++------ usr.sbin/ospfd/lsack.c | 8 ++++---- usr.sbin/ospfd/lsreq.c | 4 ++-- usr.sbin/ospfd/lsupdate.c | 6 +++--- usr.sbin/ospfd/packet.c | 11 +++++------ 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/usr.sbin/ospfd/database.c b/usr.sbin/ospfd/database.c index 5fec976e819..07005f2c3fc 100644 --- a/usr.sbin/ospfd/database.c +++ b/usr.sbin/ospfd/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.37 2023/06/20 15:19:55 claudio Exp $ */ +/* $OpenBSD: database.c,v 1.38 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -116,7 +116,7 @@ send_db_description(struct nbr *nbr) switch (nbr->iface->type) { case IF_TYPE_POINTOPOINT: - inet_aton(AllSPFRouters, &dst.sin_addr); + inet_pton(AF_INET, AllSPFRouters, &dst.sin_addr); dd_hdr.iface_mtu = htons(nbr->iface->mtu); break; case IF_TYPE_BROADCAST: diff --git a/usr.sbin/ospfd/hello.c b/usr.sbin/ospfd/hello.c index 5b66a92fd21..adbb18862e8 100644 --- a/usr.sbin/ospfd/hello.c +++ b/usr.sbin/ospfd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.26 2022/12/28 21:30:18 jmc Exp $ */ +/* $OpenBSD: hello.c,v 1.27 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -48,7 +48,7 @@ send_hello(struct iface *iface) switch (iface->type) { case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: - inet_aton(AllSPFRouters, &dst.sin_addr); + inet_pton(AF_INET, AllSPFRouters, &dst.sin_addr); break; case IF_TYPE_NBMA: case IF_TYPE_POINTOMULTIPOINT: diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index c47268c4a4e..96edbaeaee0 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.87 2023/03/08 04:43:14 guenther Exp $ */ +/* $OpenBSD: interface.c,v 1.88 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -352,7 +352,7 @@ if_act_start(struct iface *iface) switch (iface->type) { case IF_TYPE_POINTOPOINT: - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); if (if_join_group(iface, &addr)) return (-1); iface->state = IF_STA_POINTTOPOINT; @@ -366,7 +366,7 @@ if_act_start(struct iface *iface) if_type_name(iface->type), iface->name); return (-1); case IF_TYPE_BROADCAST: - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); if (if_join_group(iface, &addr)) return (-1); if (iface->priority == 0) { @@ -502,7 +502,7 @@ start: iface->bdr = bdr; if (changed) { - inet_aton(AllDRouters, &addr); + inet_pton(AF_INET, AllDRouters, &addr); if (old_state & IF_STA_DRORBDR && (iface->state & IF_STA_DRORBDR) == 0) { if (if_leave_group(iface, &addr)) @@ -543,10 +543,10 @@ if_act_reset(struct iface *iface) case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: /* try to cleanup */ - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); if_leave_group(iface, &addr); if (iface->state & IF_STA_DRORBDR) { - inet_aton(AllDRouters, &addr); + inet_pton(AF_INET, AllDRouters, &addr); if_leave_group(iface, &addr); } break; diff --git a/usr.sbin/ospfd/lsack.c b/usr.sbin/ospfd/lsack.c index 78cd67added..1255a54a3d3 100644 --- a/usr.sbin/ospfd/lsack.c +++ b/usr.sbin/ospfd/lsack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsack.c,v 1.24 2023/03/08 04:43:14 guenther Exp $ */ +/* $OpenBSD: lsack.c,v 1.25 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -268,14 +268,14 @@ ls_ack_tx_timer(int fd, short event, void *arg) /* send LS ack(s) but first set correct destination */ switch (iface->type) { case IF_TYPE_POINTOPOINT: - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); send_ls_ack(iface, addr, buf); break; case IF_TYPE_BROADCAST: if (iface->state & IF_STA_DRORBDR) - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); else - inet_aton(AllDRouters, &addr); + inet_pton(AF_INET, AllDRouters, &addr); send_ls_ack(iface, addr, buf); break; case IF_TYPE_NBMA: diff --git a/usr.sbin/ospfd/lsreq.c b/usr.sbin/ospfd/lsreq.c index 6b513ba369e..f8949c3d4df 100644 --- a/usr.sbin/ospfd/lsreq.c +++ b/usr.sbin/ospfd/lsreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsreq.c,v 1.24 2023/03/08 04:43:14 guenther Exp $ */ +/* $OpenBSD: lsreq.c,v 1.25 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -45,7 +45,7 @@ send_ls_req(struct nbr *nbr) switch (nbr->iface->type) { case IF_TYPE_POINTOPOINT: - inet_aton(AllSPFRouters, &dst.sin_addr); + inet_pton(AF_INET, AllSPFRouters, &dst.sin_addr); break; case IF_TYPE_BROADCAST: case IF_TYPE_NBMA: diff --git a/usr.sbin/ospfd/lsupdate.c b/usr.sbin/ospfd/lsupdate.c index 27415eaecb8..7a9872a0bbc 100644 --- a/usr.sbin/ospfd/lsupdate.c +++ b/usr.sbin/ospfd/lsupdate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsupdate.c,v 1.53 2023/06/21 07:44:08 claudio Exp $ */ +/* $OpenBSD: lsupdate.c,v 1.54 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -457,7 +457,7 @@ ls_retrans_timer(int fd, short event, void *bula) * because the router switched lately to DR or BDR */ if (le->le_oneshot && nbr->iface->state & IF_STA_DRORBDR) - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); else if (nbr->iface->state & IF_STA_DRORBDR) { /* * old retransmission needs to be converted into @@ -471,7 +471,7 @@ ls_retrans_timer(int fd, short event, void *bula) } else if (nbr->iface->type == IF_TYPE_POINTOPOINT) memcpy(&addr, &nbr->addr, sizeof(addr)); else - inet_aton(AllDRouters, &addr); + inet_pton(AF_INET, AllDRouters, &addr); } else memcpy(&addr, &nbr->addr, sizeof(addr)); diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c index 33372711009..be8b295f1d6 100644 --- a/usr.sbin/ospfd/packet.c +++ b/usr.sbin/ospfd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.37 2023/07/03 09:40:47 claudio Exp $ */ +/* $OpenBSD: packet.c,v 1.38 2024/08/21 15:18:00 florian Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -184,9 +184,9 @@ recv_packet(int fd, short event, void *bula) * or to the address of the interface itself. * AllDRouters is only valid for DR and BDR but this is checked later. */ - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); if (ip_hdr.ip_dst.s_addr != addr.s_addr) { - inet_aton(AllDRouters, &addr); + inet_pton(AF_INET, AllDRouters, &addr); if (ip_hdr.ip_dst.s_addr != addr.s_addr) { if (ip_hdr.ip_dst.s_addr != iface->addr.s_addr) { log_debug("recv_packet: packet sent to wrong " @@ -230,7 +230,7 @@ recv_packet(int fd, short event, void *bula) /* switch OSPF packet type */ switch (ospf_hdr->type) { case PACKET_TYPE_HELLO: - inet_aton(AllSPFRouters, &addr); + inet_pton(AF_INET, AllSPFRouters, &addr); if (iface->type == IF_TYPE_BROADCAST || iface->type == IF_TYPE_POINTOPOINT) if (ip_hdr.ip_dst.s_addr != addr.s_addr) { @@ -313,8 +313,7 @@ ospf_hdr_sanity_check(const struct ip *ip_hdr, struct ospf_hdr *ospf_hdr, } if (iface->type == IF_TYPE_BROADCAST || iface->type == IF_TYPE_NBMA) { - if (inet_aton(AllDRouters, &addr) == 0) - fatalx("recv_packet: inet_aton"); + inet_pton(AF_INET, AllDRouters, &addr); if (ip_hdr->ip_dst.s_addr == addr.s_addr && (iface->state & IF_STA_DRORBDR) == 0) { log_debug("recv_packet: invalid destination IP in " -- 2.20.1