Skip to content

Commit

Permalink
make sctp internal_buffer max_message_size
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Jan 20, 2024
1 parent 20e14e6 commit 165217e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rtc
Submodule rtc updated 1 files
+4 −4 sctp/src/config.rs
6 changes: 2 additions & 4 deletions src/handlers/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::messages::{
use data::message::{message_channel_ack::*, message_channel_open::*, message_type::*, *};
use log::{debug, error};
use retty::channel::{Handler, InboundContext, InboundHandler, OutboundContext, OutboundHandler};
use shared::error::{Error, Result};
use shared::error::Result;
use shared::marshal::*;

#[derive(Default)]
Expand Down Expand Up @@ -66,7 +66,7 @@ impl InboundHandler for DataChannelInbound {
} else {
Ok((None, None))
}
} else if message.data_message_type == DataChannelMessageType::Binary {
} else {
Ok((
Some(ApplicationMessage {
association_handle: message.association_handle,
Expand All @@ -75,8 +75,6 @@ impl InboundHandler for DataChannelInbound {
}),
None,
))
} else {
Err(Error::UnknownProtocol)
}
};

Expand Down
1 change: 1 addition & 0 deletions src/handlers/dtls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl OutboundHandler for DtlsOutbound {
dtls_endpoint.write(msg.transport.peer_addr, &dtls_message)
};
if let Err(err) = try_write() {
error!("try_write with error {}", err);
ctx.fire_write_exception(Box::new(err));
}
handle_outgoing(ctx, &self.dtls_endpoint, msg.transport.local_addr);
Expand Down
23 changes: 16 additions & 7 deletions src/handlers/sctp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ impl SctpHandler {
sctp_endpoint: Rc::clone(&sctp_endpoint),

transmits: VecDeque::new(),
internal_buffer: vec![0u8; 1500],
internal_buffer: vec![
0u8;
server_states
.server_config()
.sctp_server_config
.transport
.max_message_size() as usize
],
},
sctp_outbound: SctpOutbound {
server_states,
Expand Down Expand Up @@ -240,13 +247,14 @@ impl OutboundHandler for SctpOutbound {
msg.transport.peer_addr, message
);
let mut try_write = || -> Result<()> {
let max_payload_size = {
self.sctp_endpoint
.borrow()
.endpoint_config()
.get_max_payload_size() as usize
let max_message_size = {
self.server_states
.server_config()
.sctp_server_config
.transport
.max_message_size() as usize as usize
};
if message.payload.len() > max_payload_size {
if message.payload.len() > max_message_size {
return Err(Error::ErrOutboundPacketTooLarge);
}

Expand Down Expand Up @@ -288,6 +296,7 @@ impl OutboundHandler for SctpOutbound {
Ok(())
};
if let Err(err) = try_write() {
error!("try_write with error {}", err);
ctx.fire_write_exception(Box::new(err));
}
handle_outgoing(ctx, &mut self.transmits, msg.transport.local_addr);
Expand Down

0 comments on commit 165217e

Please sign in to comment.