-/* $OpenBSD: control.c,v 1.1 2018/07/10 16:39:54 florian Exp $ */
+/* $OpenBSD: control.c,v 1.2 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
- case IMSG_CTL_SHOW_MAIN_INFO:
- c->iev.ibuf.pid = imsg.hdr.pid;
- frontend_imsg_compose_main(imsg.hdr.type, imsg.hdr.pid,
- imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE);
- break;
- case IMSG_CTL_SHOW_FRONTEND_INFO:
- frontend_showinfo_ctl(c);
- imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1,
- NULL, 0);
- break;
- case IMSG_CTL_SHOW_ENGINE_INFO:
- c->iev.ibuf.pid = imsg.hdr.pid;
- frontend_imsg_compose_engine(imsg.hdr.type,
- imsg.hdr.pid,
- imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE);
- break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
-/* $OpenBSD: engine.c,v 1.2 2018/07/10 22:13:16 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.3 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
void engine_sig_handler(int sig, short, void *);
void engine_dispatch_frontend(int, short, void *);
void engine_dispatch_main(int, short, void *);
-void engine_showinfo_ctl(struct imsg *);
void parse_ra_rs(struct imsg_ra_rs *);
void parse_ra(struct imsg_ra_rs *);
void parse_rs(struct imsg_ra_rs *);
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
- case IMSG_CTL_SHOW_ENGINE_INFO:
- engine_showinfo_ctl(&imsg);
- break;
default:
log_debug("%s: unexpected imsg %d", __func__,
imsg.hdr.type);
}
}
-void
-engine_showinfo_ctl(struct imsg *imsg)
-{
- char filter[IF_NAMESIZE];
- struct ctl_engine_info cei;
- struct ra_iface_conf *ra_iface_conf;
-
- switch (imsg->hdr.type) {
- case IMSG_CTL_SHOW_ENGINE_INFO:
- memcpy(filter, imsg->data, sizeof(filter));
- SIMPLEQ_FOREACH(ra_iface_conf, &engine_conf->ra_iface_list,
- entry) {
- if (filter[0] == '\0' || memcmp(filter,
- ra_iface_conf->name, sizeof(filter)) == 0) {
- memcpy(cei.name, ra_iface_conf->name,
- sizeof(cei.name));
-
- engine_imsg_compose_frontend(
- IMSG_CTL_SHOW_ENGINE_INFO, imsg->hdr.pid,
- &cei, sizeof(cei));
- }
- }
- engine_imsg_compose_frontend(IMSG_CTL_END, imsg->hdr.pid, NULL,
- 0);
- break;
- default:
- log_debug("%s: error handling imsg", __func__);
- break;
- }
-}
void
parse_ra_rs(struct imsg_ra_rs *ra_rs)
-/* $OpenBSD: frontend.c,v 1.1 2018/07/10 16:39:54 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.2 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
fatal("pledge");
frontend_startup();
break;
- case IMSG_CTL_END:
- case IMSG_CTL_SHOW_MAIN_INFO:
- control_imsg_relay(&imsg);
- break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
break;
switch (imsg.hdr.type) {
- case IMSG_CTL_END:
- case IMSG_CTL_SHOW_ENGINE_INFO:
- control_imsg_relay(&imsg);
- break;
case IMSG_SEND_RA:
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(send_ra))
fatal("%s: IMSG_SEND_RA wrong length: %d",
}
}
-void
-frontend_showinfo_ctl(struct ctl_conn *c)
-{
- static struct ctl_frontend_info cfi;
-
- imsg_compose_event(&c->iev, IMSG_CTL_SHOW_FRONTEND_INFO, 0, 0, -1,
- &cfi, sizeof(struct ctl_frontend_info));
-}
-
void
frontend_startup(void)
{
-/* $OpenBSD: frontend.h,v 1.1 2018/07/10 16:39:54 florian Exp $ */
+/* $OpenBSD: frontend.h,v 1.2 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
void frontend_dispatch_engine(int, short, void *);
int frontend_imsg_compose_main(int, pid_t, void *, uint16_t);
int frontend_imsg_compose_engine(int, pid_t, void *, uint16_t);
-void frontend_showinfo_ctl(struct ctl_conn *);
-/* $OpenBSD: rad.c,v 1.1 2018/07/10 16:39:54 florian Exp $ */
+/* $OpenBSD: rad.c,v 1.2 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
const char* imsg_type_name[] = {
"IMSG_NONE",
"IMSG_CTL_LOG_VERBOSE",
- "IMSG_CTL_RELOAD",
- "IMSG_CTL_SHOW_ENGINE_INFO",
- "IMSG_CTL_SHOW_FRONTEND_INFO",
- "IMSG_CTL_SHOW_MAIN_INFO",
- "IMSG_CTL_END",
"IMSG_RECONF_CONF",
"IMSG_RECONF_RA_IFACE",
"IMSG_RECONF_RA_AUTOPREFIX",
int main_reload(void);
int main_sendboth(enum imsg_type, void *, uint16_t);
-void main_showinfo_ctl(struct imsg *);
void free_ra_iface_conf(struct ra_iface_conf *);
void in6_prefixlen2mask(struct in6_addr *, int len);
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
- case IMSG_CTL_SHOW_MAIN_INFO:
- main_showinfo_ctl(&imsg);
- break;
default:
log_debug("%s: error handling imsg %s", __func__,
imsg_type_name[imsg.hdr.type]);
return (0);
}
-void
-main_showinfo_ctl(struct imsg *imsg)
-{
- struct ctl_main_info cmi;
- size_t n;
-
- switch (imsg->hdr.type) {
- case IMSG_CTL_SHOW_MAIN_INFO:
- memset(cmi.text, 0, sizeof(cmi.text));
- n = strlcpy(cmi.text, "I'm a little teapot.",
- sizeof(cmi.text));
- if (n >= sizeof(cmi.text))
- log_debug("%s: I was cut off!", __func__);
- main_imsg_compose_frontend(IMSG_CTL_SHOW_MAIN_INFO,
- imsg->hdr.pid, &cmi, sizeof(cmi));
- memset(cmi.text, 0, sizeof(cmi.text));
- n = strlcpy(cmi.text, "Full of sencha.",
- sizeof(cmi.text));
- if (n >= sizeof(cmi.text))
- log_debug("%s: I was cut off!", __func__);
- main_imsg_compose_frontend(IMSG_CTL_SHOW_MAIN_INFO,
- imsg->hdr.pid, &cmi, sizeof(cmi));
- main_imsg_compose_frontend(IMSG_CTL_END, imsg->hdr.pid, NULL,
- 0);
- break;
- default:
- log_debug("%s: error handling imsg", __func__);
- break;
- }
-}
-
void
free_ra_iface_conf(struct ra_iface_conf *ra_iface_conf)
{
-/* $OpenBSD: rad.h,v 1.1 2018/07/10 16:39:54 florian Exp $ */
+/* $OpenBSD: rad.h,v 1.2 2018/07/10 22:14:19 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
IMSG_NONE,
IMSG_CTL_LOG_VERBOSE,
IMSG_CTL_RELOAD,
- IMSG_CTL_SHOW_ENGINE_INFO,
- IMSG_CTL_SHOW_FRONTEND_INFO,
- IMSG_CTL_SHOW_MAIN_INFO,
- IMSG_CTL_END,
IMSG_RECONF_CONF,
IMSG_RECONF_RA_IFACE,
IMSG_RECONF_RA_AUTOPREFIX,
SIMPLEQ_HEAD(ra_iface_conf_head, ra_iface_conf) ra_iface_list;
};
-struct ctl_frontend_info {
- int yesno;
- int integer;
- char global_text[RAD_MAXTEXT];
-};
-
-struct ctl_engine_info {
- char name[IF_NAMESIZE];
- int yesno;
- int integer;
-};
-
-struct ctl_main_info {
- char text[RAD_MAXTEXT];
-};
-
struct imsg_ra_rs {
uint32_t if_index;
struct sockaddr_in6 from;