[tor-commits] [tor/master] Make the get_options() return const

nickm at torproject.org nickm at torproject.org
Tue Jun 14 17:19:58 UTC 2011


commit 47c8433a0c3c579588e1e5d4f67f16843ba26bca
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Jun 14 13:01:38 2011 -0400

    Make the get_options() return const
    
    This lets us make a lot of other stuff const, allows the compiler to
    generate (slightly) better code, and will make me get slightly fewer
    patches from folks who stick mutable stuff into or_options_t.
    
    const: because not every input is an output!
---
 src/or/buffers.c          |    2 +-
 src/or/circuitbuild.c     |   41 +++++-----
 src/or/circuitbuild.h     |   10 +-
 src/or/circuitlist.c      |    4 +-
 src/or/circuituse.c       |    8 +-
 src/or/circuituse.h       |    3 +-
 src/or/config.c           |  182 +++++++++++++++++++++++++--------------------
 src/or/config.h           |   18 +++--
 src/or/connection.c       |   22 +++---
 src/or/connection_edge.c  |   18 ++--
 src/or/connection_edge.h  |    4 +-
 src/or/connection_or.c    |    9 +-
 src/or/connection_or.h    |    2 +-
 src/or/control.c          |   10 +-
 src/or/directory.c        |   16 ++--
 src/or/dirserv.c          |   29 ++++----
 src/or/dirserv.h          |   17 ++--
 src/or/dirvote.c          |    6 +-
 src/or/dirvote.h          |    4 +-
 src/or/dns.c              |    8 +-
 src/or/geoip.c            |    6 +-
 src/or/geoip.h            |    4 +-
 src/or/hibernate.c        |    8 +-
 src/or/hibernate.h        |    4 +-
 src/or/main.c             |   16 ++--
 src/or/main.h             |    2 +-
 src/or/microdesc.c        |    8 +-
 src/or/microdesc.h        |    6 +-
 src/or/networkstatus.c    |   20 +++---
 src/or/networkstatus.h    |    5 +-
 src/or/nodelist.c         |    2 +-
 src/or/policies.c         |    6 +-
 src/or/policies.h         |    4 +-
 src/or/relay.c            |    3 +-
 src/or/relay.h            |    4 +-
 src/or/rendclient.c       |    5 +-
 src/or/rendclient.h       |    2 +-
 src/or/rendservice.c      |    8 +-
 src/or/rendservice.h      |    2 +-
 src/or/rephist.c          |    2 +-
 src/or/router.c           |   56 +++++++-------
 src/or/router.h           |   34 ++++----
 src/or/routerlist.c       |   36 +++++----
 src/or/status.c           |    2 +-
 src/test/test.c           |    4 +-
 src/test/test_microdesc.c |    2 +-
 46 files changed, 349 insertions(+), 315 deletions(-)

