-/* $OpenBSD: ikev2.c,v 1.369 2023/06/13 08:45:41 claudio Exp $ */
+/* $OpenBSD: ikev2.c,v 1.370 2023/06/13 12:34:12 tb Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
print_map(hdr->ike_exchange, ikev2_exchange_map),
msg->msg_response ? "res" : "req",
msg->msg_msgid,
- print_host((struct sockaddr *)&msg->msg_peer, NULL, 0),
- print_host((struct sockaddr *)&msg->msg_local, NULL, 0),
+ print_addr(&msg->msg_peer),
+ print_addr(&msg->msg_local),
ibuf_length(msg->msg_data),
msg->msg_policy->pol_name);
log_debug("%s: ispi %s rspi %s", __func__,
sa->sa_fd = msg->msg_fd;
log_debug("%s: updated SA to peer %s local %s", __func__,
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0));
+ print_addr(&sa->sa_peer.addr), print_addr(&sa->sa_local.addr));
done:
if (initiator)
if (sa->sa_cp == IKEV2_CP_REPLY) {
if (sa->sa_cp_addr)
log_info("%s: obtained lease: %s", SPI_SA(sa, __func__),
- print_host((struct sockaddr *)&sa->sa_cp_addr->addr,
- NULL, 0));
+ print_addr(&sa->sa_cp_addr->addr));
if (sa->sa_cp_addr6)
log_info("%s: obtained lease: %s", SPI_SA(sa, __func__),
- print_host((struct sockaddr *)&sa->sa_cp_addr6->addr,
- NULL, 0));
+ print_addr(&sa->sa_cp_addr6->addr));
if (sa->sa_cp_dns)
log_info("%s: obtained DNS: %s", SPI_SA(sa, __func__),
- print_host((struct sockaddr *)&sa->sa_cp_dns->addr,
- NULL, 0));
+ print_addr(&sa->sa_cp_dns->addr));
}
return ikev2_ike_auth(env, sa);
log_debug("%s: detected NAT, enabling UDP encapsulation,"
" updated SA to peer %s local %s", __func__,
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0));
+ print_addr(&sa->sa_peer.addr), print_addr(&sa->sa_local.addr));
}
void
if (ikev2_init_ike_sa_peer(env, pol, &pol->pol_peer, NULL))
log_debug("%s: failed to initiate with peer %s",
- __func__,
- print_host((struct sockaddr *)&pol->pol_peer.addr,
- NULL, 0));
+ __func__, print_addr(&pol->pol_peer.addr));
}
timer_set(env, &env->sc_inittmr, ikev2_init_ike_sa, NULL);
frompeer ? "peer" : "local",
print_spi(betoh64(ispi), 8),
print_spi(betoh64(rspi), 8),
- print_host(src, NULL, 0));
+ print_addr(src));
ss = src;
break;
case IKEV2_N_NAT_DETECTION_DESTINATION_IP:
frompeer ? "peer" : "local",
print_spi(betoh64(ispi), 8),
print_spi(betoh64(rspi), 8),
- print_host(dst, NULL, 0));
+ print_addr(dst));
ss = dst;
break;
default:
(struct sockaddr *)&sa->sa_local.addr, sa->sa_local.addr.ss_len)
== -1)
log_warn("%s: sendtofrom: peer %s local %s", __func__,
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0));
+ print_addr(&sa->sa_peer.addr),
+ print_addr(&sa->sa_local.addr));
else
log_debug("%s: peer %s local %s", __func__,
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0));
+ print_addr(&sa->sa_peer.addr),
+ print_addr(&sa->sa_local.addr));
ikestat_inc(env, ikes_keepalive_sent);
timer_add(env, &sa->sa_keepalive, IKED_IKE_SA_KEEPALIVE_TIMEOUT);
}
fputs(", ", flowf);
fprintf(flowf, "%s-%s/%d%s%s%s%s%s=%s/%d(%u)%s",
print_map(flow->flow_saproto, ikev2_saproto_map),
- print_host((struct sockaddr *)&flow->flow_src.addr,
- NULL, 0),
+ print_addr(&flow->flow_src.addr),
flow->flow_src.addr_mask,
flow->flow_prenat.addr_af != 0 ? "[": "",
flow->flow_prenat.addr_af != 0 ?
- print_host((struct sockaddr *)
- &flow->flow_prenat.addr, NULL, 0) : "",
+ print_addr(&flow->flow_prenat.addr) : "",
flow->flow_prenat.addr_af != 0 ? "/" : "",
flow->flow_prenat.addr_af != 0 ? prenat_mask : "",
flow->flow_prenat.addr_af != 0 ? "]": "",
- print_host((struct sockaddr *)&flow->flow_dst.addr,
- NULL, 0),
+ print_addr(&flow->flow_dst.addr),
flow->flow_dst.addr_mask,
flow->flow_ipproto,
reload ? "-R" : "");
memcpy(&sa->sa_peer_loaded, &sa->sa_peer,
sizeof(sa->sa_peer_loaded));
log_debug("%s: remember SA peer %s", __func__,
- print_host((struct sockaddr *)&sa->sa_peer_loaded.addr,
- NULL, 0));
+ print_addr(&sa->sa_peer_loaded.addr));
}
fflush(spif);
log_info(
"%s: giving up assigned address %s to IKESA %s",
SPI_SA(osa, __func__),
- print_host((struct sockaddr *)
- &sa->sa_addrpool->addr, NULL, 0),
+ print_addr(&sa->sa_addrpool->addr),
print_spi(sa->sa_hdr.sh_ispi, 8));
}
if (sa->sa_addrpool6) {
log_info(
"%s: giving up assigned v6 address %s to IKESA %s",
SPI_SA(osa, __func__),
- print_host((struct sockaddr *)
- &sa->sa_addrpool6->addr, NULL, 0),
+ print_addr(&sa->sa_addrpool6->addr),
print_spi(sa->sa_hdr.sh_ispi, 8));
}
if (family == AF_INET && sa->sa_addrpool != NULL)
if (ikev2_print_id(IKESA_DSTID(sa), idstr, sizeof(idstr)) == -1)
bzero(idstr, sizeof(idstr));
log_info("%sassigned address %s to %s%s", SPI_SA(sa, NULL),
- print_host((struct sockaddr *)&addr.addr, NULL, 0),
+ print_addr(&addr.addr),
idstr, requested ? " (requested by peer)" : "");
return (0);
}
return -1;
log_info("%s: old %s new %s", SPI_SA(sa, __func__),
- print_host((struct sockaddr *)&sa->sa_peer_loaded.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0));
+ print_addr(&sa->sa_peer_loaded.addr),
+ print_addr(&sa->sa_peer.addr));
TAILQ_FOREACH(csa, &sa->sa_childsas, csa_entry) {
if (!csa->csa_loaded)
msg, sa,
print_spi(sa->sa_hdr.sh_rspi, 8),
print_spi(sa->sa_hdr.sh_ispi, 8),
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0),
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0),
+ print_addr(&sa->sa_local.addr),
+ print_addr(&sa->sa_peer.addr),
idstr,
- sa->sa_addrpool ?
- print_host((struct sockaddr *)&sa->sa_addrpool->addr, NULL, 0) : "",
+ sa->sa_addrpool ? print_addr(&sa->sa_addrpool->addr) : "",
print_map(sa->sa_state, ikev2_state_map),
sa->sa_hdr.sh_initiator ? 'i' : 'r',
sa->sa_natt ? " natt" : "",
print_map(csa->csa_saproto, ikev2_saproto_map),
print_spi(csa->csa_spi.spi, csa->csa_spi.spi_size),
csa->csa_dir == IPSP_DIRECTION_IN ? "in" : "out",
- print_host((struct sockaddr *)&csa->csa_local->addr, NULL, 0),
- print_host((struct sockaddr *)&csa->csa_peer->addr, NULL, 0),
+ print_addr(&csa->csa_local->addr),
+ print_addr(&csa->csa_peer->addr),
csa->csa_loaded ? "L" : "",
csa->csa_rekey ? "R" : "",
csa->csa_allocated ? "A" : "",
"%s: %p %s %s %s/%d -> %s/%d %s%s%s%s%s[%u]@%d (%s) @%p\n", msg, flow,
print_map(flow->flow_saproto, ikev2_saproto_map),
flow->flow_dir == IPSP_DIRECTION_IN ? "in" : "out",
- print_host((struct sockaddr *)&flow->flow_src.addr, NULL, 0),
+ print_addr(&flow->flow_src.addr),
flow->flow_src.addr_mask,
- print_host((struct sockaddr *)&flow->flow_dst.addr, NULL, 0),
+ print_addr(&flow->flow_dst.addr),
flow->flow_dst.addr_mask,
flow->flow_prenat.addr_af != 0 ? "[": "",
- flow->flow_prenat.addr_af != 0 ? print_host((struct sockaddr *)
- &flow->flow_prenat.addr, NULL, 0) : "",
+ flow->flow_prenat.addr_af != 0 ?
+ print_addr(&flow->flow_prenat.addr) : "",
flow->flow_prenat.addr_af != 0 ? "/" : "",
flow->flow_prenat.addr_af != 0 ? prenat_mask : "",
flow->flow_prenat.addr_af != 0 ? "] ": "",
log_info(
"%sestablished peer %s[%s] local %s[%s]%s%s%s%s policy '%s'%s"
" (enc %s%s%s group %s prf %s)", SPI_SA(sa, NULL),
- print_host((struct sockaddr *)&sa->sa_peer.addr, NULL, 0), dstid,
- print_host((struct sockaddr *)&sa->sa_local.addr, NULL, 0), srcid,
+ print_addr(&sa->sa_peer.addr), dstid,
+ print_addr(&sa->sa_local.addr), srcid,
sa->sa_addrpool ? " assigned " : "",
- sa->sa_addrpool ?
- print_host((struct sockaddr *)&sa->sa_addrpool->addr, NULL, 0) : "",
+ sa->sa_addrpool ? print_addr(&sa->sa_addrpool->addr) : "",
sa->sa_addrpool6 ? " assigned " : "",
- sa->sa_addrpool6 ?
- print_host((struct sockaddr *)&sa->sa_addrpool6->addr, NULL, 0) : "",
+ sa->sa_addrpool6 ? print_addr(&sa->sa_addrpool6->addr) : "",
sa->sa_policy ? sa->sa_policy->pol_name : "",
sa->sa_hdr.sh_initiator ? " as initiator" : " as responder",
print_xf(sa->sa_encr->encr_id, cipher_keylength(sa->sa_encr) -