goto fail;
}
r->sa.sin.sin_family = AF_INET;
- r->sasz = sizeof(r->sa.sin);
r->addr = xstrdup(av[i]);
if (!av[i + 1])
pt = TRIPE_PORT;
T( trace(T_ADMIN, "admin: done add op %s", BGTAG(add)); )
if (rc == ARES_OK) {
- add->peer.sasz = add->r.sasz;
add->peer.sa = add->r.sa;
if (p_findbyaddr(&add->r.sa))
a_bgfail(&add->r.bg, "peer-addr-exists", "?ADDR", &add->r.sa, A_END);
static int p_dotxend(peer *p)
{
+ socklen_t sasz = addrsz(&p->spec.sa);
+
if (!BOK(&p->b)) {
a_warn("PEER", "?PEER", p, "packet-build-failed", A_END);
return (0);
IF_TRACING(T_PEER, trace_block(T_PACKET, "peer: sending packet",
BBASE(&p->b), BLEN(&p->b)); )
if (sendto(sock.fd, BBASE(&p->b), BLEN(&p->b),
- 0, &p->spec.sa.sa, p->spec.sasz) < 0) {
+ 0, &p->spec.sa.sa, sasz) < 0) {
a_warn("PEER", "?PEER", p, "socket-write-error", "?ERRNO", A_END);
return (0);
} else {
}
}
+/* --- @addrsz@ --- *
+ *
+ * Arguments: @const addr *a@ = a network address
+ *
+ * Returns: The size of the address, for passing into the sockets API.
+ */
+
+socklen_t addrsz(const addr *a)
+{
+ switch (a->sa.sa_family) {
+ case AF_INET: return (sizeof(a->sin));
+ default: abort();
+ }
+}
+
/*----- That's all, folks -------------------------------------------------*/
const tunnel_ops *tops; /* Tunnel operations */
unsigned long t_ka; /* Keep alive interval */
addr sa; /* Socket address to speak to */
- size_t sasz; /* Socket address size */
unsigned f; /* Flags for the peer */
#define PSF_KXMASK 255u /* Key-exchange flags to set */
#define PSF_MOBILE 256u /* Address may change rapidly */
extern int mystrieq(const char */*x*/, const char */*y*/);
+/* --- @addrsz@ --- *
+ *
+ * Arguments: @const addr *a@ = a network address
+ *
+ * Returns: The size of the address, for passing into the sockets API.
+ */
+
+extern socklen_t addrsz(const addr */*a*/);
+
/* --- @seq_reset@ --- *
*
* Arguments: @seqwin *s@ = sequence-checking window