[domistream] Host: ENet accepting side and control host #11
@@ -13,11 +13,13 @@ use core::time::Duration;
|
||||
|
||||
use domistream::Instant;
|
||||
use domistream::control::{
|
||||
ClientControlMessage, ControlCipher, ControlHost, ControlHostConfig, ControlHostEvent, Direction, parse_client_message,
|
||||
parse_message,
|
||||
ClientControlMessage, ControlCipher, ControlHost, ControlHostConfig, ControlHostEvent, Direction,
|
||||
parse_client_message, parse_message,
|
||||
};
|
||||
use domistream::enet::EnetHostConfig;
|
||||
use domistream::enet::protocol::{Command, CommandBody, ConnectParams, Datagram, NO_PEER_ID, encode_datagram, parse_datagram};
|
||||
use domistream::enet::protocol::{
|
||||
Command, CommandBody, ConnectParams, Datagram, NO_PEER_ID, encode_datagram, parse_datagram,
|
||||
};
|
||||
|
||||
const PEER_ID: u16 = 3;
|
||||
const KEY: [u8; 16] = [7; 16];
|
||||
@@ -41,7 +43,12 @@ fn connected() -> ControlHost {
|
||||
packet_throttle_deceleration: 2,
|
||||
connect_id: 1,
|
||||
};
|
||||
let connect = Command { acknowledge: true, channel_id: 0xFF, reliable_sequence: 1, body: CommandBody::Connect { params, data: 0 } };
|
||||
let connect = Command {
|
||||
acknowledge: true,
|
||||
channel_id: 0xFF,
|
||||
reliable_sequence: 1,
|
||||
body: CommandBody::Connect { params, data: 0 },
|
||||
};
|
||||
let config = ControlHostConfig {
|
||||
enet: EnetHostConfig {
|
||||
peer_id: PEER_ID,
|
||||
@@ -73,7 +80,8 @@ fn check_parse(chunk: &[u8]) {
|
||||
Ok(m) => {
|
||||
assert!(raw.is_ok(), "a client message must split as a message first");
|
||||
match m {
|
||||
ClientControlMessage::Unknown { body_len, .. } | ClientControlMessage::InputRejected { body_len, .. } => {
|
||||
ClientControlMessage::Unknown { body_len, .. }
|
||||
| ClientControlMessage::InputRejected { body_len, .. } => {
|
||||
assert_eq!(body_len + 4, chunk.len());
|
||||
}
|
||||
ClientControlMessage::LossStats(b) | ClientControlMessage::FrameStats(b) => {
|
||||
@@ -107,7 +115,12 @@ fuzz_target!(|data: &[u8]| {
|
||||
check_parse(chunk);
|
||||
let wrap = |frame: Vec<u8>, reliable: &mut u16| {
|
||||
*reliable = reliable.wrapping_add(1);
|
||||
let c = Command { acknowledge: true, channel_id: 0, reliable_sequence: *reliable, body: CommandBody::SendReliable(frame) };
|
||||
let c = Command {
|
||||
acknowledge: true,
|
||||
channel_id: 0,
|
||||
reliable_sequence: *reliable,
|
||||
body: CommandBody::SendReliable(frame),
|
||||
};
|
||||
datagram(PEER_ID, (ms & 0xFFFF) as u16, vec![c])
|
||||
};
|
||||
let bytes = match op & 0x07 {
|
||||
|
||||
@@ -12,7 +12,9 @@ use libfuzzer_sys::fuzz_target;
|
||||
use core::time::Duration;
|
||||
|
||||
use domistream::Instant;
|
||||
use domistream::enet::protocol::{Command, CommandBody, ConnectParams, Datagram, NO_PEER_ID, encode_datagram, parse_datagram};
|
||||
use domistream::enet::protocol::{
|
||||
Command, CommandBody, ConnectParams, Datagram, NO_PEER_ID, encode_datagram, parse_datagram,
|
||||
};
|
||||
use domistream::enet::{EnetHostConfig, EnetHostEvent, EnetHostPeer, EnetHostState, MAX_PACKET_BYTES};
|
||||
|
||||
const PEER_ID: u16 = 3;
|
||||
@@ -46,7 +48,12 @@ fn canned_connect() -> Vec<u8> {
|
||||
packet_throttle_deceleration: 2,
|
||||
connect_id: 1,
|
||||
};
|
||||
let c = Command { acknowledge: true, channel_id: 0xFF, reliable_sequence: 1, body: CommandBody::Connect { params, data: 0 } };
|
||||
let c = Command {
|
||||
acknowledge: true,
|
||||
channel_id: 0xFF,
|
||||
reliable_sequence: 1,
|
||||
body: CommandBody::Connect { params, data: 0 },
|
||||
};
|
||||
datagram(NO_PEER_ID, vec![c])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user