[tor-commits] [tor/master] Run rectify_include_paths.py

nickm at torproject.org nickm at torproject.org
Wed Jun 20 13:49:47 UTC 2018


commit 0dab29ce1069c2ebec22a75669aa8242fdc15882
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jun 20 09:35:05 2018 -0400

    Run rectify_include_paths.py
---
 Makefile.am                                        |   3 +-
 scripts/maint/rectify_include_paths.py             |   2 +-
 src/common/address.c                               |  14 +-
 src/common/address.h                               |   6 +-
 src/common/address_set.c                           |  12 +-
 src/common/address_set.h                           |   2 +-
 src/common/aes.c                                   |  14 +-
 src/common/backtrace.c                             |   8 +-
 src/common/buffers.c                               |  12 +-
 src/common/buffers.h                               |   6 +-
 src/common/buffers_tls.c                           |  16 +--
 src/common/compat.c                                |  12 +-
 src/common/compat.h                                |   8 +-
 src/common/compat_libevent.c                       |  10 +-
 src/common/compat_libevent.h                       |   2 +-
 src/common/compat_openssl.h                        |   2 +-
 src/common/compat_pthreads.c                       |   6 +-
 src/common/compat_threads.c                        |   8 +-
 src/common/compat_threads.h                        |   4 +-
 src/common/compat_time.c                           |   8 +-
 src/common/compat_winthreads.c                     |   8 +-
 src/common/compress.c                              |  16 +--
 src/common/compress_lzma.c                         |   8 +-
 src/common/compress_none.c                         |   8 +-
 src/common/compress_zlib.c                         |   8 +-
 src/common/compress_zstd.c                         |   8 +-
 src/common/confline.c                              |  10 +-
 src/common/confline.h                              |   2 +-
 src/common/container.c                             |  10 +-
 src/common/container.h                             |   2 +-
 src/common/crypto.c                                |  36 ++---
 src/common/crypto.h                                |   8 +-
 src/common/crypto_curve25519.c                     |  16 +--
 src/common/crypto_curve25519.h                     |   8 +-
 src/common/crypto_dh.c                             |  12 +-
 src/common/crypto_dh.h                             |   2 +-
 src/common/crypto_digest.c                         |  10 +-
 src/common/crypto_digest.h                         |   4 +-
 src/common/crypto_ed25519.c                        |  18 +--
 src/common/crypto_ed25519.h                        |   8 +-
 src/common/crypto_format.c                         |  18 +--
 src/common/crypto_format.h                         |   6 +-
 src/common/crypto_hkdf.c                           |   6 +-
 src/common/crypto_hkdf.h                           |   2 +-
 src/common/crypto_openssl_mgt.c                    |   4 +-
 src/common/crypto_openssl_mgt.h                    |   2 +-
 src/common/crypto_pwbox.c                          |  18 +--
 src/common/crypto_pwbox.h                          |   2 +-
 src/common/crypto_rand.c                           |  20 +--
 src/common/crypto_rand.h                           |   4 +-
 src/common/crypto_rsa.c                            |  22 +--
 src/common/crypto_rsa.h                            |  12 +-
 src/common/crypto_s2k.c                            |  16 +--
 src/common/crypto_s2k.h                            |   2 +-
 src/common/crypto_util.c                           |   6 +-
 src/common/crypto_util.h                           |   2 +-
 src/common/di_ops.c                                |   6 +-
 src/common/di_ops.h                                |   2 +-
 src/common/handles.h                               |   2 +-
 src/common/log.c                                   |   8 +-
 src/common/memarea.c                               |  10 +-
 src/common/procmon.c                               |   4 +-
 src/common/procmon.h                               |   6 +-
 src/common/pubsub.c                                |   4 +-
 src/common/pubsub.h                                |   2 +-
 src/common/sandbox.c                               |  12 +-
 src/common/sandbox.h                               |   2 +-
 src/common/storagedir.c                            |  16 +--
 src/common/timers.c                                |  10 +-
 src/common/timers.h                                |   2 +-
 src/common/token_bucket.c                          |   4 +-
 src/common/token_bucket.h                          |   4 +-
 src/common/torlog.h                                |   4 +-
 src/common/tortls.c                                |  18 +--
 src/common/tortls.h                                |   8 +-
 src/common/util.c                                  |  20 +--
 src/common/util.h                                  |  10 +-
 src/common/util_bug.c                              |   8 +-
 src/common/util_bug.h                              |   4 +-
 src/common/util_format.c                           |   8 +-
 src/common/util_format.h                           |   4 +-
 src/common/util_process.c                          |   8 +-
 src/common/workqueue.c                             |  14 +-
 src/common/workqueue.h                             |   2 +-
 src/ext/OpenBSD_malloc_Linux.c                     |   2 +-
 src/ext/csiphash.c                                 |   4 +-
 src/ext/curve25519_donna/curve25519-donna-c64.c    |   2 +-
 src/ext/curve25519_donna/curve25519-donna.c        |   2 +-
 src/ext/ed25519/donna/ed25519-hash-custom.h        |   2 +-
 src/ext/ed25519/donna/ed25519-randombytes-custom.h |   2 +-
 src/ext/ed25519/donna/ed25519_donna_tor.h          |   2 +-
 src/ext/ed25519/donna/ed25519_tor.c                |   2 +-
 src/ext/ed25519/ref10/blinding.c                   |   2 +-
 src/ext/ed25519/ref10/crypto_hash_sha512.h         |   2 +-
 src/ext/ed25519/ref10/crypto_int32.h               |   2 +-
 src/ext/ed25519/ref10/crypto_int64.h               |   2 +-
 src/ext/ed25519/ref10/crypto_uint32.h              |   2 +-
 src/ext/ed25519/ref10/crypto_uint64.h              |   2 +-
 src/ext/ed25519/ref10/crypto_verify_32.h           |   3 +-
 src/ext/ed25519/ref10/ed25519_ref10.h              |   2 +-
 src/ext/ed25519/ref10/keypair.c                    |   5 +-
 src/ext/ed25519/ref10/randombytes.h                |   2 +-
 src/ext/keccak-tiny/keccak-tiny-unrolled.c         |   2 +-
 src/ext/keccak-tiny/keccak-tiny.h                  |   2 +-
 src/ext/mulodi/mulodi4.c                           |   2 +-
 src/or/addressmap.c                                |  24 ++--
 src/or/addressmap.h                                |   2 +-
 src/or/authority_cert_st.h                         |   2 +-
 src/or/bridges.c                                   |  36 ++---
 src/or/channel.c                                   |  48 +++----
 src/or/channel.h                                   |   8 +-
 src/or/channelpadding.c                            |  34 ++---
 src/or/channelpadding.h                            |   2 +-
 src/or/channeltls.c                                |  60 ++++----
 src/or/channeltls.h                                |   4 +-
 src/or/circpathbias.c                              |  38 +++---
 src/or/circuit_st.h                                |   4 +-
 src/or/circuitbuild.c                              |  94 ++++++-------
 src/or/circuitlist.c                               |  90 ++++++------
 src/or/circuitlist.h                               |   4 +-
 src/or/circuitmux.c                                |  18 +--
 src/or/circuitmux.h                                |   4 +-
 src/or/circuitmux_ewma.c                           |  10 +-
 src/or/circuitmux_ewma.h                           |   4 +-
 src/or/circuitstats.c                              |  36 ++---
 src/or/circuituse.c                                |  74 +++++-----
 src/or/command.c                                   |  48 +++----
 src/or/command.h                                   |   2 +-
 src/or/config.c                                    | 104 +++++++-------
 src/or/config.h                                    |   2 +-
 src/or/confparse.c                                 |   6 +-
 src/or/connection.c                                | 100 +++++++-------
 src/or/connection.h                                |   2 +-
 src/or/connection_edge.c                           | 102 +++++++-------
 src/or/connection_edge.h                           |   2 +-
 src/or/connection_or.c                             |  84 ++++++------
 src/or/conscache.c                                 |  10 +-
 src/or/conscache.h                                 |   2 +-
 src/or/consdiff.c                                  |   8 +-
 src/or/consdiff.h                                  |   2 +-
 src/or/consdiffmgr.c                               |  24 ++--
 src/or/control.c                                   | 130 +++++++++---------
 src/or/control_connection_st.h                     |   4 +-
 src/or/cpuworker.c                                 |  32 ++---
 src/or/crypt_path_st.h                             |   2 +-
 src/or/dir_connection_st.h                         |   2 +-
 src/or/dir_server_st.h                             |   6 +-
 src/or/dirauth/dircollate.c                        |   8 +-
 src/or/dirauth/dircollate.h                        |   4 +-
 src/or/dirauth/dirvote.c                           |  76 +++++------
 src/or/dirauth/mode.h                              |   2 +-
 src/or/dirauth/shared_random.c                     |  40 +++---
 src/or/dirauth/shared_random.h                     |   2 +-
 src/or/dirauth/shared_random_state.c               |  22 +--
 src/or/dirauth/shared_random_state.h               |   2 +-
 src/or/directory.c                                 | 102 +++++++-------
 src/or/directory.h                                 |   2 +-
 src/or/dirserv.c                                   |  82 +++++------
 src/or/dirserv.h                                   |   2 +-
 src/or/dns.c                                       |  32 ++---
 src/or/dns.h                                       |   2 +-
 src/or/dnsserv.c                                   |  26 ++--
 src/or/dos.c                                       |  30 ++--
 src/or/edge_connection_st.h                        |   4 +-
 src/or/entry_connection_st.h                       |   2 +-
 src/or/entry_port_cfg_st.h                         |   4 +-
 src/or/entrynodes.c                                |  58 ++++----
 src/or/entrynodes.h                                |   2 +-
 src/or/ext_orport.c                                |  26 ++--
 src/or/extrainfo_st.h                              |   2 +-
 src/or/fp_pair.c                                   |   4 +-
 src/or/geoip.c                                     |  16 +--
 src/or/geoip.h                                     |   4 +-
 src/or/git_revision.c                              |   2 +-
 src/or/hibernate.c                                 |  30 ++--
 src/or/hibernate.h                                 |   2 +-
 src/or/hs_cache.c                                  |  26 ++--
 src/or/hs_cache.h                                  |  10 +-
 src/or/hs_cell.c                                   |  28 ++--
 src/or/hs_cell.h                                   |   4 +-
 src/or/hs_circuit.c                                |  56 ++++----
 src/or/hs_circuit.h                                |   6 +-
 src/or/hs_circuitmap.c                             |  12 +-
 src/or/hs_client.c                                 |  64 ++++-----
 src/or/hs_client.h                                 |   6 +-
 src/or/hs_common.c                                 |  56 ++++----
 src/or/hs_common.h                                 |   4 +-
 src/or/hs_config.c                                 |   8 +-
 src/or/hs_config.h                                 |   2 +-
 src/or/hs_control.c                                |  22 +--
 src/or/hs_control.h                                |   2 +-
 src/or/hs_descriptor.c                             |  26 ++--
 src/or/hs_descriptor.h                             |  14 +-
 src/or/hs_ident.c                                  |   4 +-
 src/or/hs_ident.h                                  |   4 +-
 src/or/hs_intropoint.c                             |  32 ++---
 src/or/hs_intropoint.h                             |   8 +-
 src/or/hs_ntor.c                                   |   6 +-
 src/or/hs_ntor.h                                   |   2 +-
 src/or/hs_service.c                                |  82 +++++------
 src/or/hs_service.h                                |  16 +--
 src/or/hs_stats.c                                  |   6 +-
 src/or/keypin.c                                    |  18 +--
 src/or/keypin.h                                    |   2 +-
 src/or/listener_connection_st.h                    |   2 +-
 src/or/main.c                                      | 152 ++++++++++-----------
 src/or/main.h                                      |   2 +-
 src/or/microdesc.c                                 |  36 ++---
 src/or/networkstatus.c                             |  98 ++++++-------
 src/or/networkstatus.h                             |   2 +-
 src/or/networkstatus_st.h                          |   2 +-
 src/or/node_st.h                                   |   2 +-
 src/or/nodelist.c                                  |  62 ++++-----
 src/or/ntmain.c                                    |   8 +-
 src/or/onion.c                                     |  38 +++---
 src/or/onion_fast.c                                |   8 +-
 src/or/onion_ntor.c                                |  14 +-
 src/or/onion_ntor.h                                |   6 +-
 src/or/onion_tap.c                                 |  12 +-
 src/or/or.h                                        |  38 +++---
 src/or/or_circuit_st.h                             |   6 +-
 src/or/or_connection_st.h                          |   2 +-
 src/or/origin_circuit_st.h                         |   4 +-
 src/or/parsecommon.c                               |   6 +-
 src/or/parsecommon.h                               |   6 +-
 src/or/periodic.c                                  |  10 +-
 src/or/policies.c                                  |  34 ++---
 src/or/port_cfg_st.h                               |   4 +-
 src/or/proto_cell.c                                |  10 +-
 src/or/proto_control0.c                            |   6 +-
 src/or/proto_ext_or.c                              |   8 +-
 src/or/proto_http.c                                |   6 +-
 src/or/proto_socks.c                               |  22 +--
 src/or/protover.c                                  |   6 +-
 src/or/protover.h                                  |   2 +-
 src/or/protover_rust.c                             |   4 +-
 src/or/reasons.c                                   |   6 +-
 src/or/relay.c                                     |  94 ++++++-------
 src/or/relay_crypto.c                              |  22 +--
 src/or/rendcache.c                                 |  18 +--
 src/or/rendcache.h                                 |   4 +-
 src/or/rendclient.c                                |  70 +++++-----
 src/or/rendclient.h                                |   2 +-
 src/or/rendcommon.c                                |  60 ++++----
 src/or/rendmid.c                                   |  28 ++--
 src/or/rendservice.c                               |  78 +++++------
 src/or/rendservice.h                               |   4 +-
 src/or/rephist.c                                   |  30 ++--
 src/or/replaycache.c                               |   4 +-
 src/or/router.c                                    |  86 ++++++------
 src/or/router.h                                    |   2 +-
 src/or/routerinfo_st.h                             |   2 +-
 src/or/routerkeys.c                                |  14 +-
 src/or/routerkeys.h                                |   2 +-
 src/or/routerlist.c                                |  90 ++++++------
 src/or/routerlist.h                                |   2 +-
 src/or/routerlist_st.h                             |   2 +-
 src/or/routerparse.c                               |  84 ++++++------
 src/or/routerset.c                                 |  26 ++--
 src/or/routerstatus_st.h                           |   2 +-
 src/or/scheduler.c                                 |  16 +--
 src/or/scheduler.h                                 |   6 +-
 src/or/scheduler_kist.c                            |  18 +--
 src/or/scheduler_vanilla.c                         |   8 +-
 src/or/shared_random_client.c                      |  14 +-
 src/or/shared_random_client.h                      |   2 +-
 src/or/signed_descriptor_st.h                      |   2 +-
 src/or/statefile.c                                 |  26 ++--
 src/or/status.c                                    |  36 ++---
 src/or/status.h                                    |   2 +-
 src/or/tor_api.c                                   |   4 +-
 src/or/torcert.c                                   |  22 +--
 src/or/torcert.h                                   |   2 +-
 src/or/transports.c                                |  22 +--
 src/or/vote_routerstatus_st.h                      |   2 +-
 src/or/voting_schedule.c                           |  10 +-
 src/or/voting_schedule.h                           |   2 +-
 src/test/bench.c                                   |  22 +--
 src/test/fuzz/fuzz_consensus.c                     |   8 +-
 src/test/fuzz/fuzz_descriptor.c                    |  10 +-
 src/test/fuzz/fuzz_diff.c                          |   6 +-
 src/test/fuzz/fuzz_diff_apply.c                    |   6 +-
 src/test/fuzz/fuzz_extrainfo.c                     |  10 +-
 src/test/fuzz/fuzz_hsdescv2.c                      |   8 +-
 src/test/fuzz/fuzz_hsdescv3.c                      |  14 +-
 src/test/fuzz/fuzz_http.c                          |  18 +--
 src/test/fuzz/fuzz_http_connect.c                  |  26 ++--
 src/test/fuzz/fuzz_iptsv2.c                        |  10 +-
 src/test/fuzz/fuzz_microdesc.c                     |   8 +-
 src/test/fuzz/fuzz_vrs.c                           |  16 +--
 src/test/fuzz/fuzzing_common.c                     |  12 +-
 src/test/hs_test_helpers.c                         |  12 +-
 src/test/hs_test_helpers.h                         |   4 +-
 src/test/log_test_helpers.c                        |   4 +-
 src/test/log_test_helpers.h                        |   2 +-
 src/test/rend_test_helpers.c                       |  16 +--
 src/test/rend_test_helpers.h                       |   2 +-
 src/test/test-memwipe.c                            |   6 +-
 src/test/test-timers.c                             |  10 +-
 src/test/test.c                                    |  58 ++++----
 src/test/test.h                                    |   2 +-
 src/test/test_accounting.c                         |  10 +-
 src/test/test_addr.c                               |  10 +-
 src/test/test_address.c                            |   8 +-
 src/test/test_address_set.c                        |  30 ++--
 src/test/test_bridges.c                            |  16 +--
 src/test/test_bt_cl.c                              |   8 +-
 src/test/test_buffers.c                            |  14 +-
 src/test/test_bwmgt.c                              |   6 +-
 src/test/test_cell_formats.c                       |  34 ++---
 src/test/test_cell_queue.c                         |  18 +--
 src/test/test_channel.c                            |  36 ++---
 src/test/test_channelpadding.c                     |  38 +++---
 src/test/test_channeltls.c                         |  24 ++--
 src/test/test_checkdir.c                           |   8 +-
 src/test/test_circuitbuild.c                       |  16 +--
 src/test/test_circuitlist.c                        |  22 +--
 src/test/test_circuitmux.c                         |  18 +--
 src/test/test_circuitstats.c                       |  30 ++--
 src/test/test_circuituse.c                         |  22 +--
 src/test/test_compat_libevent.c                    |   8 +-
 src/test/test_config.c                             |  78 +++++------
 src/test/test_connection.c                         |  46 +++----
 src/test/test_conscache.c                          |   8 +-
 src/test/test_consdiff.c                           |  10 +-
 src/test/test_consdiffmgr.c                        |  30 ++--
 src/test/test_containers.c                         |   8 +-
 src/test/test_controller.c                         |  32 ++---
 src/test/test_controller_events.c                  |  18 +--
 src/test/test_crypto.c                             |  14 +-
 src/test/test_crypto_openssl.c                     |  12 +-
 src/test/test_crypto_slow.c                        |  10 +-
 src/test/test_data.c                               |   2 +-
 src/test/test_dir.c                                |  80 +++++------
 src/test/test_dir_common.c                         |  28 ++--
 src/test/test_dir_common.h                         |   6 +-
 src/test/test_dir_handle_get.c                     |  62 ++++-----
 src/test/test_dns.c                                |  14 +-
 src/test/test_dos.c                                |  34 ++---
 src/test/test_entryconn.c                          |  24 ++--
 src/test/test_entrynodes.c                         |  64 ++++-----
 src/test/test_extorport.c                          |  26 ++--
 src/test/test_geoip.c                              |   8 +-
 src/test/test_guardfraction.c                      |  32 ++---
 src/test/test_handles.c                            |   6 +-
 src/test/test_helpers.c                            |  44 +++---
 src/test/test_helpers.h                            |   2 +-
 src/test/test_hs.c                                 |  32 ++---
 src/test/test_hs_cache.c                           |  28 ++--
 src/test/test_hs_cell.c                            |  18 +--
 src/test/test_hs_client.c                          |  62 ++++-----
 src/test/test_hs_common.c                          |  54 ++++----
 src/test/test_hs_config.c                          |  18 +--
 src/test/test_hs_control.c                         |  24 ++--
 src/test/test_hs_descriptor.c                      |  24 ++--
 src/test/test_hs_intropoint.c                      |  34 ++---
 src/test/test_hs_ntor.c                            |   8 +-
 src/test/test_hs_ntor_cl.c                         |  14 +-
 src/test/test_hs_service.c                         |  76 +++++------
 src/test/test_introduce.c                          |   8 +-
 src/test/test_keypin.c                             |   8 +-
 src/test/test_link_handshake.c                     |  40 +++---
 src/test/test_logging.c                            |   6 +-
 src/test/test_mainloop.c                           |   8 +-
 src/test/test_microdesc.c                          |  30 ++--
 src/test/test_nodelist.c                           |  26 ++--
 src/test/test_ntor_cl.c                            |  12 +-
 src/test/test_oom.c                                |  30 ++--
 src/test/test_oos.c                                |  18 +--
 src/test/test_options.c                            |  26 ++--
 src/test/test_periodic_event.c                     |  18 +--
 src/test/test_policy.c                             |  20 +--
 src/test/test_procmon.c                            |   8 +-
 src/test/test_proto_http.c                         |  10 +-
 src/test/test_proto_misc.c                         |  18 +--
 src/test/test_protover.c                           |   8 +-
 src/test/test_pt.c                                 |  18 +--
 src/test/test_pubsub.c                             |   6 +-
 src/test/test_relay.c                              |  16 +--
 src/test/test_relaycell.c                          |  32 ++---
 src/test/test_relaycrypt.c                         |  20 +--
 src/test/test_rendcache.c                          |  32 ++---
 src/test/test_replay.c                             |   6 +-
 src/test/test_router.c                             |  16 +--
 src/test/test_routerkeys.c                         |  16 +--
 src/test/test_routerlist.c                         |  60 ++++----
 src/test/test_routerset.c                          |  26 ++--
 src/test/test_scheduler.c                          |  20 +--
 src/test/test_shared_random.c                      |  36 ++---
 src/test/test_slow.c                               |   4 +-
 src/test/test_socks.c                              |  14 +-
 src/test/test_status.c                             |  34 ++---
 src/test/test_storagedir.c                         |   8 +-
 src/test/test_switch_id.c                          |   2 +-
 src/test/test_threads.c                            |   6 +-
 src/test/test_tortls.c                             |  14 +-
 src/test/test_util.c                               |  20 +--
 src/test/test_util_format.c                        |   8 +-
 src/test/test_util_process.c                       |   8 +-
 src/test/test_util_slow.c                          |  10 +-
 src/test/test_voting_schedule.c                    |   6 +-
 src/test/test_workqueue.c                          |  14 +-
 src/test/testing_common.c                          |  20 +--
 src/test/testing_rsakeys.c                         |   6 +-
 src/tools/tor-gencert.c                            |  18 +--
 src/tools/tor-resolve.c                            |  10 +-
 src/tools/tor_runner.c                             |   4 +-
 src/trace/debug.h                                  |   2 +-
 src/trace/trace.c                                  |   2 +-
 src/trunnel/trunnel-local.h                        |   6 +-
 410 files changed, 3624 insertions(+), 3625 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cc89c7264..3c10c7f95 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,8 @@ bin_SCRIPTS=
 AM_CPPFLAGS=\
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/src/ext \
-	-I$(top_srcdir)/src/ext/trunnel
+	-I$(top_srcdir)/src/ext/trunnel \
+	-I$(top_srcdir)/src/trunnel
 
 AM_CFLAGS=@TOR_SYSTEMD_CFLAGS@ @CFLAGS_BUGTRAP@ @TOR_LZMA_CFLAGS@ @TOR_ZSTD_CFLAGS@
 SHELL=@SHELL@
diff --git a/scripts/maint/rectify_include_paths.py b/scripts/maint/rectify_include_paths.py
index dc9163445..401fadae6 100755
--- a/scripts/maint/rectify_include_paths.py
+++ b/scripts/maint/rectify_include_paths.py
@@ -46,7 +46,7 @@ def fix_includes(inp, out, mapping):
 incs = get_include_map()
 
 for dirpath,dirnames,fnames in os.walk("src"):
-    exclude(["ext", "trunnel"], dirnames)
+    exclude(["trunnel"], dirnames)
 
     for fname in fnames:
         if fname.endswith(".c") or fname.endswith(".h"):
diff --git a/src/common/address.c b/src/common/address.c
index 0ccf73d48..2e8b5fc9f 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -35,13 +35,13 @@
 #include <iphlpapi.h>
 #endif /* defined(_WIN32) */
 
-#include "compat.h"
-#include "util.h"
-#include "util_format.h"
-#include "address.h"
-#include "torlog.h"
-#include "container.h"
-#include "sandbox.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/util_format.h"
+#include "common/address.h"
+#include "common/torlog.h"
+#include "common/container.h"
+#include "common/sandbox.h"
 
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
diff --git a/src/common/address.h b/src/common/address.h
index 8e9e25175..2c9c620c2 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -13,9 +13,9 @@
 
 //#include <sys/sockio.h>
 #include "orconfig.h"
-#include "torint.h"
-#include "compat.h"
-#include "container.h"
+#include "common/torint.h"
+#include "common/compat.h"
+#include "common/container.h"
 
 #ifdef ADDRESS_PRIVATE
 
diff --git a/src/common/address_set.c b/src/common/address_set.c
index 16ae39403..763db6428 100644
--- a/src/common/address_set.c
+++ b/src/common/address_set.c
@@ -11,12 +11,12 @@
  **/
 
 #include "orconfig.h"
-#include "address_set.h"
-#include "address.h"
-#include "compat.h"
-#include "container.h"
-#include "crypto_rand.h"
-#include "util.h"
+#include "common/address_set.h"
+#include "common/address.h"
+#include "common/compat.h"
+#include "common/container.h"
+#include "common/crypto_rand.h"
+#include "common/util.h"
 #include "siphash.h"
 
 /** How many 64-bit siphash values to extract per address */
diff --git a/src/common/address_set.h b/src/common/address_set.h
index dc16cfe5f..f4986c9b0 100644
--- a/src/common/address_set.h
+++ b/src/common/address_set.h
@@ -14,7 +14,7 @@
 #define TOR_ADDRESS_SET_H
 
 #include "orconfig.h"
-#include "torint.h"
+#include "common/torint.h"
 
 /**
  * An address_set_t represents a set of tor_addr_t values. The implementation
diff --git a/src/common/aes.c b/src/common/aes.c
index 5217ad250..c0851c542 100644
--- a/src/common/aes.c
+++ b/src/common/aes.c
@@ -16,9 +16,9 @@
   #include <ws2tcpip.h>
 #endif
 
-#include "compat_openssl.h"
+#include "common/compat_openssl.h"
 #include <openssl/opensslv.h>
-#include "crypto_openssl_mgt.h"
+#include "common/crypto_openssl_mgt.h"
 
 #if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,0)
 #error "We require OpenSSL >= 1.0.0"
@@ -36,11 +36,11 @@ DISABLE_GCC_WARNING(redundant-decls)
 
 ENABLE_GCC_WARNING(redundant-decls)
 
-#include "compat.h"
-#include "aes.h"
-#include "util.h"
-#include "torlog.h"
-#include "di_ops.h"
+#include "common/compat.h"
+#include "common/aes.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/di_ops.h"
 
 #ifdef ANDROID
 /* Android's OpenSSL seems to have removed all of its Engine support. */
diff --git a/src/common/backtrace.c b/src/common/backtrace.c
index e33c02ea4..c3c0b77ab 100644
--- a/src/common/backtrace.c
+++ b/src/common/backtrace.c
@@ -14,9 +14,9 @@
  */
 
 #include "orconfig.h"
-#include "compat.h"
-#include "util.h"
-#include "torlog.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/torlog.h"
 
 #ifdef HAVE_EXECINFO_H
 #include <execinfo.h>
@@ -40,7 +40,7 @@
 #endif /* defined(HAVE_CYGWIN_SIGNAL_H) || ... */
 
 #define EXPOSE_CLEAN_BACKTRACE
-#include "backtrace.h"
+#include "common/backtrace.h"
 
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \
   defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)
diff --git a/src/common/buffers.c b/src/common/buffers.c
index d21a0db75..997bbdccc 100644
--- a/src/common/buffers.c
+++ b/src/common/buffers.c
@@ -21,12 +21,12 @@
 #define BUFFERS_PRIVATE
 #include "orconfig.h"
 #include <stddef.h>
-#include "buffers.h"
-#include "compat.h"
-#include "compress.h"
-#include "util.h"
-#include "torint.h"
-#include "torlog.h"
+#include "common/buffers.h"
+#include "common/compat.h"
+#include "common/compress.h"
+#include "common/util.h"
+#include "common/torint.h"
+#include "common/torlog.h"
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
diff --git a/src/common/buffers.h b/src/common/buffers.h
index f78f7b289..5cd9d3ec6 100644
--- a/src/common/buffers.h
+++ b/src/common/buffers.h
@@ -12,9 +12,9 @@
 #ifndef TOR_BUFFERS_H
 #define TOR_BUFFERS_H
 
-#include "compat.h"
-#include "torint.h"
-#include "testsupport.h"
+#include "common/compat.h"
+#include "common/torint.h"
+#include "common/testsupport.h"
 
 typedef struct buf_t buf_t;
 
diff --git a/src/common/buffers_tls.c b/src/common/buffers_tls.c
index c947b79ee..dfc8e44b9 100644
--- a/src/common/buffers_tls.c
+++ b/src/common/buffers_tls.c
@@ -7,14 +7,14 @@
 #define BUFFERS_PRIVATE
 #include "orconfig.h"
 #include <stddef.h>
-#include "buffers.h"
-#include "buffers_tls.h"
-#include "compat.h"
-#include "compress.h"
-#include "util.h"
-#include "torint.h"
-#include "torlog.h"
-#include "tortls.h"
+#include "common/buffers.h"
+#include "common/buffers_tls.h"
+#include "common/compat.h"
+#include "common/compress.h"
+#include "common/util.h"
+#include "common/torint.h"
+#include "common/torlog.h"
+#include "common/tortls.h"
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
diff --git a/src/common/compat.c b/src/common/compat.c
index 9f412e8fa..9b1a4d860 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -13,7 +13,7 @@
  **/
 
 #define COMPAT_PRIVATE
-#include "compat.h"
+#include "common/compat.h"
 
 #ifdef _WIN32
 #include <winsock2.h>
@@ -125,11 +125,11 @@ SecureZeroMemory(PVOID ptr, SIZE_T cnt)
 #include <sys/file.h>
 #endif
 
-#include "torlog.h"
-#include "util.h"
-#include "container.h"
-#include "address.h"
-#include "sandbox.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/container.h"
+#include "common/address.h"
+#include "common/sandbox.h"
 
 /* Inline the strl functions if the platform doesn't have them. */
 #ifndef HAVE_STRLCPY
diff --git a/src/common/compat.h b/src/common/compat.h
index fc0ce052c..3b451dd10 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -14,8 +14,8 @@
 #define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747b
 #endif
 #endif
-#include "torint.h"
-#include "testsupport.h"
+#include "common/torint.h"
+#include "common/testsupport.h"
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
@@ -45,7 +45,7 @@
 #include <netinet6/in6.h>
 #endif
 
-#include "compat_time.h"
+#include "common/compat_time.h"
 
 #if defined(__has_feature)
 #  if __has_feature(address_sanitizer)
