-/* $OpenBSD: packet.c,v 1.6 2021/01/19 11:46:10 claudio Exp $ */
+/* $OpenBSD: packet.c,v 1.7 2021/01/19 16:02:56 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
u_int16_t, const struct iface *);
struct iface *find_iface(struct dvmrpd_conf *, struct in_addr);
-extern struct dvmrpd_conf *deconf;
+static u_int8_t *recv_buf;
int
gen_dvmrp_hdr(struct ibuf *buf, struct iface *iface, u_int8_t code)
struct nbr *nbr = NULL;
struct in_addr addr;
char *buf;
- char pkt[READ_BUF_SIZE];
ssize_t r;
u_int16_t len;
int l;
if (event != EV_READ)
return;
- if ((r = recvfrom(fd, pkt, sizeof(pkt), 0, NULL, NULL)) == -1) {
+ if (recv_buf == NULL)
+ if ((recv_buf = malloc(READ_BUF_SIZE)) == NULL)
+ fatal(__func__);
+
+ buf = recv_buf;
+ if ((r = recvfrom(fd, buf, READ_BUF_SIZE, 0, NULL, NULL)) == -1) {
if (errno != EAGAIN && errno != EINTR)
log_debug("recv_packet: error receiving packet");
return;
}
len = (u_int16_t)r;
- buf = pkt;
/* IP header sanity checks */
if (len < sizeof(ip_hdr)) {