Lines Matching full:env
34 config_init(struct relayd *env)
36 struct privsep *ps = env->sc_ps;
41 env->sc_conf.timeout.tv_sec = CHECK_TIMEOUT / 1000;
42 env->sc_conf.timeout.tv_usec = (CHECK_TIMEOUT % 1000) * 1000;
43 env->sc_conf.interval.tv_sec = CHECK_INTERVAL;
44 env->sc_conf.interval.tv_usec = 0;
45 env->sc_conf.prefork_relay = RELAY_NUMPROC;
46 env->sc_conf.statinterval.tv_sec = RELAY_STATINTERVAL;
47 env->sc_ps->ps_csock.cs_name = RELAYD_SOCKET;
60 if ((env->sc_tables =
61 calloc(1, sizeof(*env->sc_tables))) == NULL)
63 TAILQ_INIT(env->sc_tables);
65 memset(&env->sc_empty_table, 0, sizeof(env->sc_empty_table));
66 env->sc_empty_table.conf.id = EMPTY_TABLE;
67 env->sc_empty_table.conf.flags |= F_DISABLE;
68 (void)strlcpy(env->sc_empty_table.conf.name, "empty",
69 sizeof(env->sc_empty_table.conf.name));
73 if ((env->sc_rdrs =
74 calloc(1, sizeof(*env->sc_rdrs))) == NULL)
76 TAILQ_INIT(env->sc_rdrs);
80 if ((env->sc_relays =
81 calloc(1, sizeof(*env->sc_relays))) == NULL)
83 TAILQ_INIT(env->sc_relays);
85 if ((env->sc_certs =
86 calloc(1, sizeof(*env->sc_certs))) == NULL)
88 TAILQ_INIT(env->sc_certs);
90 if ((env->sc_pkeys =
91 calloc(1, sizeof(*env->sc_pkeys))) == NULL)
93 TAILQ_INIT(env->sc_pkeys);
96 if ((env->sc_protos =
97 calloc(1, sizeof(*env->sc_protos))) == NULL)
99 TAILQ_INIT(env->sc_protos);
101 bzero(&env->sc_proto_default, sizeof(env->sc_proto_default));
102 env->sc_proto_default.id = EMPTY_ID;
103 env->sc_proto_default.flags = F_USED;
104 env->sc_proto_default.tcpflags = TCPFLAG_DEFAULT;
105 env->sc_proto_default.tcpbacklog = RELAY_BACKLOG;
106 env->sc_proto_default.tlsflags = TLSFLAG_DEFAULT;
107 TAILQ_INIT(&env->sc_proto_default.tlscerts);
108 (void)strlcpy(env->sc_proto_default.tlsciphers,
110 sizeof(env->sc_proto_default.tlsciphers));
111 (void)strlcpy(env->sc_proto_default.tlsecdhecurves,
113 sizeof(env->sc_proto_default.tlsecdhecurves));
114 (void)strlcpy(env->sc_proto_default.tlsdhparams,
116 sizeof(env->sc_proto_default.tlsdhparams));
117 env->sc_proto_default.type = RELAY_PROTO_TCP;
118 (void)strlcpy(env->sc_proto_default.name, "default",
119 sizeof(env->sc_proto_default.name));
122 if ((env->sc_rts =
123 calloc(1, sizeof(*env->sc_rts))) == NULL)
125 TAILQ_INIT(env->sc_rts);
128 if ((env->sc_routes =
129 calloc(1, sizeof(*env->sc_routes))) == NULL)
131 TAILQ_INIT(env->sc_routes);
138 config_purge(struct relayd *env, u_int reset)
140 struct privsep *ps = env->sc_ps;
155 if (what & CONFIG_TABLES && env->sc_tables != NULL) {
156 while ((table = TAILQ_FIRST(env->sc_tables)) != NULL)
157 purge_table(env, env->sc_tables, table);
158 env->sc_tablecount = 0;
160 if (what & CONFIG_RDRS && env->sc_rdrs != NULL) {
161 while ((rdr = TAILQ_FIRST(env->sc_rdrs)) != NULL) {
162 TAILQ_REMOVE(env->sc_rdrs, rdr, entry);
169 env->sc_rdrcount = 0;
171 if (what & CONFIG_RELAYS && env->sc_pkeys != NULL) {
172 while ((pkey = TAILQ_FIRST(env->sc_pkeys)) != NULL) {
173 TAILQ_REMOVE(env->sc_pkeys, pkey, pkey_entry);
177 if (what & CONFIG_RELAYS && env->sc_relays != NULL) {
178 while ((rlay = TAILQ_FIRST(env->sc_relays)) != NULL)
179 purge_relay(env, rlay);
180 env->sc_relaycount = 0;
182 if (what & CONFIG_PROTOS && env->sc_protos != NULL) {
183 while ((proto = TAILQ_FIRST(env->sc_protos)) != NULL) {
184 TAILQ_REMOVE(env->sc_protos, proto, entry);
190 if (what & CONFIG_PROTOS && env->sc_protos != NULL) {
191 while ((proto = TAILQ_FIRST(env->sc_protos)) != NULL) {
192 TAILQ_REMOVE(env->sc_protos, proto, entry);
203 env->sc_protocount = 0;
205 if (what & CONFIG_RTS && env->sc_rts != NULL) {
206 while ((rt = TAILQ_FIRST(env->sc_rts)) != NULL) {
207 TAILQ_REMOVE(env->sc_rts, rt, rt_entry);
210 TAILQ_REMOVE(env->sc_routes, nr, nr_route);
212 env->sc_routecount--;
216 env->sc_routercount = 0;
218 if (what & CONFIG_ROUTES && env->sc_routes != NULL) {
219 while ((nr = TAILQ_FIRST(env->sc_routes)) != NULL) {
222 TAILQ_REMOVE(env->sc_routes, nr, nr_route);
225 env->sc_routecount = 0;
230 config_setreset(struct relayd *env, u_int reset)
232 struct privsep *ps = env->sc_ps;
254 config_getreset(struct relayd *env, struct imsg *imsg)
261 config_purge(env, mode);
267 config_getcfg(struct relayd *env, struct imsg *imsg)
269 struct privsep *ps = env->sc_ps;
278 memcpy(&env->sc_conf, imsg->data, sizeof(env->sc_conf));
284 TAILQ_FOREACH(tb, env->sc_tables, entry) {
286 if (h->conf.parentid && (ph = host_find(env,
295 if (env->sc_conf.flags & (F_TLS|F_TLSCLIENT)) {
297 ca_engine_init(env);
301 proc_compose(env->sc_ps, PROC_PARENT, IMSG_CFG_DONE, NULL, 0);
307 config_settable(struct relayd *env, struct table *tb)
309 struct privsep *ps = env->sc_ps;
324 tb->conf.name, tb->conf.id, env->sc_ps->ps_title[id]);
346 config_gettable(struct relayd *env, struct imsg *imsg)
376 TAILQ_INSERT_TAIL(env->sc_tables, tb, entry);
378 env->sc_tablecount++;
381 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
388 config_gethost(struct relayd *env, struct imsg *imsg)
399 if (host_find(env, host->conf.id) != NULL) {
406 if ((tb = table_find(env, host->conf.tableid)) == NULL) {
419 TAILQ_INSERT_TAIL(&env->sc_hosts, host, globalentry);
422 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
429 config_setrdr(struct relayd *env, struct rdr *rdr)
431 struct privsep *ps = env->sc_ps;
457 config_getrdr(struct relayd *env, struct imsg *imsg)
467 if ((rdr->table = table_find(env, rdr->conf.table_id)) == NULL) {
472 if ((rdr->backup = table_find(env, rdr->conf.backup_id)) == NULL) {
474 rdr->backup = &env->sc_empty_table;
478 TAILQ_INSERT_TAIL(env->sc_rdrs, rdr, entry);
480 env->sc_rdrcount++;
483 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
490 config_getvirt(struct relayd *env, struct imsg *imsg)
501 if ((rdr = rdr_find(env, virt->rdrid)) == NULL) {
510 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
517 config_setrt(struct relayd *env, struct router *rt)
519 struct privsep *ps = env->sc_ps;
544 config_getrt(struct relayd *env, struct imsg *imsg)
554 if ((rt->rt_gwtable = table_find(env, rt->rt_conf.gwtable)) == NULL) {
561 TAILQ_INSERT_TAIL(env->sc_rts, rt, rt_entry);
563 env->sc_routercount++;
566 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
573 config_getroute(struct relayd *env, struct imsg *imsg)
584 if (route_find(env, nr->nr_conf.id) != NULL) {
591 if ((rt = router_find(env, nr->nr_conf.routerid)) == NULL) {
599 TAILQ_INSERT_TAIL(env->sc_routes, nr, nr_route);
602 env->sc_routecount++;
605 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
612 config_setproto(struct relayd *env, struct protocol *proto)
614 struct privsep *ps = env->sc_ps;
643 config_setrule(struct relayd *env, struct protocol *proto)
645 struct privsep *ps = env->sc_ps;
695 config_getproto(struct relayd *env, struct imsg *imsg)
722 TAILQ_INSERT_TAIL(env->sc_protos, proto, entry);
724 env->sc_protocount++;
727 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
734 config_getrule(struct relayd *env, struct imsg *imsg)
750 if ((proto = proto_find(env, rule->rule_protoid)) == NULL) {
796 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
823 config_setrelay(struct relayd *env, struct relay *rlay)
825 struct privsep *ps = env->sc_ps;
895 TAILQ_FOREACH(cert, env->sc_certs, cert_entry) {
1010 TAILQ_FOREACH(cert, env->sc_certs, cert_entry) {
1036 config_getrelay(struct relayd *env, struct imsg *imsg)
1038 struct privsep *ps = env->sc_ps;
1057 rlay->rl_proto = &env->sc_proto_default;
1059 proto_find(env, rlay->rl_conf.proto)) == NULL) {
1079 TAILQ_INSERT_TAIL(env->sc_relays, rlay, rl_entry);
1081 env->sc_relaycount++;
1097 config_getrelaytable(struct relayd *env, struct imsg *imsg)
1108 if ((rlay = relay_find(env, crt.relayid)) == NULL) {
1113 if ((table = table_find(env, crt.id)) == NULL) {
1128 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,
1139 config_getrelayfd(struct relayd *env, struct imsg *imsg)
1153 if ((cert = cert_find(env, crfd.id)) == NULL) {
1154 if ((cert = cert_add(env, crfd.id)) == NULL)
1160 if ((rlay = relay_find(env, crfd.relayid)) == NULL) {
1189 env->sc_ps->ps_title[privsep_process], env->sc_ps->ps_instance,