Skip to content

Commit

Permalink
Merge branch 'master' into fix-pmtu
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Grover authored Oct 15, 2019
2 parents 2e8e223 + 2ad96ea commit b34d624
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions neqo-transport/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::send_stream::{SendStream, SendStreams};
use crate::stats::Stats;
use crate::stream_id::{StreamId, StreamIndex, StreamIndexes};
use crate::tparams::consts as tp_const;
use crate::tparams::{TransportParameters, TransportParametersHandler};
use crate::tparams::{TransportParameter, TransportParameters, TransportParametersHandler};
use crate::tracking::{AckTracker, PNSpace};
use crate::QUIC_VERSION;
use crate::{AppError, ConnectionError, Error, Res};
Expand Down Expand Up @@ -434,8 +434,12 @@ impl Connection {
match &self.paths {
Some(path) if path.local.is_ipv4() => 1252,
Some(_) => 1232, // IPv6
None => 1280,
}
None => 1280
}

/// Set a local transport parameter, possibly overriding a default value.
pub fn set_local_tparam(&self, key: u16, value: TransportParameter) {
self.tps.borrow_mut().local.set(key, value)
}

/// Set the connection ID that was originally chosen by the client.
Expand Down Expand Up @@ -1165,19 +1169,15 @@ impl Connection {
}

fn set_initial_limits(&mut self) {
let swapped = mem::replace(&mut self.tps, Rc::default());
{
let tph = swapped.borrow();
let remote = tph.remote();
self.indexes.remote_max_stream_bidi =
StreamIndex::new(remote.get_integer(tp_const::INITIAL_MAX_STREAMS_BIDI));
self.indexes.remote_max_stream_uni =
StreamIndex::new(remote.get_integer(tp_const::INITIAL_MAX_STREAMS_UNI));
self.flow_mgr
.borrow_mut()
.conn_increase_max_credit(remote.get_integer(tp_const::INITIAL_MAX_DATA));
}
mem::replace(&mut self.tps, swapped);
let tps = self.tps.borrow();
let remote = tps.remote();
self.indexes.remote_max_stream_bidi =
StreamIndex::new(remote.get_integer(tp_const::INITIAL_MAX_STREAMS_BIDI));
self.indexes.remote_max_stream_uni =
StreamIndex::new(remote.get_integer(tp_const::INITIAL_MAX_STREAMS_UNI));
self.flow_mgr
.borrow_mut()
.conn_increase_max_credit(remote.get_integer(tp_const::INITIAL_MAX_DATA));
}

fn validate_odcid(&self) -> Res<()> {
Expand Down Expand Up @@ -2716,4 +2716,11 @@ mod tests {
assert_eq!(*client.state(), State::Connected);
assert_eq!(*server.state(), State::Connected);
}

#[test]
fn set_local_tparam() {
let client = default_client();

client.set_local_tparam(tp_const::INITIAL_MAX_DATA, TransportParameter::Integer(55))
}
}

0 comments on commit b34d624

Please sign in to comment.