@@ -751,7 +751,7 @@ STATIC int tor_ersatz_socketpair(int family, int type, int protocol,
 ssize_t tor_getpass(const char *prompt, char *output, size_t buflen);
 
 /* This needs some of the declarations above so we include it here. */
-#include "compat_threads.h"
+#include "common/compat_threads.h"
 
 #endif /* !defined(TOR_COMPAT_H) */
 
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 4262f58e8..c99de1ac3 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -7,14 +7,14 @@
  */
 
 #include "orconfig.h"
-#include "compat.h"
+#include "common/compat.h"
 #define COMPAT_LIBEVENT_PRIVATE
-#include "compat_libevent.h"
+#include "common/compat_libevent.h"
 
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 
-#include "util.h"
-#include "torlog.h"
+#include "common/util.h"
+#include "common/torlog.h"
 
 #include <event2/event.h>
 #include <event2/thread.h>
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index b28acda3b..76a074d93 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -5,7 +5,7 @@
 #define TOR_COMPAT_LIBEVENT_H
 
 #include "orconfig.h"
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 void configure_libevent_logging(void);
 void suppress_libevent_log_msg(const char *msg);
diff --git a/src/common/compat_openssl.h b/src/common/compat_openssl.h
index c7f51173b..a94b26492 100644
--- a/src/common/compat_openssl.h
+++ b/src/common/compat_openssl.h
@@ -8,7 +8,7 @@
 #define TOR_COMPAT_OPENSSL_H
 
 #include <openssl/opensslv.h>
-#include "crypto_openssl_mgt.h"
+#include "common/crypto_openssl_mgt.h"
 
 /**
  * \file compat_openssl.h
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c
index 2e7d3d54c..6d5f84677 100644
--- a/src/common/compat_pthreads.c
+++ b/src/common/compat_pthreads.c
@@ -15,9 +15,9 @@
 #include <signal.h>
 #include <time.h>
 
-#include "compat.h"
-#include "torlog.h"
-#include "util.h"
+#include "common/compat.h"
+#include "common/torlog.h"
+#include "common/util.h"
 
 /** Wraps a void (*)(void*) function and its argument so we can
  * invoke them in a way pthreads would expect.
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c
index 6d33d3e24..250ac48c0 100644
--- a/src/common/compat_threads.c
+++ b/src/common/compat_threads.c
@@ -13,11 +13,11 @@
 
 #include "orconfig.h"
 #include <stdlib.h>
-#include "compat.h"
-#include "compat_threads.h"
+#include "common/compat.h"
+#include "common/compat_threads.h"
 
-#include "util.h"
-#include "torlog.h"
+#include "common/util.h"
+#include "common/torlog.h"
 
 #ifdef HAVE_SYS_EVENTFD_H
 #include <sys/eventfd.h>
diff --git a/src/common/compat_threads.h b/src/common/compat_threads.h
index 2d70cf7a3..5d3883043 100644
--- a/src/common/compat_threads.h
+++ b/src/common/compat_threads.h
@@ -7,8 +7,8 @@
 #define TOR_COMPAT_THREADS_H
 
 #include "orconfig.h"
-#include "torint.h"
-#include "testsupport.h"
+#include "common/torint.h"
+#include "common/testsupport.h"
 
 #if defined(HAVE_PTHREAD_H) && !defined(_WIN32)
 #include <pthread.h>
diff --git a/src/common/compat_time.c b/src/common/compat_time.c
index ef72003de..ed0a1550f 100644
--- a/src/common/compat_time.c
+++ b/src/common/compat_time.c
@@ -10,7 +10,7 @@
  **/
 
 #define COMPAT_TIME_PRIVATE
-#include "compat.h"
+#include "common/compat.h"
 
 #ifdef _WIN32
 #include <winsock2.h>
@@ -34,9 +34,9 @@
 #include <mach/mach_time.h>
 #endif
 
-#include "torlog.h"
-#include "util.h"
-#include "container.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/container.h"
 
 #ifndef HAVE_GETTIMEOFDAY
 #ifdef HAVE_FTIME
diff --git a/src/common/compat_winthreads.c b/src/common/compat_winthreads.c
index 6908f0ddf..9d07e1798 100644
--- a/src/common/compat_winthreads.c
+++ b/src/common/compat_winthreads.c
@@ -12,12 +12,12 @@
 
 #ifdef _WIN32
 
-#include "compat.h"
+#include "common/compat.h"
 #include <windows.h>
 #include <process.h>
-#include "util.h"
-#include "container.h"
-#include "torlog.h"
+#include "common/util.h"
+#include "common/container.h"
+#include "common/torlog.h"
 
 /* This value is more or less total cargo-cult */
 #define SPIN_COUNT 2000
diff --git a/src/common/compress.c b/src/common/compress.c
index 816444825..204529a54 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -14,19 +14,19 @@
 #include <stdio.h>
 #include <assert.h>
 #include <string.h>
-#include "torint.h"
+#include "common/torint.h"
 
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
 
-#include "util.h"
-#include "torlog.h"
-#include "compress.h"
-#include "compress_lzma.h"
-#include "compress_none.h"
-#include "compress_zlib.h"
-#include "compress_zstd.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/compress.h"
+#include "common/compress_lzma.h"
+#include "common/compress_none.h"
+#include "common/compress_zlib.h"
+#include "common/compress_zstd.h"
 
 /** Total number of bytes allocated for compression state overhead. */
 static atomic_counter_t total_compress_allocation;
diff --git a/src/common/compress_lzma.c b/src/common/compress_lzma.c
index e9d0e9e51..363dc1fb9 100644
--- a/src/common/compress_lzma.c
+++ b/src/common/compress_lzma.c
@@ -13,10 +13,10 @@
 
 #include "orconfig.h"
 
-#include "util.h"
-#include "torlog.h"
-#include "compress.h"
-#include "compress_lzma.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/compress.h"
+#include "common/compress_lzma.h"
 
 #ifdef HAVE_LZMA
 #include <lzma.h>
diff --git a/src/common/compress_none.c b/src/common/compress_none.c
index 5240a686c..7e67046d3 100644
--- a/src/common/compress_none.c
+++ b/src/common/compress_none.c
@@ -16,10 +16,10 @@
 
 #include "orconfig.h"
 
-#include "util.h"
-#include "torlog.h"
-#include "compress.h"
-#include "compress_none.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/compress.h"
+#include "common/compress_none.h"
 
 /** Transfer some bytes using the identity transformation.  Read up to
  * *<b>in_len</b> bytes from *<b>in</b>, and write up to *<b>out_len</b> bytes
diff --git a/src/common/compress_zlib.c b/src/common/compress_zlib.c
index d79cc41ad..663e27f79 100644
--- a/src/common/compress_zlib.c
+++ b/src/common/compress_zlib.c
@@ -13,10 +13,10 @@
 
 #include "orconfig.h"
 
-#include "util.h"
-#include "torlog.h"
-#include "compress.h"
-#include "compress_zlib.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/compress.h"
+#include "common/compress_zlib.h"
 
 /* zlib 1.2.4 and 1.2.5 do some "clever" things with macros.  Instead of
    saying "(defined(FOO) ? FOO : 0)" they like to say "FOO-0", on the theory
diff --git a/src/common/compress_zstd.c b/src/common/compress_zstd.c
index f1fb18408..dc0dcdec9 100644
--- a/src/common/compress_zstd.c
+++ b/src/common/compress_zstd.c
@@ -13,10 +13,10 @@
 
 #include "orconfig.h"
 
-#include "util.h"
-#include "torlog.h"
-#include "compress.h"
-#include "compress_zstd.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/compress.h"
+#include "common/compress_zstd.h"
 
 #ifdef ENABLE_ZSTD_ADVANCED_APIS
 /* This is a lie, but we make sure it doesn't get us in trouble by wrapping
diff --git a/src/common/confline.c b/src/common/confline.c
index 3ba2a288f..2ea2e9c3b 100644
--- a/src/common/confline.c
+++ b/src/common/confline.c
@@ -4,11 +4,11 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "compat.h"
-#include "confline.h"
-#include "torlog.h"
-#include "util.h"
-#include "container.h"
+#include "common/compat.h"
+#include "common/confline.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/container.h"
 
 static int config_get_lines_aux(const char *string, config_line_t **result,
                                 int extended, int allow_include,
diff --git a/src/common/confline.h b/src/common/confline.h
index 57585792d..4cc8286fc 100644
--- a/src/common/confline.h
+++ b/src/common/confline.h
@@ -7,7 +7,7 @@
 #ifndef TOR_CONFLINE_H
 #define TOR_CONFLINE_H
 
-#include "container.h"
+#include "common/container.h"
 
 /** Ordinary configuration line. */
 #define CONFIG_LINE_NORMAL 0
diff --git a/src/common/container.c b/src/common/container.c
index fa9315eec..03324c873 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -11,11 +11,11 @@
  * a digest-to-void* map.
  **/
 
-#include "compat.h"
-#include "util.h"
-#include "torlog.h"
-#include "container.h"
-#include "crypto_digest.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/container.h"
+#include "common/crypto_digest.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/common/container.h b/src/common/container.h
index 68c270c43..372fa6640 100644
--- a/src/common/container.h
+++ b/src/common/container.h
@@ -6,7 +6,7 @@
 #ifndef TOR_CONTAINER_H
 #define TOR_CONTAINER_H
 
-#include "util.h"
+#include "common/util.h"
 #include "siphash.h"
 
 /** A resizeable list of pointers, with associated helpful functionality.
diff --git a/src/common/crypto.c b/src/common/crypto.c
index f34328587..14129086e 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -23,16 +23,16 @@
 #endif /* defined(_WIN32) */
 
 #define CRYPTO_PRIVATE
-#include "compat_openssl.h"
-#include "crypto.h"
-#include "crypto_curve25519.h"
-#include "crypto_digest.h"
-#include "crypto_dh.h"
-#include "crypto_ed25519.h"
-#include "crypto_format.h"
-#include "crypto_rand.h"
-#include "crypto_rsa.h"
-#include "crypto_util.h"
+#include "common/compat_openssl.h"
+#include "common/crypto.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_dh.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_format.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_rsa.h"
+#include "common/crypto_util.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 
@@ -62,14 +62,14 @@ ENABLE_GCC_WARNING(redundant-decls)
 #include <unistd.h>
 #endif
 
-#include "torlog.h"
-#include "torint.h"
-#include "aes.h"
-#include "util.h"
-#include "container.h"
-#include "compat.h"
-#include "sandbox.h"
-#include "util_format.h"
+#include "common/torlog.h"
+#include "common/torint.h"
+#include "common/aes.h"
+#include "common/util.h"
+#include "common/container.h"
+#include "common/compat.h"
+#include "common/sandbox.h"
+#include "common/util_format.h"
 
 #include "keccak-tiny/keccak-tiny.h"
 
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 7ff11f394..1a88a3d2f 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -16,10 +16,10 @@
 #include "orconfig.h"
 
 #include <stdio.h>
-#include "torint.h"
-#include "compat.h"
-#include "util.h"
-#include "crypto_rsa.h"
+#include "common/torint.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/crypto_rsa.h"
 
 /** Length of our symmetric cipher's keys of 128-bit. */
 #define CIPHER_KEY_LEN 16
diff --git a/src/common/crypto_curve25519.c b/src/common/crypto_curve25519.c
index d4d9609f6..f28cebb88 100644
--- a/src/common/crypto_curve25519.c
+++ b/src/common/crypto_curve25519.c
@@ -20,14 +20,14 @@
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#include "container.h"
-#include "crypto_curve25519.h"
-#include "crypto_digest.h"
-#include "crypto_format.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "util.h"
-#include "torlog.h"
+#include "common/container.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_format.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "common/util.h"
+#include "common/torlog.h"
 
 #include "ed25519/donna/ed25519_donna_tor.h"
 
diff --git a/src/common/crypto_curve25519.h b/src/common/crypto_curve25519.h
index 462ec85f9..96d2e0e07 100644
--- a/src/common/crypto_curve25519.h
+++ b/src/common/crypto_curve25519.h
@@ -4,10 +4,10 @@
 #ifndef TOR_CRYPTO_CURVE25519_H
 #define TOR_CRYPTO_CURVE25519_H
 
-#include "testsupport.h"
-#include "torint.h"
-#include "crypto_digest.h"
-#include "crypto_openssl_mgt.h"
+#include "common/testsupport.h"
+#include "common/torint.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_openssl_mgt.h"
 
 /** Length of a curve25519 public key when encoded. */
 #define CURVE25519_PUBKEY_LEN 32
diff --git a/src/common/crypto_dh.c b/src/common/crypto_dh.c
index 0dcdfa205..4c6b03cee 100644
--- a/src/common/crypto_dh.c
+++ b/src/common/crypto_dh.c
@@ -9,11 +9,11 @@
  * \brief Block of functions related with DH utilities and operations.
  **/
 
-#include "compat_openssl.h"
-#include "crypto_dh.h"
-#include "crypto_digest.h"
-#include "crypto_hkdf.h"
-#include "crypto_util.h"
+#include "common/compat_openssl.h"
+#include "common/crypto_dh.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_hkdf.h"
+#include "common/crypto_util.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 
@@ -21,7 +21,7 @@ DISABLE_GCC_WARNING(redundant-decls)
 
 ENABLE_GCC_WARNING(redundant-decls)
 
-#include "torlog.h"
+#include "common/torlog.h"
 
 /** A structure to hold the first half (x, g^x) of a Diffie-Hellman handshake
  * while we're waiting for the second.*/
diff --git a/src/common/crypto_dh.h b/src/common/crypto_dh.h
index 540ec6ce1..1e77acc01 100644
--- a/src/common/crypto_dh.h
+++ b/src/common/crypto_dh.h
@@ -13,7 +13,7 @@
 #ifndef TOR_CRYPTO_DH_H
 #define TOR_CRYPTO_DH_H
 
-#include "util.h"
+#include "common/util.h"
 
 /** Length of our DH keys. */
 #define DH_BYTES (1024/8)
diff --git a/src/common/crypto_digest.c b/src/common/crypto_digest.c
index 41f3691a3..708fbf9be 100644
--- a/src/common/crypto_digest.c
+++ b/src/common/crypto_digest.c
@@ -10,11 +10,11 @@
  * operations.
  **/
 
-#include "container.h"
-#include "crypto_digest.h"
-#include "crypto_openssl_mgt.h"
-#include "crypto_util.h"
-#include "torlog.h"
+#include "common/container.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_openssl_mgt.h"
+#include "common/crypto_util.h"
+#include "common/torlog.h"
 
 #include "keccak-tiny/keccak-tiny.h"
 
diff --git a/src/common/crypto_digest.h b/src/common/crypto_digest.h
index 631e6e589..25ca5ceda 100644
--- a/src/common/crypto_digest.h
+++ b/src/common/crypto_digest.h
@@ -15,8 +15,8 @@
 
 #include <stdio.h>
 
-#include "container.h"
-#include "torint.h"
+#include "common/container.h"
+#include "common/torint.h"
 
 /** Length of the output of our message digest. */
 #define DIGEST_LEN 20
diff --git a/src/common/crypto_ed25519.c b/src/common/crypto_ed25519.c
index 9859d5f34..b0b954796 100644
--- a/src/common/crypto_ed25519.c
+++ b/src/common/crypto_ed25519.c
@@ -21,15 +21,15 @@
 #include <sys/stat.h>
 #endif
 
-#include "crypto_curve25519.h"
-#include "crypto_digest.h"
-#include "crypto_ed25519.h"
-#include "crypto_format.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "torlog.h"
-#include "util.h"
-#include "util_format.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_format.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/util_format.h"
 
 #include "ed25519/ref10/ed25519_ref10.h"
 #include "ed25519/donna/ed25519_donna_tor.h"
diff --git a/src/common/crypto_ed25519.h b/src/common/crypto_ed25519.h
index 7573044b8..20c04226e 100644
--- a/src/common/crypto_ed25519.h
+++ b/src/common/crypto_ed25519.h
@@ -4,10 +4,10 @@
 #ifndef TOR_CRYPTO_ED25519_H
 #define TOR_CRYPTO_ED25519_H
 
-#include "testsupport.h"
-#include "torint.h"
-#include "crypto_curve25519.h"
-#include "util.h"
+#include "common/testsupport.h"
+#include "common/torint.h"
+#include "common/crypto_curve25519.h"
+#include "common/util.h"
 
 #define ED25519_PUBKEY_LEN 32
 #define ED25519_SECKEY_LEN 64
diff --git a/src/common/crypto_format.c b/src/common/crypto_format.c
index eb7f81d17..6245b70cc 100644
--- a/src/common/crypto_format.c
+++ b/src/common/crypto_format.c
@@ -14,15 +14,15 @@
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#include "container.h"
-#include "crypto_curve25519.h"
-#include "crypto_digest.h"
-#include "crypto_ed25519.h"
-#include "crypto_format.h"
-#include "crypto_util.h"
-#include "util.h"
-#include "util_format.h"
-#include "torlog.h"
+#include "common/container.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_format.h"
+#include "common/crypto_util.h"
+#include "common/util.h"
+#include "common/util_format.h"
+#include "common/torlog.h"
 
 /** Write the <b>datalen</b> bytes from <b>data</b> to the file named
  * <b>fname</b> in the tagged-data format.  This format contains a
diff --git a/src/common/crypto_format.h b/src/common/crypto_format.h
index 4df89c05b..325b1ef44 100644
--- a/src/common/crypto_format.h
+++ b/src/common/crypto_format.h
@@ -7,9 +7,9 @@
 #ifndef TOR_CRYPTO_FORMAT_H
 #define TOR_CRYPTO_FORMAT_H
 
-#include "testsupport.h"
-#include "torint.h"
-#include "crypto_ed25519.h"
+#include "common/testsupport.h"
+#include "common/torint.h"
+#include "common/crypto_ed25519.h"
 
 int crypto_write_tagged_contents_to_file(const char *fname,
                                          const char *typestring,
diff --git a/src/common/crypto_hkdf.c b/src/common/crypto_hkdf.c
index acadf8ab2..46c30bc72 100644
--- a/src/common/crypto_hkdf.c
+++ b/src/common/crypto_hkdf.c
@@ -9,9 +9,9 @@
  * \brief Block of functions related with HKDF utilities and operations.
  **/
 
-#include "crypto_hkdf.h"
-#include "crypto_util.h"
-#include "crypto_digest.h"
+#include "common/crypto_hkdf.h"
+#include "common/crypto_util.h"
+#include "common/crypto_digest.h"
 
 /** Given <b>key_in_len</b> bytes of negotiated randomness in <b>key_in</b>
  * ("K"), expand it into <b>key_out_len</b> bytes of negotiated key material in
diff --git a/src/common/crypto_hkdf.h b/src/common/crypto_hkdf.h
index af697b234..784f4bbbe 100644
--- a/src/common/crypto_hkdf.h
+++ b/src/common/crypto_hkdf.h
@@ -13,7 +13,7 @@
 #ifndef TOR_CRYPTO_HKDF_H
 #define TOR_CRYPTO_HKDF_H
 
-#include "util.h"
+#include "common/util.h"
 
 int crypto_expand_key_material_TAP(const uint8_t *key_in,
                                    size_t key_in_len,
diff --git a/src/common/crypto_openssl_mgt.c b/src/common/crypto_openssl_mgt.c
index e568b7aed..8acb9cdf1 100644
--- a/src/common/crypto_openssl_mgt.c
+++ b/src/common/crypto_openssl_mgt.c
@@ -10,8 +10,8 @@
  * \brief Block of functions related to operations from OpenSSL.
  **/
 
-#include "compat_openssl.h"
-#include "crypto_openssl_mgt.h"
+#include "common/compat_openssl.h"
+#include "common/crypto_openssl_mgt.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 
diff --git a/src/common/crypto_openssl_mgt.h b/src/common/crypto_openssl_mgt.h
index b892dea0e..e3f5531b7 100644
--- a/src/common/crypto_openssl_mgt.h
+++ b/src/common/crypto_openssl_mgt.h
@@ -14,7 +14,7 @@
 #define TOR_CRYPTO_OPENSSL_H
 
 #include <stdio.h>
-#include "util.h"
+#include "common/util.h"
 
 #include <openssl/engine.h>
 
diff --git a/src/common/crypto_pwbox.c b/src/common/crypto_pwbox.c
index 14ede1bd6..5ffe138ee 100644
--- a/src/common/crypto_pwbox.c
+++ b/src/common/crypto_pwbox.c
@@ -8,15 +8,15 @@
  * them to disk.
  */
 
-#include "crypto.h"
-#include "crypto_digest.h"
-#include "crypto_pwbox.h"
-#include "crypto_rand.h"
-#include "crypto_s2k.h"
-#include "crypto_util.h"
-#include "di_ops.h"
-#include "util.h"
-#include "pwbox.h"
+#include "common/crypto.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_pwbox.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_s2k.h"
+#include "common/crypto_util.h"
+#include "common/di_ops.h"
+#include "common/util.h"
+#include "trunnel/pwbox.h"
 
 /* 8 bytes "TORBOX00"
    1 byte: header len (H)
diff --git a/src/common/crypto_pwbox.h b/src/common/crypto_pwbox.h
index f36869766..2c73c700e 100644
--- a/src/common/crypto_pwbox.h
+++ b/src/common/crypto_pwbox.h
@@ -4,7 +4,7 @@
 #ifndef CRYPTO_PWBOX_H_INCLUDED_
 #define CRYPTO_PWBOX_H_INCLUDED_
 
-#include "torint.h"
+#include "common/torint.h"
 
 #define UNPWBOX_OKAY 0
 #define UNPWBOX_BAD_SECRET -1
diff --git a/src/common/crypto_rand.c b/src/common/crypto_rand.c
index df2e2f65d..6c88e28d8 100644
--- a/src/common/crypto_rand.c
+++ b/src/common/crypto_rand.c
@@ -14,22 +14,22 @@
 #ifndef CRYPTO_RAND_PRIVATE
 #define CRYPTO_RAND_PRIVATE
 
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 
 #ifdef _WIN32
 #include <windows.h>
 #include <wincrypt.h>
 #endif /* defined(_WIN32) */
 
-#include "container.h"
-#include "compat.h"
-#include "compat_openssl.h"
-#include "crypto_util.h"
-#include "sandbox.h"
-#include "testsupport.h"
-#include "torlog.h"
-#include "util.h"
-#include "util_format.h"
+#include "common/container.h"
+#include "common/compat.h"
+#include "common/compat_openssl.h"
+#include "common/crypto_util.h"
+#include "common/sandbox.h"
+#include "common/testsupport.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/util_format.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 #include <openssl/rand.h>
diff --git a/src/common/crypto_rand.h b/src/common/crypto_rand.h
index bb02e5100..2e05adc93 100644
--- a/src/common/crypto_rand.h
+++ b/src/common/crypto_rand.h
@@ -13,8 +13,8 @@
 #ifndef TOR_CRYPTO_RAND_H
 #define TOR_CRYPTO_RAND_H
 
-#include "torint.h"
-#include "util.h"
+#include "common/torint.h"
+#include "common/util.h"
 
 /* random numbers */
 int crypto_seed_rng(void) ATTR_WUR;
diff --git a/src/common/crypto_rsa.c b/src/common/crypto_rsa.c
index f365c3193..312898343 100644
--- a/src/common/crypto_rsa.c
+++ b/src/common/crypto_rsa.c
@@ -9,14 +9,14 @@
  * \brief Block of functions related with RSA utilities and operations.
  **/
 
-#include "crypto.h"
-#include "crypto_curve25519.h"
-#include "crypto_digest.h"
-#include "crypto_format.h"
-#include "compat_openssl.h"
-#include "crypto_rand.h"
-#include "crypto_rsa.h"
-#include "crypto_util.h"
+#include "common/crypto.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_format.h"
+#include "common/compat_openssl.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_rsa.h"
+#include "common/crypto_util.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 
@@ -33,9 +33,9 @@ DISABLE_GCC_WARNING(redundant-decls)
 
 ENABLE_GCC_WARNING(redundant-decls)
 
-#include "torlog.h"
-#include "util.h"
-#include "util_format.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/util_format.h"
 
 /** Declaration for crypto_pk_t structure. */
 struct crypto_pk_t
diff --git a/src/common/crypto_rsa.h b/src/common/crypto_rsa.h
index 3c09d5c62..c56eab319 100644
--- a/src/common/crypto_rsa.h
+++ b/src/common/crypto_rsa.h
@@ -15,13 +15,13 @@
 
 #include "orconfig.h"
 
-#include "crypto_digest.h"
+#include "common/crypto_digest.h"
 #include <stdio.h>
-#include "torint.h"
-#include "testsupport.h"
-#include "compat.h"
-#include "util.h"
-#include "torlog.h"
+#include "common/torint.h"
+#include "common/testsupport.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/torlog.h"
 
 /** Length of our public keys. */
 #define PK_BYTES (1024/8)
diff --git a/src/common/crypto_s2k.c b/src/common/crypto_s2k.c
index 14bd5c28b..db57691f6 100644
--- a/src/common/crypto_s2k.c
+++ b/src/common/crypto_s2k.c
@@ -12,14 +12,14 @@
 
 #define CRYPTO_S2K_PRIVATE
 
-#include "compat.h"
-#include "crypto.h"
-#include "crypto_digest.h"
-#include "crypto_hkdf.h"
-#include "crypto_rand.h"
-#include "crypto_s2k.h"
-#include "crypto_util.h"
-#include "util.h"
+#include "common/compat.h"
+#include "common/crypto.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_hkdf.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_s2k.h"
+#include "common/crypto_util.h"
+#include "common/util.h"
 
 #include <openssl/evp.h>
 
diff --git a/src/common/crypto_s2k.h b/src/common/crypto_s2k.h
index 1609a20d2..bc7224e8e 100644
--- a/src/common/crypto_s2k.h
+++ b/src/common/crypto_s2k.h
@@ -8,7 +8,7 @@
 #define TOR_CRYPTO_S2K_H_INCLUDED
 
 #include <stdio.h>
-#include "torint.h"
+#include "common/torint.h"
 
 /** Length of RFC2440-style S2K specifier: the first 8 bytes are a salt, the
  * 9th describes how much iteration to do. */
diff --git a/src/common/crypto_util.c b/src/common/crypto_util.c
index 2933579cf..71707d4bf 100644
--- a/src/common/crypto_util.c
+++ b/src/common/crypto_util.c
@@ -13,7 +13,7 @@
 #ifndef CRYPTO_UTIL_PRIVATE
 #define CRYPTO_UTIL_PRIVATE
 
-#include "crypto_util.h"
+#include "common/crypto_util.h"
 
 #include <string.h>
 
@@ -23,7 +23,7 @@
 #include <wincrypt.h>
 #endif /* defined(_WIN32) */
 
-#include "util.h"
+#include "common/util.h"
 
 DISABLE_GCC_WARNING(redundant-decls)
 
@@ -32,7 +32,7 @@ DISABLE_GCC_WARNING(redundant-decls)
 
 ENABLE_GCC_WARNING(redundant-decls)
 
-#include "torlog.h"
+#include "common/torlog.h"
 
 /**
  * Destroy the <b>sz</b> bytes of data stored at <b>mem</b>, setting them to
diff --git a/src/common/crypto_util.h b/src/common/crypto_util.h
index 31af52bff..53d9027fb 100644
--- a/src/common/crypto_util.h
+++ b/src/common/crypto_util.h
@@ -13,7 +13,7 @@
 #ifndef TOR_CRYPTO_UTIL_H
 #define TOR_CRYPTO_UTIL_H
 
-#include "torint.h"
+#include "common/torint.h"
 
 /** OpenSSL-based utility functions. */
 void memwipe(void *mem, uint8_t byte, size_t sz);
diff --git a/src/common/di_ops.c b/src/common/di_ops.c
index c09f97ef6..1ff1988b1 100644
--- a/src/common/di_ops.c
+++ b/src/common/di_ops.c
@@ -7,9 +7,9 @@
  **/
 
 #include "orconfig.h"
-#include "di_ops.h"
-#include "torlog.h"
-#include "util.h"
+#include "common/di_ops.h"
+#include "common/torlog.h"
+#include "common/util.h"
 
 /**
  * Timing-safe version of memcmp.  As memcmp, compare the <b>sz</b> bytes at
diff --git a/src/common/di_ops.h b/src/common/di_ops.h
index d54a0cc44..8298bfa73 100644
--- a/src/common/di_ops.h
+++ b/src/common/di_ops.h
@@ -12,7 +12,7 @@
 #define TOR_DI_OPS_H
 
 #include "orconfig.h"
-#include "torint.h"
+#include "common/torint.h"
 
 int tor_memcmp(const void *a, const void *b, size_t sz);
 int tor_memeq(const void *a, const void *b, size_t sz);
diff --git a/src/common/handles.h b/src/common/handles.h
index 591464366..ca345b0bc 100644
--- a/src/common/handles.h
+++ b/src/common/handles.h
@@ -51,7 +51,7 @@
 
 #include "orconfig.h"
 #include "tor_queue.h"
-#include "util.h"
+#include "common/util.h"
 
 #define HANDLE_ENTRY(name, structname)         \
   struct name ## _handle_head_t *handle_head
diff --git a/src/common/log.c b/src/common/log.c
index d7c0a898b..7ba669818 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -30,11 +30,11 @@
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include "compat.h"
-#include "util.h"
+#include "common/compat.h"
+#include "common/util.h"
 #define LOG_PRIVATE
-#include "torlog.h"
-#include "container.h"
+#include "common/torlog.h"
+#include "common/container.h"
 #ifdef HAVE_ANDROID_LOG_H
 #include <android/log.h>
 #endif // HAVE_ANDROID_LOG_H.
diff --git a/src/common/memarea.c b/src/common/memarea.c
index e0fe47161..12ad9c511 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -9,11 +9,11 @@
 #include "orconfig.h"
 #include <stddef.h>
 #include <stdlib.h>
-#include "memarea.h"
-#include "util.h"
-#include "compat.h"
-#include "torlog.h"
-#include "container.h"
+#include "common/memarea.h"
+#include "common/util.h"
+#include "common/compat.h"
+#include "common/torlog.h"
+#include "common/container.h"
 
 #ifndef DISABLE_MEMORY_SENTINELS
 
diff --git a/src/common/procmon.c b/src/common/procmon.c
index ac286abd1..7703b88af 100644
--- a/src/common/procmon.c
+++ b/src/common/procmon.c
@@ -6,9 +6,9 @@
  * \brief Process-termination monitor functions
  **/
 
-#include "procmon.h"
+#include "common/procmon.h"
 
-#include "util.h"
+#include "common/util.h"
 
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
diff --git a/src/common/procmon.h b/src/common/procmon.h
index 80a2bf963..46b6435af 100644
--- a/src/common/procmon.h
+++ b/src/common/procmon.h
@@ -9,10 +9,10 @@
 #ifndef TOR_PROCMON_H
 #define TOR_PROCMON_H
 
-#include "compat.h"
-#include "compat_libevent.h"
+#include "common/compat.h"
+#include "common/compat_libevent.h"
 
-#include "torlog.h"
+#include "common/torlog.h"
 
 typedef struct tor_process_monitor_t tor_process_monitor_t;
 
diff --git a/src/common/pubsub.c b/src/common/pubsub.c
index 744ee8345..93e8b5e6e 100644
--- a/src/common/pubsub.c
+++ b/src/common/pubsub.c
@@ -8,8 +8,8 @@
  */
 
 #include "orconfig.h"
-#include "pubsub.h"
-#include "container.h"
+#include "common/pubsub.h"
+#include "common/container.h"
 
 /** Helper: insert <b>s</b> into <b>topic's</b> list of subscribers, keeping
  * them sorted in priority order. */
diff --git a/src/common/pubsub.h b/src/common/pubsub.h
index 759b2e174..628732b67 100644
--- a/src/common/pubsub.h
+++ b/src/common/pubsub.h
@@ -42,7 +42,7 @@
 #ifndef TOR_PUBSUB_H
 #define TOR_PUBSUB_H
 
-#include "torint.h"
+#include "common/torint.h"
 
 /**
  * Flag for T_subscribe: die with an assertion failure if the event
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index 964dc0765..cba63e04f 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -32,11 +32,11 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "sandbox.h"
-#include "container.h"
-#include "torlog.h"
-#include "torint.h"
-#include "util.h"
+#include "common/sandbox.h"
+#include "common/container.h"
+#include "common/torlog.h"
+#include "common/torint.h"
+#include "common/util.h"
 #include "tor_queue.h"
 
 #include "ht.h"
@@ -79,7 +79,7 @@
   defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)
 #define USE_BACKTRACE
 #define EXPOSE_CLEAN_BACKTRACE
-#include "backtrace.h"
+#include "common/backtrace.h"
 #endif /* defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && ... */
 
 #ifdef USE_BACKTRACE
diff --git a/src/common/sandbox.h b/src/common/sandbox.h
index a25886ccb..945d57df7 100644
--- a/src/common/sandbox.h
+++ b/src/common/sandbox.h
@@ -13,7 +13,7 @@
 #define SANDBOX_H_
 
 #include "orconfig.h"
-#include "torint.h"
+#include "common/torint.h"
 
 #ifndef SYS_SECCOMP
 
diff --git a/src/common/storagedir.c b/src/common/storagedir.c
index 4c3d7238e..ee80bcc53 100644
--- a/src/common/storagedir.c
+++ b/src/common/storagedir.c
@@ -1,14 +1,14 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "container.h"
-#include "compat.h"
-#include "confline.h"
-#include "memarea.h"
-#include "sandbox.h"
-#include "storagedir.h"
-#include "torlog.h"
-#include "util.h"
+#include "common/container.h"
+#include "common/compat.h"
+#include "common/confline.h"
+#include "common/memarea.h"
+#include "common/sandbox.h"
+#include "common/storagedir.h"
+#include "common/torlog.h"
+#include "common/util.h"
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
diff --git a/src/common/timers.c b/src/common/timers.c
index cadbe7ff6..2c39cf74b 100644
--- a/src/common/timers.c
+++ b/src/common/timers.c
@@ -31,11 +31,11 @@
 
 #define TOR_TIMERS_PRIVATE
 
-#include "compat.h"
-#include "compat_libevent.h"
-#include "timers.h"
-#include "torlog.h"
-#include "util.h"
+#include "common/compat.h"
+#include "common/compat_libevent.h"
+#include "common/timers.h"
+#include "common/torlog.h"
+#include "common/util.h"
 
 struct timeout_cb {
   timer_cb_fn_t cb;
diff --git a/src/common/timers.h b/src/common/timers.h
index c8abaae10..6b6179ca7 100644
--- a/src/common/timers.h
+++ b/src/common/timers.h
@@ -5,7 +5,7 @@
 #define TOR_TIMERS_H
 
 #include "orconfig.h"
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 struct monotime_t;
 typedef struct timeout tor_timer_t;
diff --git a/src/common/token_bucket.c b/src/common/token_bucket.c
index 62b5b7829..a028b08a0 100644
--- a/src/common/token_bucket.c
+++ b/src/common/token_bucket.c
@@ -18,8 +18,8 @@
 
 #define TOKEN_BUCKET_PRIVATE
 
-#include "token_bucket.h"
-#include "util_bug.h"
+#include "common/token_bucket.h"
+#include "common/util_bug.h"
 
 /**
  * Set the <b>rate</b> and <b>burst</b> value in a token_bucket_cfg.
diff --git a/src/common/token_bucket.h b/src/common/token_bucket.h
index 6a8efeaaa..645c90c62 100644
--- a/src/common/token_bucket.h
+++ b/src/common/token_bucket.h
@@ -9,8 +9,8 @@
 #ifndef TOR_TOKEN_BUCKET_H
 #define TOR_TOKEN_BUCKET_H
 
-#include "torint.h"
-#include "testsupport.h"
+#include "common/torint.h"
+#include "common/testsupport.h"
 
 /** Largest allowable burst value for a token buffer. */
 #define TOKEN_BUCKET_MAX_BURST INT32_MAX
diff --git a/src/common/torlog.h b/src/common/torlog.h
index 9b4df6080..65921c7b0 100644
--- a/src/common/torlog.h
+++ b/src/common/torlog.h
@@ -12,8 +12,8 @@
 
 #ifndef TOR_TORLOG_H
 
-#include "compat.h"
-#include "testsupport.h"
+#include "common/compat.h"
+#include "common/testsupport.h"
 
 #ifdef HAVE_SYSLOG_H
 #include <syslog.h>
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 9e509a4b4..b22a5aa7c 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -25,11 +25,11 @@
   #include <ws2tcpip.h>
 #endif
 
-#include "crypto.h"
-#include "crypto_rand.h"
-#include "crypto_dh.h"
-#include "crypto_util.h"
-#include "compat.h"
+#include "common/crypto.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_dh.h"
+#include "common/crypto_util.h"
+#include "common/compat.h"
 
 /* Some versions of OpenSSL declare SSL_get_selected_srtp_profile twice in
  * srtp.h. Suppress the GCC warning so we can build with -Wredundant-decl. */
@@ -53,10 +53,10 @@ DISABLE_GCC_WARNING(redundant-decls)
 ENABLE_GCC_WARNING(redundant-decls)
 
 #define TORTLS_PRIVATE
-#include "tortls.h"
-#include "util.h"
-#include "torlog.h"
-#include "container.h"
+#include "common/tortls.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/container.h"
 #include <string.h>
 
 #ifdef OPENSSL_1_1_API
diff --git a/src/common/tortls.h b/src/common/tortls.h
index c86b98885..c7b319761 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -11,10 +11,10 @@
  * \brief Headers for tortls.c
  **/
 
-#include "crypto_rsa.h"
-#include "compat_openssl.h"
-#include "compat.h"
-#include "testsupport.h"
+#include "common/crypto_rsa.h"
+#include "common/compat_openssl.h"
+#include "common/compat.h"
+#include "common/testsupport.h"
 
 /* Opaque structure to hold a TLS connection. */
 typedef struct tor_tls_t tor_tls_t;
diff --git a/src/common/util.c b/src/common/util.c
index a0b672f0d..b3fdc8a43 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -14,16 +14,16 @@
 #include <fcntl.h>
 #endif
 #define UTIL_PRIVATE
-#include "util.h"
-#include "torlog.h"
-#include "crypto_digest.h"
-#include "torint.h"
-#include "container.h"
-#include "address.h"
-#include "sandbox.h"
-#include "backtrace.h"
-#include "util_process.h"
-#include "util_format.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/crypto_digest.h"
+#include "common/torint.h"
+#include "common/container.h"
+#include "common/address.h"
+#include "common/sandbox.h"
+#include "common/backtrace.h"
+#include "common/util_process.h"
+#include "common/util_format.h"
 
 #ifdef _WIN32
 #include <io.h>
diff --git a/src/common/util.h b/src/common/util.h
index 504ba322f..dcfa55f8f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -12,17 +12,17 @@
 #define TOR_UTIL_H
 
 #include "orconfig.h"
-#include "torint.h"
-#include "compat.h"
-#include "di_ops.h"
-#include "testsupport.h"
+#include "common/torint.h"
+#include "common/compat.h"
+#include "common/di_ops.h"
+#include "common/testsupport.h"
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef _WIN32
 /* for the correct alias to struct stat */
 #include <sys/stat.h>
 #endif
-#include "util_bug.h"
+#include "common/util_bug.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
diff --git a/src/common/util_bug.c b/src/common/util_bug.c
index 0fa085acb..da34201c1 100644
--- a/src/common/util_bug.c
+++ b/src/common/util_bug.c
@@ -8,10 +8,10 @@
  **/
 
 #include "orconfig.h"
-#include "util_bug.h"
-#include "torlog.h"
-#include "backtrace.h"
-#include "container.h"
+#include "common/util_bug.h"
+#include "common/torlog.h"
+#include "common/backtrace.h"
+#include "common/container.h"
 
 #ifdef __COVERITY__
 int bug_macro_deadcode_dummy__ = 0;
diff --git a/src/common/util_bug.h b/src/common/util_bug.h
index 1bd2e81c3..70a28eb15 100644
--- a/src/common/util_bug.h
+++ b/src/common/util_bug.h
@@ -37,8 +37,8 @@
 #define TOR_UTIL_BUG_H
 
 #include "orconfig.h"
-#include "compat.h"
-#include "testsupport.h"
+#include "common/compat.h"
+#include "common/testsupport.h"
 
 /* Replace assert() with a variant that sends failures to the log before
  * calling assert() normally.
diff --git a/src/common/util_format.c b/src/common/util_format.c
index b226c538f..cab257234 100644
--- a/src/common/util_format.c
+++ b/src/common/util_format.c
@@ -12,10 +12,10 @@
  */
 
 #include "orconfig.h"
-#include "torlog.h"
-#include "util.h"
-#include "util_format.h"
-#include "torint.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/util_format.h"
+#include "common/torint.h"
 
 #include <stddef.h>
 #include <string.h>
diff --git a/src/common/util_format.h b/src/common/util_format.h
index ce55b95af..7dd5ae5bd 100644
--- a/src/common/util_format.h
+++ b/src/common/util_format.h
@@ -7,8 +7,8 @@
 #ifndef TOR_UTIL_FORMAT_H
 #define TOR_UTIL_FORMAT_H
 
-#include "testsupport.h"
-#include "torint.h"
+#include "common/testsupport.h"
+#include "common/torint.h"
 
 /** @{ */
 /** These macros don't check for overflow.  Use them only for constant inputs
diff --git a/src/common/util_process.c b/src/common/util_process.c
index de218700b..6eee659b2 100644
--- a/src/common/util_process.c
+++ b/src/common/util_process.c
@@ -19,10 +19,10 @@
 #include <sys/wait.h>
 #endif
 
-#include "compat.h"
-#include "util.h"
-#include "torlog.h"
-#include "util_process.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/util_process.h"
 #include "ht.h"
 
 /* ================================================== */
diff --git a/src/common/workqueue.c b/src/common/workqueue.c
index 563a98af9..0d31a2ecc 100644
--- a/src/common/workqueue.c
+++ b/src/common/workqueue.c
@@ -24,14 +24,14 @@
  */
 
 #include "orconfig.h"
-#include "compat.h"
-#include "compat_libevent.h"
-#include "compat_threads.h"
-#include "crypto_rand.h"
-#include "util.h"
-#include "workqueue.h"
+#include "common/compat.h"
+#include "common/compat_libevent.h"
+#include "common/compat_threads.h"
+#include "common/crypto_rand.h"
+#include "common/util.h"
+#include "common/workqueue.h"
 #include "tor_queue.h"
-#include "torlog.h"
+#include "common/torlog.h"
 
 #include <event2/event.h>
 
diff --git a/src/common/workqueue.h b/src/common/workqueue.h
index 4e76fd86e..1e0efcb1a 100644
--- a/src/common/workqueue.h
+++ b/src/common/workqueue.h
@@ -4,7 +4,7 @@
 #ifndef TOR_WORKQUEUE_H
 #define TOR_WORKQUEUE_H
 
-#include "compat.h"
+#include "common/compat.h"
 
 /** A replyqueue is used to tell the main thread about the outcome of
  * work that we queued for the workers. */
diff --git a/src/ext/OpenBSD_malloc_Linux.c b/src/ext/OpenBSD_malloc_Linux.c
index 855c91231..157462b9a 100644
--- a/src/ext/OpenBSD_malloc_Linux.c
+++ b/src/ext/OpenBSD_malloc_Linux.c
@@ -59,7 +59,7 @@
 #include <errno.h>
 #include <err.h>
 /* For SIZE_MAX */
-#include "torint.h"
+#include "common/torint.h"
 
 //#include "thread_private.h"
 
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c
index 0427c8795..36c3dee76 100644
--- a/src/ext/csiphash.c
+++ b/src/ext/csiphash.c
@@ -29,10 +29,10 @@
     Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c)
 */
 
-#include "torint.h"
+#include "common/torint.h"
 #include "siphash.h"
 /* for tor_assert */
-#include "util.h"
+#include "common/util.h"
 /* for memcpy */
 #include <string.h>
 #include "byteorder.h"
diff --git a/src/ext/curve25519_donna/curve25519-donna-c64.c b/src/ext/curve25519_donna/curve25519-donna-c64.c
index b68ff3695..d2d7fb434 100644
--- a/src/ext/curve25519_donna/curve25519-donna-c64.c
+++ b/src/ext/curve25519_donna/curve25519-donna-c64.c
@@ -25,7 +25,7 @@
 #include "orconfig.h"
 
 #include <string.h>
-#include "torint.h"
+#include "common/torint.h"
 
 typedef uint8_t u8;
 typedef uint64_t limb;
diff --git a/src/ext/curve25519_donna/curve25519-donna.c b/src/ext/curve25519_donna/curve25519-donna.c
index 1c5a27ab8..573e6e26a 100644
--- a/src/ext/curve25519_donna/curve25519-donna.c
+++ b/src/ext/curve25519_donna/curve25519-donna.c
@@ -48,7 +48,7 @@
 #include "orconfig.h"
 
 #include <string.h>
-#include "torint.h"
+#include "common/torint.h"
 
 typedef uint8_t u8;
 typedef int32_t s32;
diff --git a/src/ext/ed25519/donna/ed25519-hash-custom.h b/src/ext/ed25519/donna/ed25519-hash-custom.h
index cdeab3e45..c17649991 100644
--- a/src/ext/ed25519/donna/ed25519-hash-custom.h
+++ b/src/ext/ed25519/donna/ed25519-hash-custom.h
@@ -9,7 +9,7 @@
 	void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen);
 */
 
