1 /* $OpenBSD: init.c,v 1.25 2003/06/04 07:31:16 ho 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 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 "sysdep.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 "math_group.h" 50 #include "sa.h" 51 #include "timer.h" 52 #include "transport.h" 53 #include "udp.h" 54 #include "ui.h" 55 #include "util.h" 56 57 #ifdef USE_POLICY 58 #include "policy.h" 59 #endif 60 61 void 62 init (void) 63 { 64 app_init (); 65 doi_init (); 66 exchange_init (); 67 group_init (); 68 ipsec_init (); 69 isakmp_doi_init (); 70 libcrypto_init (); 71 72 tzset (); 73 74 timer_init (); 75 76 /* The following group are depending on timer_init having run. */ 77 conf_init (); 78 connection_init (); 79 80 #ifdef USE_POLICY 81 /* policy_init depends on conf_init having run. */ 82 policy_init (); 83 #endif 84 85 /* Depends on conf_init and policy_init having run */ 86 cert_init (); 87 crl_init (); 88 89 sa_init (); 90 transport_init (); 91 udp_init (); 92 ui_init (); 93 } 94 95 /* Reinitialize, either after a SIGHUP reception or by FIFO UI cmd. */ 96 void 97 reinit (void) 98 { 99 log_print ("isakmpd: reinitializing daemon"); 100 101 /* 102 * XXX Remove all(/some?) pending exchange timers? - they may not be 103 * possible to complete after we've re-read the config file. 104 * User-initiated SIGHUP's maybe "authorizes" a wait until 105 * next connection-check. 106 * XXX This means we discard exchange->last_msg, is this really ok? 107 */ 108 109 /* Reinitialize PRNG if we are in deterministic mode. */ 110 if (regrand) 111 srandom (seed); 112 113 /* Reread config file. */ 114 conf_reinit (); 115 116 /* Set timezone */ 117 tzset (); 118 119 #ifdef USE_POLICY 120 /* Reread the policies. */ 121 policy_init (); 122 #endif 123 124 /* Reinitialize certificates */ 125 cert_init (); 126 crl_init (); 127 128 /* Reinitialize our connection list. */ 129 connection_reinit (); 130 131 /* 132 * Rescan interfaces. 133 */ 134 transport_reinit (); 135 136 /* 137 * XXX "These" (non-existant) reinitializations should not be done. 138 * cookie_reinit (); 139 * ui_reinit (); 140 */ 141 142 sa_reinit (); 143 } 144