#include "core/or/origin_circuit_st.h"
/* Trunnel. */
+#include "trunnel/congestion_control.h"
#include "trunnel/ed25519_cert.h"
#include "trunnel/extension.h"
#include "trunnel/hs/cell_establish_intro.h"
tor_free(encrypted);
}
+/** Build and set the INTRODUCE congestion control extension in the given
+ * extensions. */
+static void
+build_introduce_cc_extension(trn_extension_t *extensions)
+{
+ trn_extension_field_t *field = NULL;
+
+ /* Build CC request extension. */
+ field = trn_extension_field_new();
+ trn_extension_field_set_field_type(field,
+ TRUNNEL_EXT_TYPE_CC_FIELD_REQUEST);
+
+ /* No payload indicating a request to use congestion control. */
+ trn_extension_field_set_field_len(field, 0);
+
+ /* Build final extension. */
+ trn_extension_add_fields(extensions, field);
+ trn_extension_set_num(extensions, trn_extension_get_num(extensions) + 1);
+}
+
/** Using the INTRODUCE1 data, setup the ENCRYPTED section in cell. This means
* set it, encrypt it and encode it. */
static void
enc_cell = trn_cell_introduce_encrypted_new();
tor_assert(enc_cell);
- /* Set extension data. None are used. */
+ /* Setup extension(s) if any. */
ext = trn_extension_new();
tor_assert(ext);
- trn_extension_set_num(ext, 0);
+ /* Build congestion control extension is enabled. */
+ if (data->cc_enabled) {
+ build_introduce_cc_extension(ext);
+ }
trn_cell_introduce_encrypted_set_extensions(enc_cell, ext);
/* Set the rendezvous cookie. */
const curve25519_keypair_t *client_kp;
/** Rendezvous point link specifiers. */
smartlist_t *link_specifiers;
+ /** Congestion control parameters. */
+ unsigned int cc_enabled : 1;
} hs_cell_introduce1_data_t;
/** This data structure contains data that we need to parse an INTRODUCE2 cell
#include "trunnel/ed25519_cert.h"
#include "trunnel/hs/cell_establish_intro.h"
+#include "core/or/congestion_control_st.h"
#include "core/or/cpath_build_state_st.h"
#include "core/or/crypt_path_st.h"
#include "feature/nodelist/node_st.h"
/* We can't rendezvous without the curve25519 onion key. */
goto end;
}
+
/* Success, we have valid introduce data. */
ret = 0;
goto close;
}
+ /* If the rend circ was set up for congestion control, add that to the
+ * intro data, to signal it in an extension */
+ if (TO_CIRCUIT(rend_circ)->ccontrol) {
+ intro1_data.cc_enabled = 1;
+ }
+
/* Final step before we encode a cell, we setup the circuit identifier which
* will generate both the rendezvous cookie and client keypair for this
* connection. Those are put in the ident. */