added "hide files" option.
[kai/samba.git] / source3 / include / smb.h
index 5fd2e0846bbdebad1be7508e8326413d22131973..b36943bfe2f39a0da4d11b3fb1db982ff781f569 100644 (file)
@@ -2,7 +2,7 @@
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB parameters and setup
-   Copyright (C) Andrew Tridgell 1992-1995
+   Copyright (C) Andrew Tridgell 1992-1997
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #define BUFFER_SIZE (0xFFFF)
 #define SAFETY_MARGIN 1024
 
-#ifndef EXTERN
-#      define EXTERN extern
+/* Default size of shared memory used for share mode locking */
+#ifndef SHMEM_SIZE
+#define SHMEM_SIZE 102400
+#endif
+
+/* Default number of hash buckets used in shared memory share mode */
+#ifndef SHMEM_HASH_SIZE
+#define SHMEM_HASH_SIZE 113
 #endif
 
 #define NMB_PORT 137
 
 typedef int BOOL;
 
+/* offset in shared memory */
+typedef  int smb_shm_offset_t;
+#define NULL_OFFSET (smb_shm_offset_t)(0)
+
+
 /*
    Samba needs type definitions for int16, int32, uint16 and uint32.
    
@@ -95,20 +106,24 @@ typedef unsigned int uint32;
 #define DEF_CREATE_MASK (0755)
 #endif
 
-#ifndef DEFAULT_PIPE_TIMEOUT
-#define DEFAULT_PIPE_TIMEOUT 10000000 /* Ten seconds */
-#endif
+/* how long to wait for secondary SMB packets (milli-seconds) */
+#define SMB_SECONDARY_WAIT (60*1000)
 
 /* debugging code */
 #ifndef SYSLOG
 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
 #else
-EXTERN int syslog_level;
+extern int syslog_level;
 
-#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? \
-                                                  (syslog_level = (level), Debug1 body):0)
+#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
 #endif
 
+/* this defines the error codes that receive_smb can put in smb_read_error */
+#define READ_TIMEOUT 1
+#define READ_EOF 2
+#define READ_ERROR 3
+
+
 #define DIR_STRUCT_SIZE 43
 
 /* these define all the command types recognised by the server - there
@@ -276,23 +291,40 @@ typedef struct
        BOOL  wr_discard; /* discard all further data */
         } write_bmpx_struct;
 
+/*
+ * Structure used to indirect fd's from the files_struct.
+ * Needed as POSIX locking is based on file and process, not
+ * file descriptor and process.
+ */
+
 typedef struct
 {
-  int cnum;
+  uint16 ref_count;
+  uint32 dev;
+  uint32 inode;
   int fd;
+  int fd_readonly;
+  int fd_writeonly;
+  int real_open_flags;
+} file_fd_struct;
+
+typedef struct
+{
+  int cnum;
+  file_fd_struct *fd_ptr;
   int pos;
   int size;
   int mode;
+  int uid;
   char *mmap_ptr;
   int mmap_size;
   write_bmpx_struct *wbmpx_ptr;
-  time_t open_time;
+  struct timeval open_time;
   BOOL open;
   BOOL can_lock;
   BOOL can_read;
   BOOL can_write;
   BOOL share_mode;
-  BOOL share_pending;
   BOOL print_file;
   BOOL modified;
   char *name;
@@ -308,8 +340,6 @@ typedef struct
 {
   int service;
   BOOL force_user;
-  int uid; /* uid of user who *opened* this connection */
-  int gid; /* gid of user who *opened* this connection */
   struct uid_cache uid_cache;
   void *dirptr;
   BOOL open;
@@ -321,6 +351,9 @@ typedef struct
   char *connectpath;
   char *origpath;
   char *user; /* name of user who *opened* this connection */
+  int uid; /* uid of user who *opened* this connection */
+  int gid; /* gid of user who *opened* this connection */
+  uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
   /* following groups stuff added by ih */
   /* This groups info is valid for the user that *opened* the connection */
   int ngroups;
@@ -343,6 +376,10 @@ typedef struct
   int user_ngroups;
   gid_t *user_groups;
   int *user_igroups; /* an integer version - some OSes are broken :-( */
+#if (defined(NETGROUP) && defined(AUTOMOUNT))
+  char *home_share;  /* to store NIS home of a user - simeon */
+#endif
+  char *real_name;   /* to store real name from password file - simeon */
 } user_struct;
 
 
@@ -378,6 +415,50 @@ struct server_info_struct
 };
 
 
