Apache2-AuthenNTLM

 view release on metacpan or  search on metacpan

smb/smbval/smblib-priv.h  view on Meta::CPAN


#define SMB_clos_fid_offset     33        /* FID to close            */
#define SMB_clos_tim_offset     35        /* Last mod time           */
#define SMB_clos_bcc_offset     39        /* bcc                     */        
#define SMB_clos_len            41

/* Offsets related to Write requests                                 */

#define SMB_write_fid_offset    33        /* FID to write            */
#define SMB_write_cnt_offset    35        /* bytes to write          */
#define SMB_write_ofs_offset    37        /* location to write to    */
#define SMB_write_clf_offset    41        /* advisory count left     */
#define SMB_write_bcc_offset    43        /* bcc = data bytes + 3    */
#define SMB_write_buf_offset    45        /* Data=0x01, len, data    */
#define SMB_write_len           45        /* plus the data ...       */

#define SMB_writr_cnt_offset    33        /* Count of bytes written  */
#define SMB_writr_bcc_offset    35        /* bcc                     */
#define SMB_writr_len           37

/* Offsets related to read requests */

#define SMB_read_fid_offset     33        /* FID of file to read     */
#define SMB_read_cnt_offset     35        /* count of words to read  */
#define SMB_read_ofs_offset     37        /* Where to read from      */
#define SMB_read_clf_offset     41        /* Advisory count to go    */
#define SMB_read_bcc_offset     43
#define SMB_read_len            45

#define SMB_readr_cnt_offset    33        /* Count of bytes returned */
#define SMB_readr_res_offset    35        /* 4 shorts reserved, 8 bytes */
#define SMB_readr_bcc_offset    43        /* bcc                     */
#define SMB_readr_bff_offset    45        /* buffer format char = 0x01 */
#define SMB_readr_len_offset    46        /* buffer len              */
#define SMB_readr_len           45        /* length of the readr before data */

/* Offsets for Create file                                           */

#define SMB_creat_atr_offset    33        /* Attributes of new file ... */
#define SMB_creat_tim_offset    35        /* Time of creation           */
#define SMB_creat_dat_offset    37        /* 4004BCE :-)                */
#define SMB_creat_bcc_offset    39        /* bcc                        */
#define SMB_creat_buf_offset    41
#define SMB_creat_len           41        /* Before the data            */

#define SMB_creatr_fid_offset   33        /* FID of created file        */

/* Offsets for Delete file                                           */

#define SMB_delet_sat_offset    33        /* search attribites          */
#define SMB_delet_bcc_offset    35        /* bcc                        */
#define SMB_delet_buf_offset    37
#define SMB_delet_len           37

/* Offsets for SESSION_SETUP_ANDX for both LM and NT LM protocols    */

#define SMB_ssetpLM_mbs_offset  37        /* Max buffer Size, allow for AndX */
#define SMB_ssetpLM_mmc_offset  39        /* max multiplex count             */
#define SMB_ssetpLM_vcn_offset  41        /* VC number if new VC             */
#define SMB_ssetpLM_snk_offset  43        /* Session Key                     */
#define SMB_ssetpLM_pwl_offset  47        /* password length                 */
#define SMB_ssetpLM_res_offset  49        /* reserved                        */
#define SMB_ssetpLM_bcc_offset  53        /* bcc                             */
#define SMB_ssetpLM_len         55        /* before data ...                 */
#define SMB_ssetpLM_buf_offset  55

#define SMB_ssetpNTLM_mbs_offset 37       /* Max Buffer Size for NT LM 0.12  */
                                          /* and above                       */
#define SMB_ssetpNTLM_mmc_offset 39       /* Max Multiplex count             */
#define SMB_ssetpNTLM_vcn_offset 41       /* VC Number                       */
#define SMB_ssetpNTLM_snk_offset 43       /* Session key                     */
#define SMB_ssetpNTLM_cipl_offset 47      /* Case Insensitive PW Len         */
#define SMB_ssetpNTLM_cspl_offset 49      /* Unicode pw len                  */
#define SMB_ssetpNTLM_res_offset 51       /* reserved                        */
#define SMB_ssetpNTLM_cap_offset 55       /* server capabilities             */
#define SMB_ssetpNTLM_bcc_offset 59       /* bcc                             */
#define SMB_ssetpNTLM_len        61       /* before data                     */
#define SMB_ssetpNTLM_buf_offset 61

#define SMB_ssetpr_axo_offset  35         /* Offset of next response ...    */
#define SMB_ssetpr_act_offset  37         /* action, bit 0 = 1 => guest     */
#define SMB_ssetpr_bcc_offset  39         /* bcc                            */
#define SMB_ssetpr_buf_offset  41         /* Native OS etc                  */

/* Offsets for SMB create directory                                         */

#define SMB_creatdir_bcc_offset 33        /* only a bcc here                */
#define SMB_creatdir_buf_offset 35        /* Where things start             */
#define SMB_creatdir_len        35

/* Offsets for SMB delete directory                                         */

#define SMB_deletdir_bcc_offset 33        /* only a bcc here                */
#define SMB_deletdir_buf_offset 35        /* where things start             */
#define SMB_deletdir_len        35

/* Offsets for SMB check directory                                          */

#define SMB_checkdir_bcc_offset 33        /* Only a bcc here                */
#define SMB_checkdir_buf_offset 35        /* where things start             */
#define SMB_checkdir_len        35

