-/* $OpenBSD: packet.c,v 1.16 2021/01/19 10:30:00 claudio Exp $ */
+/* $OpenBSD: packet.c,v 1.17 2021/01/19 16:02:22 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
int rip_hdr_sanity_check(struct rip_hdr *);
struct iface *find_iface(struct ripd_conf *, unsigned int, struct in_addr);
+static u_int8_t *recv_buf;
+
int
gen_rip_hdr(struct ibuf *buf, u_int8_t command)
{
void
recv_packet(int fd, short event, void *bula)
{
- static char pkt_ptr[READ_BUF_SIZE];
union {
struct cmsghdr hdr;
char buf[CMSG_SPACE(sizeof(struct sockaddr_dl))];
if (event != EV_READ)
return;
- /* setup buffer */
- buf = pkt_ptr;
+ if (recv_buf == NULL)
+ if ((recv_buf = malloc(READ_BUF_SIZE)) == NULL)
+ fatal(__func__);
+ /* setup buffer */
bzero(&msg, sizeof(msg));
-
- iov.iov_base = buf;
+ iov.iov_base = buf = recv_buf;
iov.iov_len = READ_BUF_SIZE;
msg.msg_name = &src;
msg.msg_namelen = sizeof(src);