[tor-dev] traversing the source code of tor

Nick Mathewson nickm at alum.mit.edu
Mon Jun 10 19:08:04 UTC 2013


On Thu, Jun 6, 2013 at 5:17 PM, H S <aras_h1988 at yahoo.com> wrote:
> Hi there,
> We would like to implement some specific protocol in Tor as an
> implementation project.
> Our one of pseudo codes that we have to take into account is the one
> mentioned on the paper under the link
> http://www.cypherpunks.ca/~iang/pubs/UC-OR.pdf , page 5, figure 2.
> I would like to know how can I connect or relate this pseudo code with the
> Tor source code to help us understand where we should insert our desired
> modification on the source code of the Tor.
> For instance in the first of the pseudo code line we have  "upon an input
> (setup):". And know in which file/lines of the Tor source code we have this?

Hello, and welcome to Tor!

The problem you're facing right now is pretty common to visiting any
new codebase with which you've previously been unfamiliar, and trying
to make changes to it.  What you'll find, unfortunately, is that real
code for mature (that is, crufty) projects rarely corresponds to
pseudocode in anything like a 1:1 fashion.

The closest thing to the "upon receiving a cell" points are in
command.c, in the function command_process_cell.  Relay cells are
handled in connection_edge_process_relay_cell in relay.c.  But in both
cases, you'll want to look up and down the stack in order to find the
point where you _really_ want to introduce new behavior.

Setup functionality is best done either in the appropriate function in
main.c, or (if it's cryptographic) in init_keys() in router.c.
Looking down the call chain from tor_main() and up the call chain from
do_main_loop() should find a logical point.

Circuit extend logic is handled in circuitbuild.c; data is packaged in
connection_edge_package_raw_inbuf.

You should probably base any changes on the latest version of that
maint-0.2.4 branch, and use git for version control so that you can
get the benefit of bugfixes in your own code.

best wishes,
-- 
Nick


More information about the tor-dev mailing list