diff --git a/src/or/buffers.c b/src/or/buffers.c
index 70d3e9a..8f5fb1e 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1459,7 +1459,7 @@ log_unsafe_socks_warning(int socks_protocol, const char *address,
 {
   static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL);
 
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   char *m = NULL;
   if (! options->WarnUnsafeSocks)
     return;
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 68ca569..4f7bbe5 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1948,7 +1948,7 @@ inform_testing_reachability(void)
 static INLINE int
 should_use_create_fast_for_circuit(origin_circuit_t *circ)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   tor_assert(circ->cpath);
   tor_assert(circ->cpath->extend_info);
 
@@ -2083,7 +2083,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
       if (circ->build_state->onehop_tunnel)
         control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
       if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
-        or_options_t *options = get_options();
+        const or_options_t *options = get_options();
         can_complete_circuit=1;
         /* FFFF Log a count of known routers here */
         log_notice(LD_GENERAL,
@@ -2650,7 +2650,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
   smartlist_t *connections;
   int best_support = -1;
   int n_best_support=0;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const smartlist_t *the_nodes;
   const node_t *node=NULL;
 
@@ -2851,7 +2851,7 @@ static const node_t *
 choose_good_exit_server(uint8_t purpose,
                         int need_uptime, int need_capacity, int is_internal)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   router_crn_flags_t flags = CRN_NEED_DESC;
   if (need_uptime)
     flags |= CRN_NEED_UPTIME;
@@ -2881,7 +2881,7 @@ choose_good_exit_server(uint8_t purpose,
 static void
 warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   routerset_t *rs = options->ExcludeNodes;
   const char *description;
   uint8_t purpose = circ->_base.purpose;
@@ -3095,7 +3095,7 @@ choose_good_middle_server(uint8_t purpose,
   const node_t *r, *choice;
   crypt_path_t *cpath;
   smartlist_t *excluded;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   router_crn_flags_t flags = CRN_NEED_DESC;
   tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
              purpose <= _CIRCUIT_PURPOSE_MAX);
@@ -3137,7 +3137,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
 {
   const node_t *choice;
   smartlist_t *excluded;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC;
   const node_t *node;
 
@@ -3388,7 +3388,8 @@ build_state_get_exit_nickname(cpath_build_state_t *state)
  */
 static int
 entry_guard_set_status(entry_guard_t *e, const node_t *node,
-                       time_t now, or_options_t *options, const char **reason)
+                       time_t now, const or_options_t *options,
+                       const char **reason)
 {
   char buf[HEX_DIGEST_LEN+1];
   int changed = 0;
@@ -3471,7 +3472,7 @@ entry_is_live(entry_guard_t *e, int need_uptime, int need_capacity,
               int assume_reachable, const char **msg)
 {
   const node_t *node;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   tor_assert(msg);
 
   if (e->bad_since) {
@@ -3597,7 +3598,7 @@ control_event_guard_deferred(void)
 #if 0
   int n = 0;
   const char *msg;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (!entry_guards)
     return;
   SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
@@ -3665,7 +3666,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status)
 /** If the use of entry guards is configured, choose more entry guards
  * until we have enough in the list. */
 static void
-pick_entry_guards(or_options_t *options)
+pick_entry_guards(const or_options_t *options)
 {
   int changed = 0;
 
@@ -3798,7 +3799,7 @@ remove_dead_entry_guards(time_t now)
  * think that things are unlisted.
  */
 void
-entry_guards_compute_status(or_options_t *options, time_t now)
+entry_guards_compute_status(const or_options_t *options, time_t now)
 {
   int changed = 0;
   digestmap_t *reasons;
@@ -3988,7 +3989,7 @@ entry_nodes_should_be_added(void)
 /** Add all nodes in EntryNodes that aren't currently guard nodes to the list
  * of guard nodes, at the front. */
 static void
-entry_guards_prepend_from_config(or_options_t *options)
+entry_guards_prepend_from_config(const or_options_t *options)
 {
   smartlist_t *entry_nodes, *entry_fps;
   smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
@@ -4067,7 +4068,7 @@ entry_guards_prepend_from_config(or_options_t *options)
  * list already and we must stick to it.
  */
 int
-entry_list_is_constrained(or_options_t *options)
+entry_list_is_constrained(const or_options_t *options)
 {
   if (options->EntryNodes)
     return 1;
@@ -4084,7 +4085,7 @@ entry_list_is_constrained(or_options_t *options)
 const node_t *
 choose_random_entry(cpath_build_state_t *state)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   smartlist_t *live_entry_guards = smartlist_create();
   smartlist_t *exit_family = smartlist_create();
   const node_t *chosen_exit =
@@ -4694,7 +4695,7 @@ static void
 launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
 {
   char *address;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (connection_get_by_type_addr_port_purpose(
       CONN_TYPE_DIR, &bridge->addr, bridge->port,
@@ -4735,7 +4736,7 @@ retry_bridge_descriptor_fetch_directly(const char *digest)
  * descriptor, fetch a new copy of its descriptor -- either directly
  * from the bridge or via a bridge authority. */
 void
-fetch_bridge_descriptors(or_options_t *options, time_t now)
+fetch_bridge_descriptors(const or_options_t *options, time_t now)
 {
   int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
   int ask_bridge_directly;
@@ -4929,7 +4930,7 @@ any_pending_bridge_descriptor_fetches(void)
  * down. Else return 0. If <b>act</b> is 1, then mark the down guards
  * up; else just observe and report. */
 static int
-entries_retry_helper(or_options_t *options, int act)
+entries_retry_helper(const or_options_t *options, int act)
 {
   const node_t *node;
   int any_known = 0;
@@ -4968,7 +4969,7 @@ entries_retry_helper(or_options_t *options, int act)
 /** Do we know any descriptors for our bridges / entrynodes, and are
  * all the ones we have descriptors for down? */
 int
-entries_known_but_down(or_options_t *options)
+entries_known_but_down(const or_options_t *options)
 {
   tor_assert(entry_list_is_constrained(options));
   return entries_retry_helper(options, 0);
@@ -4976,7 +4977,7 @@ entries_known_but_down(or_options_t *options)
 
 /** Mark all down known bridges / entrynodes up. */
 void
-entries_retry_all(or_options_t *options)
+entries_retry_all(const or_options_t *options)
 {
   tor_assert(entry_list_is_constrained(options));
   entries_retry_helper(options, 1);
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index b1eb5a6..caa8a67 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -51,11 +51,11 @@ void extend_info_free(extend_info_t *info);
 const node_t *build_state_get_exit_node(cpath_build_state_t *state);
 const char *build_state_get_exit_nickname(cpath_build_state_t *state);
 
-void entry_guards_compute_status(or_options_t *options, time_t now);
+void entry_guards_compute_status(const or_options_t *options, time_t now);
 int entry_guard_register_connect_status(const char *digest, int succeeded,
                                         int mark_relay_status, time_t now);
 void entry_nodes_should_be_added(void);
-int entry_list_is_constrained(or_options_t *options);
+int entry_list_is_constrained(const or_options_t *options);
 const node_t *choose_random_entry(cpath_build_state_t *state);
 int entry_guards_parse_state(or_state_t *state, int set, char **msg);
 void entry_guards_update_state(or_state_t *state);
@@ -72,12 +72,12 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port,
 void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
                             const char *digest);
 void retry_bridge_descriptor_fetch_directly(const char *digest);
-void fetch_bridge_descriptors(or_options_t *options, time_t now);
+void fetch_bridge_descriptors(const or_options_t *options, time_t now);
 void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
 int any_bridge_descriptors_known(void);
 int any_pending_bridge_descriptor_fetches(void);
-int entries_known_but_down(or_options_t *options);
-void entries_retry_all(or_options_t *options);
+int entries_known_but_down(const or_options_t *options);
+void entries_retry_all(const or_options_t *options);
 
 void entry_guards_free_all(void);
 
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 91fb13f..601b432 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -979,7 +979,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
   int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
   int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
   int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   /* Make sure we're not trying to create a onehop circ by
    * cannibalization. */
@@ -1098,7 +1098,7 @@ void
 circuit_expire_all_dirty_circs(void)
 {
   circuit_t *circ;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   for (circ=global_circuitlist; circ; circ = circ->next) {
     if (CIRCUIT_IS_ORIGIN(circ) &&
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index dddf6a2..45fe3df 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -635,7 +635,7 @@ void
 circuit_build_needed_circs(time_t now)
 {
   static time_t time_to_new_circuit = 0;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   /* launch a new circ for any pending streams that need one */
   connection_ap_attach_pending();
@@ -1207,7 +1207,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
   int check_exit_policy;
   int need_uptime, need_internal;
   int want_onehop;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(conn);
   tor_assert(circp);
@@ -1470,7 +1470,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
 /** Return true iff <b>address</b> is matched by one of the entries in
  * TrackHostExits. */
 int
-hostname_in_track_host_exits(or_options_t *options, const char *address)
+hostname_in_track_host_exits(const or_options_t *options, const char *address)
 {
   if (!options->TrackHostExits)
     return 0;
@@ -1494,7 +1494,7 @@ hostname_in_track_host_exits(or_options_t *options, const char *address)
 static void
 consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   char *new_address = NULL;
   char fp[HEX_DIGEST_LEN+1];
 
diff --git a/src/or/circuituse.h b/src/or/circuituse.h
index 8e10212..ab7f6a2 100644
--- a/src/or/circuituse.h
+++ b/src/or/circuituse.h
@@ -50,7 +50,8 @@ int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
                                                   crypt_path_t *cpath);
 int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
 
-int hostname_in_track_host_exits(or_options_t *options, const char *address);
+int hostname_in_track_host_exits(const or_options_t *options,
+                                 const char *address);
 
 #endif
 
diff --git a/src/or/config.c b/src/or/config.c
index 53ecca2..0ae089e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -422,7 +422,7 @@ static config_var_t _option_vars[] = {
 
 /** Override default values with these if the user sets the TestingTorNetwork
  * option. */
-static config_var_t testing_tor_network_defaults[] = {
+static const config_var_t testing_tor_network_defaults[] = {
   V(ServerDNSAllowBrokenConfig,  BOOL,  "1"),
   V(DirAllowPrivateAddresses,    BOOL,     "1"),
   V(EnforceDistinctSubnets,      BOOL,     "0"),
@@ -546,39 +546,43 @@ static char *get_windows_conf_root(void);
 #endif
 static void config_line_append(config_line_t **lst,
                                const char *key, const char *val);
-static void option_clear(config_format_t *fmt, or_options_t *options,
-                         config_var_t *var);
-static void option_reset(config_format_t *fmt, or_options_t *options,
-                         config_var_t *var, int use_defaults);
-static void config_free(config_format_t *fmt, void *options);
+static void option_clear(const config_format_t *fmt, or_options_t *options,
+                         const config_var_t *var);
+static void option_reset(const config_format_t *fmt, or_options_t *options,
+                         const config_var_t *var, int use_defaults);
+static void config_free(const config_format_t *fmt, void *options);
 static int config_lines_eq(config_line_t *a, config_line_t *b);
-static int option_is_same(config_format_t *fmt,
-                          or_options_t *o1, or_options_t *o2,
+static int option_is_same(const config_format_t *fmt,
+                          const or_options_t *o1, const or_options_t *o2,
                           const char *name);
-static or_options_t *options_dup(config_format_t *fmt, or_options_t *old);
-static int options_validate(or_options_t *old_options, or_options_t *options,
+static or_options_t *options_dup(const config_format_t *fmt,
+                                 const or_options_t *old);
+static int options_validate(or_options_t *old_options,
+                            or_options_t *options,
                             int from_setconf, char **msg);
-static int options_act_reversible(or_options_t *old_options, char **msg);
-static int options_act(or_options_t *old_options);
-static int options_transition_allowed(or_options_t *old, or_options_t *new,
+static int options_act_reversible(const or_options_t *old_options, char **msg);
+static int options_act(const or_options_t *old_options);
+static int options_transition_allowed(const or_options_t *old,
+                                      const or_options_t *new,
                                       char **msg);
-static int options_transition_affects_workers(or_options_t *old_options,
-                                              or_options_t *new_options);
-static int options_transition_affects_descriptor(or_options_t *old_options,
-                                                 or_options_t *new_options);
+static int options_transition_affects_workers(
+      const or_options_t *old_options, const or_options_t *new_options);
+static int options_transition_affects_descriptor(
+      const or_options_t *old_options, const or_options_t *new_options);
 static int check_nickname_list(const char *lst, const char *name, char **msg);
-static void config_register_addressmaps(or_options_t *options);
+static void config_register_addressmaps(const or_options_t *options);
 
 static int parse_bridge_line(const char *line, int validate_only);
 static int parse_dir_server_line(const char *line,
                                  dirinfo_type_t required_type,
                                  int validate_only);
 static int validate_data_directory(or_options_t *options);
-static int write_configuration_file(const char *fname, or_options_t *options);
-static config_line_t *get_assigned_option(config_format_t *fmt,
-                                          void *options, const char *key,
-                                          int escape_val);
-static void config_init(config_format_t *fmt, void *options);
+static int write_configuration_file(const char *fname,
+                                    const or_options_t *options);
+static config_line_t *get_assigned_option(const config_format_t *fmt,
+                                        const void *options, const char *key,
+                                        int escape_val);
+static void config_init(const config_format_t *fmt, void *options);
 static int or_state_validate(or_state_t *old_options, or_state_t *options,
                              int from_setconf, char **msg);
 static int or_state_load(void);
@@ -617,7 +621,7 @@ static config_var_t state_extra_var = {
 };
 
 /** Configuration format for or_state_t. */
-static config_format_t state_format = {
+static const config_format_t state_format = {
   sizeof(or_state_t),
   OR_STATE_MAGIC,
   STRUCT_OFFSET(or_state_t, _magic),
@@ -651,7 +655,7 @@ get_dirportfrontpage(void)
 
 /** Allocate an empty configuration object of a given format type. */
 static void *
-config_alloc(config_format_t *fmt)
+config_alloc(const config_format_t *fmt)
 {
   void *opts = tor_malloc_zero(fmt->size);
   *(uint32_t*)STRUCT_VAR_P(opts, fmt->magic_offset) = fmt->magic;
@@ -661,12 +665,19 @@ config_alloc(config_format_t *fmt)
 
 /** Return the currently configured options. */
 or_options_t *
-get_options(void)
+get_options_mutable(void)
 {
   tor_assert(global_options);
   return global_options;
 }
 
+/** Returns the currently configured options */
+const or_options_t *
+get_options(void)
+{
+  return get_options_mutable();
+}
+
 /** Change the current global options to contain <b>new_val</b> instead of
  * their current value; take action based on the new value; free the old value
  * as necessary.  Returns 0 on success, -1 on failure.
@@ -903,8 +914,8 @@ validate_dir_authorities(or_options_t *options, or_options_t *old_options)
  * as appropriate.
  */
 static int
-consider_adding_dir_authorities(or_options_t *options,
-                                or_options_t *old_options)
+consider_adding_dir_authorities(const or_options_t *options,
+                                const or_options_t *old_options)
 {
   config_line_t *cl;
   int need_to_update =
@@ -958,12 +969,12 @@ consider_adding_dir_authorities(or_options_t *options,
  * Return 0 if all goes well, return -1 if things went badly.
  */
 static int
-options_act_reversible(or_options_t *old_options, char **msg)
+options_act_reversible(const or_options_t *old_options, char **msg)
 {
   smartlist_t *new_listeners = smartlist_create();
   smartlist_t *replaced_listeners = smartlist_create();
   static int libevent_initialized = 0;
-  or_options_t *options = get_options();
+  or_options_t *options = get_options_mutable();
   int running_tor = options->command == CMD_RUN_TOR;
   int set_conn_limit = 0;
   int r = -1;
@@ -1056,7 +1067,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
     /* No need to roll back, since you can't change the value. */
   }
 
- if (directory_caches_v2_dir_info(options)) {
+  if (directory_caches_v2_dir_info(options)) {
     size_t len = strlen(options->DataDirectory)+32;
     char *fn = tor_malloc(len);
     tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
@@ -1132,7 +1143,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
 /** If we need to have a GEOIP ip-to-country map to run with our configured
  * options, return 1 and set *<b>reason_out</b> to a description of why. */
 int
-options_need_geoip_info(or_options_t *options, const char **reason_out)
+options_need_geoip_info(const or_options_t *options, const char **reason_out)
 {
   int bridge_usage =
     options->BridgeRelay && options->BridgeRecordUsageByCountry;
@@ -1157,7 +1168,7 @@ options_need_geoip_info(or_options_t *options, const char **reason_out)
 /** Return the bandwidthrate that we are going to report to the authorities
  * based on the config options. */
 uint32_t
-get_effective_bwrate(or_options_t *options)
+get_effective_bwrate(const or_options_t *options)
 {
   uint64_t bw = options->BandwidthRate;
   if (bw > options->MaxAdvertisedBandwidth)
@@ -1171,7 +1182,7 @@ get_effective_bwrate(or_options_t *options)
 /** Return the bandwidthburst that we are going to report to the authorities
  * based on the config options. */
 uint32_t
-get_effective_bwburst(or_options_t *options)
+get_effective_bwburst(const or_options_t *options)
 {
   uint64_t bw = options->BandwidthBurst;
   if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
@@ -1190,10 +1201,10 @@ get_effective_bwburst(or_options_t *options)
  * here yet.  Some is still in do_hup() and other places.
  */
 static int
-options_act(or_options_t *old_options)
+options_act(const or_options_t *old_options)
 {
   config_line_t *cl;
-  or_options_t *options = get_options();
+  or_options_t *options = get_options_mutable();
   int running_tor = options->command == CMD_RUN_TOR;
   char *msg;
   const int transition_affects_workers =
@@ -1550,7 +1561,7 @@ options_act(or_options_t *old_options)
  * apply abbreviations that work for the config file and the command line.
  * If <b>warn_obsolete</b> is set, warn about deprecated names. */
 static const char *
-expand_abbrev(config_format_t *fmt, const char *option, int command_line,
+expand_abbrev(const config_format_t *fmt, const char *option, int command_line,
               int warn_obsolete)
 {
   int i;
@@ -1710,12 +1721,9 @@ config_free_lines(config_line_t *front)
   }
 }
 
-/** If <b>key</b> is a configuration option, return the corresponding
- * config_var_t.  Otherwise, if <b>key</b> is a non-standard abbreviation,
- * warn, and return the corresponding config_var_t.  Otherwise return NULL.
- */
+/** As config_find_option, but return a non-const pointer. */
 static config_var_t *
-config_find_option(config_format_t *fmt, const char *key)
+config_find_option_mutable(config_format_t *fmt, const char *key)
 {
   int i;
   size_t keylen = strlen(key);
@@ -1740,9 +1748,20 @@ config_find_option(config_format_t *fmt, const char *key)
   return NULL;
 }
 
+/** If <b>key</b> is a configuration option, return the corresponding const
+ * config_var_t.  Otherwise, if <b>key</b> is a non-standard abbreviation,
+ * warn, and return the corresponding const config_var_t.  Otherwise return
+ * NULL.
+ */
+static const config_var_t *
+config_find_option(const config_format_t *fmt, const char *key)
+{
+  return config_find_option_mutable((config_format_t*)fmt, key);
+}
+
 /** Return the number of option entries in <b>fmt</b>. */
 static int
-config_count_options(config_format_t *fmt)
+config_count_options(const config_format_t *fmt)
 {
   int i;
   for (i=0; fmt->vars[i].name; ++i)
@@ -1760,11 +1779,11 @@ config_count_options(config_format_t *fmt)
  * Called from config_assign_line() and option_reset().
  */
 static int
-config_assign_value(config_format_t *fmt, or_options_t *options,
+config_assign_value(const config_format_t *fmt, or_options_t *options,
                     config_line_t *c, char **msg)
 {
   int i, ok;
-  config_var_t *var;
+  const config_var_t *var;
   void *lvalue;
 
   CHECK(fmt, options);
@@ -1926,11 +1945,11 @@ config_assign_value(config_format_t *fmt, or_options_t *options,
  * Called from config_assign().
  */
 static int
-config_assign_line(config_format_t *fmt, or_options_t *options,
+config_assign_line(const config_format_t *fmt, or_options_t *options,
                    config_line_t *c, int use_defaults,
                    int clear_first, bitarray_t *options_seen, char **msg)
 {
-  config_var_t *var;
+  const config_var_t *var;
 
   CHECK(fmt, options);
 
@@ -1991,10 +2010,10 @@ config_assign_line(config_format_t *fmt, or_options_t *options,
 /** Restore the option named <b>key</b> in options to its default value.
  * Called from config_assign(). */
 static void
-config_reset_line(config_format_t *fmt, or_options_t *options,
+config_reset_line(const config_format_t *fmt, or_options_t *options,
                   const char *key, int use_defaults)
 {
-  config_var_t *var;
+  const config_var_t *var;
 
   CHECK(fmt, options);
 
@@ -2009,7 +2028,7 @@ config_reset_line(config_format_t *fmt, or_options_t *options,
 int
 option_is_recognized(const char *key)
 {
-  config_var_t *var = config_find_option(&options_format, key);
+  const config_var_t *var = config_find_option(&options_format, key);
   return (var != NULL);
 }
 
@@ -2018,14 +2037,14 @@ option_is_recognized(const char *key)
 const char *
 option_get_canonical_name(const char *key)
 {
-  config_var_t *var = config_find_option(&options_format, key);
+  const config_var_t *var = config_find_option(&options_format, key);
   return var ? var->name : NULL;
 }
 
 /** Return a canonical list of the options assigned for key.
  */
 config_line_t *
-option_get_assignment(or_options_t *options, const char *key)
+option_get_assignment(const or_options_t *options, const char *key)
 {
   return get_assigned_option(&options_format, options, key, 1);
 }
@@ -2078,10 +2097,10 @@ config_lines_dup(const config_line_t *inp)
  * value needs to be quoted before it's put in a config file, quote and
  * escape that value. Return NULL if no such key exists. */
 static config_line_t *
-get_assigned_option(config_format_t *fmt, void *options,
+get_assigned_option(const config_format_t *fmt, const void *options,
                     const char *key, int escape_val)
 {
-  config_var_t *var;
+  const config_var_t *var;
   const void *value;
   config_line_t *result;
   tor_assert(options && key);
@@ -2263,7 +2282,7 @@ options_trial_assign() calls config_assign(1, 1)
     returns.
 */
 static int
-config_assign(config_format_t *fmt, void *options, config_line_t *list,
+config_assign(const config_format_t *fmt, void *options, config_line_t *list,
               int use_defaults, int clear_first, char **msg)
 {
   config_line_t *p;
@@ -2325,7 +2344,7 @@ options_trial_assign(config_line_t *list, int use_defaults,
     return r;
   }
 
-  if (options_validate(get_options(), trial_options, 1, msg) < 0) {
+  if (options_validate(get_options_mutable(), trial_options, 1, msg) < 0) {
     config_free(&options_format, trial_options);
     return SETOPT_ERR_PARSE; /*XXX make this a separate return value. */
   }
@@ -2347,7 +2366,8 @@ options_trial_assign(config_line_t *list, int use_defaults,
 /** Reset config option <b>var</b> to 0, 0.0, NULL, or the equivalent.
  * Called from option_reset() and config_free(). */
 static void
-option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
+option_clear(const config_format_t *fmt, or_options_t *options,
+             const const config_var_t *var)
 {
   void *lvalue = STRUCT_VAR_P(options, var->var_offset);
   (void)fmt; /* unused */
@@ -2405,8 +2425,8 @@ option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
  * <b>use_defaults</b>, set it to its default value.
  * Called by config_init() and option_reset_line() and option_assign_line(). */
 static void
-option_reset(config_format_t *fmt, or_options_t *options,
-             config_var_t *var, int use_defaults)
+option_reset(const config_format_t *fmt, or_options_t *options,
+             const config_var_t *var, int use_defaults)
 {
   config_line_t *c;
   char *msg = NULL;
@@ -2446,7 +2466,7 @@ list_torrc_options(void)
   int i;
   smartlist_t *lines = smartlist_create();
   for (i = 0; _option_vars[i].name; ++i) {
-    config_var_t *var = &_option_vars[i];
+    const config_var_t *var = &_option_vars[i];
     if (var->type == CONFIG_TYPE_OBSOLETE ||
         var->type == CONFIG_TYPE_LINELIST_V)
       continue;
@@ -2465,7 +2485,7 @@ static uint32_t last_resolved_addr = 0;
  * public IP address.
  */
 int
-resolve_my_address(int warn_severity, or_options_t *options,
+resolve_my_address(int warn_severity, const or_options_t *options,
                    uint32_t *addr_out, char **hostname_out)
 {
   struct in_addr in;
@@ -2641,7 +2661,7 @@ is_local_addr(const tor_addr_t *addr)
 
 /** Release storage held by <b>options</b>. */
 static void
-config_free(config_format_t *fmt, void *options)
+config_free(const config_format_t *fmt, void *options)
 {
   int i;
 
@@ -2680,8 +2700,9 @@ config_lines_eq(config_line_t *a, config_line_t *b)
  * and <b>o2</b>.  Must not be called for LINELIST_S or OBSOLETE options.
  */
 static int
-option_is_same(config_format_t *fmt,
-               or_options_t *o1, or_options_t *o2, const char *name)
+option_is_same(const config_format_t *fmt,
+               const or_options_t *o1, const or_options_t *o2,
+               const char *name)
 {
   config_line_t *c1, *c2;
   int r = 1;
@@ -2698,7 +2719,7 @@ option_is_same(config_format_t *fmt,
 
 /** Copy storage held by <b>old</b> into a new or_options_t and return it. */
 static or_options_t *
-options_dup(config_format_t *fmt, or_options_t *old)
+options_dup(const config_format_t *fmt, const or_options_t *old)
 {
   or_options_t *newopts;
   int i;
@@ -2774,10 +2795,10 @@ is_listening_on_low_port(int port_option,
 /** Set all vars in the configuration object <b>options</b> to their default
  * values. */
 static void
-config_init(config_format_t *fmt, void *options)
+config_init(const config_format_t *fmt, void *options)
 {
   int i;
-  config_var_t *var;
+  const config_var_t *var;
   CHECK(fmt, options);
 
   for (i=0; fmt->vars[i].name; ++i) {
@@ -2793,7 +2814,7 @@ config_init(config_format_t *fmt, void *options)
  * Else, if comment_defaults, write default values as comments.
  */
 static char *
-config_dump(config_format_t *fmt, void *options, int minimal,
+config_dump(const config_format_t *fmt, const void *options, int minimal,
             int comment_defaults)
 {
   smartlist_t *elements;
@@ -2861,7 +2882,7 @@ config_dump(config_format_t *fmt, void *options, int minimal,
  * include options that are the same as Tor's defaults.
  */
 char *
-options_dump(or_options_t *options, int minimal)
+options_dump(const or_options_t *options, int minimal)
 {
   return config_dump(&options_format, options, minimal, 0);
 }
@@ -3862,7 +3883,8 @@ opt_streq(const char *s1, const char *s2)
 
 /** Check if any of the previous options have changed but aren't allowed to. */
 static int
-options_transition_allowed(or_options_t *old, or_options_t *new_val,
+options_transition_allowed(const or_options_t *old,
+                           const or_options_t *new_val,
                            char **msg)
 {
   if (!old)
@@ -3918,8 +3940,8 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val,
 /** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
  * will require us to rotate the CPU and DNS workers; else return 0. */
 static int
-options_transition_affects_workers(or_options_t *old_options,
-                                   or_options_t *new_options)
+options_transition_affects_workers(const or_options_t *old_options,
+                                   const or_options_t *new_options)
 {
   if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
       old_options->NumCPUs != new_options->NumCPUs ||
@@ -3942,8 +3964,8 @@ options_transition_affects_workers(or_options_t *old_options,
 /** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
  * will require us to generate a new descriptor; else return 0. */
 static int
-options_transition_affects_descriptor(or_options_t *old_options,
-                                      or_options_t *new_options)
+options_transition_affects_descriptor(const or_options_t *old_options,
+                                      const or_options_t *new_options)
 {
   /* XXX We can be smarter here. If your DirPort isn't being
    * published and you just turned it off, no need to republish. Etc. */
@@ -4309,9 +4331,9 @@ options_init_from_string(const char *cf,
     /* Change defaults. */
     int i;
     for (i = 0; testing_tor_network_defaults[i].name; ++i) {
-      config_var_t *new_var = &testing_tor_network_defaults[i];
+      const config_var_t *new_var = &testing_tor_network_defaults[i];
       config_var_t *old_var =
-          config_find_option(&options_format, new_var->name);
+          config_find_option_mutable(&options_format, new_var->name);
       tor_assert(new_var);
       tor_assert(old_var);
       old_var->initvalue = new_var->initvalue;
@@ -4388,7 +4410,7 @@ get_torrc_fname(void)
  * configuration <b>options</b>
  */
 static void
-config_register_addressmaps(or_options_t *options)
+config_register_addressmaps(const or_options_t *options)
 {
   smartlist_t *elts;
   config_line_t *opt;
@@ -4818,7 +4840,7 @@ validate_data_directory(or_options_t *options)
  * doesn't begin with GENERATED_FILE_PREFIX, rename it.  Otherwise
  * replace it.  Return 0 on success, -1 on failure. */
 static int
-write_configuration_file(const char *fname, or_options_t *options)
+write_configuration_file(const char *fname, const or_options_t *options)
 {
   char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
   int rename_old = 0, r;
@@ -5155,7 +5177,7 @@ get_or_state(void)
  * Note: Consider using the get_datadir_fname* macros in or.h.
  */
 char *
-options_get_datadir_fname2_suffix(or_options_t *options,
+options_get_datadir_fname2_suffix(const or_options_t *options,
                                   const char *sub1, const char *sub2,
                                   const char *suffix)
 {
@@ -5472,7 +5494,7 @@ getinfo_helper_config(control_connection_t *conn,
     smartlist_t *sl = smartlist_create();
     int i;
     for (i = 0; _option_vars[i].name; ++i) {
-      config_var_t *var = &_option_vars[i];
+      const config_var_t *var = &_option_vars[i];
       const char *type;
       char *line;
       switch (var->type) {
diff --git a/src/or/config.h b/src/or/config.h
index 49f7e25..bc71191 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -13,7 +13,8 @@
 #define _TOR_CONFIG_H
 
 const char *get_dirportfrontpage(void);
-or_options_t *get_options(void);
+const or_options_t *get_options(void);
+or_options_t *get_options_mutable(void);
 int set_options(or_options_t *new_val, char **msg);
 void config_free_all(void);
 const char *safe_str_client(const char *address);
@@ -26,21 +27,21 @@ int config_get_lines(const char *string, config_line_t **result);
 void config_free_lines(config_line_t *front);
 setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
                                   int clear_first, char **msg);
-int resolve_my_address(int warn_severity, or_options_t *options,
+int resolve_my_address(int warn_severity, const or_options_t *options,
                        uint32_t *addr, char **hostname_out);
 int is_local_addr(const tor_addr_t *addr) ATTR_PURE;
 void options_init(or_options_t *options);
-char *options_dump(or_options_t *options, int minimal);
+char *options_dump(const or_options_t *options, int minimal);
 int options_init_from_torrc(int argc, char **argv);
 setopt_err_t options_init_from_string(const char *cf,
                             int command, const char *command_arg, char **msg);
 int option_is_recognized(const char *key);
 const char *option_get_canonical_name(const char *key);
-config_line_t *option_get_assignment(or_options_t *options,
+config_line_t *option_get_assignment(const or_options_t *options,
                                      const char *key);
 int options_save_current(void);
 const char *get_torrc_fname(void);
-char *options_get_datadir_fname2_suffix(or_options_t *options,
+char *options_get_datadir_fname2_suffix(const or_options_t *options,
                                         const char *sub1, const char *sub2,
                                         const char *suffix);
 #define get_datadir_fname2_suffix(sub1, sub2, suffix) \
@@ -63,14 +64,15 @@ or_state_t *get_or_state(void);
 int did_last_state_file_write_fail(void);
 int or_state_save(time_t now);
 
-int options_need_geoip_info(or_options_t *options, const char **reason_out);
+int options_need_geoip_info(const or_options_t *options,
+                            const char **reason_out);
 int getinfo_helper_config(control_connection_t *conn,
                           const char *question, char **answer,
                           const char **errmsg);
 
 const char *tor_get_digests(void);
-uint32_t get_effective_bwrate(or_options_t *options);
-uint32_t get_effective_bwburst(or_options_t *options);
+uint32_t get_effective_bwrate(const or_options_t *options);
+uint32_t get_effective_bwburst(const or_options_t *options);
 
 #ifdef CONFIG_PRIVATE
 /* Used only by config.c and test.c */
diff --git a/src/or/connection.c b/src/or/connection.c
index e0b5b96..317bfb1 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -619,7 +619,7 @@ connection_about_to_close_connection(connection_t *conn)
         circuit_n_conn_done(TO_OR_CONN(conn), 0);
         /* now mark things down as needed */
         if (connection_or_nonopen_was_started_here(or_conn)) {
-          or_options_t *options = get_options();
+          const or_options_t *options = get_options();
           rep_hist_note_connect_failed(or_conn->identity_digest, now);
           entry_guard_register_connect_status(or_conn->identity_digest,0,
                                               !options->HTTPSProxy, now);
@@ -899,7 +899,7 @@ warn_too_many_conns(void)
 /** Check whether we should be willing to open an AF_UNIX socket in
  * <b>path</b>.  Return 0 if we should go ahead and -1 if we shouldn't. */
 static int
-check_location_for_unix_socket(or_options_t *options, const char *path)
+check_location_for_unix_socket(const or_options_t *options, const char *path)
 {
   int r = -1;
   char *p = tor_strdup(path);
@@ -1186,7 +1186,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
   struct sockaddr *remote = (struct sockaddr*)addrbuf;
   /* length of the remote address. Must be whatever accept() needs. */
   socklen_t remotelen = (socklen_t)sizeof(addrbuf);
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
   memset(addrbuf, 0, sizeof(addrbuf));
@@ -1366,7 +1366,7 @@ connection_connect(connection_t *conn, const char *address,
   char addrbuf[256];
   struct sockaddr *dest_addr;
   int dest_addr_len;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int protocol_family;
 
   if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
@@ -1489,7 +1489,7 @@ connection_proxy_state_to_string(int state)
 int
 connection_proxy_connect(connection_t *conn, int type)
 {
-  or_options_t *options;
+  const or_options_t *options;
 
   tor_assert(conn);
 
@@ -2005,7 +2005,7 @@ int
 retry_all_listeners(smartlist_t *replaced_conns,
                     smartlist_t *new_conns)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int retval = 0;
   const uint16_t old_or_port = router_get_advertised_or_port(options);
   const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0);
@@ -2071,7 +2071,7 @@ retry_all_listeners(smartlist_t *replaced_conns,
 static int
 connection_is_rate_limited(connection_t *conn)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (conn->linked)
     return 0; /* Internal connection */
   else if (! options->CountPrivateBandwidth &&
@@ -2269,7 +2269,7 @@ global_write_bucket_low(connection_t *conn, size_t attempt, int priority)
 
   if (priority == 1) { /* old-style v1 query */
     /* Could we handle *two* of these requests within the next two seconds? */
-    or_options_t *options = get_options();
+    const or_options_t *options = get_options();
     int64_t can_write = (int64_t)smaller_bucket
       + 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate :
                                          options->BandwidthRate);
@@ -2387,7 +2387,7 @@ connection_consider_empty_write_buckets(connection_t *conn)
 void
 connection_bucket_init(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   /* start it at max traffic */
   global_read_bucket = (int)options->BandwidthBurst;
   global_write_bucket = (int)options->BandwidthBurst;
@@ -2432,7 +2432,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
 void
 connection_bucket_refill(int seconds_elapsed, time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   smartlist_t *conns = get_connection_array();
   int relayrate, relayburst;
 
@@ -2552,7 +2552,7 @@ connection_bucket_refill(int seconds_elapsed, time_t now)
 void
 connection_bucket_init(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const struct timeval *tick = tor_libevent_get_one_tick_timeout();
   struct ev_token_bucket_cfg *bucket_cfg;
 
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 273a962..75a93fb 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -439,7 +439,7 @@ connection_ap_expire_beginning(void)
   edge_connection_t *conn;
   circuit_t *circ;
   time_t now = time(NULL);
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int severity;
   int cutoff;
   int seconds_idle, seconds_since_born;
@@ -813,7 +813,7 @@ clear_trackexithost_mappings(const char *exitname)
  * host is unknown or no longer allowed, or for which the source address
  * is no longer in trackexithosts. */
 void
-addressmap_clear_excluded_trackexithosts(or_options_t *options)
+addressmap_clear_excluded_trackexithosts(const or_options_t *options)
 {
   const routerset_t *allow_nodes = options->ExitNodes;
   const routerset_t *exclude_nodes = options->_ExcludeExitNodesUnion;
@@ -866,7 +866,7 @@ addressmap_clear_excluded_trackexithosts(or_options_t *options)
  * no longer allowed by AutomapHostsOnResolve, or for which the
  * target address is no longer in the virtual network. */
 void
-addressmap_clear_invalid_automaps(or_options_t *options)
+addressmap_clear_invalid_automaps(const or_options_t *options)
 {
   int clear_all = !options->AutomapHostsOnResolve;
   const smartlist_t *suffixes = options->AutomapHostsSuffixes;
@@ -1520,7 +1520,7 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
 static int
 consider_plaintext_ports(edge_connection_t *conn, uint16_t port)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int reject = smartlist_string_num_isin(options->RejectPlaintextPorts, port);
 
   if (smartlist_string_num_isin(options->WarnPlaintextPorts, port)) {
@@ -1557,7 +1557,7 @@ connection_ap_rewrite_and_attach_if_allowed(edge_connection_t *conn,
                                             origin_circuit_t *circ,
                                             crypt_path_t *cpath)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (options->LeaveStreamsUnattached) {
     conn->_base.state = AP_CONN_STATE_CONTROLLER_WAIT;
@@ -1588,7 +1588,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
 {
   socks_request_t *socks = conn->socks_request;
   hostname_type_t addresstype;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   struct in_addr addr_tmp;
   /* We set this to true if this is an address we should automatically
    * remap to a local address in VirtualAddrNetwork */
@@ -2079,7 +2079,7 @@ connection_ap_handshake_process_socks(edge_connection_t *conn)
 {
   socks_request_t *socks;
   int sockshere;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(conn);
   tor_assert(conn->_base.type == CONN_TYPE_AP);
@@ -2703,7 +2703,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
   char *address=NULL;
   uint16_t port;
   or_circuit_t *or_circ = NULL;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   assert_circuit_ok(circ);
   if (!CIRCUIT_IS_ORIGIN(circ))
@@ -3104,7 +3104,7 @@ connection_edge_is_rendezvous_stream(edge_connection_t *conn)
 int
 connection_ap_can_use_exit(edge_connection_t *conn, const node_t *exit)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(conn);
   tor_assert(conn->_base.type == CONN_TYPE_AP);
diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h
index 11b25f0..a7fc12e 100644
--- a/src/or/connection_edge.h
+++ b/src/or/connection_edge.h
@@ -63,8 +63,8 @@ int connection_ap_process_transparent(edge_connection_t *conn);
 int address_is_invalid_destination(const char *address, int client);
 
 void addressmap_init(void);
-void addressmap_clear_excluded_trackexithosts(or_options_t *options);
-void addressmap_clear_invalid_automaps(or_options_t *options);
+void addressmap_clear_excluded_trackexithosts(const or_options_t *options);
+void addressmap_clear_invalid_automaps(const or_options_t *options);
 void addressmap_clean(time_t now);
 void addressmap_clear_configured(void);
 void addressmap_clear_transient(void);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 73aad7e..2140e00 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -380,7 +380,7 @@ connection_or_digest_is_known_relay(const char *id_digest)
  */
 static void
 connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
-                                          or_options_t *options)
+                                          const or_options_t *options)
 {
   int rate, burst; /* per-connection rate limiting params */
   if (connection_or_digest_is_known_relay(conn->identity_digest)) {
@@ -436,7 +436,8 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
  * Go through all the OR connections and update their token buckets to make
  * sure they don't exceed their maximum values. */
 void
-connection_or_update_token_buckets(smartlist_t *conns, or_options_t *options)
+connection_or_update_token_buckets(smartlist_t *conns,
+                                   const or_options_t *options)
 {
   SMARTLIST_FOREACH(conns, connection_t *, conn,
   {
@@ -827,7 +828,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
                       const char *id_digest)
 {
   or_connection_t *conn;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int socket_error = 0;
   int using_proxy = 0;
   tor_addr_t addr;
@@ -1144,7 +1145,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
                                         char *digest_rcvd_out)
 {
   crypto_pk_env_t *identity_rcvd=NULL;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
   const char *safe_address =
     started_here ? conn->_base.address :
diff --git a/src/or/connection_or.h b/src/or/connection_or.h
index 70ef96a..4a374ca 100644
--- a/src/or/connection_or.h
+++ b/src/or/connection_or.h
@@ -27,7 +27,7 @@ int connection_or_finished_flushing(or_connection_t *conn);
 int connection_or_finished_connecting(or_connection_t *conn);
 int connection_or_digest_is_known_relay(const char *id_digest);
 void connection_or_update_token_buckets(smartlist_t *conns,
-                                        or_options_t *options);
+                                        const or_options_t *options);
 
 void connection_or_connect_failed(or_connection_t *conn,
                                   int reason, const char *msg);
diff --git a/src/or/control.c b/src/or/control.c
index 7a68f9b..4fcc3ab 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -523,7 +523,7 @@ control_ports_write_to_file(void)
 {
   smartlist_t *lines;
   char *joined = NULL;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (!options->ControlPortWriteToFile)
     return;
@@ -827,7 +827,7 @@ handle_control_getconf(control_connection_t *conn, uint32_t body_len,
   smartlist_t *unrecognized = smartlist_create();
   char *msg = NULL;
   size_t msg_len;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int i, len;
 
   (void) body_len; /* body is NUL-terminated; so we can ignore len. */
@@ -1070,7 +1070,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
                             const char *body)
 {
   int used_quoted_string = 0;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const char *errstr = NULL;
   char *password;
   size_t password_len;
@@ -2849,7 +2849,7 @@ handle_control_protocolinfo(control_connection_t *conn, uint32_t len,
       connection_mark_for_close(TO_CONN(conn));
     goto done;
   } else {
-    or_options_t *options = get_options();
+    const or_options_t *options = get_options();
     int cookies = options->CookieAuthentication;
     char *cfile = get_cookie_file();
     char *esc_cfile = esc_for_log(cfile);
@@ -4021,7 +4021,7 @@ control_event_guard(const char *nickname, const char *digest,
 static char *
 get_cookie_file(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (options->CookieAuthFile && strlen(options->CookieAuthFile)) {
     return tor_strdup(options->CookieAuthFile);
   } else {
diff --git a/src/or/directory.c b/src/or/directory.c
index e7a2a4b..5d63a54 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -252,7 +252,7 @@ int
 directories_have_accepted_server_descriptor(void)
 {
   smartlist_t *servers = router_get_trusted_dir_servers();
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
     if ((d->type & options->_PublishServerDescriptor) &&
         d->has_accepted_serverdesc) {
@@ -285,7 +285,7 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
                              const char *payload,
                              size_t payload_len, size_t extrainfo_len)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int post_via_tor;
   smartlist_t *dirservers = router_get_trusted_dir_servers();
   int found = 0;
@@ -352,7 +352,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
                              const char *resource, int pds_flags)
 {
   const routerstatus_t *rs = NULL;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int prefer_authority = directory_fetches_from_authorities(options);
   int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
   dirinfo_type_t type;
@@ -548,7 +548,7 @@ directory_initiate_command_routerstatus_rend(const routerstatus_t *status,
                                              time_t if_modified_since,
                                              const rend_data_t *rend_query)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const node_t *node;
   char address_buf[INET_NTOA_BUF_LEN+1];
   struct in_addr in;
@@ -817,7 +817,7 @@ connection_dir_download_cert_failed(dir_connection_t *conn, int status)
  * 3) Else yes.
  */
 static int
-directory_command_should_use_begindir(or_options_t *options,
+directory_command_should_use_begindir(const or_options_t *options,
                                       const tor_addr_t *addr,
                                       int or_port, uint8_t router_purpose,
                                       int anonymized_connection)
@@ -873,7 +873,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
                                 const rend_data_t *rend_query)
 {
   dir_connection_t *conn;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int socket_error = 0;
   int use_begindir = supports_begindir &&
                      directory_command_should_use_begindir(options, _addr,
@@ -2579,7 +2579,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
 {
   size_t dlen;
   char *url, *url_mem, *header;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   time_t if_modified_since = 0;
   int compressed;
   size_t url_len;
@@ -3295,7 +3295,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
                               const char *body, size_t body_len)
 {
   char *url = NULL;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   log_debug(LD_DIRSERV,"Received POST command.");
 
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index fef9450..33796fc 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -212,7 +212,7 @@ dirserv_load_fingerprint_file(void)
   authdir_config_t *fingerprint_list_new;
   int result;
   config_line_t *front=NULL, *list;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   fname = get_datadir_fname("approved-routers");
   log_info(LD_GENERAL,
@@ -1032,7 +1032,7 @@ list_server_status_v1(smartlist_t *routers, char **router_status_out,
   smartlist_t *rs_entries;
   time_t now = time(NULL);
   time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   /* We include v2 dir auths here too, because they need to answer
    * controllers. Eventually we'll deprecate this whole function;
    * see also networkstatus_getinfo_by_purpose(). */
@@ -1199,7 +1199,7 @@ dirserv_dump_directory_to_string(char **dir_out,
 /** Return 1 if we fetch our directory material directly from the
  * authorities, rather than from a mirror. */
 int
-directory_fetches_from_authorities(or_options_t *options)
+directory_fetches_from_authorities(const or_options_t *options)
 {
   const routerinfo_t *me;
   uint32_t addr;
@@ -1226,7 +1226,7 @@ directory_fetches_from_authorities(or_options_t *options)
  * on the "mirror" schedule rather than the "client" schedule.
  */
 int
-directory_fetches_dir_info_early(or_options_t *options)
+directory_fetches_dir_info_early(const or_options_t *options)
 {
   return directory_fetches_from_authorities(options);
 }
@@ -1238,7 +1238,7 @@ directory_fetches_dir_info_early(or_options_t *options)
  * client as a directory guard.
  */
 int
-directory_fetches_dir_info_later(or_options_t *options)
+directory_fetches_dir_info_later(const or_options_t *options)
 {
   return options->UseBridges != 0;
 }
@@ -1246,7 +1246,7 @@ directory_fetches_dir_info_later(or_options_t *options)
 /** Return 1 if we want to cache v2 dir info (each status file).
  */
 int
-directory_caches_v2_dir_info(or_options_t *options)
+directory_caches_v2_dir_info(const or_options_t *options)
 {
   return options->DirPort != 0;
 }
@@ -1255,7 +1255,7 @@ directory_caches_v2_dir_info(or_options_t *options)
  * and we're willing to serve them to others. Else return 0.
  */
 int
-directory_caches_dir_info(or_options_t *options)
+directory_caches_dir_info(const or_options_t *options)
 {
   if (options->BridgeRelay || options->DirPort)
     return 1;
@@ -1271,7 +1271,7 @@ directory_caches_dir_info(or_options_t *options)
  * requests via the "begin_dir" interface, which doesn't require
  * having any separate port open. */
 int
-directory_permits_begindir_requests(or_options_t *options)
+directory_permits_begindir_requests(const or_options_t *options)
 {
   return options->BridgeRelay != 0 || options->DirPort != 0;
 }
@@ -1280,7 +1280,7 @@ directory_permits_begindir_requests(or_options_t *options)
  * requests via the controller interface, which doesn't require
  * having any separate port open. */
 int
-directory_permits_controller_requests(or_options_t *options)
+directory_permits_controller_requests(const or_options_t *options)
 {
   return options->DirPort != 0;
 }
@@ -1290,7 +1290,8 @@ directory_permits_controller_requests(or_options_t *options)
  * lately.
  */
 int
-directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now)
+directory_too_idle_to_fetch_descriptors(const or_options_t *options,
+                                        time_t now)
 {
   return !directory_caches_dir_info(options) &&
          !options->FetchUselessDescriptors &&
@@ -1560,7 +1561,7 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
                             const char *name,
                             dirinfo_type_t auth_type)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int authority = (auth_type == V1_DIRINFO && authdir_mode_v1(options)) ||
                   (auth_type == V2_DIRINFO && authdir_mode_v2(options));
 
@@ -2251,7 +2252,7 @@ _compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
 static digestmap_t *
 get_possible_sybil_list(const smartlist_t *routers)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   digestmap_t *omit_as_sybil;
   smartlist_t *routers_by_ip = smartlist_create();
   uint32_t last_addr;
@@ -2551,7 +2552,7 @@ networkstatus_t *
 dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
                                         authority_cert_t *cert)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   networkstatus_t *v3_out = NULL;
   uint32_t addr;
   char *hostname = NULL, *client_versions = NULL, *server_versions = NULL;
@@ -2766,7 +2767,7 @@ generate_v2_networkstatus_opinion(void)
   char *status = NULL, *client_versions = NULL, *server_versions = NULL,
     *identity_pkey = NULL, *hostname = NULL;
   char *outp, *endp;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   char fingerprint[FINGERPRINT_LEN+1];
   char published[ISO_TIME_LEN+1];
   char digest[DIGEST_LEN];
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 8bd6d18..d3fd90c 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -71,15 +71,16 @@ int list_server_status_v1(smartlist_t *routers, char **router_status_out,
 int dirserv_dump_directory_to_string(char **dir_out,
                                      crypto_pk_env_t *private_key);
 
-int directory_fetches_from_authorities(or_options_t *options);
-int directory_fetches_dir_info_early(or_options_t *options);
-int directory_fetches_dir_info_later(or_options_t *options);
-int directory_caches_v2_dir_info(or_options_t *options);
+int directory_fetches_from_authorities(const or_options_t *options);
+int directory_fetches_dir_info_early(const or_options_t *options);
+int directory_fetches_dir_info_later(const or_options_t *options);
+int directory_caches_v2_dir_info(const or_options_t *options);
 #define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o)
-int directory_caches_dir_info(or_options_t *options);
-int directory_permits_begindir_requests(or_options_t *options);
-int directory_permits_controller_requests(or_options_t *options);
-int directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now);
+int directory_caches_dir_info(const or_options_t *options);
+int directory_permits_begindir_requests(const or_options_t *options);
+int directory_permits_controller_requests(const or_options_t *options);
+int directory_too_idle_to_fetch_descriptors(const or_options_t *options,
+                                            time_t now);
 
 void directory_set_dirty(void);
 cached_dir_t *dirserv_get_directory(void);
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index e77b4fe..bf34c62 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2504,7 +2504,7 @@ authority_cert_dup(authority_cert_t *cert)
 void
 dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(timing_out);
 
@@ -2578,7 +2578,7 @@ static struct {
 /** Set voting_schedule to hold the timing for the next vote we should be
  * doing. */
 void
-dirvote_recalculate_timing(or_options_t *options, time_t now)
+dirvote_recalculate_timing(const or_options_t *options, time_t now)
 {
   int interval, vote_delay, dist_delay;
   time_t start;
@@ -2629,7 +2629,7 @@ dirvote_recalculate_timing(or_options_t *options, time_t now)
 
 /** Entry point: Take whatever voting actions are pending as of <b>now</b>. */
 void
-dirvote_act(or_options_t *options, time_t now)
+dirvote_act(const or_options_t *options, time_t now)
 {
   if (!authdir_mode_v3(options))
     return;
diff --git a/src/or/dirvote.h b/src/or/dirvote.h
index 97bed5e..b6746c6 100644
--- a/src/or/dirvote.h
+++ b/src/or/dirvote.h
@@ -41,8 +41,8 @@ authority_cert_t *authority_cert_dup(authority_cert_t *cert);
 /* vote scheduling */
 void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
 time_t dirvote_get_start_of_next_interval(time_t now, int interval);
-void dirvote_recalculate_timing(or_options_t *options, time_t now);
-void dirvote_act(or_options_t *options, time_t now);
+void dirvote_recalculate_timing(const or_options_t *options, time_t now);
+void dirvote_act(const or_options_t *options, time_t now);
 
 /* invoked on timers and by outside triggers. */
 struct pending_vote_t * dirvote_add_vote(const char *vote_body,
diff --git a/src/or/dns.c b/src/or/dns.c
index a7fad3d..5d86e81 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -276,7 +276,7 @@ dns_init(void)
 int
 dns_reset(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (! server_mode(options)) {
 
     if (!the_evdns_base) {
@@ -1026,7 +1026,7 @@ add_answer_to_cache(const char *address, uint8_t is_reverse, uint32_t addr,
 static INLINE int
 is_test_address(const char *address)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   return options->ServerDNSTestAddresses &&
     smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
 }
@@ -1177,7 +1177,7 @@ evdns_err_is_transient(int err)
 static int
 configure_nameservers(int force)
 {
-  or_options_t *options;
+  const or_options_t *options;
   const char *conf_fname;
   struct stat st;
   int r;
@@ -1595,7 +1595,7 @@ launch_wildcard_check(int min_len, int max_len, const char *suffix)
 static void
 launch_test_addresses(int fd, short event, void *args)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   struct evdns_request *req;
   (void)fd;
   (void)event;
diff --git a/src/or/geoip.c b/src/or/geoip.c
index d369b45..59490bd 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -162,7 +162,7 @@ _geoip_compare_key_to_entry(const void *_key, const void **_member)
 /** Return 1 if we should collect geoip stats on bridge users, and
  * include them in our extrainfo descriptor. Else return 0. */
 int
-should_record_bridge_info(or_options_t *options)
+should_record_bridge_info(const or_options_t *options)
 {
   return options->BridgeRelay && options->BridgeRecordUsageByCountry;
 }
@@ -199,7 +199,7 @@ init_geoip_countries(void)
  * with '#' (comments).
  */
 int
-geoip_load_file(const char *filename, or_options_t *options)
+geoip_load_file(const char *filename, const or_options_t *options)
 {
   FILE *f;
   const char *msg = "";
@@ -424,7 +424,7 @@ void
 geoip_note_client_seen(geoip_client_action_t action,
                        uint32_t addr, time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   clientmap_entry_t lookup, *ent;
   if (action == GEOIP_CLIENT_CONNECT) {
     /* Only remember statistics as entry guard or as bridge. */
diff --git a/src/or/geoip.h b/src/or/geoip.h
index 02228ea..b50da74 100644
--- a/src/or/geoip.h
+++ b/src/or/geoip.h
@@ -15,8 +15,8 @@
 #ifdef GEOIP_PRIVATE
 int geoip_parse_entry(const char *line);
 #endif
-int should_record_bridge_info(or_options_t *options);
-int geoip_load_file(const char *filename, or_options_t *options);
+int should_record_bridge_info(const or_options_t *options);
+int geoip_load_file(const char *filename, const or_options_t *options);
 int geoip_get_country_by_ip(uint32_t ipaddr);
 int geoip_get_n_countries(void);
 const char *geoip_get_country_name(country_t num);
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index aebce4c..f03433a 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -134,7 +134,7 @@ static void accounting_set_wakeup_time(void);
  * options->AccountingStart.  Return 0 on success, -1 on failure. If
  * <b>validate_only</b> is true, do not change the current settings. */
 int
-accounting_parse_options(or_options_t *options, int validate_only)
+accounting_parse_options(const or_options_t *options, int validate_only)
 {
   time_unit_t unit;
   int ok, idx;
@@ -249,7 +249,7 @@ accounting_parse_options(or_options_t *options, int validate_only)
  * hibernate, return 1, else return 0.
  */
 int
-accounting_is_enabled(or_options_t *options)
+accounting_is_enabled(const or_options_t *options)
 {
   if (options->AccountingMax)
     return 1;
@@ -411,7 +411,7 @@ static void
 update_expected_bandwidth(void)
 {
   uint64_t expected;
-  or_options_t *options= get_options();
+  const or_options_t *options= get_options();
   uint64_t max_configured = (options->RelayBandwidthRate > 0 ?
                              options->RelayBandwidthRate :
                              options->BandwidthRate) * 60;
@@ -750,7 +750,7 @@ static void
 hibernate_begin(hibernate_state_t new_state, time_t now)
 {
   connection_t *conn;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (new_state == HIBERNATE_STATE_EXITING &&
       hibernate_state != HIBERNATE_STATE_LIVE) {
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 2aea0fa..b5826bc 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -12,8 +12,8 @@
 #ifndef _TOR_HIBERNATE_H
 #define _TOR_HIBERNATE_H
 
-int accounting_parse_options(or_options_t *options, int validate_only);
-int accounting_is_enabled(or_options_t *options);
+int accounting_parse_options(const or_options_t *options, int validate_only);
+int accounting_is_enabled(const or_options_t *options);
 void configure_accounting(time_t now);
 void accounting_run_housekeeping(time_t now);
 void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
diff --git a/src/or/main.c b/src/or/main.c
index bb56be7..35cc1cb 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -867,7 +867,7 @@ directory_all_unreachable(time_t now)
 void
 directory_info_has_arrived(time_t now, int from_cache)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (!router_have_minimum_dir_info()) {
     int quiet = directory_too_idle_to_fetch_descriptors(options, now);
@@ -912,7 +912,7 @@ run_connection_housekeeping(int i, time_t now)
 {
   cell_t cell;
   connection_t *conn = smartlist_get(connection_array, i);
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   or_connection_t *or_conn;
   int past_keepalive =
     now >= conn->timestamp_lastwritten + options->KeepalivePeriod;
@@ -1018,7 +1018,7 @@ run_connection_housekeeping(int i, time_t now)
 static void
 signewnym_impl(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (!proxy_mode(options)) {
     log_info(LD_CONTROL, "Ignoring SIGNAL NEWNYM because client functionality "
              "is disabled.");
@@ -1060,7 +1060,7 @@ run_scheduled_events(time_t now)
   static int should_init_bridge_stats = 1;
   static time_t time_to_retry_dns_init = 0;
   static time_t time_to_next_heartbeat = 0;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int is_server = server_mode(options);
   int i;
   int have_dir_info;
@@ -1487,7 +1487,7 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
 #ifdef USE_BUFFEREVENTS
   uint64_t cur_read,cur_written;
 #endif
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   (void)timer;
   (void)arg;
 
@@ -1630,7 +1630,7 @@ dns_servers_relaunch_checks(void)
 static int
 do_hup(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
 #ifdef USE_DMALLOC
   dmalloc_log_stats();
@@ -2172,7 +2172,7 @@ static tor_lockfile_t *lockfile = NULL;
  * return -1 if we can't get the lockfile.  Return 0 on success.
  */
 int
-try_locking(or_options_t *options, int err_if_locked)
+try_locking(const or_options_t *options, int err_if_locked)
 {
   if (lockfile)
     return 0;
@@ -2286,7 +2286,7 @@ tor_free_all(int postfork)
 void
 tor_cleanup(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (options->command == CMD_RUN_TOR) {
     time_t now = time(NULL);
     /* Remove our pid file. We don't care if there was an error when we
diff --git a/src/or/main.h b/src/or/main.h
index db97cf1..db25135 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -56,7 +56,7 @@ long get_uptime(void);
 void handle_signals(int is_parent);
 void process_signal(uintptr_t sig);
 
-int try_locking(or_options_t *options, int err_if_locked);
+int try_locking(const or_options_t *options, int err_if_locked);
 int have_lockfile(void);
 void release_lockfile(void);
 
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 7ebb1e1..cae31fe 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -595,7 +595,7 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache,
 void
 update_microdesc_downloads(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   networkstatus_t *consensus;
   smartlist_t *missing;
   digestmap_t *pending;
@@ -654,7 +654,7 @@ update_microdescs_from_networkstatus(time_t now)
 /** Return true iff we should prefer to use microdescriptors rather than
  * routerdescs for building circuits. */
 int
-we_use_microdescriptors_for_circuits(or_options_t *options)
+we_use_microdescriptors_for_circuits(const or_options_t *options)
 {
   int ret = options->UseMicrodescriptors;
   if (ret == -1) {
@@ -673,7 +673,7 @@ we_use_microdescriptors_for_circuits(or_options_t *options)
 
 /** Return true iff we should try to download microdescriptors at all. */
 int
-we_fetch_microdescriptors(or_options_t *options)
+we_fetch_microdescriptors(const or_options_t *options)
 {
   if (directory_caches_dir_info(options))
     return 1;
@@ -682,7 +682,7 @@ we_fetch_microdescriptors(or_options_t *options)
 
 /** Return true iff we should try to download router descriptors at all. */
 int
-we_fetch_router_descriptors(or_options_t *options)
+we_fetch_router_descriptors(const or_options_t *options)
 {
   if (directory_caches_dir_info(options))
     return 1;
diff --git a/src/or/microdesc.h b/src/or/microdesc.h
index 94b1ff6..72e4572 100644
--- a/src/or/microdesc.h
+++ b/src/or/microdesc.h
@@ -44,9 +44,9 @@ void update_microdesc_downloads(time_t now);
 void update_microdescs_from_networkstatus(time_t now);
 
 int usable_consensus_flavor(void);
-int we_fetch_microdescriptors(or_options_t *options);
-int we_fetch_router_descriptors(or_options_t *options);
-int we_use_microdescriptors_for_circuits(or_options_t *options);
+int we_fetch_microdescriptors(const or_options_t *options);
+int we_fetch_router_descriptors(const or_options_t *options);
+int we_use_microdescriptors_for_circuits(const or_options_t *options);
 
 #endif
 
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index ab1358b..2586ce6 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -213,7 +213,7 @@ router_reload_consensus_networkstatus(void)
   char *filename;
   char *s;
   struct stat st;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const unsigned int flags = NSSET_FROM_CACHE | NSSET_DONT_DOWNLOAD_CERTS;
   int flav;
 
@@ -1175,7 +1175,7 @@ update_v2_networkstatus_cache_downloads(time_t now)
 
 /** DOCDOC */
 static int
-we_want_to_fetch_flavor(or_options_t *options, int flavor)
+we_want_to_fetch_flavor(const or_options_t *options, int flavor)
 {
   if (flavor < 0 || flavor > N_CONSENSUS_FLAVORS) {
     /* This flavor is crazy; we don't want it */
@@ -1204,7 +1204,7 @@ static void
 update_consensus_networkstatus_downloads(time_t now)
 {
   int i;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (!networkstatus_get_live_consensus(now))
     time_to_download_next_consensus = now; /* No live consensus? Get one now!*/
@@ -1274,7 +1274,7 @@ networkstatus_consensus_download_failed(int status_code, const char *flavname)
 void
 update_consensus_networkstatus_fetch_time(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   networkstatus_t *c = networkstatus_get_live_consensus(now);
   if (c) {
     long dl_interval;
@@ -1348,7 +1348,7 @@ update_consensus_networkstatus_fetch_time(time_t now)
  * fetches yet (e.g. we demand bridges and none are yet known).
  * Else return 0. */
 int
-should_delay_dir_fetches(or_options_t *options)
+should_delay_dir_fetches(const or_options_t *options)
 {
   if (options->UseBridges && !any_bridge_descriptors_known()) {
     log_info(LD_DIR, "delaying dir fetches (no running bridges known)");
@@ -1362,7 +1362,7 @@ should_delay_dir_fetches(or_options_t *options)
 void
 update_networkstatus_downloads(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (should_delay_dir_fetches(options))
     return;
   if (authdir_mode_any_main(options) || options->FetchV2Networkstatus)
@@ -1585,7 +1585,7 @@ networkstatus_set_current_consensus(const char *consensus,
   networkstatus_t *c=NULL;
   int r, result = -1;
   time_t now = time(NULL);
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   char *unverified_fname = NULL, *consensus_fname = NULL;
   int flav = networkstatus_parse_flavor_name(flavor);
   const unsigned from_cache = flags & NSSET_FROM_CACHE;
@@ -1991,7 +1991,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
                                                    int reset_failures)
 {
   trusted_dir_server_t *ds;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
   networkstatus_t *ns = current_consensus;
   if (!ns || !smartlist_len(ns->routerstatus_list))
@@ -2151,7 +2151,7 @@ void
 networkstatus_dump_bridge_status_to_file(time_t now)
 {
   char *status = networkstatus_getinfo_by_purpose("bridge", now);
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   size_t len = strlen(options->DataDirectory) + 32;
   char *fname = tor_malloc(len);
   tor_snprintf(fname, len, "%s"PATH_SEPARATOR"networkstatus-bridges",
@@ -2205,7 +2205,7 @@ get_net_param_from_list(smartlist_t *net_params, const char *param_name,
  * <b>min_val</b> and at most <b>max_val</b> and raise/cap the parsed value
  * if necessary. */
 int32_t
-networkstatus_get_param(networkstatus_t *ns, const char *param_name,
+networkstatus_get_param(const networkstatus_t *ns, const char *param_name,
                         int32_t default_val, int32_t min_val, int32_t max_val)
 {
   if (!ns) /* if they pass in null, go find it ourselves */
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index 38fac55..1b10f27 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -67,7 +67,7 @@ int networkstatus_nickname_is_unnamed(const char *nickname);
 void networkstatus_consensus_download_failed(int status_code,
                                              const char *flavname);
 void update_consensus_networkstatus_fetch_time(time_t now);
-int should_delay_dir_fetches(or_options_t *options);
+int should_delay_dir_fetches(const or_options_t *options);
 void update_networkstatus_downloads(time_t now);
 void update_certificate_downloads(time_t now);
 int consensus_is_waiting_for_certs(void);
@@ -96,7 +96,8 @@ void signed_descs_update_status_from_consensus_networkstatus(
 char *networkstatus_getinfo_helper_single(const routerstatus_t *rs);
 char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
 void networkstatus_dump_bridge_status_to_file(time_t now);
-int32_t networkstatus_get_param(networkstatus_t *ns, const char *param_name,
+int32_t networkstatus_get_param(const networkstatus_t *ns,
+                                const char *param_name,
                                 int32_t default_val, int32_t min_val,
                                 int32_t max_val);
 int getinfo_helper_networkstatus(control_connection_t *conn,
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 8cded8f..96b65a1 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -171,7 +171,7 @@ nodelist_add_microdesc(microdesc_t *md)
 void
 nodelist_set_consensus(networkstatus_t *ns)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
   init_nodelist();
 
diff --git a/src/or/policies.c b/src/or/policies.c
index 73e5106..983df86 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -164,7 +164,7 @@ parse_addr_policy(config_line_t *cfg, smartlist_t **dest,
 static int
 parse_reachable_addresses(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int ret = 0;
 
   if (options->ReachableDirAddresses &&
@@ -356,7 +356,7 @@ authdir_policy_badexit_address(uint32_t addr, uint16_t port)
  * options in <b>options</b>, return -1 and set <b>msg</b> to a newly
  * allocated description of the error. Else return 0. */
 int
-validate_addr_policies(or_options_t *options, char **msg)
+validate_addr_policies(const or_options_t *options, char **msg)
 {
   /* XXXX Maybe merge this into parse_policies_from_options, to make sure
    * that the two can't go out of sync. */
@@ -440,7 +440,7 @@ load_policy_from_option(config_line_t *config, smartlist_t **policy,
 /** Set all policies based on <b>options</b>, which should have been validated
  * first by validate_addr_policies. */
 int
-policies_parse_from_options(or_options_t *options)
+policies_parse_from_options(const or_options_t *options)
 {
   int ret = 0;
   if (load_policy_from_option(options->SocksPolicy, &socks_policy, -1) < 0)
diff --git a/src/or/policies.h b/src/or/policies.h
index ee1162c..6f3624a 100644
--- a/src/or/policies.h
+++ b/src/or/policies.h
@@ -29,9 +29,9 @@ int authdir_policy_valid_address(uint32_t addr, uint16_t port);
 int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
 int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
 
-int validate_addr_policies(or_options_t *options, char **msg);
+int validate_addr_policies(const or_options_t *options, char **msg);
 void policy_expand_private(smartlist_t **policy);
-int policies_parse_from_options(or_options_t *options);
+int policies_parse_from_options(const or_options_t *options);
 
 addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
 int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
diff --git a/src/or/relay.c b/src/or/relay.c
index 28f940c..d647b18 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -2010,7 +2010,8 @@ static int ewma_enabled = 0;
 
 /** Adjust the global cell scale factor based on <b>options</b> */
 void
-cell_ewma_set_scale_factor(or_options_t *options, networkstatus_t *consensus)
+cell_ewma_set_scale_factor(const or_options_t *options,
+                           const networkstatus_t *consensus)
 {
   int32_t halflife_ms;
   double halflife;
diff --git a/src/or/relay.h b/src/or/relay.h
index f64752d..7fce8ed 100644
--- a/src/or/relay.h
+++ b/src/or/relay.h
@@ -60,8 +60,8 @@ const uint8_t *decode_address_from_payload(tor_addr_t *addr_out,
                                         const uint8_t *payload,
                                         int payload_len);
 unsigned cell_ewma_get_tick(void);
-void cell_ewma_set_scale_factor(or_options_t *options,
-                                networkstatus_t *consensus);
+void cell_ewma_set_scale_factor(const or_options_t *options,
+                                const networkstatus_t *consensus);
 void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
 
 void tor_gettimeofday_cache_clear(void);
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 3e9c6e8..c4eddb6 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -903,7 +903,7 @@ rend_client_get_random_intro_impl(const rend_cache_entry_t *entry,
   int i;
 
   rend_intro_point_t *intro;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   smartlist_t *usable_nodes;
   int n_excluded = 0;
 
@@ -1010,7 +1010,8 @@ rend_service_authorization_free_all(void)
  * service and add it to the local map of hidden service authorizations.
  * Return 0 for success and -1 for failure. */
 int
-rend_parse_service_authorization(or_options_t *options, int validate_only)
+rend_parse_service_authorization(const or_options_t *options,
+                                 int validate_only)
 {
   config_line_t *line;
   int res = -1;
diff --git a/src/or/rendclient.h b/src/or/rendclient.h
index c6cf82b..1893fd9 100644
--- a/src/or/rendclient.h
+++ b/src/or/rendclient.h
@@ -37,7 +37,7 @@ int rend_client_any_intro_points_usable(const rend_cache_entry_t *entry);
 
 int rend_client_send_introduction(origin_circuit_t *introcirc,
                                   origin_circuit_t *rendcirc);
-int rend_parse_service_authorization(or_options_t *options,
+int rend_parse_service_authorization(const or_options_t *options,
                                      int validate_only);
 rend_service_authorization_t *rend_client_lookup_service_authorization(
                                                 const char *onion_address);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index f4dcd8a..af1a290 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -292,7 +292,7 @@ parse_port_config(const char *string)
  * normal, but don't actually change the configured services.)
  */
 int
-rend_config_services(or_options_t *options, int validate_only)
+rend_config_services(const or_options_t *options, int validate_only)
 {
   config_line_t *line;
   rend_service_t *service = NULL;
@@ -903,7 +903,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   time_t now = time(NULL);
   char diffie_hellman_hash[DIGEST_LEN];
   time_t *access_time;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(circuit->rend_data);
 
@@ -1377,7 +1377,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
   /* If we already have enough introduction circuits for this service,
    * redefine this one as a general circuit or close it, depending. */
   if (count_established_intro_points(serviceid) > NUM_INTRO_POINTS) {
-    or_options_t *options = get_options();
+    const or_options_t *options = get_options();
     if (options->ExcludeNodes) {
       /* XXXX in some future version, we can test whether the transition is
          allowed or not given the actual nodes in the circuit.  But for now,
@@ -1817,7 +1817,7 @@ rend_services_introduce(void)
   int changed, prev_intro_nodes;
   smartlist_t *intro_nodes;
   time_t now;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   intro_nodes = smartlist_create();
   now = time(NULL);
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index 70389af..8a2994c 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -13,7 +13,7 @@
 #define _TOR_RENDSERVICE_H
 
 int num_rend_services(void);
-int rend_config_services(or_options_t *options, int validate_only);
+int rend_config_services(const or_options_t *options, int validate_only);
 int rend_service_load_keys(void);
 void rend_services_introduce(void);
 void rend_consider_services_upload(time_t now);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index b4dbba7..cd74f1b 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1479,7 +1479,7 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
 {
   char *cp = buf;
   int i, n;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   uint64_t cutoff;
 
   if (b->num_maxes_set <= b->next_max_idx) {
diff --git a/src/or/router.c b/src/or/router.c
index 3dcd3dd..60ee93a 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -495,7 +495,7 @@ init_keys(void)
   char digest[DIGEST_LEN];
   char v3_digest[DIGEST_LEN];
   char *cp;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   dirinfo_type_t type;
   time_t now = time(NULL);
   trusted_dir_server_t *ds;
@@ -763,7 +763,7 @@ router_reset_reachability(void)
 int
 check_whether_orport_reachable(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   return options->AssumeReachable ||
          can_reach_or_port;
 }
@@ -772,7 +772,7 @@ check_whether_orport_reachable(void)
 int
 check_whether_dirport_reachable(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   return !options->DirPort ||
          options->AssumeReachable ||
          we_are_hibernating() ||
@@ -787,7 +787,7 @@ check_whether_dirport_reachable(void)
  * a DirPort.
  */
 static int
-decide_to_advertise_dirport(or_options_t *options, uint16_t dir_port)
+decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
 {
   static int advertising=1; /* start out assuming we will advertise */
   int new_choice=1;
@@ -855,7 +855,7 @@ consider_testing_reachability(int test_or, int test_dir)
   const routerinfo_t *me = router_get_my_routerinfo();
   int orport_reachable = check_whether_orport_reachable();
   tor_addr_t addr;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (!me)
     return;
 
@@ -973,7 +973,7 @@ router_perform_bandwidth_test(int num_circs, time_t now)
  * directory server.
  */
 int
-authdir_mode(or_options_t *options)
+authdir_mode(const or_options_t *options)
 {
   return options->AuthoritativeDir != 0;
 }
@@ -981,7 +981,7 @@ authdir_mode(or_options_t *options)
  * directory server.
  */
 int
-authdir_mode_v1(or_options_t *options)
+authdir_mode_v1(const or_options_t *options)
 {
   return authdir_mode(options) && options->V1AuthoritativeDir != 0;
 }
@@ -989,7 +989,7 @@ authdir_mode_v1(or_options_t *options)
  * directory server.
  */
 int
-authdir_mode_v2(or_options_t *options)
+authdir_mode_v2(const or_options_t *options)
 {
   return authdir_mode(options) && options->V2AuthoritativeDir != 0;
 }
@@ -997,13 +997,13 @@ authdir_mode_v2(or_options_t *options)
  * directory server.
  */
 int
-authdir_mode_v3(or_options_t *options)
+authdir_mode_v3(const or_options_t *options)
 {
   return authdir_mode(options) && options->V3AuthoritativeDir != 0;
 }
 /** Return true iff we are a v1, v2, or v3 directory authority. */
 int
-authdir_mode_any_main(or_options_t *options)
+authdir_mode_any_main(const or_options_t *options)
 {
   return options->V1AuthoritativeDir ||
          options->V2AuthoritativeDir ||
@@ -1012,7 +1012,7 @@ authdir_mode_any_main(or_options_t *options)
 /** Return true if we believe ourselves to be any kind of
  * authoritative directory beyond just a hidserv authority. */
 int
-authdir_mode_any_nonhidserv(or_options_t *options)
+authdir_mode_any_nonhidserv(const or_options_t *options)
 {
   return options->BridgeAuthoritativeDir ||
          authdir_mode_any_main(options);
@@ -1021,7 +1021,7 @@ authdir_mode_any_nonhidserv(or_options_t *options)
  * authoritative about receiving and serving descriptors of type
  * <b>purpose</b> its dirport.  Use -1 for "any purpose". */
 int
-authdir_mode_handles_descs(or_options_t *options, int purpose)
+authdir_mode_handles_descs(const or_options_t *options, int purpose)
 {
   if (purpose < 0)
     return authdir_mode_any_nonhidserv(options);
@@ -1036,7 +1036,7 @@ authdir_mode_handles_descs(or_options_t *options, int purpose)
  * publishes its own network statuses.
  */
 int
-authdir_mode_publishes_statuses(or_options_t *options)
+authdir_mode_publishes_statuses(const or_options_t *options)
 {
   if (authdir_mode_bridge(options))
     return 0;
@@ -1046,7 +1046,7 @@ authdir_mode_publishes_statuses(or_options_t *options)
  * tests reachability of the descriptors it learns about.
  */
 int
-authdir_mode_tests_reachability(or_options_t *options)
+authdir_mode_tests_reachability(const or_options_t *options)
 {
   return authdir_mode_handles_descs(options, -1);
 }
@@ -1054,7 +1054,7 @@ authdir_mode_tests_reachability(or_options_t *options)
  * directory server.
  */
 int
-authdir_mode_bridge(or_options_t *options)
+authdir_mode_bridge(const or_options_t *options)
 {
   return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
 }
@@ -1062,7 +1062,7 @@ authdir_mode_bridge(or_options_t *options)
 /** Return true iff we are trying to be a server.
  */
 int
-server_mode(or_options_t *options)
+server_mode(const or_options_t *options)
 {
   if (options->ClientOnly) return 0;
   return (options->ORPort != 0 || options->ORListenAddress);
@@ -1071,7 +1071,7 @@ server_mode(or_options_t *options)
 /** Return true iff we are trying to be a non-bridge server.
  */
 int
-public_server_mode(or_options_t *options)
+public_server_mode(const or_options_t *options)
 {
   if (!server_mode(options)) return 0;
   return (!options->BridgeRelay);
@@ -1081,7 +1081,7 @@ public_server_mode(or_options_t *options)
  * in the consensus mean that we don't want to allow exits from circuits
  * we got from addresses not known to be servers. */
 int
-should_refuse_unknown_exits(or_options_t *options)
+should_refuse_unknown_exits(const or_options_t *options)
 {
   if (options->RefuseUnknownExits != -1) {
     return options->RefuseUnknownExits;
@@ -1113,7 +1113,7 @@ set_server_advertised(int s)
 
 /** Return true iff we are trying to be a socks proxy. */
 int
-proxy_mode(or_options_t *options)
+proxy_mode(const or_options_t *options)
 {
   return (options->SocksPort != 0 ||
           options->TransPort != 0 ||
@@ -1134,7 +1134,7 @@ proxy_mode(or_options_t *options)
 static int
 decide_if_publishable_server(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (options->ClientOnly)
     return 0;
@@ -1179,7 +1179,7 @@ consider_publishable_server(int force)
  * the one configured in the ORPort option, or the one we actually bound to
  * if ORPort is "auto". */
 uint16_t
-router_get_advertised_or_port(or_options_t *options)
+router_get_advertised_or_port(const or_options_t *options)
 {
   if (options->ORPort == CFG_AUTO_PORT) {
     connection_t *c = connection_get_by_type(CONN_TYPE_OR_LISTENER);
@@ -1196,7 +1196,7 @@ router_get_advertised_or_port(or_options_t *options)
  * the one configured in the DirPort option,
  * or the one we actually bound to if DirPort is "auto". */
 uint16_t
-router_get_advertised_dir_port(or_options_t *options, uint16_t dirport)
+router_get_advertised_dir_port(const or_options_t *options, uint16_t dirport)
 {
   if (!options->DirPort)
     return dirport;
@@ -1397,7 +1397,7 @@ static int router_guess_address_from_dir_headers(uint32_t *guess);
  * dirserver headers. Place the answer in *<b>addr</b> and return
  * 0 on success, else return -1 if we have no guess. */
 int
-router_pick_published_address(or_options_t *options, uint32_t *addr)
+router_pick_published_address(const or_options_t *options, uint32_t *addr)
 {
   if (resolve_my_address(LOG_INFO, options, addr, NULL) < 0) {
     log_info(LD_CONFIG, "Could not determine our address locally. "
@@ -1424,7 +1424,7 @@ router_rebuild_descriptor(int force)
   uint32_t addr;
   char platform[256];
   int hibernating = we_are_hibernating();
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (desc_clean_since && !force)
     return 0;
@@ -1686,7 +1686,7 @@ void
 check_descriptor_ipaddress_changed(time_t now)
 {
   uint32_t prev, cur;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   (void) now;
 
   if (!desc_routerinfo)
@@ -1718,7 +1718,7 @@ router_new_address_suggestion(const char *suggestion,
 {
   uint32_t addr, cur = 0;
   struct in_addr in;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   /* first, learn what the IP address actually is */
   if (!tor_inet_aton(suggestion, &in)) {
@@ -1817,7 +1817,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
   int result=0;
   addr_policy_t *tmpe;
   char *family_line;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   /* Make sure the identity key matches the one in the routerinfo. */
   if (crypto_pk_cmp_keys(ident_key, router->identity_pkey)) {
@@ -2059,7 +2059,7 @@ int
 extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
                          crypto_pk_env_t *ident_key)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   char identity[HEX_DIGEST_LEN+1];
   char published[ISO_TIME_LEN+1];
   char digest[DIGEST_LEN];
diff --git a/src/or/router.h b/src/or/router.h
index dc9ab5e..f6d3c12 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -39,27 +39,27 @@ void router_orport_found_reachable(void);
 void router_dirport_found_reachable(void);
 void router_perform_bandwidth_test(int num_circs, time_t now);
 
-int authdir_mode(or_options_t *options);
-int authdir_mode_v1(or_options_t *options);
-int authdir_mode_v2(or_options_t *options);
-int authdir_mode_v3(or_options_t *options);
-int authdir_mode_any_main(or_options_t *options);
-int authdir_mode_any_nonhidserv(or_options_t *options);
-int authdir_mode_handles_descs(or_options_t *options, int purpose);
-int authdir_mode_publishes_statuses(or_options_t *options);
-int authdir_mode_tests_reachability(or_options_t *options);
-int authdir_mode_bridge(or_options_t *options);
+int authdir_mode(const or_options_t *options);
+int authdir_mode_v1(const or_options_t *options);
+int authdir_mode_v2(const or_options_t *options);
+int authdir_mode_v3(const or_options_t *options);
+int authdir_mode_any_main(const or_options_t *options);
+int authdir_mode_any_nonhidserv(const or_options_t *options);
+int authdir_mode_handles_descs(const or_options_t *options, int purpose);
+int authdir_mode_publishes_statuses(const or_options_t *options);
+int authdir_mode_tests_reachability(const or_options_t *options);
+int authdir_mode_bridge(const or_options_t *options);
 
-uint16_t router_get_advertised_or_port(or_options_t *options);
-uint16_t router_get_advertised_dir_port(or_options_t *options,
+uint16_t router_get_advertised_or_port(const or_options_t *options);
+uint16_t router_get_advertised_dir_port(const or_options_t *options,
                                         uint16_t dirport);
 
-int server_mode(or_options_t *options);
-int public_server_mode(or_options_t *options);
+int server_mode(const or_options_t *options);
+int public_server_mode(const or_options_t *options);
 int advertised_server_mode(void);
-int proxy_mode(or_options_t *options);
+int proxy_mode(const or_options_t *options);
 void consider_publishable_server(int force);
-int should_refuse_unknown_exits(or_options_t *options);
+int should_refuse_unknown_exits(const or_options_t *options);
 
 void router_upload_dir_desc_to_dirservers(int force);
 void mark_my_descriptor_dirty_if_older_than(time_t when);
@@ -77,7 +77,7 @@ int router_digest_is_me(const char *digest);
 int router_extrainfo_digest_is_me(const char *digest);
 int router_is_me(const routerinfo_t *router);
 int router_fingerprint_is_me(const char *fp);
-int router_pick_published_address(or_options_t *options, uint32_t *addr);
+int router_pick_published_address(const or_options_t *options, uint32_t *addr);
 int router_rebuild_descriptor(int force);
 int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
                                  crypto_pk_env_t *ident_key);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index a8a5974..f711282 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -57,7 +57,7 @@ static const char *signed_descriptor_get_body_impl(
 static void list_pending_downloads(digestmap_t *result,
                                    int purpose, const char *prefix);
 static void launch_dummy_descriptor_download_as_needed(time_t now,
-                                                       or_options_t *options);
+                                   const or_options_t *options);
 
 DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
 DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
@@ -1077,7 +1077,7 @@ router_pick_trusteddirserver(dirinfo_type_t type, int flags)
 static const routerstatus_t *
 router_pick_directory_server_impl(dirinfo_type_t type, int flags)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const node_t *result;
   smartlist_t *direct, *tunnel;
   smartlist_t *trusted_direct, *trusted_tunnel;
@@ -1200,7 +1200,7 @@ static const routerstatus_t *
 router_pick_trusteddirserver_impl(dirinfo_type_t type, int flags,
                                   int *n_busy_out)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   smartlist_t *direct, *tunnel;
   smartlist_t *overloaded_direct, *overloaded_tunnel;
   const routerinfo_t *me = router_get_my_routerinfo();
@@ -1367,7 +1367,7 @@ nodelist_add_node_family(smartlist_t *sl, const node_t *node)
   /* XXXX MOVE */
   const smartlist_t *all_nodes = nodelist_get_list();
   const smartlist_t *declared_family;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   tor_assert(node);
 
@@ -1456,7 +1456,7 @@ int
 nodes_in_same_family(const node_t *node1, const node_t *node2)
 {
   /* XXXX MOVE */
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   /* Are they in the same family because of their addresses? */
   if (options->EnforceDistinctSubnets) {
@@ -1565,7 +1565,7 @@ router_find_exact_exit_enclave(const char *address, uint16_t port)
   uint32_t addr;
   struct in_addr in;
   tor_addr_t a;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (!tor_inet_aton(address, &in))
     return NULL; /* it's not an IP already */
@@ -3267,7 +3267,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
                          int from_cache, int from_fetch)
 {
   const char *id_digest;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   int authdir = authdir_mode_handles_descs(options, router->purpose);
   int authdir_believes_valid = 0;
   routerinfo_t *old_router;
@@ -4294,7 +4294,8 @@ initiate_descriptor_downloads(const routerstatus_t *source,
  * running, or otherwise not a descriptor that we would make any
  * use of even if we had it. Else return 1. */
 static INLINE int
-client_would_use_router(routerstatus_t *rs, time_t now, or_options_t *options)
+client_would_use_router(const routerstatus_t *rs, time_t now,
+                        const or_options_t *options)
 {
   if (!rs->is_flagged_running && !options->FetchUselessDescriptors) {
     /* If we had this router descriptor, we wouldn't even bother using it.
@@ -4347,7 +4348,7 @@ launch_descriptor_downloads(int purpose,
                             const routerstatus_t *source, time_t now)
 {
   int should_delay = 0, n_downloadable;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const char *descname;
 
   tor_assert(purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
@@ -4451,7 +4452,7 @@ update_router_descriptor_cache_downloads_v2(time_t now)
   digestmap_t *map; /* Which descs are in progress, or assigned? */
   int i, j, n;
   int n_download;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const smartlist_t *networkstatus_v2_list = networkstatus_get_v2_list();
 
   if (! directory_fetches_dir_info_early(options)) {
@@ -4593,7 +4594,7 @@ void
 update_consensus_router_descriptor_downloads(time_t now, int is_vote,
                                              networkstatus_t *consensus)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   digestmap_t *map = NULL;
   smartlist_t *no_longer_old = smartlist_create();
   smartlist_t *downloadable = smartlist_create();
@@ -4723,7 +4724,8 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
 /** As needed, launch a dummy router descriptor fetch to see if our
  * address has changed. */
 static void
-launch_dummy_descriptor_download_as_needed(time_t now, or_options_t *options)
+launch_dummy_descriptor_download_as_needed(time_t now,
+                                           const or_options_t *options)
 {
   static time_t last_dummy_download = 0;
   /* XXXX023 we could be smarter here; see notes on bug 652. */
@@ -4745,7 +4747,7 @@ launch_dummy_descriptor_download_as_needed(time_t now, or_options_t *options)
 void
 update_router_descriptor_downloads(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   if (should_delay_dir_fetches(options))
     return;
   if (!we_fetch_router_descriptors(options))
@@ -4762,7 +4764,7 @@ update_router_descriptor_downloads(time_t now)
 void
 update_extrainfo_downloads(time_t now)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   routerlist_t *rl;
   smartlist_t *wanted;
   digestmap_t *pending;
@@ -4884,7 +4886,7 @@ get_dir_info_status_string(void)
 static void
 count_usable_descriptors(int *num_present, int *num_usable,
                          const networkstatus_t *consensus,
-                         or_options_t *options, time_t now,
+                         const or_options_t *options, time_t now,
                          routerset_t *in_set)
 {
   const int md = (consensus->flavor == FLAV_MICRODESC);
@@ -4950,7 +4952,7 @@ update_router_have_minimum_dir_info(void)
   int num_present = 0, num_usable=0;
   time_t now = time(NULL);
   int res;
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   const networkstatus_t *consensus =
     networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
 
@@ -5497,7 +5499,7 @@ routerset_parse(routerset_t *target, const char *s, const char *description)
 void
 refresh_all_country_info(void)
 {
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
 
   if (options->EntryNodes)
     routerset_refresh_countries(options->EntryNodes);
diff --git a/src/or/status.c b/src/or/status.c
index 64e3022..acb8ba4 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -85,7 +85,7 @@ log_heartbeat(time_t now)
   char *uptime = NULL;
   const routerinfo_t *me;
 
-  or_options_t *options = get_options();
+  const or_options_t *options = get_options();
   (void)now;
 
   if (public_server_mode(options)) {
diff --git a/src/test/test.c b/src/test/test.c
index e2f8b11..1db1546 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -1074,8 +1074,8 @@ test_geoip(void)
   test_streq("??", NAMEFOR(2000));
 #undef NAMEFOR
 
-  get_options()->BridgeRelay = 1;
-  get_options()->BridgeRecordUsageByCountry = 1;
+  get_options_mutable()->BridgeRelay = 1;
+  get_options_mutable()->BridgeRecordUsageByCountry = 1;
   /* Put 9 observations in AB... */
   for (i=32; i < 40; ++i)
     geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-7200);
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 5a61c5d..b807265 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -56,7 +56,7 @@ test_md_cache(void *data)
   char *fn = NULL, *s = NULL;
   (void)data;
 
-  options = get_options();
+  options = get_options_mutable();
   tt_assert(options);
 
   time1 = time(NULL);



More information about the tor-commits mailing list