-#include "crypto_digest.h"
+#include "common/crypto_digest.h"
 
 typedef struct ed25519_hash_context {
   crypto_digest_t *ctx;
diff --git a/src/ext/ed25519/donna/ed25519-randombytes-custom.h b/src/ext/ed25519/donna/ed25519-randombytes-custom.h
index 27eade4f9..ea7a649cd 100644
--- a/src/ext/ed25519/donna/ed25519-randombytes-custom.h
+++ b/src/ext/ed25519/donna/ed25519-randombytes-custom.h
@@ -8,7 +8,7 @@
 */
 
 /* Tor: Instead of calling OpenSSL's CSPRNG directly, call the wrapper. */
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 
 static void
 ED25519_FN(ed25519_randombytes_unsafe) (void *p, size_t len)
diff --git a/src/ext/ed25519/donna/ed25519_donna_tor.h b/src/ext/ed25519/donna/ed25519_donna_tor.h
index 7d7b8c062..dfaefc865 100644
--- a/src/ext/ed25519/donna/ed25519_donna_tor.h
+++ b/src/ext/ed25519/donna/ed25519_donna_tor.h
@@ -1,7 +1,7 @@
 /* Added for Tor. */
 #ifndef SRC_EXT_ED25519_DONNA_H_INCLUDED_
 #define SRC_EXT_ED25519_DONNA_H_INCLUDED_
-#include <torint.h>
+#include "common/torint.h"
 
 typedef unsigned char curved25519_key[32];
 
diff --git a/src/ext/ed25519/donna/ed25519_tor.c b/src/ext/ed25519/donna/ed25519_tor.c
index 43de9faae..c3d4e09cd 100644
--- a/src/ext/ed25519/donna/ed25519_tor.c
+++ b/src/ext/ed25519/donna/ed25519_tor.c
@@ -40,7 +40,7 @@
 #include "ed25519-randombytes.h"
 #include "ed25519-hash.h"
 
-#include "crypto_util.h"
+#include "common/crypto_util.h"
 
 typedef unsigned char ed25519_signature[64];
 typedef unsigned char ed25519_public_key[32];
diff --git a/src/ext/ed25519/ref10/blinding.c b/src/ext/ed25519/ref10/blinding.c
index 88e84cac2..6408491fa 100644
--- a/src/ext/ed25519/ref10/blinding.c
+++ b/src/ext/ed25519/ref10/blinding.c
@@ -7,7 +7,7 @@
 #include "ed25519_ref10.h"
 
 #include <string.h>
-#include "crypto_util.h"
+#include "common/crypto_util.h"
 
 static void
 ed25519_ref10_gettweak(unsigned char *out, const unsigned char *param)
diff --git a/src/ext/ed25519/ref10/crypto_hash_sha512.h b/src/ext/ed25519/ref10/crypto_hash_sha512.h
index 7faddb159..8ab0b4565 100644
--- a/src/ext/ed25519/ref10/crypto_hash_sha512.h
+++ b/src/ext/ed25519/ref10/crypto_hash_sha512.h
@@ -1,5 +1,5 @@
 /* Added for Tor. */
-#include "crypto_digest.h"
+#include "common/crypto_digest.h"
 
 /* Set 'out' to the 512-bit SHA512 hash of the 'len'-byte string in 'inp' */
 #define crypto_hash_sha512(out, inp, len) \
diff --git a/src/ext/ed25519/ref10/crypto_int32.h b/src/ext/ed25519/ref10/crypto_int32.h
index dd13c91bd..59311a620 100644
--- a/src/ext/ed25519/ref10/crypto_int32.h
+++ b/src/ext/ed25519/ref10/crypto_int32.h
@@ -3,7 +3,7 @@
 #ifndef CRYPTO_INT32_H
 #define CRYPTO_INT32_H
 
-#include "torint.h"
+#include "common/torint.h"
 #define crypto_int32 int32_t
 #define crypto_uint32 uint32_t
 
diff --git a/src/ext/ed25519/ref10/crypto_int64.h b/src/ext/ed25519/ref10/crypto_int64.h
index 46e8852ed..6dda30f2e 100644
--- a/src/ext/ed25519/ref10/crypto_int64.h
+++ b/src/ext/ed25519/ref10/crypto_int64.h
@@ -3,7 +3,7 @@
 #ifndef CRYPTO_INT64_H
 #define CRYPTO_INT64_H
 
-#include "torint.h"
+#include "common/torint.h"
 #define crypto_int64 int64_t
 #define crypto_uint64 uint64_t
 
diff --git a/src/ext/ed25519/ref10/crypto_uint32.h b/src/ext/ed25519/ref10/crypto_uint32.h
index 62655a5b6..b12a595a1 100644
--- a/src/ext/ed25519/ref10/crypto_uint32.h
+++ b/src/ext/ed25519/ref10/crypto_uint32.h
@@ -1,3 +1,3 @@
 /* Added for Tor. */
-#include "torint.h"
+#include "common/torint.h"
 #define crypto_uint32 uint32_t
diff --git a/src/ext/ed25519/ref10/crypto_uint64.h b/src/ext/ed25519/ref10/crypto_uint64.h
index cbda882a6..73edfd1b5 100644
--- a/src/ext/ed25519/ref10/crypto_uint64.h
+++ b/src/ext/ed25519/ref10/crypto_uint64.h
@@ -1,3 +1,3 @@
 /* Added for Tor. */
-#include "torint.h"
+#include "common/torint.h"
 #define crypto_uint64 uint64_t
diff --git a/src/ext/ed25519/ref10/crypto_verify_32.h b/src/ext/ed25519/ref10/crypto_verify_32.h
index 0f63efc7a..f2000a321 100644
--- a/src/ext/ed25519/ref10/crypto_verify_32.h
+++ b/src/ext/ed25519/ref10/crypto_verify_32.h
@@ -1,5 +1,4 @@
 /* Added for Tor. */
-#include "di_ops.h"
+#include "common/di_ops.h"
 #define crypto_verify_32(a,b) \
   (! tor_memeq((a), (b), 32))
-
diff --git a/src/ext/ed25519/ref10/ed25519_ref10.h b/src/ext/ed25519/ref10/ed25519_ref10.h
index 596569497..15ac07e24 100644
--- a/src/ext/ed25519/ref10/ed25519_ref10.h
+++ b/src/ext/ed25519/ref10/ed25519_ref10.h
@@ -1,7 +1,7 @@
 /* Added for Tor */
 #ifndef SRC_EXT_ED25519_REF10_H_INCLUDED_
 #define SRC_EXT_ED25519_REF10_H_INCLUDED_
-#include <torint.h>
+#include "common/torint.h"
 
 int ed25519_ref10_seckey(unsigned char *sk);
 int ed25519_ref10_seckey_expand(unsigned char *sk, const unsigned char *sk_seed);
diff --git a/src/ext/ed25519/ref10/keypair.c b/src/ext/ed25519/ref10/keypair.c
index c437f0a4f..8ed0a4a8f 100644
--- a/src/ext/ed25519/ref10/keypair.c
+++ b/src/ext/ed25519/ref10/keypair.c
@@ -6,8 +6,8 @@
 #include "crypto_hash_sha512.h"
 #include "ge.h"
 
-#include "crypto_rand.h"
-#include "crypto_util.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
 
 int
 crypto_sign_seckey(unsigned char *sk)
@@ -52,4 +52,3 @@ int crypto_sign_keypair(unsigned char *pk,unsigned char *sk)
 
   return 0;
 }
-
diff --git a/src/ext/ed25519/ref10/randombytes.h b/src/ext/ed25519/ref10/randombytes.h
index a21dde854..f5bc3b228 100644
--- a/src/ext/ed25519/ref10/randombytes.h
+++ b/src/ext/ed25519/ref10/randombytes.h
@@ -1,4 +1,4 @@
 /* Added for Tor. */
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 #define randombytes(b, n) \
   (crypto_strongest_rand((b), (n)), 0)
diff --git a/src/ext/keccak-tiny/keccak-tiny-unrolled.c b/src/ext/keccak-tiny/keccak-tiny-unrolled.c
index 07e8c95bc..233a73331 100644
--- a/src/ext/keccak-tiny/keccak-tiny-unrolled.c
+++ b/src/ext/keccak-tiny/keccak-tiny-unrolled.c
@@ -9,7 +9,7 @@
 #include "keccak-tiny.h"
 
 #include <string.h>
-#include "crypto_util.h"
+#include "common/crypto_util.h"
 #include "byteorder.h"
 
 /******** Endianness conversion helpers ********/
diff --git a/src/ext/keccak-tiny/keccak-tiny.h b/src/ext/keccak-tiny/keccak-tiny.h
index 7efea2319..58e1d4534 100644
--- a/src/ext/keccak-tiny/keccak-tiny.h
+++ b/src/ext/keccak-tiny/keccak-tiny.h
@@ -2,7 +2,7 @@
 #define KECCAK_FIPS202_H
 
 #include <stddef.h>
-#include "torint.h"
+#include "common/torint.h"
 
 #define KECCAK_MAX_RATE 200
 
diff --git a/src/ext/mulodi/mulodi4.c b/src/ext/mulodi/mulodi4.c
index 9891bbf1a..ddd17cd1d 100644
--- a/src/ext/mulodi/mulodi4.c
+++ b/src/ext/mulodi/mulodi4.c
@@ -18,7 +18,7 @@
 #define COMPILER_RT_ABI
 #define di_int int64_t
 #define di_uint uint64_t
-#include "torint.h"
+#include "common/torint.h"
 
 di_int __mulodi4(di_int a, di_int b, int* overflow);
 #endif
diff --git a/src/or/addressmap.c b/src/or/addressmap.c
index 566dc032a..9ca232627 100644
--- a/src/or/addressmap.c
+++ b/src/or/addressmap.c
@@ -15,18 +15,18 @@
 
 #define ADDRESSMAP_PRIVATE
 
-#include "or.h"
-#include "addressmap.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection_edge.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "dns.h"
-#include "nodelist.h"
-#include "routerset.h"
-
-#include "entry_connection_st.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection_edge.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/dns.h"
+#include "or/nodelist.h"
+#include "or/routerset.h"
+
+#include "or/entry_connection_st.h"
 
 /** A client-side struct to remember requests to rewrite addresses
  * to new addresses. These structs are stored in the hash table
diff --git a/src/or/addressmap.h b/src/or/addressmap.h
index b73915446..0d53e7777 100644
--- a/src/or/addressmap.h
+++ b/src/or/addressmap.h
@@ -7,7 +7,7 @@
 #ifndef TOR_ADDRESSMAP_H
 #define TOR_ADDRESSMAP_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 void addressmap_init(void);
 void addressmap_clear_excluded_trackexithosts(const or_options_t *options);
diff --git a/src/or/authority_cert_st.h b/src/or/authority_cert_st.h
index c8fbc5238..19c3fda2d 100644
--- a/src/or/authority_cert_st.h
+++ b/src/or/authority_cert_st.h
@@ -7,7 +7,7 @@
 #ifndef AUTHORITY_CERT_ST_H
 #define AUTHORITY_CERT_ST_H
 
-#include "signed_descriptor_st.h"
+#include "or/signed_descriptor_st.h"
 
 /** Certificate for v3 directory protocol: binds long-term authority identity
  * keys to medium-term authority signing keys. */
diff --git a/src/or/bridges.c b/src/or/bridges.c
index e7e16dda6..ca0a13f2a 100644
--- a/src/or/bridges.c
+++ b/src/or/bridges.c
@@ -13,24 +13,24 @@
 
 #define TOR_BRIDGES_PRIVATE
 
-#include "or.h"
-#include "bridges.h"
-#include "circuitbuild.h"
-#include "config.h"
-#include "connection.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "transports.h"
-
-#include "extend_info_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/circuitbuild.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/transports.h"
+
+#include "or/extend_info_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 /** Information about a configured bridge. Currently this just matches the
  * ones in the torrc file, but one day we may be able to learn about new
diff --git a/src/or/channel.c b/src/or/channel.c
index 8ed36900d..2cf5b8a2a 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -57,30 +57,30 @@
 /* This one's for stuff only channel.c and the test suite should see */
 #define CHANNEL_PRIVATE_
 
-#include "or.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "channelpadding.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "connection_or.h" /* For var_cell_free() */
-#include "circuitmux.h"
-#include "entrynodes.h"
-#include "geoip.h"
-#include "main.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "scheduler.h"
-#include "compat_time.h"
-#include "networkstatus.h"
-#include "rendservice.h"
-
-#include "cell_queue_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/channelpadding.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/connection_or.h" /* For var_cell_free() */
+#include "or/circuitmux.h"
+#include "or/entrynodes.h"
+#include "or/geoip.h"
+#include "or/main.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/scheduler.h"
+#include "common/compat_time.h"
+#include "or/networkstatus.h"
+#include "or/rendservice.h"
+
+#include "or/cell_queue_st.h"
 
 /* Global lists of channels */
 
diff --git a/src/or/channel.h b/src/or/channel.h
index 57d010b36..44b752e2c 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -9,10 +9,10 @@
 #ifndef TOR_CHANNEL_H
 #define TOR_CHANNEL_H
 
-#include "or.h"
-#include "circuitmux.h"
-#include "timers.h"
-#include "handles.h"
+#include "or/or.h"
+#include "or/circuitmux.h"
+#include "common/timers.h"
+#include "common/handles.h"
 
 /* Channel handler function pointer typedefs */
 typedef void (*channel_listener_fn_ptr)(channel_listener_t *, channel_t *);
diff --git a/src/or/channelpadding.c b/src/or/channelpadding.c
index 889506414..190f54f29 100644
--- a/src/or/channelpadding.c
+++ b/src/or/channelpadding.c
@@ -8,23 +8,23 @@
  * channelpadding_channel_to_channelinfo() */
 #define TOR_CHANNEL_INTERNAL_
 
-#include "or.h"
-#include "channel.h"
-#include "channelpadding.h"
-#include "channeltls.h"
-#include "config.h"
-#include "networkstatus.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "crypto_rand.h"
-#include "main.h"
-#include "rephist.h"
-#include "router.h"
-#include "compat_time.h"
-#include "rendservice.h"
-
-#include "cell_st.h"
-#include "or_connection_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/channelpadding.h"
+#include "or/channeltls.h"
+#include "or/config.h"
+#include "or/networkstatus.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "common/crypto_rand.h"
+#include "or/main.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "common/compat_time.h"
+#include "or/rendservice.h"
+
+#include "or/cell_st.h"
+#include "or/or_connection_st.h"
 
 STATIC int32_t channelpadding_get_netflow_inactive_timeout_ms(
                                                            const channel_t *);
diff --git a/src/or/channelpadding.h b/src/or/channelpadding.h
index fb8d812e9..7eddbdbe2 100644
--- a/src/or/channelpadding.h
+++ b/src/or/channelpadding.h
@@ -11,7 +11,7 @@
 #ifndef TOR_CHANNELPADDING_H
 #define TOR_CHANNELPADDING_H
 
-#include "channelpadding_negotiation.h"
+#include "trunnel/channelpadding_negotiation.h"
 
 #define CHANNELPADDING_TOR2WEB_PARAM  "nf_pad_tor2web"
 #define CHANNELPADDING_TOR2WEB_DEFAULT 1
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 4bbfd4832..5258935ae 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -38,36 +38,36 @@
 
 #define CHANNELTLS_PRIVATE
 
-#include "or.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
-#include "command.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "control.h"
-#include "entrynodes.h"
-#include "link_handshake.h"
-#include "relay.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "scheduler.h"
-#include "torcert.h"
-#include "networkstatus.h"
-#include "channelpadding_negotiation.h"
-#include "channelpadding.h"
-
-#include "cell_st.h"
-#include "cell_queue_st.h"
-#include "extend_info_st.h"
-#include "or_connection_st.h"
-#include "or_handshake_certs_st.h"
-#include "or_handshake_state_st.h"
-#include "routerinfo_st.h"
-#include "var_cell_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
+#include "or/command.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "or/entrynodes.h"
+#include "trunnel/link_handshake.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/scheduler.h"
+#include "or/torcert.h"
+#include "or/networkstatus.h"
+#include "trunnel/channelpadding_negotiation.h"
+#include "or/channelpadding.h"
+
+#include "or/cell_st.h"
+#include "or/cell_queue_st.h"
+#include "or/extend_info_st.h"
+#include "or/or_connection_st.h"
+#include "or/or_handshake_certs_st.h"
+#include "or/or_handshake_state_st.h"
+#include "or/routerinfo_st.h"
+#include "or/var_cell_st.h"
 
 /** How many CELL_PADDING cells have we received, ever? */
 uint64_t stats_n_padding_cells_processed = 0;
diff --git a/src/or/channeltls.h b/src/or/channeltls.h
index 72788b506..be74127c9 100644
--- a/src/or/channeltls.h
+++ b/src/or/channeltls.h
@@ -9,8 +9,8 @@
 #ifndef TOR_CHANNELTLS_H
 #define TOR_CHANNELTLS_H
 
-#include "or.h"
-#include "channel.h"
+#include "or/or.h"
+#include "or/channel.h"
 
 #define BASE_CHAN_TO_TLS(c) (channel_tls_from_base((c)))
 #define TLS_CHAN_TO_BASE(c) (channel_tls_to_base((c)))
diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c
index 489a43382..ace29c4a0 100644
--- a/src/or/circpathbias.c
+++ b/src/or/circpathbias.c
@@ -21,25 +21,25 @@
  * each guard, and stored persistently in the state file.
  */
 
-#include "or.h"
-#include "channel.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "circuitstats.h"
-#include "connection_edge.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "entrynodes.h"
-#include "networkstatus.h"
-#include "relay.h"
-
-#include "cell_st.h"
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "extend_info_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/circuitstats.h"
+#include "or/connection_edge.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/entrynodes.h"
+#include "or/networkstatus.h"
+#include "or/relay.h"
+
+#include "or/cell_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/extend_info_st.h"
+#include "or/origin_circuit_st.h"
 
 static void pathbias_count_successful_close(origin_circuit_t *circ);
 static void pathbias_count_collapse(origin_circuit_t *circ);
diff --git a/src/or/circuit_st.h b/src/or/circuit_st.h
index 9657782ed..0ace64f3e 100644
--- a/src/or/circuit_st.h
+++ b/src/or/circuit_st.h
@@ -7,9 +7,9 @@
 #ifndef CIRCUIT_ST_H
 #define CIRCUIT_ST_H
 
-#include "or.h"
+#include "or/or.h"
 
-#include "cell_queue_st.h"
+#include "or/cell_queue_st.h"
 
 /**
  * A circuit is a path over the onion routing
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index fcd08d83f..f52708277 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -27,54 +27,54 @@
 
 #define CIRCUITBUILD_PRIVATE
 
-#include "or.h"
-#include "bridges.h"
-#include "channel.h"
-#include "circpathbias.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
 #define CIRCUITBUILD_PRIVATE
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "circuituse.h"
-#include "command.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "hs_ntor.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "onion.h"
-#include "onion_tap.h"
-#include "onion_fast.h"
-#include "policies.h"
-#include "relay.h"
-#include "relay_crypto.h"
-#include "rendcommon.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "transports.h"
-
-#include "cell_st.h"
-#include "cpath_build_state_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "node_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "microdesc_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "or/circuituse.h"
+#include "or/command.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/hs_ntor.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/onion.h"
+#include "or/onion_tap.h"
+#include "or/onion_fast.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/relay_crypto.h"
+#include "or/rendcommon.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/transports.h"
+
+#include "or/cell_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/node_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/microdesc_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 static channel_t * channel_connect_for_circuit(const tor_addr_t *addr,
                                             uint16_t port,
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 99ce65448..c3d017bf8 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -51,54 +51,54 @@
  * logic, which was originally circuit-focused.
  **/
 #define CIRCUITLIST_PRIVATE
-#include "torint.h"  /* TOR_PRIuSZ */
-
-#include "or.h"
-#include "channel.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "circuitstats.h"
-#include "connection.h"
-#include "config.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "main.h"
-#include "hs_circuit.h"
-#include "hs_circuitmap.h"
-#include "hs_ident.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "onion.h"
-#include "onion_fast.h"
-#include "policies.h"
-#include "relay.h"
-#include "relay_crypto.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rephist.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "channelpadding.h"
-#include "compress_lzma.h"
-#include "compress_zlib.h"
-#include "compress_zstd.h"
+#include "common/torint.h"  /* TOR_PRIuSZ */
+
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/circuitstats.h"
+#include "or/connection.h"
+#include "or/config.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/main.h"
+#include "or/hs_circuit.h"
+#include "or/hs_circuitmap.h"
+#include "or/hs_ident.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/onion.h"
+#include "or/onion_fast.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/relay_crypto.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rephist.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/channelpadding.h"
+#include "common/compress_lzma.h"
+#include "common/compress_zlib.h"
+#include "common/compress_zstd.h"
 
 #include "ht.h"
 
-#include "cpath_build_state_st.h"
-#include "crypt_path_reference_st.h"
-#include "dir_connection_st.h"
-#include "edge_connection_st.h"
-#include "extend_info_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_reference_st.h"
+#include "or/dir_connection_st.h"
+#include "or/edge_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 /********* START VARIABLES **********/
 
diff --git a/src/or/circuitlist.h b/src/or/circuitlist.h
index 2885a073b..9f80c3efd 100644
--- a/src/or/circuitlist.h
+++ b/src/or/circuitlist.h
@@ -12,8 +12,8 @@
 #ifndef TOR_CIRCUITLIST_H
 #define TOR_CIRCUITLIST_H
 
-#include "testsupport.h"
-#include "hs_ident.h"
+#include "common/testsupport.h"
+#include "or/hs_ident.h"
 
 /** Convert a circuit_t* to a pointer to the enclosing or_circuit_t.  Assert
  * if the cast is impossible. */
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 80f65f0aa..31f9281eb 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -69,15 +69,15 @@
  *     made to attach all existing circuits to the new policy.
  **/
 
-#include "or.h"
-#include "channel.h"
-#include "circuitlist.h"
-#include "circuitmux.h"
-#include "relay.h"
-
-#include "cell_queue_st.h"
-#include "destroy_cell_queue_st.h"
-#include "or_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitlist.h"
+#include "or/circuitmux.h"
+#include "or/relay.h"
+
+#include "or/cell_queue_st.h"
+#include "or/destroy_cell_queue_st.h"
+#include "or/or_circuit_st.h"
 
 /*
  * Private typedefs for circuitmux.c
diff --git a/src/or/circuitmux.h b/src/or/circuitmux.h
index 1af73340e..68bcbf6e7 100644
--- a/src/or/circuitmux.h
+++ b/src/or/circuitmux.h
@@ -9,8 +9,8 @@
 #ifndef TOR_CIRCUITMUX_H
 #define TOR_CIRCUITMUX_H
 
-#include "or.h"
-#include "testsupport.h"
+#include "or/or.h"
+#include "common/testsupport.h"
 
 typedef struct circuitmux_policy_s circuitmux_policy_t;
 typedef struct circuitmux_policy_data_s circuitmux_policy_data_t;
diff --git a/src/or/circuitmux_ewma.c b/src/or/circuitmux_ewma.c
index 631dc7c3a..3b144e7d9 100644
--- a/src/or/circuitmux_ewma.c
+++ b/src/or/circuitmux_ewma.c
@@ -34,11 +34,11 @@
 
 #include <math.h>
 
-#include "or.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
-#include "crypto_rand.h"
-#include "networkstatus.h"
+#include "or/or.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
+#include "common/crypto_rand.h"
+#include "or/networkstatus.h"
 
 /*** EWMA parameter #defines ***/
 
diff --git a/src/or/circuitmux_ewma.h b/src/or/circuitmux_ewma.h
index c0c94101a..1214b0264 100644
--- a/src/or/circuitmux_ewma.h
+++ b/src/or/circuitmux_ewma.h
@@ -9,8 +9,8 @@
 #ifndef TOR_CIRCUITMUX_EWMA_H
 #define TOR_CIRCUITMUX_EWMA_H
 
-#include "or.h"
-#include "circuitmux.h"
+#include "or/or.h"
+#include "or/circuitmux.h"
 
 /* The public EWMA policy callbacks object. */
 extern circuitmux_policy_t ewma_policy;
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index 202de567b..ebd082306 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -25,24 +25,24 @@
 
 #define CIRCUITSTATS_PRIVATE
 
-#include "or.h"
-#include "circuitbuild.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "confparse.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "rendclient.h"
-#include "rendservice.h"
-#include "router.h"
-#include "statefile.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-
-#include "crypt_path_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/rendclient.h"
+#include "or/rendservice.h"
+#include "or/router.h"
+#include "or/statefile.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+
+#include "or/crypt_path_st.h"
+#include "or/origin_circuit_st.h"
 
 #undef log
 #include <math.h>
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index e46d1459b..0ba3f34b4 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -27,43 +27,43 @@
  * logic in circuitstats.c.
  **/
 
-#include "or.h"
-#include "addressmap.h"
-#include "bridges.h"
-#include "channel.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "control.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "hs_common.h"
-#include "hs_client.h"
-#include "hs_circuit.h"
-#include "hs_ident.h"
-#include "hs_stats.h"
-#include "nodelist.h"
-#include "networkstatus.h"
-#include "policies.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-
-#include "cpath_build_state_st.h"
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "or/bridges.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/control.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/hs_common.h"
+#include "or/hs_client.h"
+#include "or/hs_circuit.h"
+#include "or/hs_ident.h"
+#include "or/hs_stats.h"
+#include "or/nodelist.h"
+#include "or/networkstatus.h"
+#include "or/policies.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/socks_request_st.h"
 
 static void circuit_expire_old_circuits_clientside(void);
 static void circuit_increment_failure_count(void);
diff --git a/src/or/command.c b/src/or/command.c
index 0c92927ec..dd8e7d6f3 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -36,30 +36,30 @@
  *   callbacks registered in command_setup_channel(),
  *   called when channels are created in circuitbuild.c
  */
-#include "or.h"
-#include "channel.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "command.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "config.h"
-#include "control.h"
-#include "cpuworker.h"
-#include "crypto_util.h"
-#include "dos.h"
-#include "hibernate.h"
-#include "nodelist.h"
-#include "onion.h"
-#include "rephist.h"
-#include "relay.h"
-#include "router.h"
-#include "routerlist.h"
-
-#include "cell_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "var_cell_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/command.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "or/cpuworker.h"
+#include "common/crypto_util.h"
+#include "or/dos.h"
+#include "or/hibernate.h"
+#include "or/nodelist.h"
+#include "or/onion.h"
+#include "or/rephist.h"
+#include "or/relay.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+
+#include "or/cell_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/var_cell_st.h"
 
 /** How many CELL_CREATE cells have we received, ever? */
 uint64_t stats_n_create_cells_processed = 0;
diff --git a/src/or/command.h b/src/or/command.h
index 5bdfa92fd..864a5b2fd 100644
--- a/src/or/command.h
+++ b/src/or/command.h
@@ -12,7 +12,7 @@
 #ifndef TOR_COMMAND_H
 #define TOR_COMMAND_H
 
-#include "channel.h"
+#include "or/channel.h"
 
 void command_process_cell(channel_t *chan, cell_t *cell);
 void command_process_var_cell(channel_t *chan, var_cell_t *cell);
diff --git a/src/or/config.c b/src/or/config.c
index 401c57f69..8c6e2382f 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -60,64 +60,64 @@
  **/
 
 #define CONFIG_PRIVATE
-#include "or.h"
-#include "bridges.h"
-#include "compat.h"
-#include "addressmap.h"
-#include "channel.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
-#include "circuitstats.h"
-#include "compress.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "consdiffmgr.h"
-#include "control.h"
-#include "confparse.h"
-#include "cpuworker.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "dirserv.h"
-#include "dns.h"
-#include "dos.h"
-#include "entrynodes.h"
-#include "git_revision.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendservice.h"
-#include "hs_config.h"
-#include "rephist.h"
-#include "router.h"
-#include "sandbox.h"
-#include "util.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "scheduler.h"
-#include "statefile.h"
-#include "transports.h"
-#include "ext_orport.h"
-#include "voting_schedule.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "common/compat.h"
+#include "or/addressmap.h"
+#include "or/channel.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
+#include "or/circuitstats.h"
+#include "common/compress.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/consdiffmgr.h"
+#include "or/control.h"
+#include "or/confparse.h"
+#include "or/cpuworker.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/dirserv.h"
+#include "or/dns.h"
+#include "or/dos.h"
+#include "or/entrynodes.h"
+#include "or/git_revision.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendservice.h"
+#include "or/hs_config.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "common/sandbox.h"
+#include "common/util.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/scheduler.h"
+#include "or/statefile.h"
+#include "or/transports.h"
+#include "or/ext_orport.h"
+#include "or/voting_schedule.h"
 #ifdef _WIN32
 #include <shlobj.h>
 #endif
 
-#include "procmon.h"
+#include "common/procmon.h"
 
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
 
-#include "connection_st.h"
-#include "port_cfg_st.h"
+#include "or/connection_st.h"
+#include "or/port_cfg_st.h"
 
 #ifdef HAVE_SYSTEMD
 #   if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
diff --git a/src/or/config.h b/src/or/config.h
index 4e901651d..a94cd7753 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -12,7 +12,7 @@
 #ifndef TOR_CONFIG_H
 #define TOR_CONFIG_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(DARWIN)
 #define KERNEL_MAY_SUPPORT_IPFW
diff --git a/src/or/confparse.c b/src/or/confparse.c
index 78fc581c7..e88c4f72d 100644
--- a/src/or/confparse.c
+++ b/src/or/confparse.c
@@ -22,9 +22,9 @@
  * specified, and a linked list of key-value pairs.
  */
 
-#include "or.h"
-#include "confparse.h"
-#include "routerset.h"
+#include "or/or.h"
+#include "or/confparse.h"
+#include "or/routerset.h"
 
 static uint64_t config_parse_memunit(const char *s, int *ok);
 static int config_parse_msec_interval(const char *s, int *ok);
diff --git a/src/or/connection.c b/src/or/connection.c
index 8915e46cc..267719881 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -55,54 +55,54 @@
  **/
 
 #define CONNECTION_PRIVATE
-#include "or.h"
-#include "bridges.h"
-#include "buffers.h"
-#include "buffers_tls.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "common/buffers.h"
+#include "common/buffers_tls.h"
 /*
  * Define this so we get channel internal functions, since we're implementing
  * part of a subclass (channel_tls_t).
  */
 #define TOR_CHANNEL_INTERNAL_
 #define CONNECTION_PRIVATE
-#include "backtrace.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dns.h"
-#include "dnsserv.h"
-#include "dos.h"
-#include "entrynodes.h"
-#include "ext_orport.h"
-#include "geoip.h"
-#include "main.h"
-#include "hibernate.h"
-#include "hs_common.h"
-#include "hs_ident.h"
-#include "nodelist.h"
-#include "proto_http.h"
-#include "proto_socks.h"
-#include "policies.h"
-#include "reasons.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "transports.h"
-#include "routerparse.h"
-#include "sandbox.h"
+#include "common/backtrace.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dns.h"
+#include "or/dnsserv.h"
+#include "or/dos.h"
+#include "or/entrynodes.h"
+#include "or/ext_orport.h"
+#include "or/geoip.h"
+#include "or/main.h"
+#include "or/hibernate.h"
+#include "or/hs_common.h"
+#include "or/hs_ident.h"
+#include "or/nodelist.h"
+#include "or/proto_http.h"
+#include "or/proto_socks.h"
+#include "or/policies.h"
+#include "or/reasons.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/transports.h"
+#include "or/routerparse.h"
+#include "common/sandbox.h"
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
@@ -113,14 +113,14 @@
 #include <sys/un.h>
 #endif
 
