-/* $OpenBSD: rtr_proto.c,v 1.20 2023/12/27 12:00:30 claudio Exp $ */
+/* $OpenBSD: rtr_proto.c,v 1.21 2024/01/03 16:07:37 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
RTR_STATE_CLOSED,
RTR_STATE_ERROR,
/* sessions with a state below this line will poll for incoming data */
- RTR_STATE_IDLE,
- RTR_STATE_ACTIVE,
+ RTR_STATE_ESTABLISHED,
+ RTR_STATE_EXCHANGE,
RTR_STATE_NEGOTIATION,
};
static const char *rtr_statenames[] = {
"closed",
"error",
- "idle",
- "active",
+ "established",
+ "exchange",
"negotiation",
};
static int
rtr_parse_notify(struct rtr_session *rs, uint8_t *buf, size_t len)
{
- if (rs->state == RTR_STATE_ACTIVE ||
+ if (rs->state == RTR_STATE_EXCHANGE ||
rs->state == RTR_STATE_NEGOTIATION) {
log_warnx("rtr %s: received %s: while in state %s (ignored)",
log_rtr(rs), log_rtr_type(SERIAL_NOTIFY),
static int
rtr_parse_cache_response(struct rtr_session *rs, uint8_t *buf, size_t len)
{
- if (rs->state != RTR_STATE_IDLE && rs->state != RTR_STATE_NEGOTIATION) {
+ if (rs->state != RTR_STATE_ESTABLISHED &&
+ rs->state != RTR_STATE_NEGOTIATION) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(CACHE_RESPONSE));
return -1;
return -1;
}
- if (rs->state != RTR_STATE_ACTIVE) {
+ if (rs->state != RTR_STATE_EXCHANGE) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(IPV4_PREFIX));
rtr_send_error(rs, CORRUPT_DATA, NULL, buf, len);
return -1;
}
- if (rs->state != RTR_STATE_ACTIVE) {
+ if (rs->state != RTR_STATE_EXCHANGE) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(IPV6_PREFIX));
rtr_send_error(rs, CORRUPT_DATA, NULL, buf, len);
return -1;
}
- if (rs->state != RTR_STATE_ACTIVE) {
+ if (rs->state != RTR_STATE_EXCHANGE) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(ASPA));
rtr_send_error(rs, CORRUPT_DATA, NULL, buf, len);
return -1;
}
- if (rs->state != RTR_STATE_ACTIVE) {
+ if (rs->state != RTR_STATE_EXCHANGE) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(END_OF_DATA));
return -1;
static int
rtr_parse_cache_reset(struct rtr_session *rs, uint8_t *buf, size_t len)
{
- if (rs->state != RTR_STATE_IDLE) {
+ if (rs->state != RTR_STATE_ESTABLISHED) {
log_warnx("rtr %s: received %s: out of context",
log_rtr(rs), log_rtr_type(CACHE_RESET));
return -1;
rs->active_lock = 0;
break;
case RTR_EVNT_CACHE_RESPONSE:
- rs->state = RTR_STATE_ACTIVE;
+ rs->state = RTR_STATE_EXCHANGE;
timer_stop(&rs->timers, Timer_Rtr_Refresh);
timer_stop(&rs->timers, Timer_Rtr_Retry);
timer_set(&rs->timers, Timer_Rtr_Active, rs->active);
timer_set(&rs->timers, Timer_Rtr_Refresh, rs->refresh);
timer_set(&rs->timers, Timer_Rtr_Expire, rs->expire);
timer_stop(&rs->timers, Timer_Rtr_Active);
- rs->state = RTR_STATE_IDLE;
+ rs->state = RTR_STATE_ESTABLISHED;
rtr_sem_release(rs->active_lock);
rtr_recalc();
rs->active_lock = 0;
timer_set(&rs->timers, Timer_Rtr_Retry, rs->retry);
/* stop refresh timer just to be sure */
timer_stop(&rs->timers, Timer_Rtr_Refresh);
- rs->state = RTR_STATE_IDLE;
+ rs->state = RTR_STATE_ESTABLISHED;
break;
case RTR_EVNT_SEND_ERROR:
rtr_reset_cache(rs);
if (rs->w.queued)
pfd->events |= POLLOUT;
- if (rs->state >= RTR_STATE_IDLE)
+ if (rs->state >= RTR_STATE_ESTABLISHED)
pfd->events |= POLLIN;
}