buf_unprepend(st->rbuf,2);
memcpy(&from.sin_port,buf_unprepend(st->rbuf,2),2);
}
+ struct comm_addr ca;
+ FILLZERO(ca);
+ ca.comm=&st->ops;
+ ca.sin=from;
done=False;
for (n=st->notify; n; n=n->next) {
- struct comm_addr ca;
- FILLZERO(ca);
- ca.comm=&st->ops;
- ca.sin=from;
if (n->fn(n->state, st->rbuf, &ca)) {
done=True;
break;
/* Manufacture and send NAK packet */
source=get_uint32(st->rbuf->start); /* Us */
dest=get_uint32(st->rbuf->start+4); /* Them */
- Message(M_INFO,"udp (port %d, peer %s):"
- " %08"PRIx32"<-%08"PRIx32": %08"PRIx32":"
- " unwanted/incorrect, sending NAK\n",
- st->port, saddr_to_string(&from),
- dest, source, msgtype);
- buffer_init(st->rbuf,0);
- buf_append_uint32(st->rbuf,dest);
- buf_append_uint32(st->rbuf,source);
- buf_append_uint32(st->rbuf,LABEL_NAK);
- sendto(st->fd, st->rbuf->start, st->rbuf->size, 0,
- (struct sockaddr *)&from, sizeof(from));
+ send_nak(&ca,source,dest,msgtype,st->rbuf,"unwanted");
}
BUF_FREE(st->rbuf);
}
#include <sys/wait.h>
#include "util.h"
#include "unaligned.h"
+#include "magic.h"
#define MIN_BUFFER_SIZE 64
#define DEFAULT_BUFFER_SIZE 4096
return new_closure(&st->cl);
}
+void send_nak(const struct comm_addr *dest, uint32_t our_index,
+ uint32_t their_index, uint32_t msgtype,
+ struct buffer_if *buf, const char *logwhy)
+{
+ buffer_init(buf,dest->comm->min_start_pad);
+ buf_append_uint32(buf,their_index);
+ buf_append_uint32(buf,our_index);
+ buf_append_uint32(buf,LABEL_NAK);
+ if (logwhy)
+ Message(M_INFO,"%s: %08"PRIx32"<-%08"PRIx32": %08"PRIx32":"
+ " %s; sending NAK\n",
+ dest->comm->addr_to_string(dest->comm->st,dest),
+ our_index, their_index, msgtype, logwhy);
+ dest->comm->sendmsg(dest->comm->st, buf, dest);
+}
+
int consttime_memeq(const void *s1in, const void *s2in, size_t n)
{
const uint8_t *s1=s1in, *s2=s2in;
extern struct log_if *init_log(list_t *loglist);
+extern void send_nak(const struct comm_addr *dest, uint32_t our_index,
+ uint32_t their_index, uint32_t msgtype,
+ struct buffer_if *buf, const char *logwhy);
+
extern int consttime_memeq(const void *s1, const void *s2, size_t n);
#endif /* util_h */