-#include "dir_connection_st.h"
-#include "control_connection_st.h"
-#include "entry_connection_st.h"
-#include "listener_connection_st.h"
-#include "or_connection_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
-#include "socks_request_st.h"
+#include "or/dir_connection_st.h"
+#include "or/control_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/listener_connection_st.h"
+#include "or/or_connection_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
+#include "or/socks_request_st.h"
 
 static connection_t *connection_listener_new(
                                const struct sockaddr *listensockaddr,
diff --git a/src/or/connection.h b/src/or/connection.h
index 7cfd4c51c..7fcf71021 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -15,7 +15,7 @@
 listener_connection_t *TO_LISTENER_CONN(connection_t *);
 
 /* XXXX For buf_datalen in inline function */
-#include "buffers.h"
+#include "common/buffers.h"
 
 const char *conn_type_to_string(int type);
 const char *conn_state_to_string(int type, int state);
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index b351a2442..125709786 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -55,57 +55,57 @@
  **/
 #define CONNECTION_EDGE_PRIVATE
 
-#include "or.h"
-
-#include "backtrace.h"
-
-#include "addressmap.h"
-#include "buffers.h"
-#include "channel.h"
-#include "circpathbias.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_util.h"
-#include "dns.h"
-#include "dnsserv.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "hibernate.h"
-#include "hs_common.h"
-#include "hs_cache.h"
-#include "hs_client.h"
-#include "hs_circuit.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "proto_http.h"
-#include "proto_socks.h"
-#include "reasons.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "circuitbuild.h"
-
-#include "cell_st.h"
-#include "cpath_build_state_st.h"
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "node_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+
+#include "common/backtrace.h"
+
+#include "or/addressmap.h"
+#include "common/buffers.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_util.h"
+#include "or/dns.h"
+#include "or/dnsserv.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/hibernate.h"
+#include "or/hs_common.h"
+#include "or/hs_cache.h"
+#include "or/hs_client.h"
+#include "or/hs_circuit.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/proto_http.h"
+#include "or/proto_socks.h"
+#include "or/reasons.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/circuitbuild.h"
+
+#include "or/cell_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/node_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/socks_request_st.h"
 
 #ifdef HAVE_LINUX_TYPES_H
 #include <linux/types.h>
diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h
index d8607af5a..9d480aec2 100644
--- a/src/or/connection_edge.h
+++ b/src/or/connection_edge.h
@@ -12,7 +12,7 @@
 #ifndef TOR_CONNECTION_EDGE_H
 #define TOR_CONNECTION_EDGE_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 edge_connection_t *TO_EDGE_CONN(connection_t *);
 entry_connection_t *TO_ENTRY_CONN(connection_t *);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 772a77423..aff5f105a 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -20,54 +20,54 @@
  *
  * This module also implements the client side of the v3 Tor link handshake,
  **/
-#include "or.h"
-#include "bridges.h"
-#include "buffers.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "common/buffers.h"
 /*
  * Define this so we get channel internal functions, since we're implementing
  * part of a subclass (channel_tls_t).
  */
 #define TOR_CHANNEL_INTERNAL_
 #define CONNECTION_OR_PRIVATE
-#include "channel.h"
-#include "channeltls.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "command.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "geoip.h"
-#include "main.h"
-#include "link_handshake.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "proto_cell.h"
-#include "reasons.h"
-#include "relay.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "ext_orport.h"
-#include "scheduler.h"
-#include "torcert.h"
-#include "channelpadding.h"
-
-#include "cell_st.h"
-#include "cell_queue_st.h"
-#include "or_connection_st.h"
-#include "or_handshake_certs_st.h"
-#include "or_handshake_state_st.h"
-#include "routerinfo_st.h"
-#include "var_cell_st.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "or/command.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "or/geoip.h"
+#include "or/main.h"
+#include "trunnel/link_handshake.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/proto_cell.h"
+#include "or/reasons.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/ext_orport.h"
+#include "or/scheduler.h"
+#include "or/torcert.h"
+#include "or/channelpadding.h"
+
+#include "or/cell_st.h"
+#include "or/cell_queue_st.h"
+#include "or/or_connection_st.h"
+#include "or/or_handshake_certs_st.h"
+#include "or/or_handshake_state_st.h"
+#include "or/routerinfo_st.h"
+#include "or/var_cell_st.h"
 
 static int connection_tls_finish_handshake(or_connection_t *conn);
 static int connection_or_launch_v3_or_handshake(or_connection_t *conn);
diff --git a/src/or/conscache.c b/src/or/conscache.c
index 48ff49120..5bfd78a78 100644
--- a/src/or/conscache.c
+++ b/src/or/conscache.c
@@ -1,12 +1,12 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 
-#include "config.h"
-#include "conscache.h"
-#include "crypto_util.h"
-#include "storagedir.h"
+#include "or/config.h"
+#include "or/conscache.h"
+#include "common/crypto_util.h"
+#include "common/storagedir.h"
 
 #define CCE_MAGIC 0x17162253
 
diff --git a/src/or/conscache.h b/src/or/conscache.h
index 738516d1c..20af6402c 100644
--- a/src/or/conscache.h
+++ b/src/or/conscache.h
@@ -4,7 +4,7 @@
 #ifndef TOR_CONSCACHE_H
 #define TOR_CONSCACHE_H
 
-#include "handles.h"
+#include "common/handles.h"
 
 typedef struct consensus_cache_entry_t consensus_cache_entry_t;
 typedef struct consensus_cache_t consensus_cache_t;
diff --git a/src/or/consdiff.c b/src/or/consdiff.c
index 1001d30fb..59e27c0ae 100644
--- a/src/or/consdiff.c
+++ b/src/or/consdiff.c
@@ -38,10 +38,10 @@
 
 #define CONSDIFF_PRIVATE
 
-#include "or.h"
-#include "consdiff.h"
-#include "memarea.h"
-#include "routerparse.h"
+#include "or/or.h"
+#include "or/consdiff.h"
+#include "common/memarea.h"
+#include "or/routerparse.h"
 
 static const char* ns_diff_version = "network-status-diff-version 1";
 static const char* hash_token = "hash";
diff --git a/src/or/consdiff.h b/src/or/consdiff.h
index 23c006860..3f73b8536 100644
--- a/src/or/consdiff.h
+++ b/src/or/consdiff.h
@@ -5,7 +5,7 @@
 #ifndef TOR_CONSDIFF_H
 #define TOR_CONSDIFF_H
 
-#include "or.h"
+#include "or/or.h"
 
 char *consensus_diff_generate(const char *cons1,
                               const char *cons2);
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c
index abb8f5583..7732cd109 100644
--- a/src/or/consdiffmgr.c
+++ b/src/or/consdiffmgr.c
@@ -13,18 +13,18 @@
 
 #define CONSDIFFMGR_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "conscache.h"
-#include "consdiff.h"
-#include "consdiffmgr.h"
-#include "cpuworker.h"
-#include "networkstatus.h"
-#include "routerparse.h"
-#include "workqueue.h"
-
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/conscache.h"
+#include "or/consdiff.h"
+#include "or/consdiffmgr.h"
+#include "or/cpuworker.h"
+#include "or/networkstatus.h"
+#include "or/routerparse.h"
+#include "common/workqueue.h"
+
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
 
 /**
  * Labels to apply to items in the conscache object.
diff --git a/src/or/control.c b/src/or/control.c
index 181667b3b..8d6da9c09 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -35,77 +35,77 @@
 
 #define CONTROL_PRIVATE
 
-#include "or.h"
-#include "addressmap.h"
-#include "bridges.h"
-#include "buffers.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "circuituse.h"
-#include "command.h"
-#include "compat_libevent.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dnsserv.h"
-#include "entrynodes.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "hs_cache.h"
-#include "hs_common.h"
-#include "hs_control.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "proto_control0.h"
-#include "proto_http.h"
-#include "reasons.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "shared_random_client.h"
-
-#include "cached_dir_st.h"
-#include "control_connection_st.h"
-#include "cpath_build_state_st.h"
-#include "entry_connection_st.h"
-#include "extrainfo_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "or_connection_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "microdesc_st.h"
-#include "rend_authorized_client_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "or/bridges.h"
+#include "common/buffers.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "or/circuituse.h"
+#include "or/command.h"
+#include "common/compat_libevent.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dnsserv.h"
+#include "or/entrynodes.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/hs_cache.h"
+#include "or/hs_common.h"
+#include "or/hs_control.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/proto_control0.h"
+#include "or/proto_http.h"
+#include "or/reasons.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/shared_random_client.h"
+
+#include "or/cached_dir_st.h"
+#include "or/control_connection_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extrainfo_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/or_connection_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/microdesc_st.h"
+#include "or/rend_authorized_client_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/socks_request_st.h"
 
 #ifndef _WIN32
 #include <pwd.h>
 #include <sys/resource.h>
 #endif
 
-#include "crypto_s2k.h"
-#include "procmon.h"
+#include "common/crypto_s2k.h"
+#include "common/procmon.h"
 
 /** Yield true iff <b>s</b> is the state of a control_connection_t that has
  * finished authentication and is accepting commands. */
diff --git a/src/or/control_connection_st.h b/src/or/control_connection_st.h
index bd2b84857..4f8ab25d9 100644
--- a/src/or/control_connection_st.h
+++ b/src/or/control_connection_st.h
@@ -7,8 +7,8 @@
 #ifndef CONTROL_CONNECTION_ST_H
 #define CONTROL_CONNECTION_ST_H
 
-#include "or.h"
-#include "connection_st.h"
+#include "or/or.h"
+#include "or/connection_st.h"
 
 /** Subtype of connection_t for an connection to a controller. */
 struct control_connection_t {
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index 6f3f8c2f1..18b8adab8 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -17,22 +17,22 @@
  *      <li>and for calculating diffs and compressing them in consdiffmgr.c.
  *  </ul>
  **/
-#include "or.h"
-#include "channel.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "connection_or.h"
-#include "config.h"
-#include "cpuworker.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "main.h"
-#include "onion.h"
-#include "rephist.h"
-#include "router.h"
-#include "workqueue.h"
-
-#include "or_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/connection_or.h"
+#include "or/config.h"
+#include "or/cpuworker.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/main.h"
+#include "or/onion.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "common/workqueue.h"
+
+#include "or/or_circuit_st.h"
 
 static void queue_pending_tasks(void);
 
diff --git a/src/or/crypt_path_st.h b/src/or/crypt_path_st.h
index ebad87217..88b4085ac 100644
--- a/src/or/crypt_path_st.h
+++ b/src/or/crypt_path_st.h
@@ -7,7 +7,7 @@
 #ifndef CRYPT_PATH_ST_H
 #define CRYPT_PATH_ST_H
 
-#include "relay_crypto_st.h"
+#include "or/relay_crypto_st.h"
 
 /** Holds accounting information for a single step in the layered encryption
  * performed by a circuit.  Used only at the client edge of a circuit. */
diff --git a/src/or/dir_connection_st.h b/src/or/dir_connection_st.h
index 5b79dfcb6..f68266ca2 100644
--- a/src/or/dir_connection_st.h
+++ b/src/or/dir_connection_st.h
@@ -7,7 +7,7 @@
 #ifndef DIR_CONNECTION_ST_H
 #define DIR_CONNECTION_ST_H
 
-#include "connection_st.h"
+#include "or/connection_st.h"
 
 /** Subtype of connection_t for an "directory connection" -- that is, an HTTP
  * connection to retrieve or serve directory material. */
diff --git a/src/or/dir_server_st.h b/src/or/dir_server_st.h
index 0c2e905fb..8fdb04a7d 100644
--- a/src/or/dir_server_st.h
+++ b/src/or/dir_server_st.h
@@ -7,9 +7,9 @@
 #ifndef DIR_SERVER_ST_H
 #define DIR_SERVER_ST_H
 
-#include "torint.h"
-#include "or.h"
-#include "routerstatus_st.h"
+#include "common/torint.h"
+#include "or/or.h"
+#include "or/routerstatus_st.h"
 
 /** Represents information about a single trusted or fallback directory
  * server. */
diff --git a/src/or/dirauth/dircollate.c b/src/or/dirauth/dircollate.c
index 52d2f838e..246977dcc 100644
--- a/src/or/dirauth/dircollate.c
+++ b/src/or/dirauth/dircollate.c
@@ -22,11 +22,11 @@
  */
 
 #define DIRCOLLATE_PRIVATE
-#include "dircollate.h"
-#include "dirvote.h"
+#include "or/dirauth/dircollate.h"
+#include "or/dirauth/dirvote.h"
 
-#include "networkstatus_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/networkstatus_st.h"
+#include "or/vote_routerstatus_st.h"
 
 static void dircollator_collate_by_ed25519(dircollator_t *dc);
 
diff --git a/src/or/dirauth/dircollate.h b/src/or/dirauth/dircollate.h
index 7dc949760..1d403b20f 100644
--- a/src/or/dirauth/dircollate.h
+++ b/src/or/dirauth/dircollate.h
@@ -12,8 +12,8 @@
 #ifndef TOR_DIRCOLLATE_H
 #define TOR_DIRCOLLATE_H
 
-#include "testsupport.h"
-#include "or.h"
+#include "common/testsupport.h"
+#include "or/or.h"
 
 typedef struct dircollator_s dircollator_t;
 
diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index bd62109e0..a9429a911 100644
--- a/src/or/dirauth/dirvote.c
+++ b/src/or/dirauth/dirvote.c
@@ -4,44 +4,44 @@
 /* See LICENSE for licensing information */
 
 #define DIRVOTE_PRIVATE
-#include "or.h"
-#include "config.h"
-#include "dircollate.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "parsecommon.h"
-#include "policies.h"
-#include "protover.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "entrynodes.h" /* needed for guardfraction methods */
-#include "torcert.h"
-#include "voting_schedule.h"
-
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-#include "dirauth/shared_random_state.h"
-
-#include "authority_cert_st.h"
-#include "cached_dir_st.h"
-#include "dir_server_st.h"
-#include "document_signature_st.h"
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "node_st.h"
-#include "ns_detached_signatures_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
-#include "vote_timing_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/dirauth/dircollate.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/parsecommon.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/entrynodes.h" /* needed for guardfraction methods */
+#include "or/torcert.h"
+#include "or/voting_schedule.h"
+
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+#include "or/dirauth/shared_random_state.h"
+
+#include "or/authority_cert_st.h"
+#include "or/cached_dir_st.h"
+#include "or/dir_server_st.h"
+#include "or/document_signature_st.h"
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/node_st.h"
+#include "or/ns_detached_signatures_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
+#include "or/vote_timing_st.h"
 
 /**
  * \file dirvote.c
diff --git a/src/or/dirauth/mode.h b/src/or/dirauth/mode.h
index 462d81d1b..17c35aff6 100644
--- a/src/or/dirauth/mode.h
+++ b/src/or/dirauth/mode.h
@@ -11,7 +11,7 @@
 
 #ifdef HAVE_MODULE_DIRAUTH
 
-#include "router.h"
+#include "or/router.h"
 
 /* Return true iff we believe ourselves to be a v3 authoritative directory
  * server. */
diff --git a/src/or/dirauth/shared_random.c b/src/or/dirauth/shared_random.c
index a577b2fb2..0860efaca 100644
--- a/src/or/dirauth/shared_random.c
+++ b/src/or/dirauth/shared_random.c
@@ -87,26 +87,26 @@
 
 #define SHARED_RANDOM_PRIVATE
 
-#include "or.h"
-#include "shared_random.h"
-#include "config.h"
-#include "confparse.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "networkstatus.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "shared_random_client.h"
-#include "shared_random_state.h"
-#include "util.h"
-#include "voting_schedule.h"
-
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-
-#include "authority_cert_st.h"
-#include "networkstatus_st.h"
+#include "or/or.h"
+#include "or/dirauth/shared_random.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/networkstatus.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/shared_random_client.h"
+#include "or/dirauth/shared_random_state.h"
+#include "common/util.h"
+#include "or/voting_schedule.h"
+
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+
+#include "or/authority_cert_st.h"
+#include "or/networkstatus_st.h"
 
 /* String prefix of shared random values in votes/consensuses. */
 static const char previous_srv_str[] = "shared-rand-previous-value";
diff --git a/src/or/dirauth/shared_random.h b/src/or/dirauth/shared_random.h
index e2597f354..93bab99f7 100644
--- a/src/or/dirauth/shared_random.h
+++ b/src/or/dirauth/shared_random.h
@@ -10,7 +10,7 @@
  * with "sr_" which stands for shared random.
  */
 
-#include "or.h"
+#include "or/or.h"
 
 /* Protocol version */
 #define SR_PROTO_VERSION  1
diff --git a/src/or/dirauth/shared_random_state.c b/src/or/dirauth/shared_random_state.c
index a7047536c..9bea02e82 100644
--- a/src/or/dirauth/shared_random_state.c
+++ b/src/or/dirauth/shared_random_state.c
@@ -10,17 +10,17 @@
 
 #define SHARED_RANDOM_STATE_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "confparse.h"
-#include "crypto_util.h"
-#include "dirauth/dirvote.h"
-#include "networkstatus.h"
-#include "router.h"
-#include "shared_random.h"
-#include "shared_random_client.h"
-#include "shared_random_state.h"
-#include "voting_schedule.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "common/crypto_util.h"
+#include "or/dirauth/dirvote.h"
+#include "or/networkstatus.h"
+#include "or/router.h"
+#include "or/dirauth/shared_random.h"
+#include "or/shared_random_client.h"
+#include "or/dirauth/shared_random_state.h"
+#include "or/voting_schedule.h"
 
 /* Default filename of the shared random state on disk. */
 static const char default_fname[] = "sr-state";
diff --git a/src/or/dirauth/shared_random_state.h b/src/or/dirauth/shared_random_state.h
index b0e7cc4c2..a8ac0134c 100644
--- a/src/or/dirauth/shared_random_state.h
+++ b/src/or/dirauth/shared_random_state.h
@@ -4,7 +4,7 @@
 #ifndef TOR_SHARED_RANDOM_STATE_H
 #define TOR_SHARED_RANDOM_STATE_H
 
-#include "shared_random.h"
+#include "or/dirauth/shared_random.h"
 
 /* Action that can be performed on the state for any objects. */
 typedef enum {
diff --git a/src/or/directory.c b/src/or/directory.c
index e7616881e..e008ac7f7 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -5,44 +5,44 @@
 
 #define DIRECTORY_PRIVATE
 
-#include "or.h"
-#include "backtrace.h"
-#include "bridges.h"
-#include "buffers.h"
-#include "circuitbuild.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "conscache.h"
-#include "consdiff.h"
-#include "consdiffmgr.h"
-#include "control.h"
-#include "compat.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "fp_pair.h"
-#include "geoip.h"
-#include "hs_cache.h"
-#include "hs_common.h"
-#include "hs_control.h"
-#include "hs_client.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "or/bridges.h"
+#include "common/buffers.h"
+#include "or/circuitbuild.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/conscache.h"
+#include "or/consdiff.h"
+#include "or/consdiffmgr.h"
+#include "or/control.h"
+#include "common/compat.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "or/fp_pair.h"
+#include "or/geoip.h"
+#include "or/hs_cache.h"
+#include "or/hs_common.h"
+#include "or/hs_control.h"
+#include "or/hs_client.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
 
 #if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
 #if !defined(OpenBSD)
@@ -50,19 +50,19 @@
 #endif
 #endif
 
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-#include "dirauth/shared_random.h"
-
-#include "authority_cert_st.h"
-#include "cached_dir_st.h"
-#include "dir_connection_st.h"
-#include "dir_server_st.h"
-#include "entry_connection_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerinfo_st.h"
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+#include "or/dirauth/shared_random.h"
+
+#include "or/authority_cert_st.h"
+#include "or/cached_dir_st.h"
+#include "or/dir_connection_st.h"
+#include "or/dir_server_st.h"
+#include "or/entry_connection_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerinfo_st.h"
 
 /**
  * \file directory.c
diff --git a/src/or/directory.h b/src/or/directory.h
index 9008df0f5..5cf8892ac 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -12,7 +12,7 @@
 #ifndef TOR_DIRECTORY_H
 #define TOR_DIRECTORY_H
 
-#include "hs_ident.h"
+#include "or/hs_ident.h"
 
 dir_connection_t *TO_DIR_CONN(connection_t *c);
 int directories_have_accepted_server_descriptor(void);
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index eaea50262..077135841 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -4,47 +4,47 @@
 /* See LICENSE for licensing information */
 
 #define DIRSERV_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "config.h"
-#include "confparse.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "command.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "conscache.h"
-#include "consdiffmgr.h"
-#include "control.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "hibernate.h"
-#include "keypin.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "protover.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "torcert.h"
-#include "voting_schedule.h"
-
-#include "dirauth/dirvote.h"
-
-#include "cached_dir_st.h"
-#include "dir_connection_st.h"
-#include "extrainfo_st.h"
-#include "microdesc_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "tor_version_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/command.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/conscache.h"
+#include "or/consdiffmgr.h"
+#include "or/control.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/hibernate.h"
+#include "or/keypin.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/torcert.h"
+#include "or/voting_schedule.h"
+
+#include "or/dirauth/dirvote.h"
+
+#include "or/cached_dir_st.h"
+#include "or/dir_connection_st.h"
+#include "or/extrainfo_st.h"
+#include "or/microdesc_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/tor_version_st.h"
+#include "or/vote_routerstatus_st.h"
 
 /**
  * \file dirserv.c
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 61f4af4b5..a8d5ac616 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -12,7 +12,7 @@
 #ifndef TOR_DIRSERV_H
 #define TOR_DIRSERV_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 /** What fraction (1 over this number) of the relay ID space do we
  * (as a directory authority) launch connections to at each reachability
diff --git a/src/or/dns.c b/src/or/dns.c
index 8536fc8e9..3f5d39b41 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -49,24 +49,24 @@
 
 #define DNS_PRIVATE
 
-#include "or.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "dns.h"
-#include "main.h"
-#include "policies.h"
-#include "relay.h"
-#include "router.h"
+#include "or/or.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/dns.h"
+#include "or/main.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/router.h"
 #include "ht.h"
-#include "sandbox.h"
+#include "common/sandbox.h"
 
-#include "edge_connection_st.h"
-#include "or_circuit_st.h"
+#include "or/edge_connection_st.h"
+#include "or/or_circuit_st.h"
 
 #include <event2/event.h>
 #include <event2/dns.h>
diff --git a/src/or/dns.h b/src/or/dns.h
index d74208363..12853205f 100644
--- a/src/or/dns.h
+++ b/src/or/dns.h
@@ -41,7 +41,7 @@ void dns_reset_correctness_checks(void);
 void dump_dns_mem_usage(int severity);
 
 #ifdef DNS_PRIVATE
-#include "dns_structs.h"
+#include "or/dns_structs.h"
 
 MOCK_DECL(STATIC int,dns_resolve_impl,(edge_connection_t *exitconn,
 int is_resolve,or_circuit_t *oncirc, char **hostname_out,
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 3f2867feb..ce1746fe2 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -21,19 +21,19 @@
  * DNS client.
  **/
 
-#include "or.h"
-#include "dnsserv.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "control.h"
-#include "main.h"
-#include "policies.h"
-
-#include "control_connection_st.h"
-#include "entry_connection_st.h"
-#include "listener_connection_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/dnsserv.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/control.h"
+#include "or/main.h"
+#include "or/policies.h"
+
+#include "or/control_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/listener_connection_st.h"
+#include "or/socks_request_st.h"
 
 #include <event2/dns.h>
 #include <event2/dns_compat.h>
diff --git a/src/or/dos.c b/src/or/dos.c
index f0b441c34..5f4142b0e 100644
--- a/src/or/dos.c
+++ b/src/or/dos.c
@@ -8,21 +8,21 @@
 
 #define DOS_PRIVATE
 
-#include "or.h"
-#include "channel.h"
-#include "config.h"
-#include "connection_or.h"
-#include "crypto_rand.h"
-#include "geoip.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "router.h"
-
-#include "dos.h"
-
-#include "or_connection_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/config.h"
+#include "or/connection_or.h"
+#include "common/crypto_rand.h"
+#include "or/geoip.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/router.h"
+
+#include "or/dos.h"
+
+#include "or/or_connection_st.h"
 
 /*
  * Circuit creation denial of service mitigation.
diff --git a/src/or/edge_connection_st.h b/src/or/edge_connection_st.h
index 6b3814353..d58e1c2b8 100644
--- a/src/or/edge_connection_st.h
+++ b/src/or/edge_connection_st.h
@@ -7,9 +7,9 @@
 #ifndef EDGE_CONNECTION_ST_H
 #define EDGE_CONNECTION_ST_H
 
-#include "or.h"
+#include "or/or.h"
 
-#include "connection_st.h"
+#include "or/connection_st.h"
 
 /** Subtype of connection_t for an "edge connection" -- that is, an entry (ap)
  * connection, or an exit. */
diff --git a/src/or/entry_connection_st.h b/src/or/entry_connection_st.h
index ade427f1f..2f9676088 100644
--- a/src/or/entry_connection_st.h
+++ b/src/or/entry_connection_st.h
@@ -7,7 +7,7 @@
 #ifndef ENTRY_CONNECTION_ST_H
 #define ENTRY_CONNECTION_ST_H
 
-#include "edge_connection_st.h"
+#include "or/edge_connection_st.h"
 
 /** Subtype of edge_connection_t for an "entry connection" -- that is, a SOCKS
  * connection, a DNS request, a TransPort connection or a NATD connection */
diff --git a/src/or/entry_port_cfg_st.h b/src/or/entry_port_cfg_st.h
index 78e0b3eb1..45dd844c4 100644
--- a/src/or/entry_port_cfg_st.h
+++ b/src/or/entry_port_cfg_st.h
@@ -7,8 +7,8 @@
 #ifndef ENTRY_PORT_CFG_ST_H
 #define ENTRY_PORT_CFG_ST_H
 
-#include "torint.h"
-#include "or.h"
+#include "common/torint.h"
+#include "or/or.h"
 
 struct entry_port_cfg_t {
   /* Client port types (socks, dns, trans, natd) only: */
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 604b79140..6d13efda9 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -112,35 +112,35 @@
 
 #define ENTRYNODES_PRIVATE
 
-#include "or.h"
-#include "channel.h"
-#include "bridges.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "transports.h"
-#include "statefile.h"
-
-#include "node_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/bridges.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/transports.h"
+#include "or/statefile.h"
+
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
 
 /** A list of existing guard selection contexts. */
 static smartlist_t *guard_contexts = NULL;
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index f26e905fd..e56d4632b 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -12,7 +12,7 @@
 #ifndef TOR_ENTRYNODES_H
 #define TOR_ENTRYNODES_H
 
-#include "handles.h"
+#include "common/handles.h"
 
 /* Forward declare for guard_selection_t; entrynodes.c has the real struct */
 typedef struct guard_selection_s guard_selection_t;
diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c
index 00c750975..d84f263aa 100644
--- a/src/or/ext_orport.c
+++ b/src/or/ext_orport.c
@@ -17,19 +17,19 @@
  */
 
 #define EXT_ORPORT_PRIVATE
-#include "or.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "control.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "ext_orport.h"
-#include "main.h"
-#include "proto_ext_or.h"
-#include "util.h"
-
-#include "or_connection_st.h"
+#include "or/or.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/ext_orport.h"
+#include "or/main.h"
+#include "or/proto_ext_or.h"
+#include "common/util.h"
+
+#include "or/or_connection_st.h"
 
 /** Allocate and return a structure capable of holding an Extended
  *  ORPort message of body length <b>len</b>. */
diff --git a/src/or/extrainfo_st.h b/src/or/extrainfo_st.h
index 041a932da..f91bba7b6 100644
--- a/src/or/extrainfo_st.h
+++ b/src/or/extrainfo_st.h
@@ -7,7 +7,7 @@
 #ifndef EXTRAINFO_ST_H
 #define EXTRAINFO_ST_H
 
-#include "signed_descriptor_st.h"
+#include "or/signed_descriptor_st.h"
 
 /** Information needed to keep and cache a signed extra-info document. */
 struct extrainfo_t {
diff --git a/src/or/fp_pair.c b/src/or/fp_pair.c
index e437562fc..1d7b751c2 100644
--- a/src/or/fp_pair.c
+++ b/src/or/fp_pair.c
@@ -17,8 +17,8 @@
  * certificate for any (ID key, signing key) pair.
  **/
 
-#include "or.h"
-#include "fp_pair.h"
+#include "or/or.h"
+#include "or/fp_pair.h"
 
 /* Define fp_pair_map_t structures */
 
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 533468a2d..634ee707b 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -28,15 +28,15 @@
  */
 
 #define GEOIP_PRIVATE
-#include "or.h"
+#include "or/or.h"
 #include "ht.h"
-#include "buffers.h"
-#include "config.h"
-#include "control.h"
-#include "dnsserv.h"
-#include "dos.h"
-#include "geoip.h"
-#include "routerlist.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "or/dnsserv.h"
+#include "or/dos.h"
+#include "or/geoip.h"
+#include "or/routerlist.h"
 
 static void init_geoip_countries(void);
 
diff --git a/src/or/geoip.h b/src/or/geoip.h
index c3b51c663..8a5dd701e 100644
--- a/src/or/geoip.h
+++ b/src/or/geoip.h
@@ -12,8 +12,8 @@
 #ifndef TOR_GEOIP_H
 #define TOR_GEOIP_H
 
-#include "testsupport.h"
-#include "dos.h"
+#include "common/testsupport.h"
+#include "or/dos.h"
 
 #ifdef GEOIP_PRIVATE
 STATIC int geoip_parse_entry(const char *line, sa_family_t family);
diff --git a/src/or/git_revision.c b/src/or/git_revision.c
index cd63ed830..be6f67423 100644
--- a/src/or/git_revision.c
+++ b/src/or/git_revision.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "git_revision.h"
+#include "or/git_revision.h"
 
 /** String describing which Tor Git repository version the source was
  * built from.  This string is generated by a bit of shell kludging in
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 36534516b..595b83957 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -28,21 +28,21 @@ hibernating, phase 2:
 */
 
 #define HIBERNATE_PRIVATE
-#include "or.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "hibernate.h"
-#include "main.h"
-#include "router.h"
-#include "statefile.h"
-
-#include "or_connection_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/router.h"
+#include "or/statefile.h"
+
+#include "or/or_connection_st.h"
 
 /** Are we currently awake, asleep, running out of bandwidth, or shutting
  * down? */
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index b31dfb8fd..cdef33543 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -12,7 +12,7 @@
 #ifndef TOR_HIBERNATE_H
 #define TOR_HIBERNATE_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 int accounting_parse_options(const or_options_t *options, int validate_only);
 MOCK_DECL(int, accounting_is_enabled, (const or_options_t *options));
diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c
index 3170f7196..c16a42a48 100644
--- a/src/or/hs_cache.c
+++ b/src/or/hs_cache.c
@@ -9,19 +9,19 @@
 /* For unit tests.*/
 #define HS_CACHE_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "hs_ident.h"
-#include "hs_common.h"
-#include "hs_client.h"
-#include "hs_descriptor.h"
-#include "networkstatus.h"
-#include "rendcache.h"
-
-#include "hs_cache.h"
-
-#include "networkstatus_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/hs_ident.h"
+#include "or/hs_common.h"
+#include "or/hs_client.h"
+#include "or/hs_descriptor.h"
+#include "or/networkstatus.h"
+#include "or/rendcache.h"
+
+#include "or/hs_cache.h"
+
+#include "or/networkstatus_st.h"
 
 static int cached_client_descriptor_has_expired(time_t now,
            const hs_cache_client_descriptor_t *cached_desc);
diff --git a/src/or/hs_cache.h b/src/or/hs_cache.h
index 03cea8412..5ca158781 100644
--- a/src/or/hs_cache.h
+++ b/src/or/hs_cache.h
@@ -11,11 +11,11 @@
 
 #include <stdint.h>
 
-#include "crypto_ed25519.h"
-#include "hs_common.h"
-#include "hs_descriptor.h"
-#include "rendcommon.h"
-#include "torcert.h"
+#include "common/crypto_ed25519.h"
+#include "or/hs_common.h"
+#include "or/hs_descriptor.h"
+#include "or/rendcommon.h"
+#include "or/torcert.h"
 
 /* This is the maximum time an introduction point state object can stay in the
  * client cache in seconds (2 mins or 120 seconds). */
diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c
index f10840789..40ec4ba9e 100644
--- a/src/or/hs_cell.c
+++ b/src/or/hs_cell.c
@@ -6,24 +6,24 @@
  * \brief Hidden service API for cell creation and handling.
  **/
 
-#include "or.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "rendservice.h"
-#include "replaycache.h"
-#include "util.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/rendservice.h"
+#include "or/replaycache.h"
+#include "common/util.h"
 
-#include "hs_cell.h"
-#include "hs_ntor.h"
+#include "or/hs_cell.h"
+#include "or/hs_ntor.h"
 
-#include "origin_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 /* Trunnel. */
-#include "ed25519_cert.h"
-#include "hs/cell_common.h"
-#include "hs/cell_establish_intro.h"
-#include "hs/cell_introduce1.h"
-#include "hs/cell_rendezvous.h"
+#include "trunnel/ed25519_cert.h"
+#include "trunnel/hs/cell_common.h"
+#include "trunnel/hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_introduce1.h"
+#include "trunnel/hs/cell_rendezvous.h"
 
 /* Compute the MAC of an INTRODUCE cell in mac_out. The encoded_cell param is
  * the cell content up to the ENCRYPTED section of length encoded_cell_len.
diff --git a/src/or/hs_cell.h b/src/or/hs_cell.h
index 5c6f64350..4a522810c 100644
--- a/src/or/hs_cell.h
+++ b/src/or/hs_cell.h
@@ -9,8 +9,8 @@
 #ifndef TOR_HS_CELL_H
 #define TOR_HS_CELL_H
 
-#include "or.h"
-#include "hs_service.h"
+#include "or/or.h"
+#include "or/hs_service.h"
 
 /* An INTRODUCE1 cell requires at least this amount of bytes (see section
  * 3.2.2 of the specification). Below this value, the cell must be padded. */
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
index d0c2d7520..36a982044 100644
--- a/src/or/hs_circuit.c
+++ b/src/or/hs_circuit.c
@@ -7,36 +7,36 @@
 
 #define HS_CIRCUIT_PRIVATE
 
-#include "or.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "relay.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-
-#include "hs_cell.h"
-#include "hs_ident.h"
-#include "hs_ntor.h"
-#include "hs_service.h"
-#include "hs_circuit.h"
+#include "or/or.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/relay.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+
+#include "or/hs_cell.h"
+#include "or/hs_ident.h"
+#include "or/hs_ntor.h"
+#include "or/hs_service.h"
+#include "or/hs_circuit.h"
 
 /* Trunnel. */
-#include "ed25519_cert.h"
-#include "hs/cell_common.h"
-#include "hs/cell_establish_intro.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
+#include "trunnel/ed25519_cert.h"
+#include "trunnel/hs/cell_common.h"
+#include "trunnel/hs/cell_establish_intro.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
 
 /* A circuit is about to become an e2e rendezvous circuit. Check
  * <b>circ_purpose</b> and ensure that it's properly set. Return true iff
diff --git a/src/or/hs_circuit.h b/src/or/hs_circuit.h
index 9ea42b316..fbf11d1cc 100644
--- a/src/or/hs_circuit.h
+++ b/src/or/hs_circuit.h
@@ -9,10 +9,10 @@
 #ifndef TOR_HS_CIRCUIT_H
 #define TOR_HS_CIRCUIT_H
 
-#include "or.h"
-#include "crypto_ed25519.h"
+#include "or/or.h"
+#include "common/crypto_ed25519.h"
 
-#include "hs_service.h"
+#include "or/hs_service.h"
 
 /* Cleanup function when the circuit is closed or/and freed. */
 void hs_circ_cleanup(circuit_t *circ);
diff --git a/src/or/hs_circuitmap.c b/src/or/hs_circuitmap.c
index 7f9b7e3cf..21db65249 100644
--- a/src/or/hs_circuitmap.c
+++ b/src/or/hs_circuitmap.c
@@ -13,13 +13,13 @@
 
 #define HS_CIRCUITMAP_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "circuitlist.h"
-#include "hs_circuitmap.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/circuitlist.h"
+#include "or/hs_circuitmap.h"
 
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 /************************** HS circuitmap code *******************************/
 
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 01d7f8cb9..331793c1f 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -8,38 +8,38 @@
 
 #define HS_CLIENT_PRIVATE
 
-#include "or.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "container.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "hs_cache.h"
-#include "hs_cell.h"
-#include "hs_circuit.h"
-#include "hs_client.h"
-#include "hs_control.h"
-#include "hs_descriptor.h"
-#include "hs_ident.h"
-#include "hs_ntor.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "reasons.h"
-#include "rendclient.h"
-#include "router.h"
-#include "routerset.h"
-
-#include "cpath_build_state_st.h"
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "common/container.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/hs_cache.h"
+#include "or/hs_cell.h"
+#include "or/hs_circuit.h"
+#include "or/hs_client.h"
+#include "or/hs_control.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_ident.h"
+#include "or/hs_ntor.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/reasons.h"
+#include "or/rendclient.h"
+#include "or/router.h"
+#include "or/routerset.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/origin_circuit_st.h"
 
 /* Return a human-readable string for the client fetch status code. */
 static const char *
diff --git a/src/or/hs_client.h b/src/or/hs_client.h
index 3854aadeb..f7fca0b00 100644
--- a/src/or/hs_client.h
+++ b/src/or/hs_client.h
@@ -9,9 +9,9 @@
 #ifndef TOR_HS_CLIENT_H
 #define TOR_HS_CLIENT_H
 
-#include "crypto_ed25519.h"
-#include "hs_descriptor.h"
-#include "hs_ident.h"
+#include "common/crypto_ed25519.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_ident.h"
 
 /* Status code of a descriptor fetch request. */
 typedef enum {
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 3586ce1ba..51d74bf5a 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -11,36 +11,36 @@
 
 #define HS_COMMON_PRIVATE
 
-#include "or.h"
-
-#include "config.h"
-#include "circuitbuild.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "hs_cache.h"
-#include "hs_common.h"
-#include "hs_client.h"
-#include "hs_ident.h"
-#include "hs_service.h"
-#include "hs_circuitmap.h"
-#include "policies.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "routerset.h"
-#include "router.h"
-#include "shared_random_client.h"
-#include "dirauth/shared_random_state.h"
-
-#include "edge_connection_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+
+#include "or/config.h"
+#include "or/circuitbuild.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/hs_cache.h"
+#include "or/hs_common.h"
+#include "or/hs_client.h"
+#include "or/hs_ident.h"
+#include "or/hs_service.h"
+#include "or/hs_circuitmap.h"
+#include "or/policies.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/routerset.h"
+#include "or/router.h"
+#include "or/shared_random_client.h"
+#include "or/dirauth/shared_random_state.h"
+
+#include "or/edge_connection_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerstatus_st.h"
 
 /* Trunnel */
-#include "ed25519_cert.h"
+#include "trunnel/ed25519_cert.h"
 
 /* Ed25519 Basepoint value. Taken from section 5 of
  * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03 */
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index 82b1f3908..6d60d7799 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -9,10 +9,10 @@
 #ifndef TOR_HS_COMMON_H
 #define TOR_HS_COMMON_H
 
-#include "or.h"
+#include "or/or.h"
 
 /* Trunnel */
-#include "ed25519_cert.h"
+#include "trunnel/ed25519_cert.h"
 
 /* Protocol version 2. Use this instead of hardcoding "2" in the code base,
  * this adds a clearer semantic to the value when used. */
diff --git a/src/or/hs_config.c b/src/or/hs_config.c
index a8ca54944..c8ce5b43f 100644
--- a/src/or/hs_config.c
+++ b/src/or/hs_config.c
@@ -25,10 +25,10 @@
 
 #define HS_CONFIG_PRIVATE
 
-#include "hs_common.h"
-#include "hs_config.h"
-#include "hs_service.h"
-#include "rendservice.h"
+#include "or/hs_common.h"
+#include "or/hs_config.h"
+#include "or/hs_service.h"
+#include "or/rendservice.h"
 
 /* Using the given list of services, stage them into our global state. Every
  * service version are handled. This function can remove entries in the given
diff --git a/src/or/hs_config.h b/src/or/hs_config.h
index c8800d33e..461d58d38 100644
--- a/src/or/hs_config.h
+++ b/src/or/hs_config.h
@@ -9,7 +9,7 @@
 #ifndef TOR_HS_CONFIG_H
 #define TOR_HS_CONFIG_H
 
-#include "or.h"
+#include "or/or.h"
 
 /* Max value for HiddenServiceMaxStreams */
 #define HS_CONFIG_MAX_STREAMS_PER_RDV_CIRCUIT 65535
diff --git a/src/or/hs_control.c b/src/or/hs_control.c
index 399a1d9bf..fc828d072 100644
--- a/src/or/hs_control.c
+++ b/src/or/hs_control.c
@@ -6,17 +6,17 @@
  * \brief Contains control port event related code.
  **/
 
-#include "or.h"
-#include "control.h"
-#include "crypto_util.h"
-#include "hs_common.h"
-#include "hs_control.h"
-#include "hs_descriptor.h"
-#include "hs_service.h"
-#include "nodelist.h"
-
-#include "node_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/control.h"
+#include "common/crypto_util.h"
+#include "or/hs_common.h"
+#include "or/hs_control.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_service.h"
+#include "or/nodelist.h"
+
+#include "or/node_st.h"
+#include "or/routerstatus_st.h"
 
 /* Send on the control port the "HS_DESC REQUESTED [...]" event.
  *
diff --git a/src/or/hs_control.h b/src/or/hs_control.h
index 936e0c01b..040ce4a79 100644
--- a/src/or/hs_control.h
+++ b/src/or/hs_control.h
@@ -9,7 +9,7 @@
 #ifndef TOR_HS_CONTROL_H
 #define TOR_HS_CONTROL_H
 
-#include "hs_ident.h"
+#include "or/hs_ident.h"
 
 /* Event "HS_DESC REQUESTED [...]" */
 void hs_control_desc_event_requested(const ed25519_public_key_t *onion_pk,
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 9b814e305..feec0e66d 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -55,19 +55,19 @@
 /* For unit tests.*/
 #define HS_DESCRIPTOR_PRIVATE
 
-#include "or.h"
-#include "ed25519_cert.h" /* Trunnel interface. */
-#include "hs_descriptor.h"
-#include "circuitbuild.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "parsecommon.h"
-#include "rendcache.h"
-#include "hs_cache.h"
-#include "hs_config.h"
-#include "torcert.h" /* tor_cert_encode_ed22519() */
-
-#include "extend_info_st.h"
+#include "or/or.h"
+#include "trunnel/ed25519_cert.h" /* Trunnel interface. */
+#include "or/hs_descriptor.h"
+#include "or/circuitbuild.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/parsecommon.h"
+#include "or/rendcache.h"
+#include "or/hs_cache.h"
+#include "or/hs_config.h"
+#include "or/torcert.h" /* tor_cert_encode_ed22519() */
+
+#include "or/extend_info_st.h"
 
 /* Constant string value used for the descriptor format. */
 #define str_hs_desc "hs-descriptor"
diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h
index def50997c..8a2df9527 100644
--- a/src/or/hs_descriptor.h
+++ b/src/or/hs_descriptor.h
@@ -11,13 +11,13 @@
 
 #include <stdint.h>
 
-#include "or.h"
-#include "address.h"
-#include "container.h"
-#include "crypto.h"
-#include "crypto_ed25519.h"
-#include "ed25519_cert.h" /* needed for trunnel */
-#include "torcert.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "common/container.h"
+#include "common/crypto.h"
+#include "common/crypto_ed25519.h"
+#include "trunnel/ed25519_cert.h" /* needed for trunnel */
+#include "or/torcert.h"
 
 /* Trunnel */
 struct link_specifier_t;
diff --git a/src/or/hs_ident.c b/src/or/hs_ident.c
index ff33d8d06..d3d11393f 100644
--- a/src/or/hs_ident.c
+++ b/src/or/hs_ident.c
@@ -7,8 +7,8 @@
  *        subsytem.
  **/
 
-#include "crypto_util.h"
-#include "hs_ident.h"
+#include "common/crypto_util.h"
+#include "or/hs_ident.h"
 
 /* Return a newly allocated circuit identifier. The given public key is copied
  * identity_pk into the identifier. */
diff --git a/src/or/hs_ident.h b/src/or/hs_ident.h
index cd50f7795..476cdc19e 100644
--- a/src/or/hs_ident.h
+++ b/src/or/hs_ident.h
@@ -21,9 +21,9 @@
 #ifndef TOR_HS_IDENT_H
 #define TOR_HS_IDENT_H
 
-#include "crypto_ed25519.h"
+#include "common/crypto_ed25519.h"
 
-#include "hs_common.h"
+#include "or/hs_common.h"
 
 /* Length of the rendezvous cookie that is used to connect circuits at the
  * rendezvous point. */
diff --git a/src/or/hs_intropoint.c b/src/or/hs_intropoint.c
index 430f2ce4b..6c0729b05 100644
--- a/src/or/hs_intropoint.c
+++ b/src/or/hs_intropoint.c
@@ -8,26 +8,26 @@
 
 #define HS_INTROPOINT_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "relay.h"
-#include "rendmid.h"
-#include "rephist.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/relay.h"
+#include "or/rendmid.h"
+#include "or/rephist.h"
 
 /* Trunnel */
-#include "ed25519_cert.h"
-#include "hs/cell_common.h"
-#include "hs/cell_establish_intro.h"
-#include "hs/cell_introduce1.h"
+#include "trunnel/ed25519_cert.h"
+#include "trunnel/hs/cell_common.h"
+#include "trunnel/hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_introduce1.h"
 
-#include "hs_circuitmap.h"
-#include "hs_descriptor.h"
-#include "hs_intropoint.h"
-#include "hs_common.h"
+#include "or/hs_circuitmap.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_intropoint.h"
+#include "or/hs_common.h"
 
-#include "or_circuit_st.h"
+#include "or/or_circuit_st.h"
 
 /** Extract the authentication key from an ESTABLISH_INTRO or INTRODUCE1 using
  * the given <b>cell_type</b> from <b>cell</b> and place it in
diff --git a/src/or/hs_intropoint.h b/src/or/hs_intropoint.h
index 68b9178b0..77e41647b 100644
--- a/src/or/hs_intropoint.h
+++ b/src/or/hs_intropoint.h
@@ -9,8 +9,8 @@
 #ifndef TOR_HS_INTRO_H
 #define TOR_HS_INTRO_H
 
-#include "crypto_curve25519.h"
-#include "torcert.h"
+#include "common/crypto_curve25519.h"
+#include "or/torcert.h"
 
 /* Authentication key type in an ESTABLISH_INTRO cell. */
 typedef enum {
@@ -55,8 +55,8 @@ void hs_intropoint_clear(hs_intropoint_t *ip);
 
 #ifdef HS_INTROPOINT_PRIVATE
 
-#include "hs/cell_establish_intro.h"
-#include "hs/cell_introduce1.h"
+#include "trunnel/hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_introduce1.h"
 
 STATIC int
 verify_establish_intro_cell(const trn_cell_establish_intro_t *out,
diff --git a/src/or/hs_ntor.c b/src/or/hs_ntor.c
index 76ff3c9ac..61e1474aa 100644
--- a/src/or/hs_ntor.c
+++ b/src/or/hs_ntor.c
@@ -24,9 +24,9 @@
  *  rendezvous key expansion to setup end-to-end rend circuit keys.
  */
 
-#include "or.h"
-#include "crypto_util.h"
-#include "hs_ntor.h"
+#include "or/or.h"
+#include "common/crypto_util.h"
+#include "or/hs_ntor.h"
 
 /* String constants used by the ntor HS protocol */
 #define PROTOID "tor-hs-ntor-curve25519-sha3-256-1"
diff --git a/src/or/hs_ntor.h b/src/or/hs_ntor.h
index bfd6745b2..cc4afd536 100644
--- a/src/or/hs_ntor.h
+++ b/src/or/hs_ntor.h
@@ -4,7 +4,7 @@
 #ifndef TOR_HS_NTOR_H
 #define TOR_HS_NTOR_H
 
-#include "or.h"
+#include "or/or.h"
 
 /* Output length of KDF for key expansion */
 #define HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN \
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index af7369e17..722cc7fc5 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -8,49 +8,49 @@
 
 #define HS_SERVICE_PRIVATE
 
-#include "or.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "rendservice.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "shared_random_client.h"
-#include "statefile.h"
-
-#include "hs_circuit.h"
-#include "hs_common.h"
-#include "hs_config.h"
-#include "hs_control.h"
-#include "hs_descriptor.h"
-#include "hs_ident.h"
-#include "hs_intropoint.h"
-#include "hs_service.h"
-#include "hs_stats.h"
-
-#include "dir_connection_st.h"
-#include "edge_connection_st.h"
-#include "extend_info_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/rendservice.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/shared_random_client.h"
+#include "or/statefile.h"
+
+#include "or/hs_circuit.h"
+#include "or/hs_common.h"
+#include "or/hs_config.h"
+#include "or/hs_control.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_ident.h"
+#include "or/hs_intropoint.h"
+#include "or/hs_service.h"
+#include "or/hs_stats.h"
+
+#include "or/dir_connection_st.h"
+#include "or/edge_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerstatus_st.h"
 
 /* Trunnel */
-#include "ed25519_cert.h"
-#include "hs/cell_common.h"
-#include "hs/cell_establish_intro.h"
+#include "trunnel/ed25519_cert.h"
+#include "trunnel/hs/cell_common.h"
+#include "trunnel/hs/cell_establish_intro.h"
 
 /* Helper macro. Iterate over every service in the global map. The var is the
  * name of the service pointer. */
diff --git a/src/or/hs_service.h b/src/or/hs_service.h
index 8bc2201d0..32db63bd2 100644
--- a/src/or/hs_service.h
+++ b/src/or/hs_service.h
@@ -9,17 +9,17 @@
 #ifndef TOR_HS_SERVICE_H
 #define TOR_HS_SERVICE_H
 
-#include "crypto_curve25519.h"
-#include "crypto_ed25519.h"
-#include "replaycache.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_ed25519.h"
+#include "or/replaycache.h"
 
-#include "hs_common.h"
-#include "hs_descriptor.h"
-#include "hs_ident.h"
-#include "hs_intropoint.h"
+#include "or/hs_common.h"
+#include "or/hs_descriptor.h"
+#include "or/hs_ident.h"
+#include "or/hs_intropoint.h"
 
 /* Trunnel */
-#include "hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_establish_intro.h"
 
 /* When loading and configuring a service, this is the default version it will
  * be configured for as it is possible that no HiddenServiceVersion is
diff --git a/src/or/hs_stats.c b/src/or/hs_stats.c
index 1e2a96945..c8a99b19d 100644
--- a/src/or/hs_stats.c
+++ b/src/or/hs_stats.c
@@ -6,9 +6,9 @@
  * \brief Keeps stats about the activity of our onion service(s).
  **/
 
-#include "or.h"
-#include "hs_stats.h"
-#include "hs_service.h"
+#include "or/or.h"
+#include "or/hs_stats.h"
+#include "or/hs_service.h"
 
 /** Number of v3 INTRODUCE2 cells received */
 static uint32_t n_introduce2_v3 = 0;
diff --git a/src/or/keypin.c b/src/or/keypin.c
index fa6b412d5..402646028 100644
--- a/src/or/keypin.c
+++ b/src/or/keypin.c
@@ -11,17 +11,17 @@
 #define KEYPIN_PRIVATE
 
 #include "orconfig.h"
-#include "compat.h"
-#include "crypto_digest.h"
-#include "crypto_format.h"
-#include "di_ops.h"
+#include "common/compat.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_format.h"
+#include "common/di_ops.h"
 #include "ht.h"
-#include "keypin.h"
+#include "or/keypin.h"
 #include "siphash.h"
-#include "torint.h"
-#include "torlog.h"
-#include "util.h"
-#include "util_format.h"
+#include "common/torint.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/util_format.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
diff --git a/src/or/keypin.h b/src/or/keypin.h
index 98434d26d..b8b9ff597 100644
--- a/src/or/keypin.h
+++ b/src/or/keypin.h
@@ -4,7 +4,7 @@
 #ifndef TOR_KEYPIN_H
 #define TOR_KEYPIN_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 int keypin_check_and_add(const uint8_t *rsa_id_digest,
                          const uint8_t *ed25519_id_key,
diff --git a/src/or/listener_connection_st.h b/src/or/listener_connection_st.h
index 513878392..7b5aafcb5 100644
--- a/src/or/listener_connection_st.h
+++ b/src/or/listener_connection_st.h
@@ -7,7 +7,7 @@
 #ifndef LISTENER_CONNECTION_ST_H
 #define LISTENER_CONNECTION_ST_H
 
-#include "connection_st.h"
+#include "or/connection_st.h"
 
 /** Subtype of connection_t; used for a listener socket. */
 struct listener_connection_t {
diff --git a/src/or/main.c b/src/or/main.c
index b87644f96..a1d7a5e9a 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -47,88 +47,88 @@
  **/
 
 #define MAIN_PRIVATE
-#include "or.h"
-#include "addressmap.h"
-#include "backtrace.h"
-#include "bridges.h"
-#include "buffers.h"
-#include "buffers_tls.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "channelpadding.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "circuitmux_ewma.h"
-#include "command.h"
-#include "compress.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "consdiffmgr.h"
-#include "control.h"
-#include "cpuworker.h"
-#include "crypto_s2k.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dns.h"
-#include "dnsserv.h"
-#include "dos.h"
-#include "entrynodes.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "hs_cache.h"
-#include "hs_circuitmap.h"
-#include "hs_client.h"
-#include "keypin.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "ntmain.h"
-#include "onion.h"
-#include "periodic.h"
-#include "policies.h"
-#include "protover.h"
-#include "transports.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "scheduler.h"
-#include "statefile.h"
-#include "status.h"
-#include "tor_api.h"
-#include "tor_api_internal.h"
-#include "util_process.h"
-#include "ext_orport.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "common/backtrace.h"
+#include "or/bridges.h"
+#include "common/buffers.h"
+#include "common/buffers_tls.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/channelpadding.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/circuitmux_ewma.h"
+#include "or/command.h"
+#include "common/compress.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/consdiffmgr.h"
+#include "or/control.h"
+#include "or/cpuworker.h"
+#include "common/crypto_s2k.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dns.h"
+#include "or/dnsserv.h"
+#include "or/dos.h"
+#include "or/entrynodes.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/hs_cache.h"
+#include "or/hs_circuitmap.h"
+#include "or/hs_client.h"
+#include "or/keypin.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/ntmain.h"
+#include "or/onion.h"
+#include "or/periodic.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/transports.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/scheduler.h"
+#include "or/statefile.h"
+#include "or/status.h"
+#include "or/tor_api.h"
+#include "or/tor_api_internal.h"
+#include "common/util_process.h"
+#include "or/ext_orport.h"
 #ifdef USE_DMALLOC
 #include <dmalloc.h>
 #endif
-#include "memarea.h"
-#include "sandbox.h"
+#include "common/memarea.h"
+#include "common/sandbox.h"
 
 #include <event2/event.h>
 
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-#include "dirauth/shared_random.h"
-
-#include "cell_st.h"
-#include "entry_connection_st.h"
-#include "networkstatus_st.h"
-#include "or_connection_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
-#include "socks_request_st.h"
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+#include "or/dirauth/shared_random.h"
+
+#include "or/cell_st.h"
+#include "or/entry_connection_st.h"
+#include "or/networkstatus_st.h"
+#include "or/or_connection_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
+#include "or/socks_request_st.h"
 
 #ifdef HAVE_SYSTEMD
 #   if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
diff --git a/src/or/main.h b/src/or/main.h
index 4739d1684..214a9b3b0 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -112,7 +112,7 @@ STATIC int get_my_roles(const or_options_t *options);
 extern smartlist_t *connection_array;
 
 /* We need the periodic_event_item_t definition. */
-#include "periodic.h"
+#include "or/periodic.h"
 extern periodic_event_item_t periodic_events[];
 #endif
 #endif /* defined(MAIN_PRIVATE) */
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 31e2a2bd1..d29d2c300 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -8,24 +8,24 @@
  *  less-frequently-changing router information.
  */
 
-#include "or.h"
-#include "circuitbuild.h"
-#include "config.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
+#include "or/config.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/routerstatus_st.h"
 
 /** A data structure to hold a bunch of cached microdescriptors.  There are
  * two active files in the cache: a "cache file" that we mmap, and a "journal
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 5a2dbdcbc..649d146d4 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -37,55 +37,55 @@
  */
 
 #define NETWORKSTATUS_PRIVATE
-#include "or.h"
-#include "bridges.h"
-#include "channel.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "consdiffmgr.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dos.h"
-#include "entrynodes.h"
-#include "hibernate.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "protover.h"
-#include "relay.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "scheduler.h"
-#include "transports.h"
-#include "torcert.h"
-#include "channelpadding.h"
-#include "voting_schedule.h"
-
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-#include "dirauth/shared_random.h"
-
-#include "authority_cert_st.h"
-#include "dir_connection_st.h"
-#include "dir_server_st.h"
-#include "document_signature_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "ns_detached_signatures_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/channel.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/consdiffmgr.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dos.h"
+#include "or/entrynodes.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/protover.h"
+#include "or/relay.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/scheduler.h"
+#include "or/transports.h"
+#include "or/torcert.h"
+#include "or/channelpadding.h"
+#include "or/voting_schedule.h"
+
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+#include "or/dirauth/shared_random.h"
+
+#include "or/authority_cert_st.h"
+#include "or/dir_connection_st.h"
+#include "or/dir_server_st.h"
+#include "or/document_signature_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/ns_detached_signatures_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
 
 /** Most recently received and validated v3 "ns"-flavored consensus network
  * status. */
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index 42cfa5b9b..97b90dab6 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -12,7 +12,7 @@
 #ifndef TOR_NETWORKSTATUS_H
 #define TOR_NETWORKSTATUS_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 void networkstatus_reset_warnings(void);
 void networkstatus_reset_download_failures(void);
diff --git a/src/or/networkstatus_st.h b/src/or/networkstatus_st.h
index 0a564ae0e..4fc04a5aa 100644
--- a/src/or/networkstatus_st.h
+++ b/src/or/networkstatus_st.h
@@ -7,7 +7,7 @@
 #ifndef NETWORKSTATUS_ST_H
 #define NETWORKSTATUS_ST_H
 
-#include "networkstatus_sr_info_st.h"
+#include "or/networkstatus_sr_info_st.h"
 
 /** A common structure to hold a v3 network status vote, or a v3 network
  * status consensus. */
diff --git a/src/or/node_st.h b/src/or/node_st.h
index f8772cbad..cc777003d 100644
--- a/src/or/node_st.h
+++ b/src/or/node_st.h
@@ -7,7 +7,7 @@
 #ifndef NODE_ST_H
 #define NODE_ST_H
 
-#include "hsdir_index_st.h"
+#include "or/hsdir_index_st.h"
 
 /** A node_t represents a Tor router.
  *
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 5ad91227a..561ac9fda 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -40,41 +40,41 @@
 
 #define NODELIST_PRIVATE
 
-#include "or.h"
-#include "address.h"
-#include "address_set.h"
-#include "bridges.h"
-#include "config.h"
-#include "control.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "geoip.h"
-#include "hs_common.h"
-#include "hs_client.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "protover.h"
-#include "rendservice.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "torcert.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "common/address_set.h"
+#include "or/bridges.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "or/geoip.h"
+#include "or/hs_common.h"
+#include "or/hs_client.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/rendservice.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/torcert.h"
 
 #include <string.h>
 
-#include "dirauth/mode.h"
+#include "or/dirauth/mode.h"
 
-#include "dir_server_st.h"
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "routerstatus_st.h"
+#include "or/dir_server_st.h"
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/routerstatus_st.h"
 
 static void nodelist_drop_node(node_t *node, int remove_from_ht);
 #define node_free(val) \
diff --git a/src/or/ntmain.c b/src/or/ntmain.c
index 8b9adb0ee..72ab5d9d5 100644
--- a/src/or/ntmain.c
+++ b/src/or/ntmain.c
@@ -19,10 +19,10 @@
 
 #ifdef _WIN32
 
-#include "or.h"
-#include "config.h"
-#include "main.h"
-#include "ntmain.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/main.h"
+#include "or/ntmain.h"
 
 #include <windows.h>
 #define GENSRV_SERVICENAME  "tor"
diff --git a/src/or/onion.c b/src/or/onion.c
index c2bb3940c..27e05c7cc 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -62,27 +62,27 @@
  * onion_fast.c for more information.
  **/
 
-#include "or.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "config.h"
-#include "cpuworker.h"
-#include "crypto_util.h"
-#include "networkstatus.h"
-#include "onion.h"
-#include "onion_fast.h"
-#include "onion_ntor.h"
-#include "onion_tap.h"
-#include "relay.h"
-#include "rephist.h"
-#include "router.h"
-
-#include "cell_st.h"
-#include "extend_info_st.h"
-#include "or_circuit_st.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/config.h"
+#include "or/cpuworker.h"
+#include "common/crypto_util.h"
+#include "or/networkstatus.h"
+#include "or/onion.h"
+#include "or/onion_fast.h"
+#include "or/onion_ntor.h"
+#include "or/onion_tap.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/router.h"
+
+#include "or/cell_st.h"
+#include "or/extend_info_st.h"
+#include "or/or_circuit_st.h"
 
 // trunnel
-#include "ed25519_cert.h"
+#include "trunnel/ed25519_cert.h"
 
 /** Type for a linked list of circuits that are waiting for a free CPU worker
  * to process a waiting onion handshake. */
diff --git a/src/or/onion_fast.c b/src/or/onion_fast.c
index 84377f6f0..7d92de038 100644
--- a/src/or/onion_fast.c
+++ b/src/or/onion_fast.c
@@ -27,10 +27,10 @@
  * many RSA1024 keys.
  **/
 
-#include "or.h"
-#include "onion_fast.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
+#include "or/or.h"
+#include "or/onion_fast.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
 
 /** Release all state held in <b>victim</b>. */
 void
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index c8c96e21b..d44933a2b 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -21,13 +21,13 @@
 #include "orconfig.h"
 
 #define ONION_NTOR_PRIVATE
-#include "crypto.h"
-#include "crypto_hkdf.h"
-#include "crypto_digest.h"
-#include "crypto_util.h"
-#include "onion_ntor.h"
-#include "torlog.h"
-#include "util.h"
+#include "common/crypto.h"
+#include "common/crypto_hkdf.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_util.h"
+#include "or/onion_ntor.h"
+#include "common/torlog.h"
+#include "common/util.h"
 
 /** Free storage held in an ntor handshake state. */
 void
diff --git a/src/or/onion_ntor.h b/src/or/onion_ntor.h
index e90657e88..3acb1eb62 100644
--- a/src/or/onion_ntor.h
+++ b/src/or/onion_ntor.h
@@ -4,9 +4,9 @@
 #ifndef TOR_ONION_NTOR_H
 #define TOR_ONION_NTOR_H
 
-#include "torint.h"
-#include "crypto_curve25519.h"
-#include "di_ops.h"
+#include "common/torint.h"
+#include "common/crypto_curve25519.h"
+#include "common/di_ops.h"
 
 /** State to be maintained by a client between sending an ntor onionskin
  * and receiving a reply. */
diff --git a/src/or/onion_tap.c b/src/or/onion_tap.c
index 06dc7c93e..0f9fe31be 100644
--- a/src/or/onion_tap.c
+++ b/src/or/onion_tap.c
@@ -27,12 +27,12 @@
  * invoked from onion.c.
  **/
 
-#include "or.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "onion_tap.h"
-#include "rephist.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/onion_tap.h"
+#include "or/rephist.h"
 
 /*----------------------------------------------------------------------*/
 
diff --git a/src/or/or.h b/src/or/or.h
index b9935ed2c..dc6d353cd 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -26,7 +26,7 @@
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h> /* FreeBSD needs this to know what version it is */
 #endif
-#include "torint.h"
+#include "common/torint.h"
 #ifdef HAVE_SYS_FCNTL_H
 #include <sys/fcntl.h>
 #endif
@@ -66,29 +66,29 @@
 #include <windows.h>
 #endif /* defined(_WIN32) */
 
-#include "crypto.h"
-#include "crypto_format.h"
-#include "crypto_dh.h"
-#include "crypto_hkdf.h"
-#include "tortls.h"
-#include "torlog.h"
-#include "container.h"
-#include "compress.h"
-#include "address.h"
-#include "compat_libevent.h"
+#include "common/crypto.h"
+#include "common/crypto_format.h"
+#include "common/crypto_dh.h"
+#include "common/crypto_hkdf.h"
+#include "common/tortls.h"
+#include "common/torlog.h"
+#include "common/container.h"
+#include "common/compress.h"
+#include "common/address.h"
+#include "common/compat_libevent.h"
 #include "ht.h"
-#include "confline.h"
-#include "replaycache.h"
-#include "crypto_curve25519.h"
-#include "crypto_ed25519.h"
+#include "common/confline.h"
+#include "or/replaycache.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_ed25519.h"
 #include "tor_queue.h"
-#include "token_bucket.h"
-#include "util_format.h"
-#include "hs_circuitmap.h"
+#include "common/token_bucket.h"
+#include "common/util_format.h"
+#include "or/hs_circuitmap.h"
 
 // These, more than other includes, are for keeping the other struct
 // definitions working. We should remove them when we minimize our includes.
-#include "entry_port_cfg_st.h"
+#include "or/entry_port_cfg_st.h"
 
 /* These signals are defined to help handle_control_signal work.
  */
diff --git a/src/or/or_circuit_st.h b/src/or/or_circuit_st.h
index 741621950..158a5314e 100644
--- a/src/or/or_circuit_st.h
+++ b/src/or/or_circuit_st.h
@@ -7,10 +7,10 @@
 #ifndef OR_CIRCUIT_ST_H
 #define OR_CIRCUIT_ST_H
 
-#include "or.h"
+#include "or/or.h"
 
-#include "circuit_st.h"
-#include "crypt_path_st.h"
+#include "or/circuit_st.h"
+#include "or/crypt_path_st.h"
 
 struct onion_queue_t;
 
diff --git a/src/or/or_connection_st.h b/src/or/or_connection_st.h
index a043c63f4..eba2721c3 100644
--- a/src/or/or_connection_st.h
+++ b/src/or/or_connection_st.h
@@ -7,7 +7,7 @@
 #ifndef OR_CONNECTION_ST_H
 #define OR_CONNECTION_ST_H
 
-#include "connection_st.h"
+#include "or/connection_st.h"
 
 /** Subtype of connection_t for an "OR connection" -- that is, one that speaks
  * cells over TLS. */
diff --git a/src/or/origin_circuit_st.h b/src/or/origin_circuit_st.h
index de25b67d7..fa41214d4 100644
--- a/src/or/origin_circuit_st.h
+++ b/src/or/origin_circuit_st.h
@@ -7,9 +7,9 @@
 #ifndef ORIGIN_CIRCUIT_ST_H
 #define ORIGIN_CIRCUIT_ST_H
 
-#include "or.h"
+#include "or/or.h"
 
-#include "circuit_st.h"
+#include "or/circuit_st.h"
 
 struct onion_queue_t;
 
diff --git a/src/or/parsecommon.c b/src/or/parsecommon.c
index 8a8b7f6b1..09c7d665f 100644
--- a/src/or/parsecommon.c
+++ b/src/or/parsecommon.c
@@ -6,9 +6,9 @@
  * \brief Common code to parse and validate various type of descriptors.
  **/
 
-#include "parsecommon.h"
-#include "torlog.h"
-#include "util_format.h"
+#include "or/parsecommon.h"
+#include "common/torlog.h"
+#include "common/util_format.h"
 
 #define MIN_ANNOTATION A_PURPOSE
 #define MAX_ANNOTATION A_UNKNOWN_
diff --git a/src/or/parsecommon.h b/src/or/parsecommon.h
index fdcd2838e..bfd5c58b8 100644
--- a/src/or/parsecommon.h
+++ b/src/or/parsecommon.h
@@ -9,9 +9,9 @@
 #ifndef TOR_PARSECOMMON_H
 #define TOR_PARSECOMMON_H
 
-#include "container.h"
-#include "crypto.h"
-#include "memarea.h"
+#include "common/container.h"
+#include "common/crypto.h"
+#include "common/memarea.h"
 
 /** Enumeration of possible token types.  The ones starting with K_ correspond
 * to directory 'keywords'. A_ is for an annotation, R or C is related to
diff --git a/src/or/periodic.c b/src/or/periodic.c
index 57967ccdf..d379325f5 100644
--- a/src/or/periodic.c
+++ b/src/or/periodic.c
@@ -11,11 +11,11 @@
  * that they fire.  See periodic_events[] in main.c for examples.
  */
 
-#include "or.h"
-#include "compat_libevent.h"
-#include "config.h"
-#include "main.h"
-#include "periodic.h"
+#include "or/or.h"
+#include "common/compat_libevent.h"
+#include "or/config.h"
+#include "or/main.h"
+#include "or/periodic.h"
 
 /** We disable any interval greater than this number of seconds, on the
  * grounds that it is probably an absolute time mistakenly passed in as a
diff --git a/src/or/policies.c b/src/or/policies.c
index 150635580..0f52d6bf1 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -17,25 +17,25 @@
 
 #define POLICIES_PRIVATE
 
-#include "or.h"
-#include "bridges.h"
-#include "config.h"
-#include "dirserv.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerparse.h"
-#include "geoip.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/config.h"
+#include "or/dirserv.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerparse.h"
+#include "or/geoip.h"
 #include "ht.h"
 
-#include "dir_server_st.h"
-#include "microdesc_st.h"
-#include "node_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "or/dir_server_st.h"
+#include "or/microdesc_st.h"
+#include "or/node_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 /** Policy that addresses for incoming SOCKS connections must match. */
 static smartlist_t *socks_policy = NULL;
diff --git a/src/or/port_cfg_st.h b/src/or/port_cfg_st.h
index 4a1aa5dbd..86a3b963b 100644
--- a/src/or/port_cfg_st.h
+++ b/src/or/port_cfg_st.h
@@ -7,8 +7,8 @@
 #ifndef PORT_CFG_ST_H
 #define PORT_CFG_ST_H
 
-#include "entry_port_cfg_st.h"
-#include "server_port_cfg_st.h"
+#include "or/entry_port_cfg_st.h"
+#include "or/server_port_cfg_st.h"
 
 /** Configuration for a single port that we're listening on. */
 struct port_cfg_t {
diff --git a/src/or/proto_cell.c b/src/or/proto_cell.c
index b27368911..af0862a97 100644
--- a/src/or/proto_cell.c
+++ b/src/or/proto_cell.c
@@ -4,13 +4,13 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "buffers.h"
-#include "proto_cell.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/proto_cell.h"
 
-#include "connection_or.h"
+#include "or/connection_or.h"
 
-#include "var_cell_st.h"
+#include "or/var_cell_st.h"
 
 /** True iff the cell command <b>command</b> is one that implies a
  * variable-length cell in Tor link protocol <b>linkproto</b>. */
diff --git a/src/or/proto_control0.c b/src/or/proto_control0.c
index 9b4f7384c..5d83b11cb 100644
--- a/src/or/proto_control0.c
+++ b/src/or/proto_control0.c
@@ -4,9 +4,9 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "buffers.h"
-#include "proto_control0.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/proto_control0.h"
 
 /** Return 1 iff buf looks more like it has an (obsolete) v0 controller
  * command on it than any valid v1 controller command. */
diff --git a/src/or/proto_ext_or.c b/src/or/proto_ext_or.c
index 3e793f6e0..495b489bc 100644
--- a/src/or/proto_ext_or.c
+++ b/src/or/proto_ext_or.c
@@ -4,10 +4,10 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "buffers.h"
-#include "ext_orport.h"
-#include "proto_ext_or.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/ext_orport.h"
+#include "or/proto_ext_or.h"
 
 /** The size of the header of an Extended ORPort message: 2 bytes for
  *  COMMAND, 2 bytes for BODYLEN */
diff --git a/src/or/proto_http.c b/src/or/proto_http.c
index 3c8f108c9..45f763b2a 100644
--- a/src/or/proto_http.c
+++ b/src/or/proto_http.c
@@ -5,9 +5,9 @@
 /* See LICENSE for licensing information */
 
 #define PROTO_HTTP_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "proto_http.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/proto_http.h"
 
 /** Return true if <b>cmd</b> looks like a HTTP (proxy) request. */
 int
diff --git a/src/or/proto_socks.c b/src/or/proto_socks.c
index d908cd84f..d113bc9ca 100644
--- a/src/or/proto_socks.c
+++ b/src/or/proto_socks.c
@@ -4,17 +4,17 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "addressmap.h"
-#include "buffers.h"
-#include "control.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "ext_orport.h"
-#include "proto_socks.h"
-#include "reasons.h"
-
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "common/buffers.h"
+#include "or/control.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/ext_orport.h"
+#include "or/proto_socks.h"
+#include "or/reasons.h"
+
+#include "or/socks_request_st.h"
 
 static void socks_request_set_socks5_error(socks_request_t *req,
                               socks5_reply_status_t reason);
diff --git a/src/or/protover.c b/src/or/protover.c
index 1dbb43007..3a106a50e 100644
--- a/src/or/protover.c
+++ b/src/or/protover.c
@@ -23,9 +23,9 @@
 
 #define PROTOVER_PRIVATE
 
-#include "or.h"
-#include "protover.h"
-#include "routerparse.h"
+#include "or/or.h"
+#include "or/protover.h"
+#include "or/routerparse.h"
 
 #ifndef HAVE_RUST
 
diff --git a/src/or/protover.h b/src/or/protover.h
index 30b61ff59..6236ed133 100644
--- a/src/or/protover.h
+++ b/src/or/protover.h
@@ -9,7 +9,7 @@
 #ifndef TOR_PROTOVER_H
 #define TOR_PROTOVER_H
 
-#include "container.h"
+#include "common/container.h"
 
 /** The first version of Tor that included "proto" entries in its
  * descriptors.  Authorities should use this to decide whether to
diff --git a/src/or/protover_rust.c b/src/or/protover_rust.c
index f9743491c..bd2f88b98 100644
--- a/src/or/protover_rust.c
+++ b/src/or/protover_rust.c
@@ -7,8 +7,8 @@
  * and safe translation/handling between the Rust/C boundary.
  */
 
-#include "or.h"
-#include "protover.h"
+#include "or/or.h"
+#include "or/protover.h"
 
 #ifdef HAVE_RUST
 
diff --git a/src/or/reasons.c b/src/or/reasons.c
index 4082c8d0b..b9b7a7db8 100644
--- a/src/or/reasons.c
+++ b/src/or/reasons.c
@@ -14,9 +14,9 @@
  * to another.
  **/
 
-#include "or.h"
-#include "config.h"
-#include "reasons.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/reasons.h"
 
 /***************************** Edge (stream) reasons **********************/
 
diff --git a/src/or/relay.c b/src/or/relay.c
index a60e5d601..143580a31 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -46,53 +46,53 @@
  **/
 
 #define RELAY_PRIVATE
-#include "or.h"
-#include "addressmap.h"
-#include "backtrace.h"
-#include "buffers.h"
-#include "channel.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "compress.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "geoip.h"
-#include "hs_cache.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "onion.h"
-#include "policies.h"
-#include "reasons.h"
-#include "relay.h"
-#include "relay_crypto.h"
-#include "rendcache.h"
-#include "rendcommon.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "scheduler.h"
-#include "rephist.h"
-
-#include "cell_st.h"
-#include "cell_queue_st.h"
-#include "cpath_build_state_st.h"
-#include "dir_connection_st.h"
-#include "destroy_cell_queue_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
-#include "routerinfo_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/addressmap.h"
+#include "common/backtrace.h"
+#include "common/buffers.h"
+#include "or/channel.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "common/compress.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/geoip.h"
+#include "or/hs_cache.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/onion.h"
+#include "or/policies.h"
+#include "or/reasons.h"
+#include "or/relay.h"
+#include "or/relay_crypto.h"
+#include "or/rendcache.h"
+#include "or/rendcommon.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/scheduler.h"
+#include "or/rephist.h"
+
+#include "or/cell_st.h"
+#include "or/cell_queue_st.h"
+#include "or/cpath_build_state_st.h"
+#include "or/dir_connection_st.h"
+#include "or/destroy_cell_queue_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerinfo_st.h"
+#include "or/socks_request_st.h"
 
 static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell,
                                             cell_direction_t cell_direction,
diff --git a/src/or/relay_crypto.c b/src/or/relay_crypto.c
index 82ff9aca8..5179984e7 100644
--- a/src/or/relay_crypto.c
+++ b/src/or/relay_crypto.c
@@ -4,17 +4,17 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "circuitlist.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "hs_ntor.h" // for HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN
-#include "relay.h"
-#include "relay_crypto.h"
-
-#include "cell_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/circuitlist.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/hs_ntor.h" // for HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN
+#include "or/relay.h"
+#include "or/relay_crypto.h"
+
+#include "or/cell_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 /** Update digest from the payload of cell. Assign integrity part to
  * cell.
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index 1d1223883..c18920154 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -7,17 +7,17 @@
  **/
 
 #define RENDCACHE_PRIVATE
-#include "rendcache.h"
+#include "or/rendcache.h"
 
-#include "config.h"
-#include "rephist.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "rendcommon.h"
+#include "or/config.h"
+#include "or/rephist.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/rendcommon.h"
 
-#include "extend_info_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
+#include "or/extend_info_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
 
 /** Map from service id (as generated by rend_get_service_id) to
  * rend_cache_entry_t. */
diff --git a/src/or/rendcache.h b/src/or/rendcache.h
index 12af720cf..bb075409e 100644
--- a/src/or/rendcache.h
+++ b/src/or/rendcache.h
@@ -9,8 +9,8 @@
 #ifndef TOR_RENDCACHE_H
 #define TOR_RENDCACHE_H
 
-#include "or.h"
-#include "rendcommon.h"
+#include "or/or.h"
+#include "or/rendcommon.h"
 
 /** How old do we let hidden service descriptors get before discarding
  * them as too old? */
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index f1c410dfb..6fde0ba26 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -7,41 +7,41 @@
  * \brief Client code to access location-hidden services.
  **/
 
-#include "or.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "hs_circuit.h"
-#include "hs_client.h"
-#include "hs_common.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerset.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "origin_circuit_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/hs_circuit.h"
+#include "or/hs_client.h"
+#include "or/hs_common.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerstatus_st.h"
 
 static extend_info_t *rend_client_get_random_intro_impl(
                           const rend_cache_entry_t *rend_query,
diff --git a/src/or/rendclient.h b/src/or/rendclient.h
index 2d32a3b8f..77395d6cb 100644
--- a/src/or/rendclient.h
+++ b/src/or/rendclient.h
@@ -12,7 +12,7 @@
 #ifndef TOR_RENDCLIENT_H
 #define TOR_RENDCLIENT_H
 
-#include "rendcache.h"
+#include "or/rendcache.h"
 
 void rend_client_purge_state(void);
 
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index ab064af70..2c1caa6ce 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -10,36 +10,36 @@
 
 #define RENDCOMMON_PRIVATE
 
-#include "or.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "hs_client.h"
-#include "hs_common.h"
-#include "hs_intropoint.h"
-#include "networkstatus.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendmid.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "extend_info_st.h"
-#include "networkstatus_st.h"
-#include "origin_circuit_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/hs_client.h"
+#include "or/hs_common.h"
+#include "or/hs_intropoint.h"
+#include "or/networkstatus.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendmid.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/extend_info_st.h"
+#include "or/networkstatus_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerstatus_st.h"
 
 /** Return 0 if one and two are the same service ids, else -1 or 1 */
 int
diff --git a/src/or/rendmid.c b/src/or/rendmid.c
index a6e987dc4..77a534712 100644
--- a/src/or/rendmid.c
+++ b/src/or/rendmid.c
@@ -7,20 +7,20 @@
  * \brief Implement introductions points and rendezvous points.
  **/
 
-#include "or.h"
-#include "channel.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "crypto.h"
-#include "dos.h"
-#include "relay.h"
-#include "rendmid.h"
-#include "rephist.h"
-#include "hs_circuitmap.h"
-#include "hs_intropoint.h"
-
-#include "or_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "common/crypto.h"
+#include "or/dos.h"
+#include "or/relay.h"
+#include "or/rendmid.h"
+#include "or/rephist.h"
+#include "or/hs_circuitmap.h"
+#include "or/hs_intropoint.h"
+
+#include "or/or_circuit_st.h"
 
 /** Respond to an ESTABLISH_INTRO cell by checking the signed data and
  * setting the circuit's purpose and service pk digest.
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 89088153b..21a5a4e03 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -9,45 +9,45 @@
 
 #define RENDSERVICE_PRIVATE
 
-#include "or.h"
-#include "circpathbias.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "directory.h"
-#include "hs_common.h"
-#include "hs_config.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "rendclient.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "router.h"
-#include "relay.h"
-#include "rephist.h"
-#include "replaycache.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "crypt_path_reference_st.h"
-#include "edge_connection_st.h"
-#include "extend_info_st.h"
-#include "networkstatus_st.h"
-#include "origin_circuit_st.h"
-#include "rend_authorized_client_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/circpathbias.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "or/directory.h"
+#include "or/hs_common.h"
+#include "or/hs_config.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/rendclient.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/router.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/replaycache.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/crypt_path_reference_st.h"
+#include "or/edge_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/networkstatus_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/rend_authorized_client_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerstatus_st.h"
 
 struct rend_service_t;
 static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro,
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index a4d770078..b2644d8b4 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -12,8 +12,8 @@
 #ifndef TOR_RENDSERVICE_H
 #define TOR_RENDSERVICE_H
 
-#include "or.h"
-#include "hs_service.h"
+#include "or/or.h"
+#include "or/hs_service.h"
 
 typedef struct rend_intro_cell_s rend_intro_cell_t;
 
diff --git a/src/or/rephist.c b/src/or/rephist.c
index d401e0b3e..c7a0a2556 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -74,23 +74,23 @@
  * (The "rephist" name originally stood for "reputation and history". )
  **/
 
-#include "or.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
+#include "or/or.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
 #include "ht.h"
-#include "channelpadding.h"
-#include "connection_or.h"
-#include "statefile.h"
+#include "or/channelpadding.h"
+#include "or/connection_or.h"
+#include "or/statefile.h"
 
-#include "networkstatus_st.h"
-#include "or_circuit_st.h"
+#include "or/networkstatus_st.h"
+#include "or/or_circuit_st.h"
 
 static void bw_arrays_init(void);
 static void predicted_ports_alloc(void);
diff --git a/src/or/replaycache.c b/src/or/replaycache.c
index fd09b9f40..b5cc6a282 100644
--- a/src/or/replaycache.c
+++ b/src/or/replaycache.c
@@ -21,8 +21,8 @@
 
 #define REPLAYCACHE_PRIVATE
 
-#include "or.h"
-#include "replaycache.h"
+#include "or/or.h"
+#include "or/replaycache.h"
 
 /** Free the replaycache r and all of its entries.
  */
diff --git a/src/or/router.c b/src/or/router.c
index 53dc7e836..4f162ceac 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -6,49 +6,49 @@
 
 #define ROUTER_PRIVATE
 
-#include "or.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "config.h"
-#include "connection.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "crypto_curve25519.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dns.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "protover.h"
-#include "relay.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "statefile.h"
-#include "torcert.h"
-#include "transports.h"
-#include "routerset.h"
-
-#include "dirauth/mode.h"
-
-#include "authority_cert_st.h"
-#include "crypt_path_st.h"
-#include "dir_connection_st.h"
-#include "dir_server_st.h"
-#include "extend_info_st.h"
-#include "extrainfo_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "common/crypto_curve25519.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dns.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/relay.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/statefile.h"
+#include "or/torcert.h"
+#include "or/transports.h"
+#include "or/routerset.h"
+
+#include "or/dirauth/mode.h"
+
+#include "or/authority_cert_st.h"
+#include "or/crypt_path_st.h"
+#include "or/dir_connection_st.h"
+#include "or/dir_server_st.h"
+#include "or/extend_info_st.h"
+#include "or/extrainfo_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
 
 /**
  * \file router.c
diff --git a/src/or/router.h b/src/or/router.h
index d4cf82d59..4a383ac42 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -12,7 +12,7 @@
 #ifndef TOR_ROUTER_H
 #define TOR_ROUTER_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 #define TOR_ROUTERINFO_ERROR_NO_EXT_ADDR     (-1)
 #define TOR_ROUTERINFO_ERROR_CANNOT_PARSE    (-2)
diff --git a/src/or/routerinfo_st.h b/src/or/routerinfo_st.h
index c9f989439..feb3b41fc 100644
--- a/src/or/routerinfo_st.h
+++ b/src/or/routerinfo_st.h
@@ -7,7 +7,7 @@
 #ifndef ROUTERINFO_ST_H
 #define ROUTERINFO_ST_H
 
-#include "signed_descriptor_st.h"
+#include "or/signed_descriptor_st.h"
 
 /** Information about another onion router in the network. */
 struct routerinfo_t {
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 3fab049df..6bf066fbb 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -14,13 +14,13 @@
  * (TODO: The keys in router.c should go here too.)
  */
 
-#include "or.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "router.h"
-#include "crypto_pwbox.h"
-#include "routerkeys.h"
-#include "torcert.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/router.h"
+#include "common/crypto_pwbox.h"
+#include "or/routerkeys.h"
+#include "or/torcert.h"
 
 #define ENC_KEY_HEADER "Boxed Ed25519 key"
 #define ENC_KEY_TAG "master"
diff --git a/src/or/routerkeys.h b/src/or/routerkeys.h
index 764f7513a..2339495d4 100644
--- a/src/or/routerkeys.h
+++ b/src/or/routerkeys.h
@@ -4,7 +4,7 @@
 #ifndef TOR_ROUTERKEYS_H
 #define TOR_ROUTERKEYS_H
 
-#include "crypto_ed25519.h"
+#include "common/crypto_ed25519.h"
 
 #define INIT_ED_KEY_CREATE                      (1u<<0)
 #define INIT_ED_KEY_REPLACE                     (1u<<1)
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 8bdfbeee1..9ab01f4b3 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -91,51 +91,51 @@
  **/
 
 #define ROUTERLIST_PRIVATE
-#include "or.h"
-#include "backtrace.h"
-#include "bridges.h"
-#include "crypto_ed25519.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "connection.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "fp_pair.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "main.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "reasons.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "sandbox.h"
-#include "torcert.h"
-
-#include "dirauth/dirvote.h"
-#include "dirauth/mode.h"
-
-#include "authority_cert_st.h"
-#include "dir_connection_st.h"
-#include "dir_server_st.h"
-#include "document_signature_st.h"
-#include "extrainfo_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "or/bridges.h"
+#include "common/crypto_ed25519.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "or/fp_pair.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/reasons.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "common/sandbox.h"
+#include "or/torcert.h"
+
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/mode.h"
+
+#include "or/authority_cert_st.h"
+#include "or/dir_connection_st.h"
+#include "or/dir_server_st.h"
+#include "or/document_signature_st.h"
+#include "or/extrainfo_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/vote_routerstatus_st.h"
 
 // #define DEBUG_ROUTERLIST
 
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index eb6a658fb..a90c26b44 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -11,7 +11,7 @@
 #ifndef TOR_ROUTERLIST_H
 #define TOR_ROUTERLIST_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 int get_n_authorities(dirinfo_type_t type);
 int trusted_dirs_reload_certs(void);
diff --git a/src/or/routerlist_st.h b/src/or/routerlist_st.h
index 123c0ab63..0b94a4dfc 100644
--- a/src/or/routerlist_st.h
+++ b/src/or/routerlist_st.h
@@ -7,7 +7,7 @@
 #ifndef ROUTERLIST_ST_H
 #define ROUTERLIST_ST_H
 
-#include "desc_store_st.h"
+#include "or/desc_store_st.h"
 
 /** Contents of a directory of onion routers. */
 struct routerlist_t {
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 20fb6d170..48b182817 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -55,48 +55,48 @@
 
 #define ROUTERPARSE_PRIVATE
 
-#include "or.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "dirauth/shared_random.h"
-#include "dirserv.h"
-#include "entrynodes.h"
-#include "memarea.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "parsecommon.h"
-#include "policies.h"
-#include "protover.h"
-#include "rendcommon.h"
-#include "rephist.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "sandbox.h"
-#include "shared_random_client.h"
-#include "torcert.h"
-#include "voting_schedule.h"
-
-#include "dirauth/dirvote.h"
-
-#include "authority_cert_st.h"
-#include "document_signature_st.h"
-#include "extend_info_st.h"
-#include "extrainfo_st.h"
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "ns_detached_signatures_st.h"
-#include "rend_authorized_client_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "tor_version_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/or.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/dirauth/shared_random.h"
+#include "or/dirserv.h"
+#include "or/entrynodes.h"
+#include "common/memarea.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/parsecommon.h"
+#include "or/policies.h"
+#include "or/protover.h"
+#include "or/rendcommon.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "common/sandbox.h"
+#include "or/shared_random_client.h"
+#include "or/torcert.h"
+#include "or/voting_schedule.h"
+
+#include "or/dirauth/dirvote.h"
+
+#include "or/authority_cert_st.h"
+#include "or/document_signature_st.h"
+#include "or/extend_info_st.h"
+#include "or/extrainfo_st.h"
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/ns_detached_signatures_st.h"
+#include "or/rend_authorized_client_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/tor_version_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
 
 #undef log
 #include <math.h>
diff --git a/src/or/routerset.c b/src/or/routerset.c
index d08db8f4b..231ae152a 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -27,19 +27,19 @@
 
 #define ROUTERSET_PRIVATE
 
-#include "or.h"
-#include "bridges.h"
-#include "geoip.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerparse.h"
-#include "routerset.h"
-
-#include "extend_info_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/geoip.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+
+#include "or/extend_info_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 /** Return a new empty routerset. */
 routerset_t *
diff --git a/src/or/routerstatus_st.h b/src/or/routerstatus_st.h
index 9d749ddb6..3de4a40ae 100644
--- a/src/or/routerstatus_st.h
+++ b/src/or/routerstatus_st.h
@@ -7,7 +7,7 @@
 #ifndef ROUTERSTATUS_ST_H
 #define ROUTERSTATUS_ST_H
 
-#include "download_status_st.h"
+#include "or/download_status_st.h"
 
 /** Contents of a single router entry in a network status object.
  */
diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index 90c81eb05..519010026 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -1,19 +1,19 @@
 /* Copyright (c) 2013-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "config.h"
+#include "or/or.h"
+#include "or/config.h"
 
-#include "compat_libevent.h"
+#include "common/compat_libevent.h"
 #define SCHEDULER_PRIVATE_
 #define SCHEDULER_KIST_PRIVATE
-#include "scheduler.h"
-#include "main.h"
-#include "buffers.h"
+#include "or/scheduler.h"
+#include "or/main.h"
+#include "common/buffers.h"
 #define TOR_CHANNEL_INTERNAL_
-#include "channeltls.h"
+#include "or/channeltls.h"
 
-#include "or_connection_st.h"
+#include "or/or_connection_st.h"
 
 /**
  * \file scheduler.c
diff --git a/src/or/scheduler.h b/src/or/scheduler.h
index 24e85b21a..37c192fea 100644
--- a/src/or/scheduler.h
+++ b/src/or/scheduler.h
@@ -9,9 +9,9 @@
 #ifndef TOR_SCHEDULER_H
 #define TOR_SCHEDULER_H
 
-#include "or.h"
-#include "channel.h"
-#include "testsupport.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "common/testsupport.h"
 
 /** Scheduler type, we build an ordered list with those values from the
  * parsed strings in Schedulers. The reason to do such a thing is so we can
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index 796bdf6ab..6f07458d4 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -3,18 +3,18 @@
 
 #define SCHEDULER_KIST_PRIVATE
 
-#include "or.h"
-#include "buffers.h"
-#include "config.h"
-#include "connection.h"
-#include "networkstatus.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/networkstatus.h"
 #define TOR_CHANNEL_INTERNAL_
-#include "channel.h"
-#include "channeltls.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
 #define SCHEDULER_PRIVATE_
-#include "scheduler.h"
+#include "or/scheduler.h"
 
-#include "or_connection_st.h"
+#include "or/or_connection_st.h"
 
 #define TLS_PER_CELL_OVERHEAD 29
 
diff --git a/src/or/scheduler_vanilla.c b/src/or/scheduler_vanilla.c
index 0400d77d7..0346af2ad 100644
--- a/src/or/scheduler_vanilla.c
+++ b/src/or/scheduler_vanilla.c
@@ -1,12 +1,12 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "config.h"
+#include "or/or.h"
+#include "or/config.h"
 #define TOR_CHANNEL_INTERNAL_
-#include "channel.h"
+#include "or/channel.h"
 #define SCHEDULER_PRIVATE_
-#include "scheduler.h"
+#include "or/scheduler.h"
 
 /*****************************************************************************
  * Other internal data
diff --git a/src/or/shared_random_client.c b/src/or/shared_random_client.c
index e34c6e9a8..f0b13a171 100644
--- a/src/or/shared_random_client.c
+++ b/src/or/shared_random_client.c
@@ -9,15 +9,15 @@
  **/
 
 #define SHARED_RANDOM_CLIENT_PRIVATE
-#include "shared_random_client.h"
+#include "or/shared_random_client.h"
 
-#include "config.h"
-#include "voting_schedule.h"
-#include "networkstatus.h"
-#include "util.h"
-#include "util_format.h"
+#include "or/config.h"
+#include "or/voting_schedule.h"
+#include "or/networkstatus.h"
+#include "common/util.h"
+#include "common/util_format.h"
 
-#include "networkstatus_st.h"
+#include "or/networkstatus_st.h"
 
 /* Convert a given srv object to a string for the control port. This doesn't
  * fail and the srv object MUST be valid. */
diff --git a/src/or/shared_random_client.h b/src/or/shared_random_client.h
index aa71eb0d9..079829496 100644
--- a/src/or/shared_random_client.h
+++ b/src/or/shared_random_client.h
@@ -10,7 +10,7 @@
 #define TOR_SHARED_RANDOM_CLIENT_H
 
 /* Dirauth module. */
-#include "dirauth/shared_random.h"
+#include "or/dirauth/shared_random.h"
 
 /* Helper functions. */
 void sr_srv_encode(char *dst, size_t dst_len, const sr_srv_t *srv);
diff --git a/src/or/signed_descriptor_st.h b/src/or/signed_descriptor_st.h
index 92990ab5d..90cd4a270 100644
--- a/src/or/signed_descriptor_st.h
+++ b/src/or/signed_descriptor_st.h
@@ -7,7 +7,7 @@
 #ifndef SIGNED_DESCRIPTOR_ST_H
 #define SIGNED_DESCRIPTOR_ST_H
 
-#include "download_status_st.h"
+#include "or/download_status_st.h"
 
 /** Information need to cache an onion router's descriptor. */
 struct signed_descriptor_t {
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 5b30228b9..53a25e13f 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -29,19 +29,19 @@
  */
 
 #define STATEFILE_PRIVATE
-#include "or.h"
-#include "circuitstats.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "control.h"
-#include "entrynodes.h"
-#include "hibernate.h"
-#include "main.h"
-#include "rephist.h"
-#include "router.h"
-#include "sandbox.h"
-#include "statefile.h"
+#include "or/or.h"
+#include "or/circuitstats.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/control.h"
+#include "or/entrynodes.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/rephist.h"
+#include "or/router.h"
+#include "common/sandbox.h"
+#include "or/statefile.h"
 
 /** A list of state-file "abbreviations," for compatibility. */
 static config_abbrev_t state_abbrevs_[] = {
diff --git a/src/or/status.c b/src/or/status.c
index 4f1d92cc2..d0b3bc553 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -14,26 +14,26 @@
 
 #define STATUS_PRIVATE
 
-#include "or.h"
-#include "circuituse.h"
-#include "config.h"
-#include "status.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "router.h"
-#include "circuitlist.h"
-#include "main.h"
-#include "rephist.h"
-#include "hibernate.h"
-#include "statefile.h"
-#include "hs_stats.h"
-#include "hs_service.h"
-#include "dos.h"
-
-#include "routerinfo_st.h"
+#include "or/or.h"
+#include "or/circuituse.h"
+#include "or/config.h"
+#include "or/status.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/router.h"
+#include "or/circuitlist.h"
+#include "or/main.h"
+#include "or/rephist.h"
+#include "or/hibernate.h"
+#include "or/statefile.h"
+#include "or/hs_stats.h"
+#include "or/hs_service.h"
+#include "or/dos.h"
+
+#include "or/routerinfo_st.h"
 
 static void log_accounting(const time_t now, const or_options_t *options);
-#include "geoip.h"
+#include "or/geoip.h"
 
 /** Return the total number of circuits. */
 STATIC int
diff --git a/src/or/status.h b/src/or/status.h
index f75e8f999..840ec1198 100644
--- a/src/or/status.h
+++ b/src/or/status.h
@@ -4,7 +4,7 @@
 #ifndef TOR_STATUS_H
 #define TOR_STATUS_H
 
-#include "testsupport.h"
+#include "common/testsupport.h"
 
 int log_heartbeat(time_t now);
 
diff --git a/src/or/tor_api.c b/src/or/tor_api.c
index 9d3355f31..efedf2dc7 100644
--- a/src/or/tor_api.c
+++ b/src/or/tor_api.c
@@ -8,8 +8,8 @@
  * \file tor_api.c
  **/
 
-#include "tor_api.h"
-#include "tor_api_internal.h"
+#include "or/tor_api.h"
+#include "or/tor_api_internal.h"
 
 // Include this after the above headers, to insure that they don't
 // depend on anything else.
diff --git a/src/or/torcert.c b/src/or/torcert.c
index 688b3486b..a6bbe4231 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -25,17 +25,17 @@
  * that one is authority_cert_t, and it's mostly handled in routerlist.c.
  */
 
-#include "or.h"
-#include "config.h"
-#include "crypto_util.h"
-#include "torcert.h"
-#include "ed25519_cert.h"
-#include "torlog.h"
-#include "util.h"
-#include "compat.h"
-#include "link_handshake.h"
-
-#include "or_handshake_certs_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_util.h"
+#include "or/torcert.h"
+#include "trunnel/ed25519_cert.h"
+#include "common/torlog.h"
+#include "common/util.h"
+#include "common/compat.h"
+#include "trunnel/link_handshake.h"
+
+#include "or/or_handshake_certs_st.h"
 
 /** Helper for tor_cert_create(): signs any 32 bytes, not just an ed25519
  * key.
diff --git a/src/or/torcert.h b/src/or/torcert.h
index cf61ac830..cba3d3622 100644
--- a/src/or/torcert.h
+++ b/src/or/torcert.h
@@ -4,7 +4,7 @@
 #ifndef TORCERT_H_INCLUDED
 #define TORCERT_H_INCLUDED
 
-#include "crypto_ed25519.h"
+#include "common/crypto_ed25519.h"
 
 #define SIGNED_KEY_TYPE_ED25519     0x01
 
diff --git a/src/or/transports.c b/src/or/transports.c
index e2deb31ea..b88c42cbb 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -90,17 +90,17 @@
  **/
 
 #define PT_PRIVATE
-#include "or.h"
-#include "bridges.h"
-#include "config.h"
-#include "circuitbuild.h"
-#include "transports.h"
-#include "util.h"
-#include "router.h"
-#include "statefile.h"
-#include "connection_or.h"
-#include "ext_orport.h"
-#include "control.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/config.h"
+#include "or/circuitbuild.h"
+#include "or/transports.h"
+#include "common/util.h"
+#include "or/router.h"
+#include "or/statefile.h"
+#include "or/connection_or.h"
+#include "or/ext_orport.h"
+#include "or/control.h"
 
 static process_environment_t *
 create_managed_proxy_environment(const managed_proxy_t *mp);
diff --git a/src/or/vote_routerstatus_st.h b/src/or/vote_routerstatus_st.h
index fcd0a993f..7ec0c962f 100644
--- a/src/or/vote_routerstatus_st.h
+++ b/src/or/vote_routerstatus_st.h
@@ -7,7 +7,7 @@
 #ifndef VOTE_ROUTERSTATUS_ST_H
 #define VOTE_ROUTERSTATUS_ST_H
 
-#include "routerstatus_st.h"
+#include "or/routerstatus_st.h"
 
 /** The claim about a single router, made in a vote. */
 struct vote_routerstatus_t {
diff --git a/src/or/voting_schedule.c b/src/or/voting_schedule.c
index b53d88672..6edde3f22 100644
--- a/src/or/voting_schedule.c
+++ b/src/or/voting_schedule.c
@@ -9,13 +9,13 @@
  **/
 
 #define VOTING_SCHEDULE_PRIVATE
-#include "voting_schedule.h"
+#include "or/voting_schedule.h"
 
-#include "or.h"
-#include "config.h"
-#include "networkstatus.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/networkstatus.h"
 
-#include "networkstatus_st.h"
+#include "or/networkstatus_st.h"
 
 /* =====
  * Vote scheduling
diff --git a/src/or/voting_schedule.h b/src/or/voting_schedule.h
index 6758477fa..0f27d36d5 100644
--- a/src/or/voting_schedule.h
+++ b/src/or/voting_schedule.h
@@ -9,7 +9,7 @@
 #ifndef TOR_VOTING_SCHEDULE_H
 #define TOR_VOTING_SCHEDULE_H
 
-#include "or.h"
+#include "or/or.h"
 
 /** Scheduling information for a voting interval. */
 typedef struct {
diff --git a/src/test/bench.c b/src/test/bench.c
index f1f19411d..f54d8f5c6 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -10,24 +10,24 @@
 
 #include "orconfig.h"
 
-#include "or.h"
-#include "onion_tap.h"
-#include "relay_crypto.h"
+#include "or/or.h"
+#include "or/onion_tap.h"
+#include "or/relay_crypto.h"
 #include <openssl/opensslv.h>
 #include <openssl/evp.h>
 #include <openssl/ec.h>
 #include <openssl/ecdh.h>
 #include <openssl/obj_mac.h>
 
-#include "config.h"
-#include "crypto_curve25519.h"
-#include "onion_ntor.h"
-#include "crypto_ed25519.h"
-#include "crypto_rand.h"
-#include "consdiff.h"
+#include "or/config.h"
+#include "common/crypto_curve25519.h"
+#include "or/onion_ntor.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_rand.h"
+#include "or/consdiff.h"
 
-#include "cell_st.h"
-#include "or_circuit_st.h"
+#include "or/cell_st.h"
+#include "or/or_circuit_st.h"
 
 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
 static uint64_t nanostart;
diff --git a/src/test/fuzz/fuzz_consensus.c b/src/test/fuzz/fuzz_consensus.c
index 9761c27ad..de54da61b 100644
--- a/src/test/fuzz/fuzz_consensus.c
+++ b/src/test/fuzz/fuzz_consensus.c
@@ -1,10 +1,10 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "networkstatus.h"
-#include "fuzzing.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/networkstatus.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_descriptor.c b/src/test/fuzz/fuzz_descriptor.c
index 3b5af883f..d28793fdf 100644
--- a/src/test/fuzz/fuzz_descriptor.c
+++ b/src/test/fuzz/fuzz_descriptor.c
@@ -1,11 +1,11 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "routerlist.h"
-#include "routerkeys.h"
-#include "fuzzing.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/routerlist.h"
+#include "or/routerkeys.h"
+#include "test/fuzz/fuzzing.h"
 
 static int
 mock_check_tap_onion_key_crosscert__nocheck(const uint8_t *crosscert,
diff --git a/src/test/fuzz/fuzz_diff.c b/src/test/fuzz/fuzz_diff.c
index 91ecfe309..eb5fc27e0 100644
--- a/src/test/fuzz/fuzz_diff.c
+++ b/src/test/fuzz/fuzz_diff.c
@@ -4,10 +4,10 @@
 #define CONSDIFF_PRIVATE
 
 #include "orconfig.h"
-#include "or.h"
-#include "consdiff.h"
+#include "or/or.h"
+#include "or/consdiff.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static int
 mock_consensus_compute_digest_(const char *c, consensus_digest_t *d)
diff --git a/src/test/fuzz/fuzz_diff_apply.c b/src/test/fuzz/fuzz_diff_apply.c
index 589406e07..76789fabc 100644
--- a/src/test/fuzz/fuzz_diff_apply.c
+++ b/src/test/fuzz/fuzz_diff_apply.c
@@ -4,10 +4,10 @@
 #define CONSDIFF_PRIVATE
 
 #include "orconfig.h"
-#include "or.h"
-#include "consdiff.h"
+#include "or/or.h"
+#include "or/consdiff.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static int
 mock_consensus_compute_digest_(const char *c, consensus_digest_t *d)
diff --git a/src/test/fuzz/fuzz_extrainfo.c b/src/test/fuzz/fuzz_extrainfo.c
index a3f10f6a3..274ecc786 100644
--- a/src/test/fuzz/fuzz_extrainfo.c
+++ b/src/test/fuzz/fuzz_extrainfo.c
@@ -1,11 +1,11 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "routerlist.h"
-#include "routerkeys.h"
-#include "fuzzing.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/routerlist.h"
+#include "or/routerkeys.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_hsdescv2.c b/src/test/fuzz/fuzz_hsdescv2.c
index 1dd41c857..5cf2cffb8 100644
--- a/src/test/fuzz/fuzz_hsdescv2.c
+++ b/src/test/fuzz/fuzz_hsdescv2.c
@@ -1,10 +1,10 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "rendcommon.h"
-#include "fuzzing.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/rendcommon.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_hsdescv3.c b/src/test/fuzz/fuzz_hsdescv3.c
index e6c553ba6..d1ef34b6b 100644
--- a/src/test/fuzz/fuzz_hsdescv3.c
+++ b/src/test/fuzz/fuzz_hsdescv3.c
@@ -4,14 +4,14 @@
 #define ROUTERPARSE_PRIVATE
 #define HS_DESCRIPTOR_PRIVATE
 
-#include "or.h"
-#include "ed25519_cert.h" /* Trunnel interface. */
-#include "crypto_ed25519.h"
-#include "hs_descriptor.h"
-#include "routerparse.h"
-#include "util.h"
+#include "or/or.h"
+#include "trunnel/ed25519_cert.h" /* Trunnel interface. */
+#include "common/crypto_ed25519.h"
+#include "or/hs_descriptor.h"
+#include "or/routerparse.h"
+#include "common/util.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_http.c b/src/test/fuzz/fuzz_http.c
index 99e3102c5..a5be26df4 100644
--- a/src/test/fuzz/fuzz_http.c
+++ b/src/test/fuzz/fuzz_http.c
@@ -6,17 +6,17 @@
 #define BUFFERS_PRIVATE
 #define DIRECTORY_PRIVATE
 
-#include "or.h"
-#include "backtrace.h"
-#include "buffers.h"
-#include "config.h"
-#include "connection.h"
-#include "directory.h"
-#include "torlog.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/directory.h"
+#include "common/torlog.h"
 
-#include "dir_connection_st.h"
+#include "or/dir_connection_st.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_connection_write_to_buf_impl_(const char *string, size_t len,
diff --git a/src/test/fuzz/fuzz_http_connect.c b/src/test/fuzz/fuzz_http_connect.c
index d1db654df..664007502 100644
--- a/src/test/fuzz/fuzz_http_connect.c
+++ b/src/test/fuzz/fuzz_http_connect.c
@@ -6,19 +6,19 @@
 #define BUFFERS_PRIVATE
 #define CONNECTION_EDGE_PRIVATE
 
-#include "or.h"
-#include "backtrace.h"
-#include "buffers.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "proto_socks.h"
-#include "torlog.h"
-
-#include "entry_connection_st.h"
-#include "socks_request_st.h"
-
-#include "fuzzing.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/proto_socks.h"
+#include "common/torlog.h"
+
+#include "or/entry_connection_st.h"
+#include "or/socks_request_st.h"
+
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_connection_write_to_buf_impl_(const char *string, size_t len,
diff --git a/src/test/fuzz/fuzz_iptsv2.c b/src/test/fuzz/fuzz_iptsv2.c
index 5a44ca5a9..7bf4d1282 100644
--- a/src/test/fuzz/fuzz_iptsv2.c
+++ b/src/test/fuzz/fuzz_iptsv2.c
@@ -1,13 +1,13 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "rendcommon.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/rendcommon.h"
 
-#include "rend_service_descriptor_st.h"
+#include "or/rend_service_descriptor_st.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_microdesc.c b/src/test/fuzz/fuzz_microdesc.c
index 02fde6c37..74e0ef4f4 100644
--- a/src/test/fuzz/fuzz_microdesc.c
+++ b/src/test/fuzz/fuzz_microdesc.c
@@ -1,10 +1,10 @@
 /* Copyright (c) 2016-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "microdesc.h"
-#include "fuzzing.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "or/microdesc.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzz_vrs.c b/src/test/fuzz/fuzz_vrs.c
index 3e47c46d4..8126f8e48 100644
--- a/src/test/fuzz/fuzz_vrs.c
+++ b/src/test/fuzz/fuzz_vrs.c
@@ -2,16 +2,16 @@
 /* See LICENSE for licensing information */
 #define ROUTERPARSE_PRIVATE
 #define NETWORKSTATUS_PRIVATE
-#include "or.h"
-#include "routerparse.h"
-#include "memarea.h"
-#include "microdesc.h"
-#include "networkstatus.h"
+#include "or/or.h"
+#include "or/routerparse.h"
+#include "common/memarea.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
 
-#include "networkstatus_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/networkstatus_st.h"
+#include "or/vote_routerstatus_st.h"
 
-#include "fuzzing.h"
+#include "test/fuzz/fuzzing.h"
 
 static void
 mock_dump_desc__nodump(const char *desc, const char *type)
diff --git a/src/test/fuzz/fuzzing_common.c b/src/test/fuzz/fuzzing_common.c
index 4111be598..b2fc85a49 100644
--- a/src/test/fuzz/fuzzing_common.c
+++ b/src/test/fuzz/fuzzing_common.c
@@ -2,12 +2,12 @@
 /* See LICENSE for licensing information */
 #define CRYPTO_ED25519_PRIVATE
 #include "orconfig.h"
-#include "or.h"
-#include "backtrace.h"
-#include "config.h"
-#include "fuzzing.h"
-#include "crypto.h"
-#include "crypto_ed25519.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "or/config.h"
+#include "test/fuzz/fuzzing.h"
+#include "common/crypto.h"
+#include "common/crypto_ed25519.h"
 
 static or_options_t *mock_options = NULL;
 static const or_options_t *
diff --git a/src/test/hs_test_helpers.c b/src/test/hs_test_helpers.c
index 0b79004e2..ea12970b9 100644
--- a/src/test/hs_test_helpers.c
+++ b/src/test/hs_test_helpers.c
@@ -1,13 +1,13 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "crypto_ed25519.h"
-#include "test.h"
-#include "torcert.h"
+#include "or/or.h"
+#include "common/crypto_ed25519.h"
+#include "test/test.h"
+#include "or/torcert.h"
 
-#include "hs_common.h"
-#include "hs_test_helpers.h"
+#include "or/hs_common.h"
+#include "test/hs_test_helpers.h"
 
 hs_desc_intro_point_t *
 hs_helper_build_intro_point(const ed25519_keypair_t *signing_kp, time_t now,
diff --git a/src/test/hs_test_helpers.h b/src/test/hs_test_helpers.h
index d1bb30c16..5c0262207 100644
--- a/src/test/hs_test_helpers.h
+++ b/src/test/hs_test_helpers.h
@@ -4,8 +4,8 @@
 #ifndef TOR_HS_TEST_HELPERS_H
 #define TOR_HS_TEST_HELPERS_H
 
-#include "ed25519_cert.h"
-#include "hs_descriptor.h"
+#include "trunnel/ed25519_cert.h"
+#include "or/hs_descriptor.h"
 
 /* Set of functions to help build and test descriptors. */
 hs_desc_intro_point_t *hs_helper_build_intro_point(
diff --git a/src/test/log_test_helpers.c b/src/test/log_test_helpers.c
index 7a4412c2b..03429b72c 100644
--- a/src/test/log_test_helpers.c
+++ b/src/test/log_test_helpers.c
@@ -1,8 +1,8 @@
 /* Copyright (c) 2015-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 #define LOG_PRIVATE
-#include "torlog.h"
-#include "log_test_helpers.h"
+#include "common/torlog.h"
+#include "test/log_test_helpers.h"
 
 /**
  * \file log_test_helpers.c
diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h
index 8125b1c6c..7c3850452 100644
--- a/src/test/log_test_helpers.h
+++ b/src/test/log_test_helpers.h
@@ -1,7 +1,7 @@
 /* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 
 #ifndef TOR_LOG_TEST_HELPERS_H
 #define TOR_LOG_TEST_HELPERS_H
diff --git a/src/test/rend_test_helpers.c b/src/test/rend_test_helpers.c
index 284462961..6f0c1c121 100644
--- a/src/test/rend_test_helpers.c
+++ b/src/test/rend_test_helpers.c
@@ -1,15 +1,15 @@
 /* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "crypto_rand.h"
-#include "test.h"
-#include "rendcommon.h"
-#include "rend_test_helpers.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "test/test.h"
+#include "or/rendcommon.h"
+#include "test/rend_test_helpers.h"
 
-#include "extend_info_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
+#include "or/extend_info_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
 
 void
 generate_desc(int time_diff, rend_encoded_v2_service_descriptor_t **desc,
diff --git a/src/test/rend_test_helpers.h b/src/test/rend_test_helpers.h
index 13846acd4..aca675b2a 100644
--- a/src/test/rend_test_helpers.h
+++ b/src/test/rend_test_helpers.h
@@ -1,7 +1,7 @@
 /* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 
 #ifndef TOR_REND_TEST_HELPERS_H
 #define TOR_REND_TEST_HELPERS_H
diff --git a/src/test/test-memwipe.c b/src/test/test-memwipe.c
index 452a44014..a8326aa67 100644
--- a/src/test/test-memwipe.c
+++ b/src/test/test-memwipe.c
@@ -7,9 +7,9 @@
 #include <sys/types.h>
 #include <stdlib.h>
 
-#include "crypto_util.h"
-#include "compat.h"
-#include "util.h"
+#include "common/crypto_util.h"
+#include "common/compat.h"
+#include "common/util.h"
 
 static unsigned fill_a_buffer_memset(void) __attribute__((noinline));
 static unsigned fill_a_buffer_memwipe(void) __attribute__((noinline));
diff --git a/src/test/test-timers.c b/src/test/test-timers.c
index 6636869af..1953ea5e3 100644
--- a/src/test/test-timers.c
+++ b/src/test/test-timers.c
@@ -7,11 +7,11 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "compat.h"
-#include "compat_libevent.h"
-#include "crypto_rand.h"
-#include "timers.h"
-#include "util.h"
+#include "common/compat.h"
+#include "common/compat_libevent.h"
+#include "common/crypto_rand.h"
+#include "common/timers.h"
+#include "common/util.h"
 
 #define N_TIMERS 1000
 #define MAX_DURATION 30
diff --git a/src/test/test.c b/src/test/test.c
index 8ae172538..98f554b31 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -9,7 +9,7 @@
  **/
 
 #include "orconfig.h"
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 
 #include <stdio.h>
 #ifdef HAVE_FCNTL_H
@@ -39,34 +39,34 @@
 long int lround(double x);
 double fabs(double x);
 
-#include "or.h"
-#include "backtrace.h"
-#include "buffers.h"
-#include "circuitlist.h"
-#include "circuitstats.h"
-#include "compress.h"
-#include "config.h"
-#include "connection_edge.h"
-#include "rendcommon.h"
-#include "rendcache.h"
-#include "test.h"
-#include "main.h"
-#include "memarea.h"
-#include "onion.h"
-#include "onion_ntor.h"
-#include "onion_fast.h"
-#include "onion_tap.h"
-#include "policies.h"
-#include "rephist.h"
-#include "routerparse.h"
-#include "statefile.h"
-#include "crypto_curve25519.h"
-
-#include "extend_info_st.h"
-#include "or_circuit_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
+#include "or/or.h"
+#include "common/backtrace.h"
+#include "common/buffers.h"
+#include "or/circuitlist.h"
+#include "or/circuitstats.h"
+#include "common/compress.h"
+#include "or/config.h"
+#include "or/connection_edge.h"
+#include "or/rendcommon.h"
+#include "or/rendcache.h"
+#include "test/test.h"
+#include "or/main.h"
+#include "common/memarea.h"
+#include "or/onion.h"
+#include "or/onion_ntor.h"
+#include "or/onion_fast.h"
+#include "or/onion_tap.h"
+#include "or/policies.h"
+#include "or/rephist.h"
+#include "or/routerparse.h"
+#include "or/statefile.h"
+#include "common/crypto_curve25519.h"
+
+#include "or/extend_info_st.h"
+#include "or/or_circuit_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
 
 /** Run unit tests for the onion handshake code. */
 static void
diff --git a/src/test/test.h b/src/test/test.h
index 7cbebcb6a..29e654469 100644
--- a/src/test/test.h
+++ b/src/test/test.h
@@ -13,7 +13,7 @@
 
 #define DEBUG_SMARTLIST 1
 
-#include "compat.h"
+#include "common/compat.h"
 #include "tinytest.h"
 #define TT_EXIT_TEST_FUNCTION STMT_BEGIN goto done; STMT_END
 #include "tinytest_macros.h"
diff --git a/src/test/test_accounting.c b/src/test/test_accounting.c
index 9e16c09ed..ce8e08f7c 100644
--- a/src/test/test_accounting.c
+++ b/src/test/test_accounting.c
@@ -1,13 +1,13 @@
 /* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 #define HIBERNATE_PRIVATE
-#include "hibernate.h"
-#include "config.h"
+#include "or/hibernate.h"
+#include "or/config.h"
 #define STATEFILE_PRIVATE
-#include "statefile.h"
+#include "or/statefile.h"
 
 #define NS_MODULE accounting
 
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index b61a9478c..6778fde97 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -5,11 +5,11 @@
 
 #define ADDRESSMAP_PRIVATE
 #include "orconfig.h"
-#include "or.h"
-#include "crypto_rand.h"
-#include "test.h"
-#include "addressmap.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "test/test.h"
+#include "or/addressmap.h"
+#include "test/log_test_helpers.h"
 
 /** Mocking replacement: only handles localhost. */
 static int
diff --git a/src/test/test_address.c b/src/test/test_address.c
index 1a0f16353..38a5310ed 100644
--- a/src/test/test_address.c
+++ b/src/test/test_address.c
@@ -23,10 +23,10 @@
 #include <net/if.h>
 #endif /* defined(HAVE_IFCONF_TO_SMARTLIST) */
 
-#include "or.h"
-#include "address.h"
-#include "test.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 
 /** Return 1 iff <b>sockaddr1</b> and <b>sockaddr2</b> represent
  * the same IP address and port combination. Otherwise, return 0.
diff --git a/src/test/test_address_set.c b/src/test/test_address_set.c
index 0ed9987a2..1df7b3442 100644
--- a/src/test/test_address_set.c
+++ b/src/test/test_address_set.c
@@ -1,21 +1,21 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "crypto_rand.h"
-#include "address_set.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "routerlist.h"
-#include "torcert.h"
-
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "common/address_set.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/routerlist.h"
+#include "or/torcert.h"
+
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
 
 static networkstatus_t *dummy_ns = NULL;
 static networkstatus_t *
diff --git a/src/test/test_bridges.c b/src/test/test_bridges.c
index c44f791e0..c1de731b2 100644
--- a/src/test/test_bridges.c
+++ b/src/test/test_bridges.c
@@ -11,16 +11,16 @@
 
 #include <stdbool.h>
 
-#include "or.h"
-#include "address.h"
-#include "bridges.h"
-#include "config.h"
-#include "container.h"
-#include "transports.h"
-#include "util.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "or/bridges.h"
+#include "or/config.h"
+#include "common/container.h"
+#include "or/transports.h"
+#include "common/util.h"
 
 /* Test suite stuff */
-#include "test.h"
+#include "test/test.h"
 
 /**
  * A mocked transport_t, constructed via mock_transport_get_by_name().
diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c
index 9f16f8f50..d2d167ac3 100644
--- a/src/test/test_bt_cl.c
+++ b/src/test/test_bt_cl.c
@@ -7,10 +7,10 @@
 
 /* To prevent 'assert' from going away. */
 #undef TOR_COVERAGE
-#include "or.h"
-#include "util.h"
-#include "backtrace.h"
-#include "torlog.h"
+#include "or/or.h"
+#include "common/util.h"
+#include "common/backtrace.h"
+#include "common/torlog.h"
 
 /* -1: no crash.
  *  0: crash with a segmentation fault.
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index 0828e720f..cd4c9d0ae 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -5,13 +5,13 @@
 
 #define BUFFERS_PRIVATE
 #define PROTO_HTTP_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "buffers_tls.h"
-#include "crypto_rand.h"
-#include "proto_http.h"
-#include "proto_socks.h"
-#include "test.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "common/buffers_tls.h"
+#include "common/crypto_rand.h"
+#include "or/proto_http.h"
+#include "or/proto_socks.h"
+#include "test/test.h"
 
 /** Run unit tests for buffers.c */
 static void
diff --git a/src/test/test_bwmgt.c b/src/test/test_bwmgt.c
index 268917005..90c1b457d 100644
--- a/src/test/test_bwmgt.c
+++ b/src/test/test_bwmgt.c
@@ -8,10 +8,10 @@
 
 #define TOKEN_BUCKET_PRIVATE
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
-#include "token_bucket.h"
+#include "common/token_bucket.h"
 
 // an imaginary time, in timestamp units. Chosen so it will roll over.
 static const uint32_t START_TS = UINT32_MAX-10;
diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c
index 4b73aa9b5..685b6efc3 100644
--- a/src/test/test_cell_formats.c
+++ b/src/test/test_cell_formats.c
@@ -7,23 +7,23 @@
 
 #define CONNECTION_EDGE_PRIVATE
 #define RELAY_PRIVATE
-#include "or.h"
-#include "channel.h"
-#include "connection_edge.h"
-#include "connection_or.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "onion.h"
-#include "onion_tap.h"
-#include "onion_fast.h"
-#include "onion_ntor.h"
-#include "relay.h"
-
-#include "cell_st.h"
-#include "cell_queue_st.h"
-#include "var_cell_st.h"
-
-#include "test.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/connection_edge.h"
+#include "or/connection_or.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/onion.h"
+#include "or/onion_tap.h"
+#include "or/onion_fast.h"
+#include "or/onion_ntor.h"
+#include "or/relay.h"
+
+#include "or/cell_st.h"
+#include "or/cell_queue_st.h"
+#include "or/var_cell_st.h"
+
+#include "test/test.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/test/test_cell_queue.c b/src/test/test_cell_queue.c
index 7662cad10..3369511af 100644
--- a/src/test/test_cell_queue.c
+++ b/src/test/test_cell_queue.c
@@ -3,15 +3,15 @@
 
 #define CIRCUITLIST_PRIVATE
 #define RELAY_PRIVATE
-#include "or.h"
-#include "circuitlist.h"
-#include "relay.h"
-#include "test.h"
-
-#include "cell_st.h"
-#include "cell_queue_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/circuitlist.h"
+#include "or/relay.h"
+#include "test/test.h"
+
+#include "or/cell_st.h"
+#include "or/cell_queue_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 static void
 test_cq_manip(void *arg)
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index b7f7653db..5b30c7112 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -3,33 +3,33 @@
 
 #define TOR_CHANNEL_INTERNAL_
 #define CHANNEL_PRIVATE_
-#include "or.h"
-#include "channel.h"
+#include "or/or.h"
+#include "or/channel.h"
 /* For channel_note_destroy_not_pending */
 #define CIRCUITLIST_PRIVATE
-#include "circuitlist.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
+#include "or/circuitlist.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
 /* For var_cell_free */
-#include "connection_or.h"
-#include "crypto_rand.h"
+#include "or/connection_or.h"
+#include "common/crypto_rand.h"
 /* For packed_cell stuff */
 #define RELAY_PRIVATE
-#include "relay.h"
+#include "or/relay.h"
 /* For init/free stuff */
-#include "scheduler.h"
-#include "networkstatus.h"
+#include "or/scheduler.h"
+#include "or/networkstatus.h"
 
-#include "cell_st.h"
-#include "networkstatus_st.h"
-#include "origin_circuit_st.h"
-#include "routerstatus_st.h"
-#include "var_cell_st.h"
+#include "or/cell_st.h"
+#include "or/networkstatus_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerstatus_st.h"
+#include "or/var_cell_st.h"
 
 /* Test suite stuff */
-#include "log_test_helpers.h"
-#include "test.h"
-#include "fakechans.h"
+#include "test/log_test_helpers.h"
+#include "test/test.h"
+#include "test/fakechans.h"
 
 static int test_chan_accept_cells = 0;
 static int test_chan_fixed_cells_recved = 0;
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c
index 630d4ba60..b48bf0f16 100644
--- a/src/test/test_channelpadding.c
+++ b/src/test/test_channelpadding.c
@@ -5,25 +5,25 @@
 #define MAIN_PRIVATE
 #define NETWORKSTATUS_PRIVATE
 #define TOR_TIMERS_PRIVATE
-#include "or.h"
-#include "test.h"
-#include "testsupport.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "channelpadding.h"
-#include "compat_libevent.h"
-#include "config.h"
-#include "compat_time.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "log_test_helpers.h"
-
-#include "cell_st.h"
-#include "networkstatus_st.h"
-#include "or_connection_st.h"
-#include "routerstatus_st.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/testsupport.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/channelpadding.h"
+#include "common/compat_libevent.h"
+#include "or/config.h"
+#include "common/compat_time.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "test/log_test_helpers.h"
+
+#include "or/cell_st.h"
+#include "or/networkstatus_st.h"
+#include "or/or_connection_st.h"
+#include "or/routerstatus_st.h"
 
 int channelpadding_get_netflow_inactive_timeout_ms(channel_t *chan);
 int64_t channelpadding_compute_time_until_pad_for_netflow(channel_t *chan);
diff --git a/src/test/test_channeltls.c b/src/test/test_channeltls.c
index b6d2746aa..08fec2de2 100644
--- a/src/test/test_channeltls.c
+++ b/src/test/test_channeltls.c
@@ -6,22 +6,22 @@
 #include <math.h>
 
 #define TOR_CHANNEL_INTERNAL_
-#include "or.h"
-#include "address.h"
-#include "buffers.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "connection_or.h"
-#include "config.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "common/buffers.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/connection_or.h"
+#include "or/config.h"
 /* For init/free stuff */
-#include "scheduler.h"
-#include "tortls.h"
+#include "or/scheduler.h"
+#include "common/tortls.h"
 
-#include "or_connection_st.h"
+#include "or/or_connection_st.h"
 
 /* Test suite stuff */
-#include "test.h"
-#include "fakechans.h"
+#include "test/test.h"
+#include "test/fakechans.h"
 
 /* The channeltls unit tests */
 static void test_channeltls_create(void *arg);
diff --git a/src/test/test_checkdir.c b/src/test/test_checkdir.c
index c2a44d127..d0c899a07 100644
--- a/src/test/test_checkdir.c
+++ b/src/test/test_checkdir.c
@@ -2,7 +2,7 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
 #ifdef _WIN32
 #include <direct.h>
@@ -10,9 +10,9 @@
 #include <dirent.h>
 #endif
 
-#include "config.h"
-#include "test.h"
-#include "util.h"
+#include "or/config.h"
+#include "test/test.h"
+#include "common/util.h"
 
 #ifdef _WIN32
 #define mkdir(a,b) mkdir(a)
diff --git a/src/test/test_circuitbuild.c b/src/test/test_circuitbuild.c
index 1dde24ab9..d17a04614 100644
--- a/src/test/test_circuitbuild.c
+++ b/src/test/test_circuitbuild.c
@@ -5,14 +5,14 @@
 
 #define CIRCUITBUILD_PRIVATE
 
-#include "or.h"
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-#include "config.h"
-#include "circuitbuild.h"
-
-#include "extend_info_st.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+#include "or/config.h"
+#include "or/circuitbuild.h"
+
+#include "or/extend_info_st.h"
 
 /* Dummy nodes smartlist for testing */
 static smartlist_t dummy_nodes;
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 6f8f23ef1..96de2eed0 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -5,17 +5,17 @@
 #define CIRCUITBUILD_PRIVATE
 #define CIRCUITLIST_PRIVATE
 #define HS_CIRCUITMAP_PRIVATE
-#include "or.h"
-#include "channel.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuitmux_ewma.h"
-#include "hs_circuitmap.h"
-#include "test.h"
-#include "log_test_helpers.h"
-
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuitmux_ewma.h"
+#include "or/hs_circuitmap.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
+
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 static channel_t *
 new_fake_channel(void)
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index 4ed92f20f..8a89927df 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -5,15 +5,15 @@
 #define CIRCUITMUX_PRIVATE
 #define CIRCUITMUX_EWMA_PRIVATE
 #define RELAY_PRIVATE
-#include "or.h"
-#include "channel.h"
-#include "circuitmux.h"
-#include "circuitmux_ewma.h"
-#include "relay.h"
-#include "scheduler.h"
-#include "test.h"
-
-#include "destroy_cell_queue_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/circuitmux.h"
+#include "or/circuitmux_ewma.h"
+#include "or/relay.h"
+#include "or/scheduler.h"
+#include "test/test.h"
+
+#include "or/destroy_cell_queue_st.h"
 
 /* XXXX duplicated function from test_circuitlist.c */
 static channel_t *
diff --git a/src/test/test_circuitstats.c b/src/test/test_circuitstats.c
index 79cf126fb..94ba6ed44 100644
--- a/src/test/test_circuitstats.c
+++ b/src/test/test_circuitstats.c
@@ -6,21 +6,21 @@
 #define CIRCUITLIST_PRIVATE
 #define CHANNEL_PRIVATE_
 
-#include "or.h"
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-#include "config.h"
-#include "circuitlist.h"
-#include "circuitbuild.h"
-#include "circuitstats.h"
-#include "circuituse.h"
-#include "channel.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "extend_info_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+#include "or/config.h"
+#include "or/circuitlist.h"
+#include "or/circuitbuild.h"
+#include "or/circuitstats.h"
+#include "or/circuituse.h"
+#include "or/channel.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/extend_info_st.h"
+#include "or/origin_circuit_st.h"
 
 void test_circuitstats_timeout(void *arg);
 void test_circuitstats_hoplen(void *arg);
diff --git a/src/test/test_circuituse.c b/src/test/test_circuituse.c
index 3417d2e9e..2524e43c6 100644
--- a/src/test/test_circuituse.c
+++ b/src/test/test_circuituse.c
@@ -5,17 +5,17 @@
 
 #define CIRCUITLIST_PRIVATE
 
-#include "or.h"
-#include "test.h"
-#include "test_helpers.h"
-#include "config.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "circuitbuild.h"
-#include "nodelist.h"
-
-#include "cpath_build_state_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "or/config.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "or/circuitbuild.h"
+#include "or/nodelist.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/origin_circuit_st.h"
 
 static void
 test_circuit_is_available_for_use_ret_false_when_marked_for_close(void *arg)
diff --git a/src/test/test_compat_libevent.c b/src/test/test_compat_libevent.c
index 292148d42..8e5913785 100644
--- a/src/test/test_compat_libevent.c
+++ b/src/test/test_compat_libevent.c
@@ -3,15 +3,15 @@
 
 #define COMPAT_LIBEVENT_PRIVATE
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
-#include "test.h"
+#include "test/test.h"
 
-#include "compat_libevent.h"
+#include "common/compat_libevent.h"
 
 #include <event2/event.h>
 
-#include "log_test_helpers.h"
+#include "test/log_test_helpers.h"
 
 #define NS_MODULE compat_libevent
 
diff --git a/src/test/test_config.c b/src/test/test_config.c
index a0a015a49..177368c65 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -8,45 +8,45 @@
 #define CONFIG_PRIVATE
 #define PT_PRIVATE
 #define ROUTERSET_PRIVATE
-#include "or.h"
-#include "address.h"
-#include "addressmap.h"
-#include "bridges.h"
-#include "circuitmux_ewma.h"
-#include "circuitbuild.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "test.h"
-#include "util.h"
-#include "connection_or.h"
-#include "control.h"
-#include "cpuworker.h"
-#include "dirserv.h"
-#include "dirauth/dirvote.h"
-#include "dns.h"
-#include "entrynodes.h"
-#include "transports.h"
-#include "ext_orport.h"
-#include "geoip.h"
-#include "hibernate.h"
-#include "main.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "rendclient.h"
-#include "rendservice.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "statefile.h"
-
-#include "test_helpers.h"
-
-#include "dir_server_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
+#include "or/or.h"
+#include "common/address.h"
+#include "or/addressmap.h"
+#include "or/bridges.h"
+#include "or/circuitmux_ewma.h"
+#include "or/circuitbuild.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "test/test.h"
+#include "common/util.h"
+#include "or/connection_or.h"
+#include "or/control.h"
+#include "or/cpuworker.h"
+#include "or/dirserv.h"
+#include "or/dirauth/dirvote.h"
+#include "or/dns.h"
+#include "or/entrynodes.h"
+#include "or/transports.h"
+#include "or/ext_orport.h"
+#include "or/geoip.h"
+#include "or/hibernate.h"
+#include "or/main.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/rendclient.h"
+#include "or/rendservice.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/statefile.h"
+
+#include "test/test_helpers.h"
+
+#include "or/dir_server_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
 
 static void
 test_config_addressmap(void *arg)
diff --git a/src/test/test_connection.c b/src/test/test_connection.c
index db273e3ec..674e2284e 100644
--- a/src/test/test_connection.c
+++ b/src/test/test_connection.c
@@ -7,29 +7,29 @@
 #define MAIN_PRIVATE
 #define CONNECTION_OR_PRIVATE
 
-#include "or.h"
-#include "test.h"
-
-#include "connection.h"
-#include "connection_edge.h"
-#include "hs_common.h"
-#include "main.h"
-#include "microdesc.h"
-#include "nodelist.h"
-#include "networkstatus.h"
-#include "rendcache.h"
-#include "directory.h"
-#include "connection_or.h"
-
-#include "test_connection.h"
-#include "test_helpers.h"
-
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "node_st.h"
-#include "or_connection_st.h"
-#include "routerinfo_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "test/test.h"
+
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/hs_common.h"
+#include "or/main.h"
+#include "or/microdesc.h"
+#include "or/nodelist.h"
+#include "or/networkstatus.h"
+#include "or/rendcache.h"
+#include "or/directory.h"
+#include "or/connection_or.h"
+
+#include "test/test_connection.h"
+#include "test/test_helpers.h"
+
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/node_st.h"
+#include "or/or_connection_st.h"
+#include "or/routerinfo_st.h"
+#include "or/socks_request_st.h"
 
 static void * test_conn_get_basic_setup(const struct testcase_t *tc);
 static int test_conn_get_basic_teardown(const struct testcase_t *tc,
diff --git a/src/test/test_conscache.c b/src/test/test_conscache.c
index fb5e4c842..e3a617fe3 100644
--- a/src/test/test_conscache.c
+++ b/src/test/test_conscache.c
@@ -1,10 +1,10 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "config.h"
-#include "conscache.h"
-#include "test.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/conscache.h"
+#include "test/test.h"
 
 #ifdef HAVE_UTIME_H
 #include <utime.h>
diff --git a/src/test/test_consdiff.c b/src/test/test_consdiff.c
index cb0203679..e293866f3 100644
--- a/src/test/test_consdiff.c
+++ b/src/test/test_consdiff.c
@@ -4,12 +4,12 @@
 
 #define CONSDIFF_PRIVATE
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
-#include "consdiff.h"
-#include "memarea.h"
-#include "log_test_helpers.h"
+#include "or/consdiff.h"
+#include "common/memarea.h"
+#include "test/log_test_helpers.h"
 
 #define tt_str_eq_line(a,b) \
   tt_assert(line_str_eq((b),(a)))
diff --git a/src/test/test_consdiffmgr.c b/src/test/test_consdiffmgr.c
index a8f862fdb..c4b89ddf0 100644
--- a/src/test/test_consdiffmgr.c
+++ b/src/test/test_consdiffmgr.c
@@ -3,21 +3,21 @@
 
 #define CONSDIFFMGR_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "conscache.h"
-#include "consdiff.h"
-#include "consdiffmgr.h"
-#include "cpuworker.h"
-#include "crypto_rand.h"
-#include "networkstatus.h"
-#include "routerparse.h"
-#include "workqueue.h"
-
-#include "networkstatus_st.h"
-
-#include "test.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/conscache.h"
+#include "or/consdiff.h"
+#include "or/consdiffmgr.h"
+#include "or/cpuworker.h"
+#include "common/crypto_rand.h"
+#include "or/networkstatus.h"
+#include "or/routerparse.h"
+#include "common/workqueue.h"
+
+#include "or/networkstatus_st.h"
+
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 
 // ============================== Setup/teardown the consdiffmgr
 // These functions get run before/after each test in this module
diff --git a/src/test/test_containers.c b/src/test/test_containers.c
index 72a02863f..1d5ee4fc9 100644
--- a/src/test/test_containers.c
+++ b/src/test/test_containers.c
@@ -4,10 +4,10 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
-#include "crypto_rand.h"
-#include "fp_pair.h"
-#include "test.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "or/fp_pair.h"
+#include "test/test.h"
 
 /** Helper: return a tristate based on comparing the strings in *<b>a</b> and
  * *<b>b</b>. */
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index 4044a841e..de8e4630c 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -2,22 +2,22 @@
 /* See LICENSE for licensing information */
 
 #define CONTROL_PRIVATE
-#include "or.h"
-#include "bridges.h"
-#include "control.h"
-#include "entrynodes.h"
-#include "hs_common.h"
-#include "networkstatus.h"
-#include "rendservice.h"
-#include "routerlist.h"
-#include "nodelist.h"
-#include "test.h"
-#include "test_helpers.h"
-
-#include "control_connection_st.h"
-#include "download_status_st.h"
-#include "microdesc_st.h"
-#include "node_st.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/control.h"
+#include "or/entrynodes.h"
+#include "or/hs_common.h"
+#include "or/networkstatus.h"
+#include "or/rendservice.h"
+#include "or/routerlist.h"
+#include "or/nodelist.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+
+#include "or/control_connection_st.h"
+#include "or/download_status_st.h"
+#include "or/microdesc_st.h"
+#include "or/node_st.h"
 
 static void
 test_add_onion_helper_keyarg_v3(void *arg)
diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c
index 5f0de3d38..b642a37d2 100644
--- a/src/test/test_controller_events.c
+++ b/src/test/test_controller_events.c
@@ -4,15 +4,15 @@
 #define CONNECTION_PRIVATE
 #define TOR_CHANNEL_INTERNAL_
 #define CONTROL_PRIVATE
-#include "or.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "connection.h"
-#include "control.h"
-#include "test.h"
-
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/connection.h"
+#include "or/control.h"
+#include "test/test.h"
+
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 static void
 add_testing_cell_stats_entry(circuit_t *circ, uint8_t command,
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index ffe4983cd..ed4c0b05f 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -6,14 +6,14 @@
 #include "orconfig.h"
 #define CRYPTO_CURVE25519_PRIVATE
 #define CRYPTO_RAND_PRIVATE
-#include "or.h"
-#include "test.h"
-#include "aes.h"
-#include "util.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/aes.h"
+#include "common/util.h"
 #include "siphash.h"
-#include "crypto_curve25519.h"
-#include "crypto_ed25519.h"
-#include "crypto_rand.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_rand.h"
 #include "ed25519_vectors.inc"
 
 /** Run unit tests for Diffie-Hellman functionality. */
diff --git a/src/test/test_crypto_openssl.c b/src/test/test_crypto_openssl.c
index 910d5cbe8..f33ed58d4 100644
--- a/src/test/test_crypto_openssl.c
+++ b/src/test/test_crypto_openssl.c
@@ -7,15 +7,15 @@
 
 #define CRYPTO_RAND_PRIVATE
 
-#include "crypto_rand.h"
-#include "util.h"
-#include "util_format.h"
-#include "compat.h"
-#include "test.h"
+#include "common/crypto_rand.h"
+#include "common/util.h"
+#include "common/util_format.h"
+#include "common/compat.h"
+#include "test/test.h"
 
 #include <openssl/evp.h>
 #include <openssl/rand.h>
-#include "compat_openssl.h"
+#include "common/compat_openssl.h"
 
 /* Test for rectifying openssl RAND engine. */
 static void
diff --git a/src/test/test_crypto_slow.c b/src/test/test_crypto_slow.c
index 137953d45..c15d8deb9 100644
--- a/src/test/test_crypto_slow.c
+++ b/src/test/test_crypto_slow.c
@@ -5,11 +5,11 @@
 
 #include "orconfig.h"
 #define CRYPTO_S2K_PRIVATE
-#include "or.h"
-#include "test.h"
-#include "crypto_s2k.h"
-#include "crypto_pwbox.h"
-#include "crypto_rand.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/crypto_s2k.h"
+#include "common/crypto_pwbox.h"
+#include "common/crypto_rand.h"
 
 #if defined(HAVE_LIBSCRYPT_H) && defined(HAVE_LIBSCRYPT_SCRYPT)
 #define HAVE_LIBSCRYPT
diff --git a/src/test/test_data.c b/src/test/test_data.c
index 6a6979fc6..be8153258 100644
--- a/src/test/test_data.c
+++ b/src/test/test_data.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "test.h"
+#include "test/test.h"
 
 /* Our unit test expect that the AUTHORITY_CERT_* public keys will sort
  * in this order. */
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index d6939ede3..56293b578 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -17,46 +17,46 @@
 #define NETWORKSTATUS_PRIVATE
 #define RELAY_PRIVATE
 
-#include "or.h"
-#include "bridges.h"
-#include "confparse.h"
-#include "config.h"
-#include "control.h"
-#include "crypto_ed25519.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "dirserv.h"
-#include "dirauth/dirvote.h"
-#include "entrynodes.h"
-#include "fp_pair.h"
-#include "hibernate.h"
-#include "memarea.h"
-#include "networkstatus.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "dirauth/shared_random_state.h"
-#include "test.h"
-#include "test_dir_common.h"
-#include "torcert.h"
-#include "relay.h"
-#include "log_test_helpers.h"
-#include "voting_schedule.h"
-
-#include "authority_cert_st.h"
-#include "document_signature_st.h"
-#include "extrainfo_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "ns_detached_signatures_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
-#include "tor_version_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/or.h"
+#include "or/bridges.h"
+#include "or/confparse.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/dirserv.h"
+#include "or/dirauth/dirvote.h"
+#include "or/entrynodes.h"
+#include "or/fp_pair.h"
+#include "or/hibernate.h"
+#include "common/memarea.h"
+#include "or/networkstatus.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/dirauth/shared_random_state.h"
+#include "test/test.h"
+#include "test/test_dir_common.h"
+#include "or/torcert.h"
+#include "or/relay.h"
+#include "test/log_test_helpers.h"
+#include "or/voting_schedule.h"
+
+#include "or/authority_cert_st.h"
+#include "or/document_signature_st.h"
+#include "or/extrainfo_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/ns_detached_signatures_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
+#include "or/tor_version_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
 
 #define NS_MODULE dir
 
diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c
index 7712c1a65..6933800eb 100644
--- a/src/test/test_dir_common.c
+++ b/src/test/test_dir_common.c
@@ -5,21 +5,21 @@
 
 #include "orconfig.h"
 #define DIRVOTE_PRIVATE
-#include "test.h"
-#include "container.h"
-#include "or.h"
-#include "dirauth/dirvote.h"
-#include "nodelist.h"
-#include "routerlist.h"
-#include "test_dir_common.h"
-#include "voting_schedule.h"
+#include "test/test.h"
+#include "common/container.h"
+#include "or/or.h"
+#include "or/dirauth/dirvote.h"
+#include "or/nodelist.h"
+#include "or/routerlist.h"
+#include "test/test_dir_common.h"
+#include "or/voting_schedule.h"
 
-#include "authority_cert_st.h"
-#include "networkstatus_st.h"
-#include "networkstatus_voter_info_st.h"
-#include "routerinfo_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
+#include "or/authority_cert_st.h"
+#include "or/networkstatus_st.h"
+#include "or/networkstatus_voter_info_st.h"
+#include "or/routerinfo_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
 
 void dir_common_setup_vote(networkstatus_t **vote, time_t now);
 networkstatus_t * dir_common_add_rs_and_parse(networkstatus_t *vote,
diff --git a/src/test/test_dir_common.h b/src/test/test_dir_common.h
index d3441205b..7d5f55afe 100644
--- a/src/test/test_dir_common.h
+++ b/src/test/test_dir_common.h
@@ -3,9 +3,9 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "networkstatus.h"
-#include "routerparse.h"
+#include "or/or.h"
+#include "or/networkstatus.h"
+#include "or/routerparse.h"
 
 #define TEST_DIR_ROUTER_ID_1 3
 #define TEST_DIR_ROUTER_ID_2 5
diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c
index 9c2e6b849..fbc14e3d3 100644
--- a/src/test/test_dir_handle_get.c
+++ b/src/test/test_dir_handle_get.c
@@ -9,37 +9,37 @@
 #define CONFIG_PRIVATE
 #define RENDCACHE_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "connection.h"
-#include "consdiffmgr.h"
-#include "directory.h"
-#include "test.h"
-#include "compress.h"
-#include "rendcommon.h"
-#include "rendcache.h"
-#include "router.h"
-#include "routerlist.h"
-#include "rend_test_helpers.h"
-#include "microdesc.h"
-#include "test_helpers.h"
-#include "nodelist.h"
-#include "entrynodes.h"
-#include "routerparse.h"
-#include "networkstatus.h"
-#include "proto_http.h"
-#include "geoip.h"
-#include "dirserv.h"
-#include "dirauth/dirvote.h"
-#include "log_test_helpers.h"
-#include "voting_schedule.h"
-
-#include "dir_connection_st.h"
-#include "dir_server_st.h"
-#include "networkstatus_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "routerinfo_st.h"
-#include "routerlist_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/consdiffmgr.h"
+#include "or/directory.h"
+#include "test/test.h"
+#include "common/compress.h"
+#include "or/rendcommon.h"
+#include "or/rendcache.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "test/rend_test_helpers.h"
+#include "or/microdesc.h"
+#include "test/test_helpers.h"
+#include "or/nodelist.h"
+#include "or/entrynodes.h"
+#include "or/routerparse.h"
+#include "or/networkstatus.h"
+#include "or/proto_http.h"
+#include "or/geoip.h"
+#include "or/dirserv.h"
+#include "or/dirauth/dirvote.h"
+#include "test/log_test_helpers.h"
+#include "or/voting_schedule.h"
+
+#include "or/dir_connection_st.h"
+#include "or/dir_server_st.h"
+#include "or/networkstatus_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerlist_st.h"
 
 #ifdef _WIN32
 /* For mkdir() */
diff --git a/src/test/test_dns.c b/src/test/test_dns.c
index b843aef6b..3bcef0aa7 100644
--- a/src/test/test_dns.c
+++ b/src/test/test_dns.c
@@ -1,17 +1,17 @@
 /* Copyright (c) 2015-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
 #define DNS_PRIVATE
 
-#include "dns.h"
-#include "connection.h"
-#include "router.h"
+#include "or/dns.h"
+#include "or/connection.h"
+#include "or/router.h"
 
-#include "edge_connection_st.h"
-#include "or_circuit_st.h"
+#include "or/edge_connection_st.h"
+#include "or/or_circuit_st.h"
 
 #define NS_MODULE dns
 
diff --git a/src/test/test_dos.c b/src/test/test_dos.c
index bc77bd8cd..7a2a87d32 100644
--- a/src/test/test_dos.c
+++ b/src/test/test_dos.c
@@ -5,23 +5,23 @@
 #define TOR_CHANNEL_INTERNAL_
 #define CIRCUITLIST_PRIVATE
 
-#include "or.h"
-#include "dos.h"
-#include "circuitlist.h"
-#include "crypto_rand.h"
-#include "geoip.h"
-#include "channel.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "routerlist.h"
-
-#include "networkstatus_st.h"
-#include "or_connection_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "or/dos.h"
+#include "or/circuitlist.h"
+#include "common/crypto_rand.h"
+#include "or/geoip.h"
+#include "or/channel.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/routerlist.h"
+
+#include "or/networkstatus_st.h"
+#include "or/or_connection_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 
 static networkstatus_t *dummy_ns = NULL;
 static networkstatus_t *
diff --git a/src/test/test_entryconn.c b/src/test/test_entryconn.c
index 503f311f3..d6ac5e1d3 100644
--- a/src/test/test_entryconn.c
+++ b/src/test/test_entryconn.c
@@ -6,21 +6,21 @@
 #define CONNECTION_PRIVATE
 #define CONNECTION_EDGE_PRIVATE
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
-#include "addressmap.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "nodelist.h"
+#include "or/addressmap.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/nodelist.h"
 
-#include "hs_cache.h"
-#include "rendcache.h"
+#include "or/hs_cache.h"
+#include "or/rendcache.h"
 
-#include "entry_connection_st.h"
-#include "socks_request_st.h"
+#include "or/entry_connection_st.h"
+#include "or/socks_request_st.h"
 
 static void *
 entryconn_rewrite_setup(const struct testcase_t *tc)
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index e36705927..2af9c4a37 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -10,38 +10,38 @@
 #define ROUTERLIST_PRIVATE
 #define DIRECTORY_PRIVATE
 
-#include "or.h"
-#include "test.h"
-
-#include "bridges.h"
-#include "circuitlist.h"
-#include "circuitbuild.h"
-#include "config.h"
-#include "confparse.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "entrynodes.h"
-#include "nodelist.h"
-#include "networkstatus.h"
-#include "policies.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "routerset.h"
-#include "statefile.h"
-#include "util.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "dir_connection_st.h"
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
-
-#include "test_helpers.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "test/test.h"
+
+#include "or/bridges.h"
+#include "or/circuitlist.h"
+#include "or/circuitbuild.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/entrynodes.h"
+#include "or/nodelist.h"
+#include "or/networkstatus.h"
+#include "or/policies.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/routerset.h"
+#include "or/statefile.h"
+#include "common/util.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/dir_connection_st.h"
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
 
 /* TODO:
  * choose_random_entry() test with state set.
diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c
index 5e782c785..64ecd422f 100644
--- a/src/test/test_extorport.c
+++ b/src/test/test_extorport.c
@@ -4,19 +4,19 @@
 #define CONNECTION_PRIVATE
 #define EXT_ORPORT_PRIVATE
 #define MAIN_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "config.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "ext_orport.h"
-#include "main.h"
-
-#include "or_connection_st.h"
-
-#include "test.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/ext_orport.h"
+#include "or/main.h"
+
+#include "or/or_connection_st.h"
+
+#include "test/test.h"
 
 /* Test connection_or_remove_from_ext_or_id_map and
  * connection_or_set_ext_or_identifier */
diff --git a/src/test/test_geoip.c b/src/test/test_geoip.c
index 0711a113e..6951ab185 100644
--- a/src/test/test_geoip.c
+++ b/src/test/test_geoip.c
@@ -8,10 +8,10 @@
 /* These macros pull in declarations for some functions and structures that
  * are typically file-private. */
 #define GEOIP_PRIVATE
-#include "or.h"
-#include "config.h"
-#include "geoip.h"
-#include "test.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/geoip.h"
+#include "test/test.h"
 
   /* Record odd numbered fake-IPs using ipv6, even numbered fake-IPs
    * using ipv4.  Since our fake geoip database is the same between
diff --git a/src/test/test_guardfraction.c b/src/test/test_guardfraction.c
index 169d3e87e..fc451b162 100644
--- a/src/test/test_guardfraction.c
+++ b/src/test/test_guardfraction.c
@@ -6,22 +6,22 @@
 #define NETWORKSTATUS_PRIVATE
 
 #include "orconfig.h"
-#include "or.h"
-#include "config.h"
-#include "dirserv.h"
-#include "container.h"
-#include "entrynodes.h"
-#include "util.h"
-#include "routerparse.h"
-#include "networkstatus.h"
-
-#include "networkstatus_st.h"
-#include "vote_microdesc_hash_st.h"
-#include "vote_routerstatus_st.h"
-
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/dirserv.h"
+#include "common/container.h"
+#include "or/entrynodes.h"
+#include "common/util.h"
+#include "or/routerparse.h"
+#include "or/networkstatus.h"
+
+#include "or/networkstatus_st.h"
+#include "or/vote_microdesc_hash_st.h"
+#include "or/vote_routerstatus_st.h"
+
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
 
 /** Generate a vote_routerstatus_t for a router with identity digest
  * <b>digest_in_hex</b>. */
diff --git a/src/test/test_handles.c b/src/test/test_handles.c
index 44c52fd57..153ac5787 100644
--- a/src/test/test_handles.c
+++ b/src/test/test_handles.c
@@ -2,10 +2,10 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "test.h"
+#include "test/test.h"
 
-#include "util.h"
-#include "handles.h"
+#include "common/util.h"
+#include "common/handles.h"
 
 typedef struct demo_t {
   HANDLE_ENTRY(demo, demo_t);
diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c
index 4d1514db2..f346c15ca 100644
--- a/src/test/test_helpers.c
+++ b/src/test/test_helpers.c
@@ -12,27 +12,27 @@
 #define MAIN_PRIVATE
 
 #include "orconfig.h"
-#include "or.h"
-
-#include "buffers.h"
-#include "config.h"
-#include "confparse.h"
-#include "connection.h"
-#include "crypto_rand.h"
-#include "main.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "routerlist.h"
-
-#include "cell_st.h"
-#include "connection_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "routerlist_st.h"
-
-#include "test.h"
-#include "test_helpers.h"
-#include "test_connection.h"
+#include "or/or.h"
+
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/connection.h"
+#include "common/crypto_rand.h"
+#include "or/main.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/routerlist.h"
+
+#include "or/cell_st.h"
+#include "or/connection_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerlist_st.h"
+
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/test_connection.h"
 
 #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
 DISABLE_GCC_WARNING(overlength-strings)
@@ -40,7 +40,7 @@ DISABLE_GCC_WARNING(overlength-strings)
  * at large. */
 #endif
 #include "test_descriptors.inc"
-#include "circuitlist.h"
+#include "or/circuitlist.h"
 #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
 ENABLE_GCC_WARNING(overlength-strings)
 #endif
diff --git a/src/test/test_helpers.h b/src/test/test_helpers.h
index 7f15be708..c6339d97f 100644
--- a/src/test/test_helpers.h
+++ b/src/test/test_helpers.h
@@ -4,7 +4,7 @@
 #ifndef TOR_TEST_HELPERS_H
 #define TOR_TEST_HELPERS_H
 
-#include "or.h"
+#include "or/or.h"
 
 const char *get_yesterday_date_str(void);
 
diff --git a/src/test/test_hs.c b/src/test/test_hs.c
index 7e14d73c2..166faa892 100644
--- a/src/test/test_hs.c
+++ b/src/test/test_hs.c
@@ -12,22 +12,22 @@
 #define RENDSERVICE_PRIVATE
 #define HS_SERVICE_PRIVATE
 
-#include "or.h"
-#include "test.h"
-#include "control.h"
-#include "config.h"
-#include "hs_common.h"
-#include "rendcommon.h"
-#include "rendservice.h"
-#include "routerset.h"
-#include "circuitbuild.h"
-
-#include "node_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_intro_point_st.h"
-#include "routerinfo_st.h"
-
-#include "test_helpers.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "or/control.h"
+#include "or/config.h"
+#include "or/hs_common.h"
+#include "or/rendcommon.h"
+#include "or/rendservice.h"
+#include "or/routerset.h"
+#include "or/circuitbuild.h"
+
+#include "or/node_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/routerinfo_st.h"
+
+#include "test/test_helpers.h"
 
 /* mock ID digest and longname for node that's in nodelist */
 #define HSDIR_EXIST_ID "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" \
diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c
index a0d2c56d2..ccad3062b 100644
--- a/src/test/test_hs_cache.c
+++ b/src/test/test_hs_cache.c
@@ -10,20 +10,20 @@
 #define DIRECTORY_PRIVATE
 #define HS_CACHE_PRIVATE
 
-#include "ed25519_cert.h"
-#include "hs_cache.h"
-#include "rendcache.h"
-#include "directory.h"
-#include "networkstatus.h"
-#include "connection.h"
-#include "proto_http.h"
-
-#include "dir_connection_st.h"
-#include "networkstatus_st.h"
-
-#include "hs_test_helpers.h"
-#include "test_helpers.h"
-#include "test.h"
+#include "trunnel/ed25519_cert.h"
+#include "or/hs_cache.h"
+#include "or/rendcache.h"
+#include "or/directory.h"
+#include "or/networkstatus.h"
+#include "or/connection.h"
+#include "or/proto_http.h"
+
+#include "or/dir_connection_st.h"
+#include "or/networkstatus_st.h"
+
+#include "test/hs_test_helpers.h"
+#include "test/test_helpers.h"
+#include "test/test.h"
 
 /* Static variable used to encoded the HSDir query. */
 static char query_b64[256];
diff --git a/src/test/test_hs_cell.c b/src/test/test_hs_cell.c
index 90c32c076..f9d25ca09 100644
--- a/src/test/test_hs_cell.c
+++ b/src/test/test_hs_cell.c
@@ -9,18 +9,18 @@
 #define HS_INTROPOINT_PRIVATE
 #define HS_SERVICE_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
 
-#include "crypto_ed25519.h"
-#include "crypto_rand.h"
-#include "hs_cell.h"
-#include "hs_intropoint.h"
-#include "hs_service.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_rand.h"
+#include "or/hs_cell.h"
+#include "or/hs_intropoint.h"
+#include "or/hs_service.h"
 
 /* Trunnel. */
-#include "hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_establish_intro.h"
 
 /** We simulate the creation of an outgoing ESTABLISH_INTRO cell, and then we
  *  parse it from the receiver side. */
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c
index 196d7479b..ebe75d5aa 100644
--- a/src/test/test_hs_client.c
+++ b/src/test/test_hs_client.c
@@ -14,37 +14,37 @@
 #define CIRCUITLIST_PRIVATE
 #define CONNECTION_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-#include "rend_test_helpers.h"
-#include "hs_test_helpers.h"
-
-#include "config.h"
-#include "crypto.h"
-#include "channeltls.h"
-#include "main.h"
-#include "nodelist.h"
-#include "routerset.h"
-
-#include "hs_circuit.h"
-#include "hs_client.h"
-#include "hs_ident.h"
-#include "hs_cache.h"
-#include "circuitlist.h"
-#include "circuitbuild.h"
-#include "connection.h"
-#include "connection_edge.h"
-#include "networkstatus.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "dir_connection_st.h"
-#include "entry_connection_st.h"
-#include "extend_info_st.h"
-#include "networkstatus_st.h"
-#include "origin_circuit_st.h"
-#include "socks_request_st.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+#include "test/rend_test_helpers.h"
+#include "test/hs_test_helpers.h"
+
+#include "or/config.h"
+#include "common/crypto.h"
+#include "or/channeltls.h"
+#include "or/main.h"
+#include "or/nodelist.h"
+#include "or/routerset.h"
+
+#include "or/hs_circuit.h"
+#include "or/hs_client.h"
+#include "or/hs_ident.h"
+#include "or/hs_cache.h"
+#include "or/circuitlist.h"
+#include "or/circuitbuild.h"
+#include "or/connection.h"
+#include "or/connection_edge.h"
+#include "or/networkstatus.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/dir_connection_st.h"
+#include "or/entry_connection_st.h"
+#include "or/extend_info_st.h"
+#include "or/networkstatus_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/socks_request_st.h"
 
 static int
 mock_connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index cb1069aa2..1822d6c21 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -11,33 +11,33 @@
 #define HS_SERVICE_PRIVATE
 #define NODELIST_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-#include "hs_test_helpers.h"
-
-#include "connection_edge.h"
-#include "crypto_rand.h"
-#include "hs_common.h"
-#include "hs_client.h"
-#include "hs_service.h"
-#include "config.h"
-#include "networkstatus.h"
-#include "directory.h"
-#include "dirauth/dirvote.h"
-#include "nodelist.h"
-#include "routerlist.h"
-#include "statefile.h"
-#include "circuitlist.h"
-#include "dirauth/shared_random.h"
-#include "util.h"
-#include "voting_schedule.h"
-
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+#include "test/hs_test_helpers.h"
+
+#include "or/connection_edge.h"
+#include "common/crypto_rand.h"
+#include "or/hs_common.h"
+#include "or/hs_client.h"
+#include "or/hs_service.h"
+#include "or/config.h"
+#include "or/networkstatus.h"
+#include "or/directory.h"
+#include "or/dirauth/dirvote.h"
+#include "or/nodelist.h"
+#include "or/routerlist.h"
+#include "or/statefile.h"
+#include "or/circuitlist.h"
+#include "or/dirauth/shared_random.h"
+#include "common/util.h"
+#include "or/voting_schedule.h"
+
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 /** Test the validation of HS v3 addresses */
 static void
diff --git a/src/test/test_hs_config.c b/src/test/test_hs_config.c
index c3674435f..33ad09313 100644
--- a/src/test/test_hs_config.c
+++ b/src/test/test_hs_config.c
@@ -9,15 +9,15 @@
 #define CONFIG_PRIVATE
 #define HS_SERVICE_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-
-#include "config.h"
-#include "hs_common.h"
-#include "hs_config.h"
-#include "hs_service.h"
-#include "rendservice.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+
+#include "or/config.h"
+#include "or/hs_common.h"
+#include "or/hs_config.h"
+#include "or/hs_service.h"
+#include "or/rendservice.h"
 
 static int
 helper_config_service(const char *conf, int validate_only)
diff --git a/src/test/test_hs_control.c b/src/test/test_hs_control.c
index 424bc9f28..f5beced45 100644
--- a/src/test/test_hs_control.c
+++ b/src/test/test_hs_control.c
@@ -8,18 +8,18 @@
 
 #define CONTROL_PRIVATE
 
-#include "or.h"
-#include "test.h"
-#include "control.h"
-#include "config.h"
-#include "hs_common.h"
-#include "hs_control.h"
-#include "nodelist.h"
-
-#include "node_st.h"
-#include "routerstatus_st.h"
-
-#include "test_helpers.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "or/control.h"
+#include "or/config.h"
+#include "or/hs_common.h"
+#include "or/hs_control.h"
+#include "or/nodelist.h"
+
+#include "or/node_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test_helpers.h"
 
 /* mock ID digest and longname for node that's in nodelist */
 #define HSDIR_EXIST_ID \
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index a7eac59b1..00b25f142 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -8,18 +8,18 @@
 
 #define HS_DESCRIPTOR_PRIVATE
 
-#include "crypto_ed25519.h"
-#include "crypto_digest.h"
-#include "crypto_rand.h"
-#include "ed25519_cert.h"
-#include "or.h"
-#include "hs_descriptor.h"
-#include "test.h"
-#include "torcert.h"
-
-#include "hs_test_helpers.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
+#include "common/crypto_ed25519.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_rand.h"
+#include "trunnel/ed25519_cert.h"
+#include "or/or.h"
+#include "or/hs_descriptor.h"
+#include "test/test.h"
+#include "or/torcert.h"
+
+#include "test/hs_test_helpers.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
 
 #ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
 DISABLE_GCC_WARNING(overlength-strings)
diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c
index e7f49faa6..34e51cba6 100644
--- a/src/test/test_hs_intropoint.c
+++ b/src/test/test_hs_intropoint.c
@@ -11,29 +11,29 @@
 #define RENDSERVICE_PRIVATE
 #define CIRCUITLIST_PRIVATE
 
-#include "test.h"
-#include "log_test_helpers.h"
-#include "crypto_rand.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
+#include "common/crypto_rand.h"
 
-#include "or.h"
-#include "circuitlist.h"
-#include "circuituse.h"
+#include "or/or.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
 #include "ht.h"
-#include "relay.h"
-#include "rendservice.h"
+#include "or/relay.h"
+#include "or/rendservice.h"
 
-#include "hs_cell.h"
-#include "hs_circuitmap.h"
-#include "hs_common.h"
-#include "hs_intropoint.h"
-#include "hs_service.h"
+#include "or/hs_cell.h"
+#include "or/hs_circuitmap.h"
+#include "or/hs_common.h"
+#include "or/hs_intropoint.h"
+#include "or/hs_service.h"
 
-#include "or_circuit_st.h"
+#include "or/or_circuit_st.h"
 
 /* Trunnel. */
-#include "hs/cell_establish_intro.h"
-#include "hs/cell_introduce1.h"
-#include "hs/cell_common.h"
+#include "trunnel/hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_introduce1.h"
+#include "trunnel/hs/cell_common.h"
 
 static size_t
 new_establish_intro_cell(const char *circ_nonce,
diff --git a/src/test/test_hs_ntor.c b/src/test/test_hs_ntor.c
index 8bd5f7fdb..51373af64 100644
--- a/src/test/test_hs_ntor.c
+++ b/src/test/test_hs_ntor.c
@@ -6,11 +6,11 @@
  * \brief Test hidden service ntor functionality.
  */
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
 
-#include "hs_ntor.h"
+#include "or/hs_ntor.h"
 
 /* Test the HS ntor handshake. Simulate the sending of an encrypted INTRODUCE1
  * cell, and verify the proper derivation of decryption keys on the other end.
diff --git a/src/test/test_hs_ntor_cl.c b/src/test/test_hs_ntor_cl.c
index 943d787f0..8c1987772 100644
--- a/src/test/test_hs_ntor_cl.c
+++ b/src/test/test_hs_ntor_cl.c
@@ -13,13 +13,13 @@
 #include <stdlib.h>
 
 #define ONION_NTOR_PRIVATE
-#include "or.h"
-#include "util.h"
-#include "compat.h"
-#include "crypto.h"
-#include "crypto_curve25519.h"
-#include "hs_ntor.h"
-#include "onion_ntor.h"
+#include "or/or.h"
+#include "common/util.h"
+#include "common/compat.h"
+#include "common/crypto.h"
+#include "common/crypto_curve25519.h"
+#include "or/hs_ntor.h"
+#include "or/onion_ntor.h"
 
 #define N_ARGS(n) STMT_BEGIN {                                  \
     if (argc < (n)) {                                           \
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 036745bec..bcf72b454 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -22,46 +22,46 @@
 #define HS_CLIENT_PRIVATE
 #define ROUTERPARSE_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-#include "log_test_helpers.h"
-#include "rend_test_helpers.h"
-#include "hs_test_helpers.h"
-
-#include "or.h"
-#include "config.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "circuituse.h"
-#include "crypto_rand.h"
-#include "dirauth/dirvote.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "relay.h"
-#include "routerparse.h"
-#include "hs_common.h"
-#include "hs_config.h"
-#include "hs_ident.h"
-#include "hs_intropoint.h"
-#include "hs_ntor.h"
-#include "hs_circuit.h"
-#include "hs_service.h"
-#include "hs_client.h"
-#include "main.h"
-#include "rendservice.h"
-#include "statefile.h"
-#include "dirauth/shared_random_state.h"
-#include "voting_schedule.h"
-
-#include "cpath_build_state_st.h"
-#include "crypt_path_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "origin_circuit_st.h"
-#include "routerinfo_st.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+#include "test/log_test_helpers.h"
+#include "test/rend_test_helpers.h"
+#include "test/hs_test_helpers.h"
+
+#include "or/or.h"
+#include "or/config.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/circuituse.h"
+#include "common/crypto_rand.h"
+#include "or/dirauth/dirvote.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/relay.h"
+#include "or/routerparse.h"
+#include "or/hs_common.h"
+#include "or/hs_config.h"
+#include "or/hs_ident.h"
+#include "or/hs_intropoint.h"
+#include "or/hs_ntor.h"
+#include "or/hs_circuit.h"
+#include "or/hs_service.h"
+#include "or/hs_client.h"
+#include "or/main.h"
+#include "or/rendservice.h"
+#include "or/statefile.h"
+#include "or/dirauth/shared_random_state.h"
+#include "or/voting_schedule.h"
+
+#include "or/cpath_build_state_st.h"
+#include "or/crypt_path_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/routerinfo_st.h"
 
 /* Trunnel */
-#include "hs/cell_establish_intro.h"
+#include "trunnel/hs/cell_establish_intro.h"
 
 static networkstatus_t mock_ns;
 
diff --git a/src/test/test_introduce.c b/src/test/test_introduce.c
index 3c53f8107..6ffb22fca 100644
--- a/src/test/test_introduce.c
+++ b/src/test/test_introduce.c
@@ -2,12 +2,12 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "crypto.h"
-#include "or.h"
-#include "test.h"
+#include "common/crypto.h"
+#include "or/or.h"
+#include "test/test.h"
 
 #define RENDSERVICE_PRIVATE
-#include "rendservice.h"
+#include "or/rendservice.h"
 
 static uint8_t v0_test_plaintext[] =
     /* 20 bytes of rendezvous point nickname */
diff --git a/src/test/test_keypin.c b/src/test/test_keypin.c
index c1e74259c..e7e7e6296 100644
--- a/src/test/test_keypin.c
+++ b/src/test/test_keypin.c
@@ -3,11 +3,11 @@
 
 #include "orconfig.h"
 #define KEYPIN_PRIVATE
-#include "or.h"
-#include "keypin.h"
-#include "util.h"
+#include "or/or.h"
+#include "or/keypin.h"
+#include "common/util.h"
 
-#include "test.h"
+#include "test/test.h"
 
 static void
 test_keypin_parse_line(void *arg)
diff --git a/src/test/test_link_handshake.c b/src/test/test_link_handshake.c
index e84c37e94..2650caf95 100644
--- a/src/test/test_link_handshake.c
+++ b/src/test/test_link_handshake.c
@@ -8,26 +8,26 @@
 #define TOR_CHANNEL_INTERNAL_
 #define TORTLS_PRIVATE
 
-#include "compat.h"
-
-#include "or.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "channeltls.h"
-#include "link_handshake.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "scheduler.h"
-#include "torcert.h"
-
-#include "or_connection_st.h"
-#include "or_handshake_certs_st.h"
-#include "or_handshake_state_st.h"
-#include "var_cell_st.h"
-
-#include "test.h"
-#include "log_test_helpers.h"
+#include "common/compat.h"
+
+#include "or/or.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/channeltls.h"
+#include "trunnel/link_handshake.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/scheduler.h"
+#include "or/torcert.h"
+
+#include "or/or_connection_st.h"
+#include "or/or_handshake_certs_st.h"
+#include "or/or_handshake_state_st.h"
+#include "or/var_cell_st.h"
+
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 
 static var_cell_t *mock_got_var_cell = NULL;
 
diff --git a/src/test/test_logging.c b/src/test/test_logging.c
index 898f9dab5..aebfd3606 100644
--- a/src/test/test_logging.c
+++ b/src/test/test_logging.c
@@ -2,9 +2,9 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
-#include "torlog.h"
-#include "test.h"
+#include "or/or.h"
+#include "common/torlog.h"
+#include "test/test.h"
 
 static void
 dummy_cb_fn(int severity, uint32_t domain, const char *msg)
diff --git a/src/test/test_mainloop.c b/src/test/test_mainloop.c
index 9da8a039d..559bbe587 100644
--- a/src/test/test_mainloop.c
+++ b/src/test/test_mainloop.c
@@ -6,11 +6,11 @@
  * \brief Tests for functions closely related to the Tor main loop
  */
 
-#include "test.h"
-#include "log_test_helpers.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 
-#include "or.h"
-#include "main.h"
+#include "or/or.h"
+#include "or/main.h"
 
 static const uint64_t BILLION = 1000000000;
 
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 68c7432b5..1b680c02c 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -2,23 +2,23 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
-#include "config.h"
+#include "or/config.h"
 #define DIRVOTE_PRIVATE
-#include "dirauth/dirvote.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "torcert.h"
-
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
+#include "or/dirauth/dirvote.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/torcert.h"
+
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
 
 #ifdef _WIN32
 /* For mkdir() */
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c
index 781088371..0e5ad7bba 100644
--- a/src/test/test_nodelist.c
+++ b/src/test/test_nodelist.c
@@ -6,19 +6,19 @@
  * \brief Unit tests for nodelist related functions.
  **/
 
-#include "or.h"
-#include "crypto_rand.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "torcert.h"
-
-#include "microdesc_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/torcert.h"
+
+#include "or/microdesc_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
 
 /** Test the case when node_get_by_id() returns NULL,
  * node_get_verbose_nickname_by_id should return the base 16 encoding
diff --git a/src/test/test_ntor_cl.c b/src/test/test_ntor_cl.c
index 2e1a8f62a..dbc607db3 100644
--- a/src/test/test_ntor_cl.c
+++ b/src/test/test_ntor_cl.c
@@ -6,12 +6,12 @@
 #include <stdlib.h>
 
 #define ONION_NTOR_PRIVATE
-#include "or.h"
-#include "util.h"
-#include "compat.h"
-#include "crypto.h"
-#include "crypto_curve25519.h"
-#include "onion_ntor.h"
+#include "or/or.h"
+#include "common/util.h"
+#include "common/compat.h"
+#include "common/crypto.h"
+#include "common/crypto_curve25519.h"
+#include "or/onion_ntor.h"
 
 #define N_ARGS(n) STMT_BEGIN {                                  \
     if (argc < (n)) {                                           \
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index 48578f905..0edc22c50 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -7,21 +7,21 @@
 #define BUFFERS_PRIVATE
 #define CIRCUITLIST_PRIVATE
 #define CONNECTION_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "circuitlist.h"
-#include "compat_libevent.h"
-#include "connection.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "relay.h"
-#include "test.h"
-#include "test_helpers.h"
-
-#include "cell_st.h"
-#include "entry_connection_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/circuitlist.h"
+#include "common/compat_libevent.h"
+#include "or/connection.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/relay.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+
+#include "or/cell_st.h"
+#include "or/entry_connection_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
 /* small replacement mock for circuit_mark_for_close_ to avoid doing all
  * the other bookkeeping that comes with marking circuits. */
diff --git a/src/test/test_oos.c b/src/test/test_oos.c
index 6db9d644c..6ecb1a078 100644
--- a/src/test/test_oos.c
+++ b/src/test/test_oos.c
@@ -5,15 +5,15 @@
 
 #define CONNECTION_PRIVATE
 
-#include "or.h"
-#include "config.h"
-#include "connection.h"
-#include "connection_or.h"
-#include "main.h"
-#include "test.h"
-
-#include "dir_connection_st.h"
-#include "or_connection_st.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "or/connection_or.h"
+#include "or/main.h"
+#include "test/test.h"
+
+#include "or/dir_connection_st.h"
+#include "or/or_connection_st.h"
 
 static or_options_t mock_options;
 
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 587f0ba99..bf35e3c5b 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -4,21 +4,21 @@
 /* See LICENSE for licensing information */
 
 #define CONFIG_PRIVATE
-#include "or.h"
-#include "confparse.h"
-#include "config.h"
-#include "test.h"
-#include "geoip.h"
+#include "or/or.h"
+#include "or/confparse.h"
+#include "or/config.h"
+#include "test/test.h"
+#include "or/geoip.h"
 
 #define ROUTERSET_PRIVATE
-#include "routerset.h"
-#include "main.h"
-#include "log_test_helpers.h"
-
-#include "sandbox.h"
-#include "memarea.h"
-#include "policies.h"
-#include "test_helpers.h"
+#include "or/routerset.h"
+#include "or/main.h"
+#include "test/log_test_helpers.h"
+
+#include "common/sandbox.h"
+#include "common/memarea.h"
+#include "or/policies.h"
+#include "test/test_helpers.h"
 
 #define NS_MODULE test_options
 
diff --git a/src/test/test_periodic_event.c b/src/test/test_periodic_event.c
index 34689b64f..b353cf87a 100644
--- a/src/test/test_periodic_event.c
+++ b/src/test/test_periodic_event.c
@@ -11,15 +11,15 @@
 #define HS_SERVICE_PRIVATE
 #define MAIN_PRIVATE
 
-#include "test.h"
-#include "test_helpers.h"
-
-#include "or.h"
-#include "config.h"
-#include "hibernate.h"
-#include "hs_service.h"
-#include "main.h"
-#include "periodic.h"
+#include "test/test.h"
+#include "test/test_helpers.h"
+
+#include "or/or.h"
+#include "or/config.h"
+#include "or/hibernate.h"
+#include "or/hs_service.h"
+#include "or/main.h"
+#include "or/periodic.h"
 
 /** Helper function: This is replaced in some tests for the event callbacks so
  * we don't actually go into the code path of those callbacks. */
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 48a093ce1..2c29bbb16 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -1,19 +1,19 @@
 /* Copyright (c) 2013-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 #define CONFIG_PRIVATE
-#include "config.h"
-#include "router.h"
-#include "routerparse.h"
+#include "or/config.h"
+#include "or/router.h"
+#include "or/routerparse.h"
 #define POLICIES_PRIVATE
-#include "policies.h"
-#include "test.h"
+#include "or/policies.h"
+#include "test/test.h"
 
-#include "node_st.h"
-#include "port_cfg_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
+#include "or/node_st.h"
+#include "or/port_cfg_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
 
 /* Helper: assert that short_policy parses and writes back out as itself,
    or as <b>expected</b> if that's provided. */
diff --git a/src/test/test_procmon.c b/src/test/test_procmon.c
index 25f2417cb..ae30bd00b 100644
--- a/src/test/test_procmon.c
+++ b/src/test/test_procmon.c
@@ -3,12 +3,12 @@
 
 #define PROCMON_PRIVATE
 #include "orconfig.h"
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
-#include "procmon.h"
+#include "common/procmon.h"
 
-#include "log_test_helpers.h"
+#include "test/log_test_helpers.h"
 
 #define NS_MODULE procmon
 
diff --git a/src/test/test_proto_http.c b/src/test/test_proto_http.c
index 588086885..b98ee83ae 100644
--- a/src/test/test_proto_http.c
+++ b/src/test/test_proto_http.c
@@ -6,11 +6,11 @@
  * \brief Tests for our HTTP protocol parser code
  */
 
-#include "or.h"
-#include "test.h"
-#include "buffers.h"
-#include "proto_http.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/buffers.h"
+#include "or/proto_http.h"
+#include "test/log_test_helpers.h"
 
 #define S(str) str, sizeof(str)-1
 
diff --git a/src/test/test_proto_misc.c b/src/test/test_proto_misc.c
index 539fd1ad5..979fc72f1 100644
--- a/src/test/test_proto_misc.c
+++ b/src/test/test_proto_misc.c
@@ -6,16 +6,16 @@
  * \brief Test our smaller buffer-based protocol functions
  */
 
-#include "or.h"
-#include "test.h"
-#include "buffers.h"
-#include "connection_or.h"
-#include "ext_orport.h"
-#include "proto_cell.h"
-#include "proto_control0.h"
-#include "proto_ext_or.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/buffers.h"
+#include "or/connection_or.h"
+#include "or/ext_orport.h"
+#include "or/proto_cell.h"
+#include "or/proto_control0.h"
+#include "or/proto_ext_or.h"
 
-#include "var_cell_st.h"
+#include "or/var_cell_st.h"
 
 static void
 test_proto_var_cell(void *arg)
diff --git a/src/test/test_protover.c b/src/test/test_protover.c
index 7899c099f..f17f68ced 100644
--- a/src/test/test_protover.c
+++ b/src/test/test_protover.c
@@ -4,12 +4,12 @@
 #define PROTOVER_PRIVATE
 
 #include "orconfig.h"
-#include "test.h"
+#include "test/test.h"
 
-#include "protover.h"
+#include "or/protover.h"
 
-#include "or.h"
-#include "connection_or.h"
+#include "or/or.h"
+#include "or/connection_or.h"
 
 static void
 test_protover_parse(void *arg)
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index 6529dd037..d6ab00bb6 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -8,15 +8,15 @@
 #define UTIL_PRIVATE
 #define STATEFILE_PRIVATE
 #define CONTROL_PRIVATE
-#include "or.h"
-#include "config.h"
-#include "confparse.h"
-#include "control.h"
-#include "transports.h"
-#include "circuitbuild.h"
-#include "util.h"
-#include "statefile.h"
-#include "test.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/confparse.h"
+#include "or/control.h"
+#include "or/transports.h"
+#include "or/circuitbuild.h"
+#include "common/util.h"
+#include "or/statefile.h"
+#include "test/test.h"
 
 static void
 reset_mp(managed_proxy_t *mp)
diff --git a/src/test/test_pubsub.c b/src/test/test_pubsub.c
index d281e51ee..4f6cdc199 100644
--- a/src/test/test_pubsub.c
+++ b/src/test/test_pubsub.c
@@ -6,9 +6,9 @@
  * \brief Unit tests for publish-subscribe abstraction.
  **/
 
-#include "or.h"
-#include "test.h"
-#include "pubsub.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "common/pubsub.h"
 
 DECLARE_PUBSUB_STRUCT_TYPES(foobar)
 DECLARE_PUBSUB_TOPIC(foobar)
diff --git a/src/test/test_relay.c b/src/test/test_relay.c
index 559f046fd..777153d11 100644
--- a/src/test/test_relay.c
+++ b/src/test/test_relay.c
@@ -1,20 +1,20 @@
 /* Copyright (c) 2014-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 #define CIRCUITBUILD_PRIVATE
-#include "circuitbuild.h"
+#include "or/circuitbuild.h"
 #define RELAY_PRIVATE
-#include "relay.h"
+#include "or/relay.h"
 /* For init/free stuff */
-#include "scheduler.h"
+#include "or/scheduler.h"
 
-#include "cell_st.h"
-#include "or_circuit_st.h"
+#include "or/cell_st.h"
+#include "or/or_circuit_st.h"
 
 /* Test suite stuff */
-#include "test.h"
-#include "fakechans.h"
+#include "test/test.h"
+#include "test/fakechans.h"
 
 static or_circuit_t * new_fake_orcirc(channel_t *nchan, channel_t *pchan);
 
diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c
index 63b47d896..770692440 100644
--- a/src/test/test_relaycell.c
+++ b/src/test/test_relaycell.c
@@ -5,22 +5,22 @@
 
 #define RELAY_PRIVATE
 #define CIRCUITLIST_PRIVATE
-#include "or.h"
-#include "main.h"
-#include "config.h"
-#include "connection.h"
-#include "crypto.h"
-#include "circuitbuild.h"
-#include "circuitlist.h"
-#include "connection_edge.h"
-#include "relay.h"
-#include "test.h"
-
-#include "cell_st.h"
-#include "crypt_path_st.h"
-#include "entry_connection_st.h"
-#include "origin_circuit_st.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "or/main.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "common/crypto.h"
+#include "or/circuitbuild.h"
+#include "or/circuitlist.h"
+#include "or/connection_edge.h"
+#include "or/relay.h"
+#include "test/test.h"
+
+#include "or/cell_st.h"
+#include "or/crypt_path_st.h"
+#include "or/entry_connection_st.h"
+#include "or/origin_circuit_st.h"
+#include "or/socks_request_st.h"
 
 static int srm_ncalls;
 static entry_connection_t *srm_conn;
diff --git a/src/test/test_relaycrypt.c b/src/test/test_relaycrypt.c
index 9f6b5bbe6..0b8541974 100644
--- a/src/test/test_relaycrypt.c
+++ b/src/test/test_relaycrypt.c
@@ -3,19 +3,19 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "circuitbuild.h"
+#include "or/or.h"
+#include "or/circuitbuild.h"
 #define CIRCUITLIST_PRIVATE
-#include "circuitlist.h"
-#include "crypto_rand.h"
-#include "relay.h"
-#include "relay_crypto.h"
+#include "or/circuitlist.h"
+#include "common/crypto_rand.h"
+#include "or/relay.h"
+#include "or/relay_crypto.h"
 
-#include "cell_st.h"
-#include "or_circuit_st.h"
-#include "origin_circuit_st.h"
+#include "or/cell_st.h"
+#include "or/or_circuit_st.h"
+#include "or/origin_circuit_st.h"
 
-#include "test.h"
+#include "test/test.h"
 
 static const char KEY_MATERIAL[3][CPATH_KEY_MATERIAL_LEN] = {
   "    'My public key is in this signed x509 object', said Tom assertively.",
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c
index 44b84d07e..3d606aac0 100644
--- a/src/test/test_rendcache.c
+++ b/src/test/test_rendcache.c
@@ -2,24 +2,24 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
-#include "test.h"
+#include "test/test.h"
 #define RENDCACHE_PRIVATE
-#include "rendcache.h"
-#include "router.h"
-#include "routerlist.h"
-#include "config.h"
-#include "hs_common.h"
-
-#include "extend_info_st.h"
-#include "rend_encoded_v2_service_descriptor_st.h"
-#include "rend_intro_point_st.h"
-#include "rend_service_descriptor_st.h"
-#include "routerinfo_st.h"
-
-#include "rend_test_helpers.h"
-#include "log_test_helpers.h"
+#include "or/rendcache.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/config.h"
+#include "or/hs_common.h"
+
+#include "or/extend_info_st.h"
+#include "or/rend_encoded_v2_service_descriptor_st.h"
+#include "or/rend_intro_point_st.h"
+#include "or/rend_service_descriptor_st.h"
+#include "or/routerinfo_st.h"
+
+#include "test/rend_test_helpers.h"
+#include "test/log_test_helpers.h"
 
 #define NS_MODULE rend_cache
 
diff --git a/src/test/test_replay.c b/src/test/test_replay.c
index 97951241e..7f9c0b09e 100644
--- a/src/test/test_replay.c
+++ b/src/test/test_replay.c
@@ -4,9 +4,9 @@
 #define REPLAYCACHE_PRIVATE
 
 #include "orconfig.h"
-#include "or.h"
-#include "replaycache.h"
-#include "test.h"
+#include "or/or.h"
+#include "or/replaycache.h"
+#include "test/test.h"
 
 static const char *test_buffer =
   "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed do eiusmod"
diff --git a/src/test/test_router.c b/src/test/test_router.c
index 239c17a94..f2f325785 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -7,17 +7,17 @@
  * \brief Unittests for code in src/or/router.c
  **/
 
-#include "or.h"
-#include "config.h"
-#include "crypto_curve25519.h"
-#include "crypto_ed25519.h"
-#include "router.h"
-#include "routerlist.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_ed25519.h"
+#include "or/router.h"
+#include "or/routerlist.h"
 
-#include "routerinfo_st.h"
+#include "or/routerinfo_st.h"
 
 /* Test suite stuff */
-#include "test.h"
+#include "test/test.h"
 
 NS_DECL(const routerinfo_t *, router_get_my_routerinfo, (void));
 
diff --git a/src/test/test_routerkeys.c b/src/test/test_routerkeys.c
index fd1117485..8cfc9f808 100644
--- a/src/test/test_routerkeys.c
+++ b/src/test/test_routerkeys.c
@@ -5,14 +5,14 @@
 
 #include "orconfig.h"
 #define ROUTER_PRIVATE
-#include "or.h"
-#include "config.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "util.h"
-#include "crypto.h"
-#include "torcert.h"
-#include "test.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "common/util.h"
+#include "common/crypto.h"
+#include "or/torcert.h"
+#include "test/test.h"
 
 #ifdef _WIN32
 /* For mkdir() */
diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c
index 15f717f1a..b6032ed87 100644
--- a/src/test/test_routerlist.c
+++ b/src/test/test_routerlist.c
@@ -13,36 +13,36 @@
 #define NETWORKSTATUS_PRIVATE
 #define ROUTERLIST_PRIVATE
 #define TOR_UNIT_TESTING
-#include "or.h"
-#include "config.h"
-#include "connection.h"
-#include "container.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "directory.h"
-#include "dirauth/dirvote.h"
-#include "entrynodes.h"
-#include "hibernate.h"
-#include "microdesc.h"
-#include "networkstatus.h"
-#include "nodelist.h"
-#include "policies.h"
-#include "router.h"
-#include "routerlist.h"
-#include "routerset.h"
-#include "routerparse.h"
-#include "dirauth/shared_random.h"
-#include "statefile.h"
-
-#include "authority_cert_st.h"
-#include "dir_connection_st.h"
-#include "networkstatus_st.h"
-#include "node_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
-#include "test_dir_common.h"
-#include "log_test_helpers.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "or/connection.h"
+#include "common/container.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "or/directory.h"
+#include "or/dirauth/dirvote.h"
+#include "or/entrynodes.h"
+#include "or/hibernate.h"
+#include "or/microdesc.h"
+#include "or/networkstatus.h"
+#include "or/nodelist.h"
+#include "or/policies.h"
+#include "or/router.h"
+#include "or/routerlist.h"
+#include "or/routerset.h"
+#include "or/routerparse.h"
+#include "or/dirauth/shared_random.h"
+#include "or/statefile.h"
+
+#include "or/authority_cert_st.h"
+#include "or/dir_connection_st.h"
+#include "or/networkstatus_st.h"
+#include "or/node_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
+#include "test/test_dir_common.h"
+#include "test/log_test_helpers.h"
 
 void construct_consensus(char **consensus_text_md, time_t now);
 
diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c
index 727e15392..e64c24e89 100644
--- a/src/test/test_routerset.c
+++ b/src/test/test_routerset.c
@@ -3,19 +3,19 @@
 
 #define ROUTERSET_PRIVATE
 
-#include "or.h"
-#include "geoip.h"
-#include "routerset.h"
-#include "routerparse.h"
-#include "policies.h"
-#include "nodelist.h"
-
-#include "extend_info_st.h"
-#include "node_st.h"
-#include "routerinfo_st.h"
-#include "routerstatus_st.h"
-
-#include "test.h"
+#include "or/or.h"
+#include "or/geoip.h"
+#include "or/routerset.h"
+#include "or/routerparse.h"
+#include "or/policies.h"
+#include "or/nodelist.h"
+
+#include "or/extend_info_st.h"
+#include "or/node_st.h"
+#include "or/routerinfo_st.h"
+#include "or/routerstatus_st.h"
+
+#include "test/test.h"
 
 #define NS_MODULE routerset
 
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index eece5db93..1087befa6 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -8,19 +8,19 @@
 #define SCHEDULER_KIST_PRIVATE
 #define TOR_CHANNEL_INTERNAL_
 #define CHANNEL_PRIVATE_
-#include "or.h"
-#include "config.h"
-#include "compat_libevent.h"
-#include "channel.h"
-#include "channeltls.h"
-#include "connection.h"
-#include "networkstatus.h"
+#include "or/or.h"
+#include "or/config.h"
+#include "common/compat_libevent.h"
+#include "or/channel.h"
+#include "or/channeltls.h"
+#include "or/connection.h"
+#include "or/networkstatus.h"
 #define SCHEDULER_PRIVATE_
-#include "scheduler.h"
+#include "or/scheduler.h"
 
 /* Test suite stuff */
-#include "test.h"
-#include "fakechans.h"
+#include "test/test.h"
+#include "test/fakechans.h"
 
 /* Shamelessly stolen from compat_libevent.c */
 #define V(major, minor, patch) \
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index 06eb65f25..149129d0c 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -6,24 +6,24 @@
 #define CONFIG_PRIVATE
 #define DIRVOTE_PRIVATE
 
-#include "or.h"
-#include "test.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "dirauth/dirvote.h"
-#include "dirauth/shared_random.h"
-#include "dirauth/shared_random_state.h"
-#include "log_test_helpers.h"
-#include "networkstatus.h"
-#include "router.h"
-#include "routerkeys.h"
-#include "routerlist.h"
-#include "routerparse.h"
-#include "shared_random_client.h"
-#include "voting_schedule.h"
-
-#include "dir_server_st.h"
-#include "networkstatus_st.h"
+#include "or/or.h"
+#include "test/test.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/dirauth/dirvote.h"
+#include "or/dirauth/shared_random.h"
+#include "or/dirauth/shared_random_state.h"
+#include "test/log_test_helpers.h"
+#include "or/networkstatus.h"
+#include "or/router.h"
+#include "or/routerkeys.h"
+#include "or/routerlist.h"
+#include "or/routerparse.h"
+#include "or/shared_random_client.h"
+#include "or/voting_schedule.h"
+
+#include "or/dir_server_st.h"
+#include "or/networkstatus_st.h"
 
 static authority_cert_t *mock_cert;
 
diff --git a/src/test/test_slow.c b/src/test/test_slow.c
index 74f6bdeeb..951851ec0 100644
--- a/src/test/test_slow.c
+++ b/src/test/test_slow.c
@@ -15,8 +15,8 @@
 #include <fcntl.h>
 #endif
 
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
 struct testgroup_t testgroups[] = {
   { "slow/crypto/", slow_crypto_tests },
diff --git a/src/test/test_socks.c b/src/test/test_socks.c
index d7b9f0393..04c028058 100644
--- a/src/test/test_socks.c
+++ b/src/test/test_socks.c
@@ -3,13 +3,13 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "buffers.h"
-#include "config.h"
-#include "proto_socks.h"
-#include "test.h"
-#include "log_test_helpers.h"
-#include "socks_request_st.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/proto_socks.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
+#include "or/socks_request_st.h"
 
 typedef struct socks_test_data_t {
   socks_request_t *req;
diff --git a/src/test/test_status.c b/src/test/test_status.c
index 8ed636461..2f305224c 100644
--- a/src/test/test_status.c
+++ b/src/test/test_status.c
@@ -11,24 +11,24 @@
 #include <float.h>
 #include <math.h>
 
-#include "or.h"
-#include "torlog.h"
+#include "or/or.h"
+#include "common/torlog.h"
 #include "tor_queue.h"
-#include "status.h"
-#include "circuitlist.h"
-#include "config.h"
-#include "hibernate.h"
-#include "rephist.h"
-#include "relay.h"
-#include "router.h"
-#include "main.h"
-#include "nodelist.h"
-#include "statefile.h"
-
-#include "origin_circuit_st.h"
-#include "routerinfo_st.h"
-
-#include "test.h"
+#include "or/status.h"
+#include "or/circuitlist.h"
+#include "or/config.h"
+#include "or/hibernate.h"
+#include "or/rephist.h"
+#include "or/relay.h"
+#include "or/router.h"
+#include "or/main.h"
+#include "or/nodelist.h"
+#include "or/statefile.h"
+
+#include "or/origin_circuit_st.h"
+#include "or/routerinfo_st.h"
+
+#include "test/test.h"
 
 #define NS_MODULE status
 
diff --git a/src/test/test_storagedir.c b/src/test/test_storagedir.c
index 1214448e4..4deb88133 100644
--- a/src/test/test_storagedir.c
+++ b/src/test/test_storagedir.c
@@ -1,10 +1,10 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "crypto_rand.h"
-#include "storagedir.h"
-#include "test.h"
+#include "or/or.h"
+#include "common/crypto_rand.h"
+#include "common/storagedir.h"
+#include "test/test.h"
 
 #ifdef HAVE_UTIME_H
 #include <utime.h>
diff --git a/src/test/test_switch_id.c b/src/test/test_switch_id.c
index 63be10288..149dda8f7 100644
--- a/src/test/test_switch_id.c
+++ b/src/test/test_switch_id.c
@@ -1,7 +1,7 @@
 /* Copyright (c) 2015-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
+#include "or/or.h"
 
 #ifdef HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
diff --git a/src/test/test_threads.c b/src/test/test_threads.c
index eecbf69e4..11f41a044 100644
--- a/src/test/test_threads.c
+++ b/src/test/test_threads.c
@@ -4,9 +4,9 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
-#include "compat_threads.h"
-#include "test.h"
+#include "or/or.h"
+#include "common/compat_threads.h"
+#include "test/test.h"
 
 /** mutex for thread test to stop the threads hitting data at the same time. */
 static tor_mutex_t *thread_test_mutex_ = NULL;
diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c
index 0bf9d8055..6c6314942 100644
--- a/src/test/test_tortls.c
+++ b/src/test/test_tortls.c
@@ -11,7 +11,7 @@
 #endif
 #include <math.h>
 
-#include "compat.h"
+#include "common/compat.h"
 
 /* Some versions of OpenSSL declare SSL_get_selected_srtp_profile twice in
  * srtp.h. Suppress the GCC warning so we can build with -Wredundant-decl. */
@@ -30,13 +30,13 @@ DISABLE_GCC_WARNING(redundant-decls)
 
 ENABLE_GCC_WARNING(redundant-decls)
 
-#include "or.h"
-#include "torlog.h"
-#include "config.h"
-#include "tortls.h"
+#include "or/or.h"
+#include "common/torlog.h"
+#include "or/config.h"
+#include "common/tortls.h"
 
-#include "test.h"
-#include "log_test_helpers.h"
+#include "test/test.h"
+#include "test/log_test_helpers.h"
 #define NS_MODULE tortls
 
 #ifndef HAVE_SSL_STATE
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 9585f5872..4d06e3e7c 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -8,16 +8,16 @@
 #define COMPAT_TIME_PRIVATE
 #define CONTROL_PRIVATE
 #define UTIL_PRIVATE
-#include "or.h"
-#include "buffers.h"
-#include "config.h"
-#include "control.h"
-#include "crypto_rand.h"
-#include "test.h"
-#include "memarea.h"
-#include "util_process.h"
-#include "log_test_helpers.h"
-#include "compress_zstd.h"
+#include "or/or.h"
+#include "common/buffers.h"
+#include "or/config.h"
+#include "or/control.h"
+#include "common/crypto_rand.h"
+#include "test/test.h"
+#include "common/memarea.h"
+#include "common/util_process.h"
+#include "test/log_test_helpers.h"
+#include "common/compress_zstd.h"
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c
index 3a1db6258..d56915822 100644
--- a/src/test/test_util_format.c
+++ b/src/test/test_util_format.c
@@ -2,13 +2,13 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
-#include "test.h"
+#include "test/test.h"
 
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 #define UTIL_FORMAT_PRIVATE
-#include "util_format.h"
+#include "common/util_format.h"
 
 #define NS_MODULE util_format
 
diff --git a/src/test/test_util_process.c b/src/test/test_util_process.c
index d05c04653..a09d12ac6 100644
--- a/src/test/test_util_process.c
+++ b/src/test/test_util_process.c
@@ -3,13 +3,13 @@
 
 #define UTIL_PROCESS_PRIVATE
 #include "orconfig.h"
-#include "or.h"
+#include "or/or.h"
 
-#include "test.h"
+#include "test/test.h"
 
-#include "util_process.h"
+#include "common/util_process.h"
 
-#include "log_test_helpers.h"
+#include "test/log_test_helpers.h"
 
 #ifndef _WIN32
 #define NS_MODULE util_process
diff --git a/src/test/test_util_slow.c b/src/test/test_util_slow.c
index e3b65bc96..3d725d502 100644
--- a/src/test/test_util_slow.c
+++ b/src/test/test_util_slow.c
@@ -5,11 +5,11 @@
 
 #include "orconfig.h"
 #define UTIL_PRIVATE
-#include "util.h"
-#include "util_process.h"
-#include "crypto.h"
-#include "torlog.h"
-#include "test.h"
+#include "common/util.h"
+#include "common/util_process.h"
+#include "common/crypto.h"
+#include "common/torlog.h"
+#include "test/test.h"
 
 #ifndef BUILDDIR
 #define BUILDDIR "."
diff --git a/src/test/test_voting_schedule.c b/src/test/test_voting_schedule.c
index df6058b74..b5df59643 100644
--- a/src/test/test_voting_schedule.c
+++ b/src/test/test_voting_schedule.c
@@ -3,10 +3,10 @@
 
 #include "orconfig.h"
 
-#include "or.h"
-#include "voting_schedule.h"
+#include "or/or.h"
+#include "or/voting_schedule.h"
 
-#include "test.h"
+#include "test/test.h"
 
 static void
 test_voting_schedule_interval_start(void *arg)
diff --git a/src/test/test_workqueue.c b/src/test/test_workqueue.c
index 92b0d94d3..6935d286c 100644
--- a/src/test/test_workqueue.c
+++ b/src/test/test_workqueue.c
@@ -3,13 +3,13 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "or.h"
-#include "compat_threads.h"
-#include "onion.h"
-#include "workqueue.h"
-#include "crypto_curve25519.h"
-#include "crypto_rand.h"
-#include "compat_libevent.h"
+#include "or/or.h"
+#include "common/compat_threads.h"
+#include "or/onion.h"
+#include "common/workqueue.h"
+#include "common/crypto_curve25519.h"
+#include "common/crypto_rand.h"
+#include "common/compat_libevent.h"
 
 #include <stdio.h>
 
diff --git a/src/test/testing_common.c b/src/test/testing_common.c
index eb1838e16..18b5b6106 100644
--- a/src/test/testing_common.c
+++ b/src/test/testing_common.c
@@ -10,15 +10,15 @@
 
 #define MAIN_PRIVATE
 #include "orconfig.h"
-#include "or.h"
-#include "control.h"
-#include "config.h"
-#include "crypto_rand.h"
-#include "rephist.h"
-#include "backtrace.h"
-#include "test.h"
-#include "channelpadding.h"
-#include "main.h"
+#include "or/or.h"
+#include "or/control.h"
+#include "or/config.h"
+#include "common/crypto_rand.h"
+#include "or/rephist.h"
+#include "common/backtrace.h"
+#include "test/test.h"
+#include "or/channelpadding.h"
+#include "or/main.h"
 
 #include <stdio.h>
 #ifdef HAVE_FCNTL_H
@@ -34,7 +34,7 @@
 
 #ifdef USE_DMALLOC
 #include <dmalloc.h>
-#include "main.h"
+#include "or/main.h"
 #endif
 
 /** Temporary directory (set up by setup_directory) under which we store all
diff --git a/src/test/testing_rsakeys.c b/src/test/testing_rsakeys.c
index 9c2c52180..f45fcb11a 100644
--- a/src/test/testing_rsakeys.c
+++ b/src/test/testing_rsakeys.c
@@ -3,10 +3,10 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "crypto_rand.h"
+#include "common/crypto_rand.h"
 #include "orconfig.h"
-#include "or.h"
-#include "test.h"
+#include "or/or.h"
+#include "test/test.h"
 
 /** Define this if unit tests spend too much time generating public keys.
  * This module is meant to save time by using a bunch of pregenerated RSA
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index 7f716e685..e1d3e54d8 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -13,7 +13,7 @@
 #include <unistd.h>
 #endif
 
-#include "compat.h"
+#include "common/compat.h"
 
 /* Some versions of OpenSSL declare X509_STORE_CTX_set_verify_cb twice in
  * x509.h and x509_vfy.h. Suppress the GCC warning so we can build with
@@ -36,14 +36,14 @@ ENABLE_GCC_WARNING(redundant-decls)
 #include <assert.h>
 #endif
 
-#include "util.h"
-#include "torlog.h"
-#include "crypto.h"
-#include "crypto_digest.h"
-#include "crypto_rand.h"
-#include "crypto_util.h"
-#include "address.h"
-#include "util_format.h"
+#include "common/util.h"
+#include "common/torlog.h"
+#include "common/crypto.h"
+#include "common/crypto_digest.h"
+#include "common/crypto_rand.h"
+#include "common/crypto_util.h"
+#include "common/address.h"
+#include "common/util_format.h"
 
 #define IDENTITY_KEY_BITS 3072
 #define SIGNING_KEY_BITS 2048
diff --git a/src/tools/tor-resolve.c b/src/tools/tor-resolve.c
index 072f54569..dfca7d792 100644
--- a/src/tools/tor-resolve.c
+++ b/src/tools/tor-resolve.c
@@ -4,11 +4,11 @@
 /* See LICENSE for licensing information */
 
 #include "orconfig.h"
-#include "compat.h"
-#include "util.h"
-#include "address.h"
-#include "torlog.h"
-#include "sandbox.h"
+#include "common/compat.h"
+#include "common/util.h"
+#include "common/address.h"
+#include "common/torlog.h"
+#include "common/sandbox.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/tools/tor_runner.c b/src/tools/tor_runner.c
index c03a806a8..8e74a06cd 100644
--- a/src/tools/tor_runner.c
+++ b/src/tools/tor_runner.c
@@ -23,8 +23,8 @@
  * functions.  Don't add more dependencies!
  */
 
-#include "tor_api.h"
-#include "tor_api_internal.h"
+#include "or/tor_api.h"
+#include "or/tor_api_internal.h"
 
 #include "orconfig.h"
 #ifdef HAVE_UNISTD_H
diff --git a/src/trace/debug.h b/src/trace/debug.h
index 59fa73d55..0241f2ccf 100644
--- a/src/trace/debug.h
+++ b/src/trace/debug.h
@@ -4,7 +4,7 @@
 #ifndef TOR_TRACE_LOG_DEBUG_H
 #define TOR_TRACE_LOG_DEBUG_H
 
-#include "torlog.h"
+#include "common/torlog.h"
 
 /* Stringify pre-processor trick. */
 #define XSTR(d) STR(d)
diff --git a/src/trace/trace.c b/src/trace/trace.c
index 14d0254b1..b39a2bbc5 100644
--- a/src/trace/trace.c
+++ b/src/trace/trace.c
@@ -1,7 +1,7 @@
 /* Copyright (c) 2017-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#include "trace.h"
+#include "trace/trace.h"
 
 /** Initialize the tracing library. */
 void
diff --git a/src/trunnel/trunnel-local.h b/src/trunnel/trunnel-local.h
index 8aa6d0dda..f25659bf6 100644
--- a/src/trunnel/trunnel-local.h
+++ b/src/trunnel/trunnel-local.h
@@ -2,9 +2,9 @@
 #ifndef TRUNNEL_LOCAL_H_INCLUDED
 #define TRUNNEL_LOCAL_H_INCLUDED
 
-#include "util.h"
-#include "compat.h"
-#include "crypto_util.h"
+#include "common/util.h"
+#include "common/compat.h"
+#include "common/crypto_util.h"
 
 #define trunnel_malloc tor_malloc
 #define trunnel_calloc tor_calloc





More information about the tor-commits mailing list