Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions smb-cli/src/info.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::{path::*, Cli};
use clap::Parser;
use maybe_async::*;
use smb::{
packets::smb2::{FileBasicInformation, FileIdBothDirectoryInformation},
resource::Resource,
};
use smb::{packets::fscc::*, resource::Resource};
use std::error::Error;
#[derive(Parser, Debug)]
pub struct InfoCmd {
Expand Down
2 changes: 1 addition & 1 deletion smb-cli/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::cli::Cli;
use maybe_async::*;
use smb::{
connection::{Connection, EncryptionMode},
packets::smb2::*,
packets::{fscc::*, smb2::*},
resource::Resource,
session::Session,
tree::Tree,
Expand Down
2 changes: 2 additions & 0 deletions smb/src/packets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod binrw_util;
pub mod fscc;
pub mod guid;
pub mod netbios;
pub mod security;
pub mod smb1;
pub mod smb2;
22 changes: 22 additions & 0 deletions smb/src/packets/binrw_util/pos_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,28 @@ where
)
}

/// Writer for value
/// * fill absolute offset to offset location.
/// * with value args.
#[binrw::writer(writer, endian)]
pub fn write_aoff_a<U>(
value: &U,
write_offset_to: &Self,
value_args: U::Args<'_>,
) -> BinResult<()>
where
U: BinWrite,
{
let no_size: Option<&PosMarker<T>> = None;
let no_base: Option<&PosMarker<T>> = None;
Self::write_hero(
value,
writer,
endian,
(no_size, Some(write_offset_to), no_base, value_args),
)
}

#[binrw::writer(writer, endian)]
pub fn write_roff_size<U, S>(
value: &U,
Expand Down
6 changes: 3 additions & 3 deletions smb/src/packets/smb2/fscc.rs → smb/src/packets/fscc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::access_mask;
use binrw::{io::TakeSeekExt, meta::ReadEndian, prelude::*};
use modular_bitfield::prelude::*;

use super::{super::binrw_util::prelude::*, SID};
use super::{binrw_util::prelude::*, security::SID};
pub mod chained_item;
pub mod common_info;
pub mod directory_info;
Expand Down Expand Up @@ -198,7 +198,7 @@ macro_rules! file_info_classes {
}
}

impl crate::packets::smb2::fscc::FileInfoType for $name {
impl crate::packets::fscc::FileInfoType for $name {
type Class = [<$name Class>];
fn class(&self) -> Self::Class {
match self {
Expand All @@ -220,7 +220,7 @@ macro_rules! file_info_classes {
type Error = crate::Error;

fn try_from(value: $name) -> Result<Self, Self::Error> {
pub use crate::packets::smb2::fscc::FileInfoType;
pub use crate::packets::fscc::FileInfoType;
match value {
$name::[<$field_name Information>](v) => Ok(v),
_ => Err(crate::Error::UnexpectedInformationType(<Self as [<$name Value>]>::CLASS_ID as u8, value.class() as u8)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//!
use std::ops::Deref;

use super::super::super::binrw_util::prelude::*;
use crate::packets::binrw_util::prelude::*;
use binrw::prelude::*;

#[binrw::binrw]
Expand Down
5 changes: 5 additions & 0 deletions smb/src/packets/guid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ use rand::{rngs::OsRng, Rng};
pub struct Guid(u32, u16, u16, [u8; 8]);

impl Guid {
/// Bytes
pub const GUID_SIZE: usize = 16;

/// Generates a new random GUID.
pub fn gen() -> Self {
let mut rng = OsRng;
let mut bytes = [0u8; 16];
rng.fill(&mut bytes);
Self::try_from(&bytes).unwrap()
}

/// The maximum possible GUID value (all bits set to 1).
pub const MAX: Guid = Guid {
0: u32::MAX,
1: u16::MAX,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions smb/src/packets/smb2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod echo;
pub mod encrypted;
pub mod error;
pub mod file;
pub mod fscc;
pub mod header;
pub mod info;
pub mod ioctl;
Expand All @@ -16,7 +15,6 @@ pub mod notify;
pub mod oplock;
pub mod plain;
pub mod query_dir;
pub mod security;
pub mod session_setup;
pub mod tree_connect;

Expand All @@ -27,7 +25,6 @@ pub use echo::*;
pub use encrypted::*;
pub use error::*;
pub use file::*;
pub use fscc::*;
pub use header::*;
pub use info::*;
pub use ioctl::*;
Expand All @@ -38,7 +35,6 @@ pub use notify::*;
pub use oplock::*;
pub use plain::*;
pub use query_dir::*;
pub use security::*;
pub use session_setup::*;
pub use tree_connect::*;

Expand Down
4 changes: 2 additions & 2 deletions smb/src/packets/smb2/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

use std::io::{Cursor, SeekFrom};

use super::super::binrw_util::prelude::*;
use super::super::guid::Guid;
use super::header::Status;
use super::*;
use crate::packets::security::SecurityDescriptor;
use crate::packets::{binrw_util::prelude::*, fscc::*, guid::Guid};
use binrw::io::TakeSeekExt;
use binrw::prelude::*;
use modular_bitfield::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion smb/src/packets/smb2/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::io::SeekFrom;
use binrw::prelude::*;
use modular_bitfield::prelude::*;

use super::super::binrw_util::prelude::*;
use super::header::Header;
use super::FileId;
use crate::packets::binrw_util::prelude::*;

#[binrw::binrw]
#[derive(Debug)]
Expand Down
5 changes: 3 additions & 2 deletions smb/src/packets/smb2/info/query.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//! Get/Set Info Request/Response

use crate::packets::smb2::{FileId, SecurityDescriptor, SID};
use crate::packets::security::{SecurityDescriptor, SID};
use crate::packets::smb2::FileId;
use crate::query_info_data;
use binrw::{io::TakeSeekExt, prelude::*};
use modular_bitfield::prelude::*;
use std::io::{Cursor, SeekFrom};

use super::super::{super::binrw_util::prelude::*, fscc::*};
use super::common::*;
use crate::packets::{binrw_util::prelude::*, fscc::*};

#[binrw::binrw]
#[derive(Debug)]
Expand Down
9 changes: 3 additions & 6 deletions smb/src/packets/smb2/info/set.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
//! SMB2 Set Info Request/Response messages.

use crate::packets::smb2::FileId;
use crate::{packets::smb2::SecurityDescriptor, query_info_data};
use crate::{packets::security::SecurityDescriptor, query_info_data};

use super::common::*;
use super::{
super::{super::binrw_util::prelude::*, fscc::*},
QueryQuotaInfo,
};
use super::{common::*, QueryQuotaInfo};
use crate::packets::{binrw_util::prelude::*, fscc::*};
use binrw::io::TakeSeekExt;
use binrw::prelude::*;

Expand Down
Loading