When I read source code of Tor,I found a concept called origin circuit, which appears a lot in the source code. I think it refers to the circuit from OP to OR.Is that correct? And what are the differences among origin_circuit_t, or_circuit_t and circuit_t? Thank you very much!

1 Answer 1


These circuit objects link connections together. An origin_circuit_t represents the beginning of a circuit. It links application connections (for example, SOCKS connections from a web browser) to the first relay connection (for example a connection to the guard). An or_circuit_t is used where most other connections need to be linked. For example at a relay which links a relay connection (from a client or relay) to a relay connection to some other relay, or a relay connection to edge connections (connections leaving the tor network).

Both origin_circuit_t and or_circuit_t contain a circuit_t. In an OOP sense, origin_circuit_t and or_circuit_t "inherit" from circuit_t and so are subtypes of circuit_t. You can use TO_CIRCUIT() to cast either to a circuit_t.

  • Thank you very much! Your answer has helped me a lot in the understanding of Tor source code! Oct 24 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.