Skip to content

Commit

Permalink
add sctp_port in sctp::TransportConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
rainliu committed Feb 3, 2024
1 parent cb04fac commit 7add9ad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sctp/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ pub(crate) const INITIAL_MTU: u32 = 1228;
pub(crate) const INITIAL_RECV_BUF_SIZE: u32 = 1024 * 1024;
pub(crate) const COMMON_HEADER_SIZE: u32 = 12;
pub(crate) const DATA_CHUNK_HEADER_SIZE: u32 = 16;
pub(crate) const DEFAULT_MAX_MESSAGE_SIZE: u32 = 65536;
pub(crate) const DEFAULT_MAX_MESSAGE_SIZE: u32 = 262144;

/// Config collects the arguments to create_association construction into
/// a single structure
#[derive(Debug)]
pub struct TransportConfig {
sctp_port: u16,
max_receive_buffer_size: u32,
max_message_size: u32,
max_num_outbound_streams: u16,
Expand All @@ -26,6 +27,7 @@ pub struct TransportConfig {
impl Default for TransportConfig {
fn default() -> Self {
TransportConfig {
sctp_port: 5000,
max_receive_buffer_size: INITIAL_RECV_BUF_SIZE,
max_message_size: DEFAULT_MAX_MESSAGE_SIZE,
max_num_outbound_streams: u16::MAX,
Expand All @@ -35,6 +37,11 @@ impl Default for TransportConfig {
}

impl TransportConfig {
pub fn with_sctp_port(mut self, value: u16) -> Self {
self.sctp_port = value;
self
}

pub fn with_max_receive_buffer_size(mut self, value: u32) -> Self {
self.max_receive_buffer_size = value;
self
Expand All @@ -55,6 +62,10 @@ impl TransportConfig {
self
}

pub fn sctp_port(&self) -> u16 {
self.sctp_port
}

pub fn max_receive_buffer_size(&self) -> u32 {
self.max_receive_buffer_size
}
Expand Down

0 comments on commit 7add9ad

Please sign in to comment.