/* Offsets for SMB search                                                   */

#define SMB_search_mdc_offset   33        /* Max Dir ents to return         */
#define SMB_search_atr_offset   35        /* Search attributes              */
#define SMB_search_bcc_offset   37        /* bcc                            */
#define SMB_search_buf_offset   39        /* where the action is            */
#define SMB_search_len          39

#define SMB_searchr_dec_offset  33        /* Dir ents returned              */
#define SMB_searchr_bcc_offset  35        /* bcc                            */
#define SMB_searchr_buf_offset  37        /* Where the action starts        */
#define SMB_searchr_len         37        /* before the dir ents            */

#define SMB_searchr_dirent_len  43        /* 53 bytes                       */

/* Defines for SMB transact and transact2 calls                             */

#define SMB_trans_tpc_offset    33        /* Total param count              */
#define SMB_trans_tdc_offset    35        /* total Data count               */

smb/smbval/smblib-priv.h  view on Meta::CPAN


typedef enum {SMB_State_NoState, SMB_State_Stopped, SMB_State_Started} SMB_State_Types;

/* The following two arrays need to be in step!              */
/* We must make it possible for callers to specify these ... */


static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0", 
			    "MICROSOFT NETWORKS 1.03",
			    "MICROSOFT NETWORKS 3.0",
			    "DOS LANMAN1.0",
			    "LANMAN1.0",
			    "DOS LM1.2X002",
			    "LM1.2X002",
			    "DOS LANMAN2.1",
			    "LANMAN2.1",
			    "Samba",
			    "NT LM 0.12",
			    "NT LANMAN 1.0",
			    NULL};

static int SMB_Types[] = {SMB_P_Core,
                          SMB_P_CorePlus,
			  SMB_P_DOSLanMan1,
			  SMB_P_DOSLanMan1,
	                  SMB_P_LanMan1,
			  SMB_P_DOSLanMan2,
		          SMB_P_LanMan2,
	 	          SMB_P_LanMan2_1,
		          SMB_P_LanMan2_1,
		          SMB_P_NT1,
		          SMB_P_NT1,
		          SMB_P_NT1,
		          -1};

typedef struct SMB_Status {

  union {
    struct {
      unsigned char ErrorClass;
      unsigned char Reserved;
      unsigned short Error;
    } DosError;
    unsigned int NtStatus;
  } status;
} SMB_Status;

typedef struct SMB_Tree_Structure * SMB_Tree_Handle;

typedef struct SMB_Connect_Def * SMB_Handle_Type;

struct SMB_Connect_Def {

  SMB_Handle_Type Next_Con, Prev_Con;          /* Next and previous conn */
  int protocol;                                /* What is the protocol   */
  int prot_IDX;                                /* And what is the index  */
  void *Trans_Connect;                         /* The connection         */

  /* All these strings should be malloc'd */

  char service[80], username[80], password[80], desthost[80], sock_options[80];
  char address[80], myname[80];

  SMB_Tree_Handle first_tree, last_tree;  /* List of trees on this server */

  int gid;         /* Group ID, do we need it?                      */
  int mid;         /* Multiplex ID? We might need one per con       */
  int pid;         /* Process ID                                    */

  int uid;         /* Authenticated user id.                        */

                   /* It is pretty clear that we need to bust some of */
                   /* these out into a per TCon record, as there may  */
                   /* be multiple TCon's per server, etc ... later    */

  int port;        /* port to use in case not default, this is a TCPism! */

  int max_xmit;    /* Max xmit permitted by server                  */
  int Security;    /* 0 = share, 1 = user                           */
  int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */
  BOOL encrypt_passwords; /* FALSE = don't                          */ 
  int MaxMPX, MaxVC, MaxRaw;
  unsigned int SessionKey, Capabilities;
  int SvrTZ;                                 /* Server Time Zone */
  int Encrypt_Key_Len;
  char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40];
  char Svr_OS[80], Svr_LMType[80], Svr_PDom[80];

};

#define SMBLIB_DEFAULT_DOMAIN "STAFF"
#define SMBLIB_DEFAULT_OSNAME "UNIX of some type"
#define SMBLIB_DEFAULT_LMTYPE "SMBlib LM2.1 minus a bit"
#define SMBLIB_MAX_XMIT 65535

#define SMB_Sec_Mode_Share 0
#define SMB_Sec_Mode_User  1

/* A Tree_Structure                       */

struct SMB_Tree_Structure {

  SMB_Tree_Handle next, prev;
  SMB_Handle_Type con;
  char path[129];
  char device_type[20];
  int mbs;                   /* Local MBS */
  int tid;

};

typedef struct SMB_File_Def SMB_File;

struct SMB_File_Def {

  SMB_Tree_Handle tree;
  char filename[256];          /* We should malloc this ... */
  UWORD fid;
  unsigned int lastmod;
  unsigned int size;           /* Could blow up if 64bit files supported */
  UWORD access;
  off_t fileloc;

};

/* global Variables for the library */

extern SMB_State_Types SMBlib_State;

#ifndef SMBLIB_ERRNO
extern int SMBlib_errno;
extern int SMBlib_SMB_Error;          /* last Error             */
#endif

SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, SMB_Tree_Handle tree,
				char *path, char *password, char *dev);



( run in 1.660 second using v1.01-cache-2.11-cpan-99c4e6809bf )