123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //---------------------------------------------------------------------------
- // __________________ _________ _____ _____ .__ ._.
- // \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
- // | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
- // | | \| ` \/ / Y \ / | | \ ___/ \|
- // |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
- // \/ \/ \/ \/ )/ \/ \/ \/
- //
- // This file is part of libdsm. Copyright © 2014 VideoLabs SAS
- //
- // Author: Julien 'Lta' BALLET <contact@lta.io>
- //
- // This program is free software. It comes without any warranty, to the extent
- // permitted by applicable law. You can redistribute it and/or modify it under
- // the terms of the Do What The Fuck You Want To Public License, Version 2, as
- // published by Sam Hocevar. See the COPYING file for more details.
- //----------------------------------------------------------------------------
- /**
- * @file smb_types.h
- * @brief liBDSM types and structures
- */
- #ifndef __BDSM_SMB_TYPES_H_
- #define __BDSM_SMB_TYPES_H_
- /**
- * @struct smb_tid
- * @brief The id of a connection to a share within a session.
- */
- typedef uint16_t smb_tid;
- /**
- * @struct smb_fid
- * @brief The id of a file within a share within a session.
- */
- typedef uint16_t smb_fid;
- // Concatenation of the two above, representing a file inside of a session
- // First 4 bytes are the TreeID (smb_tid), last 4 are the File ID (FUID)
- // A map between smb_fd and smb_file is maintained inside each session
- /** @struct smb_fd
- * @brief SMB File descriptor, represents a file within a session.
- */
- typedef uint32_t smb_fd;
- /**
- * @internal
- * @struct smb_file
- * @brief An opaque data structure to represent file
- */
- typedef struct smb_file_s
- {
- struct smb_file_s *next; // Next file in this share
- char *name;
- smb_fid fid;
- smb_tid tid;
- size_t name_len;
- uint64_t created;
- uint64_t accessed;
- uint64_t written;
- uint64_t changed;
- uint64_t alloc_size;
- uint64_t size;
- uint32_t attr;
- uint32_t readp; // Current read pointer (position);
- int is_dir; // 0 -> file, 1 -> directory
- } smb_file;
- typedef struct smb_share_s
- {
- struct smb_share_s *next; // Next share in this session
- struct smb_file_s *files; // List of all open files for this share
- smb_tid tid;
- uint16_t opts; // Optionnal support opts
- uint16_t rights; // Maximum rights field
- uint16_t guest_rights;
- } smb_share;
- /**
- * @brief An opaque data structure to represent a SMB Session.
- */
- typedef struct
- {
- int state;
- int guest; // boolean, are we logged as guest ?
- uint16_t uid; // uid attributed by the server
- netbios_session *nb_session;
- // Informations about the smb server we are connected to.
- struct {
- char name[16]; // The server name
- uint16_t dialect; // The selected dialect
- uint16_t security_mode; // Security mode
- uint32_t caps; // Server caps replyed during negotiate
- uint32_t session_key; // XXX Is this really usefull?
- uint64_t challenge; // For challenge response security
- uint64_t ts; // It seems Win7 requires it :-/
- } srv;
- struct smb_share_s *shares; // shares->files | Map fd <-> smb_file
- } smb_session;
- /**
- * @struct smb_share_list
- * @brief An opaque object representing the list of share of a SMB file server.
- */
- typedef char **smb_share_list;
- /**
- * @struct smb_stat_list
- * @brief An opaque structure containing a list of file status
- */
- typedef smb_file *smb_stat_list;
- /**
- * @struct smb_stat
- * @brief An opaque structure containing info about a file
- */
- typedef smb_file *smb_stat;
- /**
- * @internal
- * @struct smb_message
- * @brief A convenience structure used to build smb messages
- */
- typedef struct
- {
- size_t payload_size; // Size of the allocated payload
- size_t cursor; // Write cursor in the payload
- smb_packet *packet; // Yummy yummy, Fruity fruity !
- } smb_message;
- #endif
|