1 /* $OpenBSD: init.c,v 1.44 2021/10/13 16:56:30 tb Exp $ */ 2 /* $EOM: init.c,v 1.25 2000/03/30 14:27:24 ho Exp $ */ 3 4 /* 5 * Copyright (c) 1998, 1999, 2000 Niklas Hallqvist. All rights reserved. 6 * Copyright (c) 2000 Angelos D. Keromytis. All rights reserved. 7 * Copyright (c) 2003, 2004 H�kan Olsson. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /* 31 * This code was written under funding by Ericsson Radio Systems. 32 */ 33 34 /* XXX This file could easily be built dynamically instead. */ 35 36 #include <stdlib.h> 37 38 #include "app.h" 39 #include "cert.h" 40 #include "conf.h" 41 #include "connection.h" 42 #include "doi.h" 43 #include "exchange.h" 44 #include "init.h" 45 #include "ipsec.h" 46 #include "isakmp_doi.h" 47 #include "libcrypto.h" 48 #include "log.h" 49 #include "dh.h" 50 #include "monitor.h" 51 #include "sa.h" 52 #include "timer.h" 53 #include "transport.h" 54 #include "virtual.h" 55 #include "udp.h" 56 #include "ui.h" 57 #include "util.h" 58 #include "vendor.h" 59 60 #include "policy.h" 61 62 #include "nat_traversal.h" 63 #include "udp_encap.h" 64 65 void 66 init(void) 67 { 68 app_init(); 69 doi_init(); 70 exchange_init(); 71 group_init(); 72 ipsec_init(); 73 isakmp_doi_init(); 74 75 timer_init(); 76 77 /* The following group are depending on timer_init having run. */ 78 conf_init(); 79 connection_init(); 80 81 /* This depends on conf_init, thus check as soon as possible. */ 82 log_reinit(); 83 84 /* policy_init depends on conf_init having run. */ 85 policy_init(); 86 87 /* Depends on conf_init and policy_init having run */ 88 cert_init(); 89 crl_init(); 90 91 sa_init(); 92 transport_init(); 93 virtual_init(); 94 udp_init(); 95 nat_t_init(); 96 udp_encap_init(); 97 vendor_init(); 98 } 99 100 /* Reinitialize, either after a SIGHUP reception or by FIFO UI cmd. */ 101 void 102 reinit(void) 103 { 104 log_print("isakmpd: reinitializing daemon"); 105 106 /* 107 * XXX Remove all(/some?) pending exchange timers? - they may not be 108 * possible to complete after we've re-read the config file. 109 * User-initiated SIGHUP's maybe "authorizes" a wait until 110 * next connection-check. 111 * XXX This means we discard exchange->last_msg, is this really ok? 112 */ 113 114 /* Reread config file. */ 115 conf_reinit(); 116 117 log_reinit(); 118 119 /* Reread the policies. */ 120 policy_init(); 121 122 /* Reinitialize certificates */ 123 cert_init(); 124 crl_init(); 125 126 /* Reinitialize our connection list. */ 127 connection_reinit(); 128 129 /* 130 * Rescan interfaces (call reinit() in all transports). 131 */ 132 transport_reinit(); 133 134 /* 135 * XXX "These" (non-existent) reinitializations should not be done. 136 * cookie_reinit (); 137 * ui_reinit (); 138 */ 139 140 sa_reinit(); 141 } 142