-/* $OpenBSD: engine.c,v 1.32 2017/05/30 14:56:34 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.33 2017/05/30 15:39:49 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
void gen_dfr_proposal(struct slaacd_iface *, struct
radv *);
void configure_dfr(struct dfr_proposal *);
+void withdraw_dfr(struct dfr_proposal *);
void debug_log_ra(struct imsg_ra *);
char *parse_dnssl(char *, int);
void update_iface_ra(struct slaacd_iface *, struct radv *);
engine_imsg_compose_main(IMSG_CONFIGURE_DFR, 0, &dfr, sizeof(dfr));
}
+void
+withdraw_dfr(struct dfr_proposal *dfr_proposal)
+{
+ struct imsg_configure_dfr dfr;
+
+ log_debug("%s: %d", __func__, dfr_proposal->if_index);
+
+ dfr.if_index = dfr_proposal->if_index;
+ memcpy(&dfr.addr, &dfr_proposal->addr, sizeof(dfr.addr));
+ dfr.router_lifetime = dfr_proposal->router_lifetime;
+
+ engine_imsg_compose_main(IMSG_WITHDRAW_DFR, 0, &dfr, sizeof(dfr));
+}
+
void
send_proposal(struct imsg_proposal *proposal)
{
dfr_proposal->router_lifetime) == 0) {
evtimer_del(&dfr_proposal->timer);
LIST_REMOVE(dfr_proposal, entries);
+ withdraw_dfr(dfr_proposal);
free(dfr_proposal);
log_debug("%s: removing dfr proposal", __func__);
break;
-/* $OpenBSD: slaacd.c,v 1.20 2017/05/29 20:31:31 florian Exp $ */
+/* $OpenBSD: slaacd.c,v 1.21 2017/05/30 15:39:49 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
"IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSALS",
"IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL",
"IMSG_CONFIGURE_DFR",
+ "IMSG_WITHDRAW_DFR",
};
__dead void usage(void);
void main_dispatch_engine(int, short, void *);
void handle_proposal(struct imsg_proposal *);
void configure_interface(struct imsg_configure_address *);
-void configure_gateway(struct imsg_configure_dfr *);
+void configure_gateway(struct imsg_configure_dfr *, uint8_t);
+void add_gateway(struct imsg_configure_dfr *);
+void delete_gateway(struct imsg_configure_dfr *);
static int main_imsg_send_ipc_sockets(struct imsgbuf *, struct imsgbuf *);
fatal("%s: IMSG_CONFIGURE_DFR wrong "
"length: %d", __func__, imsg.hdr.len);
memcpy(&dfr, imsg.data, sizeof(dfr));
- configure_gateway(&dfr);
+ add_gateway(&dfr);
+ break;
+ case IMSG_WITHDRAW_DFR:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(dfr))
+ fatal("%s: IMSG_CONFIGURE_DFR wrong "
+ "length: %d", __func__, imsg.hdr.len);
+ memcpy(&dfr, imsg.data, sizeof(dfr));
+ delete_gateway(&dfr);
break;
default:
log_debug("%s: error handling imsg %d", __func__,
}
void
-configure_gateway(struct imsg_configure_dfr *dfr)
+configure_gateway(struct imsg_configure_dfr *dfr, uint8_t rtm_type)
{
struct rt_msghdr rtm;
struct sockaddr_in6 dst, gw, mask;
memset(&rtm, 0, sizeof(rtm));
rtm.rtm_version = RTM_VERSION;
- rtm.rtm_type = RTM_ADD;
+ rtm.rtm_type = rtm_type;
rtm.rtm_msglen = sizeof(rtm);
rtm.rtm_tableid = 0; /* XXX imsg->rdomain; */
rtm.rtm_index = dfr->if_index;
}
if (writev(routesock, iov, iovcnt) == -1)
- log_warn("failed to send RTM_ADD");
+ log_warn("failed to send route message");
+}
+
+void
+add_gateway(struct imsg_configure_dfr *dfr)
+{
+ configure_gateway(dfr, RTM_ADD);
+}
+
+void
+delete_gateway(struct imsg_configure_dfr *dfr)
+{
+ configure_gateway(dfr, RTM_DELETE);
}