send_packet(int fd, int af, union ldpd_addr *dst, struct iface_af *ia,
void *pkt, size_t len)
{
- struct sockaddr *sa;
+ union sockunion su;
switch (af) {
case AF_INET:
fatalx("send_packet: unknown af");
}
- sa = addr2sa(af, dst, LDP_PORT);
- if (sendto(fd, pkt, len, 0, sa, sockaddr_len(sa)) == -1) {
+ addr2sa(af, dst, LDP_PORT, &su);
+ if (sendto(fd, pkt, len, 0, &su.sa, sockaddr_len(&su.sa)) == -1) {
log_warn("%s: error sending packet to %s", __func__,
- log_sockaddr(sa));
+ log_sockaddr(&su.sa));
return (-1);
}
struct in_addr lsr_id;
/* reschedule read */
- *threadp = thread_add_read(master, disc_recv_packet, threadp, fd,
- NULL);
+ *threadp = NULL;
+ thread_add_read(master, disc_recv_packet, threadp, fd, threadp);
/* setup buffer */
memset(&m, 0, sizeof(m));
uint16_t pdu_len, msg_len, msg_size, max_pdu_len;
int ret;
- tcp->rev = thread_add_read(master, session_read, nbr, fd, NULL);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, fd, &tcp->rev);
if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos,
sizeof(tcp->rbuf->buf) - tcp->rbuf->wpos)) == -1) {
msg_len = ntohs(msg->length);
if (msg_len < LDP_MSG_LEN ||
(msg_len + LDP_MSG_DEAD_LEN) > pdu_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
+ session_shutdown(nbr, S_BAD_MSG_LEN, msg->id,
msg->type);
free(buf);
return (0);
len -= msg_size;
}
free(buf);
+ buf = NULL;
if (len != 0) {
session_shutdown(nbr, S_BAD_PDU_LEN, 0, 0);
return (0);
}
}
+ /* shouldn't happen, session_get_pdu should be > 0 if buf was
+ * allocated - but let's get rid of the SA warning.
+ */
+ free(buf);
return (0);
}
if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL)
fatal(__func__);
- tcp->rev = thread_add_read(master, session_read, nbr, tcp->fd,
- NULL);
+ tcp->rev = NULL;
+ thread_add_read(master, session_read, nbr, tcp->fd, &tcp->rev);
tcp->nbr = nbr;
}
pconn->af = af;
pconn->addr = *addr;
TAILQ_INSERT_TAIL(&global.pending_conns, pconn, entry);
- pconn->ev_timeout = thread_add_timer(master, pending_conn_timeout,
- pconn, PENDING_CONN_TIMEOUT,
- NULL);
+ pconn->ev_timeout = NULL;
+ thread_add_timer(master, pending_conn_timeout, pconn, PENDING_CONN_TIMEOUT,
+ &pconn->ev_timeout);
return (pconn);
}