summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2009-01-31 08:55:00 +0000
committerclaudio <claudio@openbsd.org>2009-01-31 08:55:00 +0000
commitb0caf98574b8d1c6b9ad596d9bd87c1fa7541386 (patch)
tree8cf9999ddb8035260d3948c883e9982bb77aa98d
parentAdd missing free. Found by norby@ in ospfctl, same fix. (diff)
downloadwireguard-openbsd-b0caf98574b8d1c6b9ad596d9bd87c1fa7541386.tar.xz
wireguard-openbsd-b0caf98574b8d1c6b9ad596d9bd87c1fa7541386.zip
Pass the buffer to send_packet() instead of spliting it up. This removes
some direct access to struct buf internals in the rest of ospfe. Based on a larger buffer cleanup diff that was OK norby@ henning@
-rw-r--r--usr.sbin/ospfd/database.c4
-rw-r--r--usr.sbin/ospfd/hello.c4
-rw-r--r--usr.sbin/ospfd/lsack.c4
-rw-r--r--usr.sbin/ospfd/lsreq.c4
-rw-r--r--usr.sbin/ospfd/lsupdate.c4
-rw-r--r--usr.sbin/ospfd/ospfe.h4
-rw-r--r--usr.sbin/ospfd/packet.c10
7 files changed, 17 insertions, 17 deletions
diff --git a/usr.sbin/ospfd/database.c b/usr.sbin/ospfd/database.c
index 3281d7e7cca..27634437968 100644
--- a/usr.sbin/ospfd/database.c
+++ b/usr.sbin/ospfd/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.24 2009/01/08 19:18:17 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.25 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -150,7 +150,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:
buf_free(buf);
return (ret);
diff --git a/usr.sbin/ospfd/hello.c b/usr.sbin/ospfd/hello.c
index 56b786a70bb..f1be89ee8e5 100644
--- a/usr.sbin/ospfd/hello.c
+++ b/usr.sbin/ospfd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.14 2007/10/11 12:19:31 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.15 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -104,7 +104,7 @@ send_hello(struct iface *iface)
if (auth_gen(buf, iface))
goto fail;
- ret = send_packet(iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(iface, buf, &dst);
buf_free(buf);
return (ret);
fail:
diff --git a/usr.sbin/ospfd/lsack.c b/usr.sbin/ospfd/lsack.c
index f2640d8d37a..81a118a1f03 100644
--- a/usr.sbin/ospfd/lsack.c
+++ b/usr.sbin/ospfd/lsack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsack.c,v 1.17 2006/04/25 08:33:00 claudio Exp $ */
+/* $OpenBSD: lsack.c,v 1.18 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -61,7 +61,7 @@ send_ls_ack(struct iface *iface, struct in_addr addr, void *data, size_t len)
if (auth_gen(buf, iface))
goto fail;
- ret = send_packet(iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(iface, buf, &dst);
buf_free(buf);
return (ret);
diff --git a/usr.sbin/ospfd/lsreq.c b/usr.sbin/ospfd/lsreq.c
index 99df7da5272..a7cc9358c43 100644
--- a/usr.sbin/ospfd/lsreq.c
+++ b/usr.sbin/ospfd/lsreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsreq.c,v 1.14 2006/03/13 09:36:06 claudio Exp $ */
+/* $OpenBSD: lsreq.c,v 1.15 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -80,7 +80,7 @@ send_ls_req(struct nbr *nbr)
if (auth_gen(buf, nbr->iface))
goto fail;
- ret = send_packet(nbr->iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(nbr->iface, buf, &dst);
buf_free(buf);
return (ret);
diff --git a/usr.sbin/ospfd/lsupdate.c b/usr.sbin/ospfd/lsupdate.c
index 385162a052d..de564db2da6 100644
--- a/usr.sbin/ospfd/lsupdate.c
+++ b/usr.sbin/ospfd/lsupdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsupdate.c,v 1.33 2008/02/11 12:37:37 norby Exp $ */
+/* $OpenBSD: lsupdate.c,v 1.34 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -217,7 +217,7 @@ send_ls_update(struct buf *buf, struct iface *iface, struct in_addr addr,
dst.sin_len = sizeof(struct sockaddr_in);
dst.sin_addr.s_addr = addr.s_addr;
- ret = send_packet(iface, buf->buf, buf->wpos, &dst);
+ ret = send_packet(iface, buf, &dst);
buf_free(buf);
return (ret);
diff --git a/usr.sbin/ospfd/ospfe.h b/usr.sbin/ospfd/ospfe.h
index 2136f910499..a6534d6541f 100644
--- a/usr.sbin/ospfd/ospfe.h
+++ b/usr.sbin/ospfd/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.38 2007/10/13 13:21:24 claudio Exp $ */
+/* $OpenBSD: ospfe.h,v 1.39 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -234,7 +234,7 @@ struct lsa_hdr *lsa_hdr_new(void);
/* packet.c */
int gen_ospf_hdr(struct buf *, struct iface *, u_int8_t);
-int send_packet(struct iface *, void *, size_t, struct sockaddr_in *);
+int send_packet(struct iface *, struct buf *, struct sockaddr_in *);
void recv_packet(int, short, void *);
char *pkt_ptr; /* packet buffer */
diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c
index 66851b2c941..fc95f414de0 100644
--- a/usr.sbin/ospfd/packet.c
+++ b/usr.sbin/ospfd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.26 2008/09/12 09:54:47 claudio Exp $ */
+/* $OpenBSD: packet.c,v 1.27 2009/01/31 08:55:00 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -59,7 +59,7 @@ gen_ospf_hdr(struct buf *buf, struct iface *iface, u_int8_t type)
/* send and receive packets */
int
-send_packet(struct iface *iface, void *pkt, size_t len, struct sockaddr_in *dst)
+send_packet(struct iface *iface, struct buf *buf, struct sockaddr_in *dst)
{
struct msghdr msg;
struct iovec iov[2];
@@ -70,7 +70,7 @@ send_packet(struct iface *iface, void *pkt, size_t len, struct sockaddr_in *dst)
ip_hdr.ip_v = IPVERSION;
ip_hdr.ip_hl = sizeof(ip_hdr) >> 2;
ip_hdr.ip_tos = IPTOS_PREC_INTERNETCONTROL;
- ip_hdr.ip_len = htons(len + sizeof(ip_hdr));
+ ip_hdr.ip_len = htons(buf->wpos + sizeof(ip_hdr));
ip_hdr.ip_id = 0; /* 0 means kernel set appropriate value */
ip_hdr.ip_off = 0;
ip_hdr.ip_ttl = iface->type != IF_TYPE_VIRTUALLINK ?
@@ -84,8 +84,8 @@ send_packet(struct iface *iface, void *pkt, size_t len, struct sockaddr_in *dst)
bzero(&msg, sizeof(msg));
iov[0].iov_base = &ip_hdr;
iov[0].iov_len = sizeof(ip_hdr);
- iov[1].iov_base = pkt;
- iov[1].iov_len = len;
+ iov[1].iov_base = buf->buf;
+ iov[1].iov_len = buf->wpos;
msg.msg_name = dst;
msg.msg_namelen = sizeof(*dst);
msg.msg_iov = iov;