[tor-bugs] #22220 [Core Tor/Tor]: hs: Move cell encoding/decoding out of hs_intropoint.c to hs_cell.c

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed May 23 00:13:40 UTC 2018


#22220: hs: Move cell encoding/decoding out of hs_intropoint.c to hs_cell.c
-------------------------------------------------+-------------------------
 Reporter:  dgoulet                              |          Owner:  neel
     Type:  enhancement                          |         Status:
                                                 |  assigned
 Priority:  Low                                  |      Milestone:  Tor:
                                                 |  unspecified
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  tor-hs, prop224, prop224-extra       |  Actual Points:
  refactor code-movement                         |
Parent ID:                                       |         Points:  0.1
 Reviewer:                                       |        Sponsor:
                                                 |  SponsorR-can
-------------------------------------------------+-------------------------

Comment (by neel):

 In `hs_intropoint.c`, I noticed code like:

 {{{
   encoded_len = trn_cell_intro_established_encoded_len(cell);
   tor_assert(encoded_len > 0);
   encoded_cell = tor_malloc_zero(encoded_len);
   result_len = trn_cell_intro_established_encode(encoded_cell,
 encoded_len,
                                                 cell);
   tor_assert(encoded_len == result_len);
 }}}

 in `hs_intro_send_intro_established_cell()`, and:

 {{{
   encoded_len = trn_cell_introduce_ack_encoded_len(cell);
   tor_assert(encoded_len > 0);
   encoded_cell = tor_malloc_zero(encoded_len);
   result_len = trn_cell_introduce_ack_encode(encoded_cell, encoded_len,
 cell);
   tor_assert(encoded_len == result_len);
 }}}

 in `send_introduce_ack_cell()`.

 Would it be okay if I have a function in `hs_cell.c` which does the
 encoding, and I pass in the function calls to get the cell length and
 encoded cells? The functions I am thinking about passing are:

  * Either `trn_cell_intro_established_encoded_len()` or
 `trn_cell_introduce_ack_encoded_len()`, and
  * Either `trn_cell_intro_established_encode()` or
 `trn_cell_introduce_ack_encode()`

 And in the new function, I return a `ssize_t` for `encoded_len`, and pass
 in the functions, the cell itself, and the pointer to `*encoded_cell` to
 get returned the cell itself.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22220#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list