[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add cmux policy notify_set_n_cells() and notify_xmit_cells() callbacks



commit eade7a37cdc9c128d66d2c2c74d7056516fde364
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date:   Thu Sep 27 12:20:05 2012 -0700

    Add cmux policy notify_set_n_cells() and notify_xmit_cells() callbacks
---
 src/or/circuitmux.c |   13 +++++++++++++
 src/or/circuitmux.h |   11 +++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 5a5739f..53d3a1b 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -995,6 +995,19 @@ circuitmux_set_num_cells(circuitmux_t *cmux, circuit_t *circ,
   cmux->n_cells -= hashent->muxinfo.cell_count;
   cmux->n_cells += n_cells;
 
+  /* Do we need to notify a cmux policy? */
+  if (cmux->policy && cmux->policy_data &&
+      cmux->policy->notify_set_n_cells) {
+    /* Yeah; assert that we have circuit policy data */
+    tor_assert(hashent->muxinfo.policy_data);
+    /* ... and call notify_set_n_cells */
+    cmux->policy->notify_set_n_cells(cmux,
+                                     cmux->policy_data,
+                                     circ,
+                                     hashent->muxinfo.policy_data,
+                                     n_cells);
+  }
+
   /*
    * Update cmux active circuit counter: is the old cell count > 0 and the
    * new cell count == 0 ?
diff --git a/src/or/circuitmux.h b/src/or/circuitmux.h
index e344b6e..dcacb8e 100644
--- a/src/or/circuitmux.h
+++ b/src/or/circuitmux.h
@@ -42,6 +42,17 @@ struct circuitmux_policy_s {
                                circuitmux_policy_data_t *pol_data,
                                circuit_t *circ,
                                circuitmux_policy_circ_data_t *pol_circ_data);
+  /* Notify of arriving/transmitted cells on a circuit */
+  void (*notify_set_n_cells)(circuitmux_t *cmux,
+                             circuitmux_policy_data_t *pol_data,
+                             circuit_t *circ,
+                             circuitmux_policy_circ_data_t *pol_circ_data,
+                             unsigned int n_cells);
+  void (*notify_xmit_cells)(circuitmux_t *cmux,
+                            circuitmux_policy_data_t *pol_data,
+                            circuit_t *circ,
+                            circuitmux_policy_circ_data_t *pol_circ_data,
+                            unsigned int n_cells);
 };
 
 /*



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits