/*
|
/*
|
* smb.h
|
* smb.h
|
*
|
*
|
* Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
|
* Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
|
*
|
*
|
*/
|
*/
|
|
|
#ifndef _LINUX_SMB_H
|
#ifndef _LINUX_SMB_H
|
#define _LINUX_SMB_H
|
#define _LINUX_SMB_H
|
|
|
#define SMB_PORT 139
|
#define SMB_PORT 139
|
#define SMB_MAXNAMELEN 255
|
#define SMB_MAXNAMELEN 255
|
#define SMB_MAXPATHLEN 1024
|
#define SMB_MAXPATHLEN 1024
|
|
|
#define SMB_DEF_MAX_XMIT 32768
|
#define SMB_DEF_MAX_XMIT 32768
|
|
|
/* Allocate max. 1 page */
|
/* Allocate max. 1 page */
|
#define TRANS2_MAX_TRANSFER (4096-17)
|
#define TRANS2_MAX_TRANSFER (4096-17)
|
|
|
#include <asm/types.h>
|
#include <asm/types.h>
|
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
typedef u8 byte;
|
typedef u8 byte;
|
typedef u16 word;
|
typedef u16 word;
|
typedef u32 dword;
|
typedef u32 dword;
|
#else
|
#else
|
typedef unsigned char byte;
|
typedef unsigned char byte;
|
typedef unsigned short word;
|
typedef unsigned short word;
|
typedef unsigned long dword;
|
typedef unsigned long dword;
|
#endif
|
#endif
|
|
|
/* The following macros have been taken directly from Samba. Thanks,
|
/* The following macros have been taken directly from Samba. Thanks,
|
Andrew! */
|
Andrew! */
|
|
|
#undef CAREFUL_ALIGNMENT
|
#undef CAREFUL_ALIGNMENT
|
|
|
/* we know that the 386 can handle misalignment and has the "right"
|
/* we know that the 386 can handle misalignment and has the "right"
|
byteorder */
|
byteorder */
|
#if defined(__i386__)
|
#if defined(__i386__)
|
#define CAREFUL_ALIGNMENT 0
|
#define CAREFUL_ALIGNMENT 0
|
#endif
|
#endif
|
|
|
#ifndef CAREFUL_ALIGNMENT
|
#ifndef CAREFUL_ALIGNMENT
|
#define CAREFUL_ALIGNMENT 1
|
#define CAREFUL_ALIGNMENT 1
|
#endif
|
#endif
|
|
|
#define BVAL(buf,pos) (((u8 *)(buf))[pos])
|
#define BVAL(buf,pos) (((u8 *)(buf))[pos])
|
#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
|
#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
|
#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
|
#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
|
|
|
|
|
#if CAREFUL_ALIGNMENT
|
#if CAREFUL_ALIGNMENT
|
#define WVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
|
#define WVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
|
#define DVAL(buf,pos) (WVAL(buf,pos)|WVAL(buf,(pos)+2)<<16)
|
#define DVAL(buf,pos) (WVAL(buf,pos)|WVAL(buf,(pos)+2)<<16)
|
|
|
#define SSVALX(buf,pos,val) (BVAL(buf,pos)=(val)&0xFF,BVAL(buf,pos+1)=(val)>>8)
|
#define SSVALX(buf,pos,val) (BVAL(buf,pos)=(val)&0xFF,BVAL(buf,pos+1)=(val)>>8)
|
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
|
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
|
#define WSET(buf,pos,val) { word __val = (val); \
|
#define WSET(buf,pos,val) { word __val = (val); \
|
SSVALX((buf),(pos),((word)(__val))); }
|
SSVALX((buf),(pos),((word)(__val))); }
|
#define DSET(buf,pos,val) { dword __val = (val); \
|
#define DSET(buf,pos,val) { dword __val = (val); \
|
SIVALX((buf),(pos),((dword)(__val))); }
|
SIVALX((buf),(pos),((dword)(__val))); }
|
#else
|
#else
|
/* this handles things for architectures like the 386 that can handle
|
/* this handles things for architectures like the 386 that can handle
|
alignment errors */
|
alignment errors */
|
/*
|
/*
|
WARNING: This section is dependent on the length of word and dword
|
WARNING: This section is dependent on the length of word and dword
|
being correct
|
being correct
|
*/
|
*/
|
#define WVAL(buf,pos) (*(word *)((char *)(buf) + (pos)))
|
#define WVAL(buf,pos) (*(word *)((char *)(buf) + (pos)))
|
#define DVAL(buf,pos) (*(dword *)((char *)(buf) + (pos)))
|
#define DVAL(buf,pos) (*(dword *)((char *)(buf) + (pos)))
|
#define WSET(buf,pos,val) WVAL(buf,pos)=((word)(val))
|
#define WSET(buf,pos,val) WVAL(buf,pos)=((word)(val))
|
#define DSET(buf,pos,val) DVAL(buf,pos)=((dword)(val))
|
#define DSET(buf,pos,val) DVAL(buf,pos)=((dword)(val))
|
#endif
|
#endif
|
|
|
|
|
/* where to find the base of the SMB packet proper */
|
/* where to find the base of the SMB packet proper */
|
#define smb_base(buf) ((byte *)(((byte *)(buf))+4))
|
#define smb_base(buf) ((byte *)(((byte *)(buf))+4))
|
|
|
#define LANMAN1
|
#define LANMAN1
|
#define LANMAN2
|
#define LANMAN2
|
#define NT1
|
#define NT1
|
|
|
enum smb_protocol {
|
enum smb_protocol {
|
PROTOCOL_NONE,
|
PROTOCOL_NONE,
|
PROTOCOL_CORE,
|
PROTOCOL_CORE,
|
PROTOCOL_COREPLUS,
|
PROTOCOL_COREPLUS,
|
PROTOCOL_LANMAN1,
|
PROTOCOL_LANMAN1,
|
PROTOCOL_LANMAN2,
|
PROTOCOL_LANMAN2,
|
PROTOCOL_NT1
|
PROTOCOL_NT1
|
};
|
};
|
|
|
enum smb_case_hndl {
|
enum smb_case_hndl {
|
CASE_DEFAULT,
|
CASE_DEFAULT,
|
CASE_LOWER,
|
CASE_LOWER,
|
CASE_UPPER
|
CASE_UPPER
|
};
|
};
|
|
|
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
|
|
enum smb_conn_state {
|
enum smb_conn_state {
|
CONN_VALID, /* everything's fine */
|
CONN_VALID, /* everything's fine */
|
CONN_INVALID, /* Something went wrong, but did not
|
CONN_INVALID, /* Something went wrong, but did not
|
try to reconnect yet. */
|
try to reconnect yet. */
|
CONN_RETRIED /* Tried a reconnection, but was refused */
|
CONN_RETRIED /* Tried a reconnection, but was refused */
|
};
|
};
|
|
|
struct smb_dskattr {
|
struct smb_dskattr {
|
word total;
|
word total;
|
word allocblocks;
|
word allocblocks;
|
word blocksize;
|
word blocksize;
|
word free;
|
word free;
|
};
|
};
|
|
|
/*
|
/*
|
* Contains all relevant data on a SMB networked file.
|
* Contains all relevant data on a SMB networked file.
|
*/
|
*/
|
struct smb_dirent {
|
struct smb_dirent {
|
|
|
unsigned long f_ino;
|
unsigned long f_ino;
|
umode_t f_mode;
|
umode_t f_mode;
|
nlink_t f_nlink;
|
nlink_t f_nlink;
|
uid_t f_uid;
|
uid_t f_uid;
|
gid_t f_gid;
|
gid_t f_gid;
|
kdev_t f_rdev;
|
kdev_t f_rdev;
|
off_t f_size;
|
off_t f_size;
|
time_t f_atime;
|
time_t f_atime;
|
time_t f_mtime;
|
time_t f_mtime;
|
time_t f_ctime;
|
time_t f_ctime;
|
unsigned long f_blksize;
|
unsigned long f_blksize;
|
unsigned long f_blocks;
|
unsigned long f_blocks;
|
|
|
int opened; /* is it open on the fileserver? */
|
int opened; /* is it open on the fileserver? */
|
word fileid; /* What id to handle a file with? */
|
word fileid; /* What id to handle a file with? */
|
word attr; /* Attribute fields, DOS value */
|
word attr; /* Attribute fields, DOS value */
|
|
|
unsigned short access; /* Access bits. */
|
unsigned short access; /* Access bits. */
|
unsigned long f_pos; /* File position. (For readdir.) */
|
unsigned long f_pos; /* File position. (For readdir.) */
|
unsigned char name[SMB_MAXNAMELEN+1];
|
unsigned char name[SMB_MAXNAMELEN+1];
|
int len; /* namelength */
|
int len; /* namelength */
|
};
|
};
|
|
|
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
#endif /* _LINUX_SMB_H */
|
#endif /* _LINUX_SMB_H */
|
|
|