+/* used for network interfaces */
+struct interface
+{
+       struct interface *next;
+       struct in_addr ip;
+       struct in_addr bcast;
+       struct in_addr nmask;
+};
+
+/* share mode record pointed to in shared memory hash bucket */
+typedef struct
+{
+  smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
+  int locking_version;
+  int32 st_dev;
+  int32 st_ino;
+  int num_share_mode_entries;
+  smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
+  char file_name[1];
+} share_mode_record;
+
+/* share mode entry pointed to by share_mode_record struct */
+typedef struct
+{
+  smb_shm_offset_t next_share_mode_entry;
+  int pid;
+  int share_mode;
+  struct timeval time;
+} share_mode_entry;
+
+/* struct returned by get_share_modes */
+typedef struct
+{
+  int pid;
+  int share_mode;
+  struct timeval time;
+} min_share_mode_entry;
+
+/* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
+typedef int share_lock_token;
+
+/* Conversion to hash entry index from device and inode numbers. */
+#define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
+
 /* this is used for smbstatus */
 struct connect_record
 {
@@ -393,7 +474,7 @@ struct connect_record
 };
 
 
-#define LOCKING_VERSION 2
+#define LOCKING_VERSION 3
 
 /* these are useful macros for checking validity of handles */
 #define VALID_FNUM(fnum)   (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
@@ -430,7 +511,6 @@ struct connect_record
 #define MAP_HIDDEN(cnum)   (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
 #define MAP_SYSTEM(cnum)   (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
 #define MAP_ARCHIVE(cnum)   (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
-#define CREATE_MODE(cnum)  (lp_create_mode(SNUM(cnum)) | 0700)
 #ifdef SMB_PASSWD
 #define SMBENCRYPT()       (lp_encrypted_passwords())
 #else
@@ -620,13 +700,6 @@ struct connect_record
 #define ERRHRD 0x03  /* Error is an hardware error. */
 #define ERRCMD 0xFF  /* Command was not in the "SMB" format. */
 
-/* structure used to hold the incoming hosts info */
-struct from_host {
-    char   *name;                      /* host name */
-    char   *addr;                      /* host address */
-    struct sockaddr_in *sin;           /* their side of the link */
-};
-
 #ifdef __STDC__
 int Debug1(char *, ...);
 #else
@@ -743,12 +816,43 @@ char *Strstr(char *s, char *p);
 #define SV_TYPE_DOMAIN_MASTER       0x00080000
 #define SV_TYPE_SERVER_OSF          0x00100000
 #define SV_TYPE_SERVER_VMS          0x00200000
+#define SV_TYPE_WIN95_PLUS          0x00400000
 #define SV_TYPE_ALTERNATE_XPORT     0x20000000  
 #define SV_TYPE_LOCAL_LIST_ONLY     0x40000000  
 #define SV_TYPE_DOMAIN_ENUM         0x80000000
 #define SV_TYPE_ALL                 0xFFFFFFFF  
 
-
+/* what server type are we currently  - JHT Says we ARE 4.20 */
+/* this was set by JHT in liaison with Jeremy Allison early 1997 */
+/* setting to 4.20 at same time as announcing ourselves as NT Server */
+/* History: */
+/* Version 4.0 - never made public */
+/* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */
+/*             - Reappeared in 1.9.16p11 with fixed smbd services */
+/* Version 4.20 - To indicate that nmbd and browsing now works better */
+
+#define MAJOR_VERSION 0x04
+#define MINOR_VERSION 0x02
+
+/* Browser Election Values */
+#define BROWSER_ELECTION_VERSION       0x010f
+#define BROWSER_CONSTANT       0xaa55
+
+
+/* Capabilities.  see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
+
+#define CAP_RAW_MODE         0x0001
+#define CAP_MPX_MODE         0x0002
+#define CAP_UNICODE          0x0004
+#define CAP_LARGE_FILES      0x0008
+#define CAP_NT_SMBS          0x0010
+#define CAP_RPC_REMOTE_APIS  0x0020
+#define CAP_STATUS32         0x0040
+#define CAP_LEVEL_II_OPLOCKS 0x0080
+#define CAP_LOCK_AND_READ    0x0100
+#define CAP_NT_FIND          0x0200
+#define CAP_DFS              0x1000
+#define CAP_LARGE_READX      0x4000
 
 /* protocol types. It assumes that higher protocols include lower protocols
    as subsets */
@@ -759,7 +863,7 @@ enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
 
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
-                    PRINT_QNX,PRINT_PLP};
+                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
 
 
 /* case handling */
@@ -795,5 +899,27 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
 
 #define ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
 
+/*
+ * Global value meaing that the smb_uid field should be
+ * ingored (in share level security and protocol level == CORE)
+ */
+
+#define UID_FIELD_INVALID 0
+#define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
+
 #endif 
+
+/* Default client code page - 850 - Western European */
+#define DEFAULT_CLIENT_CODE_PAGE 850
+
+/* Size of buffer to use when moving files across filesystems. */
+#define COPYBUF_SIZE (8*1024)
+
+/* Default files that will be hidden, but accessible.  intended
+   to replace the "hide dot files" parameter if the "hide files"
+   parameter moves to the service section instead of the global
+   section.
+ */
+#define DEFAULT_FILES_TO_HIDE ".*"
+
 /* _SMB_H */