summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authordenis <denis@cvs.openbsd.org>2019-12-11 21:33:57 +0000
committerdenis <denis@cvs.openbsd.org>2019-12-11 21:33:57 +0000
commit6b9c3b04d0b7af28e22cebc656403319b0064ebc (patch)
tree259845fd70c478660493cc4205cc2ffe93a37b18 /usr.sbin
parentfd707b4be35280be3af34fe6b461275d589933de (diff)
Convert sendto() to sendmsg().
This makes code similar to ospfd(8). OK claudio@ deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ospf6d/database.c4
-rw-r--r--usr.sbin/ospf6d/hello.c4
-rw-r--r--usr.sbin/ospf6d/lsack.c4
-rw-r--r--usr.sbin/ospf6d/lsreq.c4
-rw-r--r--usr.sbin/ospf6d/lsupdate.c4
-rw-r--r--usr.sbin/ospf6d/ospfe.h4
-rw-r--r--usr.sbin/ospf6d/packet.c19
7 files changed, 26 insertions, 17 deletions
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index 93f13a01402..d8dc8558d4b 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.16 2019/05/10 13:50:34 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.17 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -147,7 +147,7 @@ send_db_description(struct nbr *nbr)
goto fail;
/* transmit packet */
- ret = send_packet(nbr->iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(nbr->iface, buf, &dst);
done:
ibuf_free(buf);
return (ret);
diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c
index 13dff3a94fd..186af93895c 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.18 2018/02/22 07:43:29 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.19 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -104,7 +104,7 @@ send_hello(struct iface *iface)
if (upd_ospf_hdr(buf, iface))
goto fail;
- ret = send_packet(iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(iface, buf, &dst);
ibuf_free(buf);
return (ret);
diff --git a/usr.sbin/ospf6d/lsack.c b/usr.sbin/ospf6d/lsack.c
index e8287a449f7..26aa263af91 100644
--- a/usr.sbin/ospf6d/lsack.c
+++ b/usr.sbin/ospf6d/lsack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsack.c,v 1.6 2014/10/25 03:23:49 lteo Exp $ */
+/* $OpenBSD: lsack.c,v 1.7 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -55,7 +55,7 @@ send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len)
if (upd_ospf_hdr(buf, iface))
goto fail;
- ret = send_packet(iface, buf->buf, buf->wpos, &addr);
+ ret = send_packet(iface, buf, &addr);
ibuf_free(buf);
return (ret);
diff --git a/usr.sbin/ospf6d/lsreq.c b/usr.sbin/ospf6d/lsreq.c
index ac28dd8762e..0817771ec2e 100644
--- a/usr.sbin/ospf6d/lsreq.c
+++ b/usr.sbin/ospf6d/lsreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsreq.c,v 1.9 2019/05/10 13:50:34 claudio Exp $ */
+/* $OpenBSD: lsreq.c,v 1.10 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -77,7 +77,7 @@ send_ls_req(struct nbr *nbr)
if (upd_ospf_hdr(buf, nbr->iface))
goto fail;
- ret = send_packet(nbr->iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(nbr->iface, buf, &dst);
ibuf_free(buf);
return (ret);
diff --git a/usr.sbin/ospf6d/lsupdate.c b/usr.sbin/ospf6d/lsupdate.c
index 6e40d0da65b..d85fb17a37c 100644
--- a/usr.sbin/ospf6d/lsupdate.c
+++ b/usr.sbin/ospf6d/lsupdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsupdate.c,v 1.13 2015/01/28 22:03:17 bluhm Exp $ */
+/* $OpenBSD: lsupdate.c,v 1.14 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -227,7 +227,7 @@ send_ls_update(struct ibuf *buf, struct iface *iface, struct in6_addr addr,
if (upd_ospf_hdr(buf, iface))
goto fail;
- ret = send_packet(iface, buf->buf, buf->wpos, &addr);
+ ret = send_packet(iface, buf, &addr);
ibuf_free(buf);
return (ret);
diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h
index face4fb6aca..ba011ca0a85 100644
--- a/usr.sbin/ospf6d/ospfe.h
+++ b/usr.sbin/ospf6d/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.19 2014/10/25 03:23:49 lteo Exp $ */
+/* $OpenBSD: ospfe.h,v 1.20 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -228,7 +228,7 @@ struct lsa_hdr *lsa_hdr_new(void);
/* packet.c */
int gen_ospf_hdr(struct ibuf *, struct iface *, u_int8_t);
int upd_ospf_hdr(struct ibuf *, struct iface *);
-int send_packet(struct iface *, void *, size_t, struct in6_addr *);
+int send_packet(struct iface *, struct ibuf *, struct in6_addr *);
void recv_packet(int, short, void *);
char *pkt_ptr; /* packet buffer */
diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c
index be1f5ef862a..8c30b41cdba 100644
--- a/usr.sbin/ospf6d/packet.c
+++ b/usr.sbin/ospf6d/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.15 2019/05/10 01:29:31 guenther Exp $ */
+/* $OpenBSD: packet.c,v 1.16 2019/12/11 21:33:56 denis Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -78,10 +78,12 @@ upd_ospf_hdr(struct ibuf *buf, struct iface *iface)
/* send and receive packets */
int
-send_packet(struct iface *iface, void *pkt, size_t len,
+send_packet(struct iface *iface, struct ibuf *buf,
struct in6_addr *dst)
{
- struct sockaddr_in6 sa6;
+ struct sockaddr_in6 sa6;
+ struct msghdr msg;
+ struct iovec iov[1];
/* setup buffer */
bzero(&sa6, sizeof(sa6));
@@ -102,8 +104,15 @@ send_packet(struct iface *iface, void *pkt, size_t len,
return (-1);
}
- if (sendto(iface->fd, pkt, len, 0, (struct sockaddr *)&sa6,
- sizeof(sa6)) == -1) {
+ bzero(&msg, sizeof(msg));
+ msg.msg_name = &sa6;
+ msg.msg_namelen = sizeof(sa6);
+ iov[0].iov_base = buf->buf;
+ iov[0].iov_len = ibuf_size(buf);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+
+ if (sendmsg(iface->fd, &msg, 0) == -1) {
log_warn("send_packet: error sending packet on interface %s",
iface->name);
return (-1);