a static memory region. Just use the stack.
-/* $OpenBSD: dvmrpd.h,v 1.22 2016/09/02 16:20:34 benno Exp $ */
+/* $OpenBSD: dvmrpd.h,v 1.23 2021/01/19 11:46:10 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
#define NBR_IDSELF 1
#define NBR_CNTSTART (NBR_IDSELF + 1)
+#define READ_BUF_SIZE 65535
#define RT_BUF_SIZE 16384
#define DVMRPD_FLAG_NO_FIB_UPDATE 0x0001
-/* $OpenBSD: dvmrpe.c,v 1.19 2016/09/02 16:20:34 benno Exp $ */
+/* $OpenBSD: dvmrpe.c,v 1.20 2021/01/19 11:46:10 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
TAILQ_INIT(&ctl_conns);
control_listen();
- if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL)
- fatal("dvmrpe");
-
/* start interfaces */
LIST_FOREACH(iface, &deconf->iface_list, entry) {
if_init(xconf, iface);
/* clean up */
free(iev_rde);
free(iev_main);
- free(pkt_ptr);
log_info("dvmrp engine exiting");
_exit(0);
-/* $OpenBSD: dvmrpe.h,v 1.5 2014/10/25 03:23:49 lteo Exp $ */
+/* $OpenBSD: dvmrpe.h,v 1.6 2021/01/19 11:46:10 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
int send_packet(struct iface *, void *, size_t, struct sockaddr_in *);
void recv_packet(int, short, void *);
-char *pkt_ptr; /* packet buffer */
-
/* probe.c */
int send_probe(struct iface *);
void recv_probe(struct iface *, struct in_addr, u_int32_t, u_int8_t,
-/* $OpenBSD: packet.c,v 1.5 2015/12/07 19:14:49 mmcc Exp $ */
+/* $OpenBSD: packet.c,v 1.6 2021/01/19 11:46:10 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
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;
- /* setup buffer */
- buf = pkt_ptr;
-
- if ((r = recvfrom(fd, buf, IBUF_READ_SIZE, 0, NULL, NULL)) == -1) {
+ if ((r = recvfrom(fd, pkt, sizeof(pkt), 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)) {