extern "C" {
#endif
-/* Error responses */
-/* these should follow the spec ... is there one ? */
+ /* Error responses */
+ /* these should follow the spec ... is there one ? */
#define RFCNBE_Bad -1 /* Bad response */
#define RFCNBE_OK 0 /* Routine completed successfully. */
#define RFCNBE_BadParam 15 /* Bad parameters passed ... */
#define RFCNBE_Timeout 16 /* IO Timed out */
-/* Text strings for the error responses */
-extern char const *RFCNB_Error_Strings[];
-/*
- * static char *RFCNB_Error_Strings[] = {
- *
- * "RFCNBE_OK: Routine completed successfully.",
- * "RFCNBE_NoSpace: No space available for a malloc call.",
- * "RFCNBE_BadName: NetBIOS name could not be translated to IP address.",
- * "RFCNBE_BadRead: Read system call returned an error. Check errno.",
- * "RFCNBE_BadWrite: Write system call returned an error. Check errno.",
- * "RFCNBE_ProtErr: A protocol error has occurred.",
- * "RFCNBE_ConGone: Connection dropped during a read or write system call.",
- * "RFCNBE_BadHandle: Bad connection handle passed.",
- * "RFCNBE_BadSocket: Problems creating socket.",
- * "RFCNBE_ConnectFailed: Connection failed. See errno.",
- * "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.",
- * "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.",
- * "RFCNBE_CallRejCNNP: Call rejected. Called name not present.",
- * "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.",
- * "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.",
- * "RFCNBE_BadParam: Bad parameters passed to a routine.",
- * "RFCNBE_Timeout: IO Operation timed out ..."
- *
- * };
- */
+ /* Text strings for the error responses */
+ extern char const *RFCNB_Error_Strings[];
+ /*
+ * static char *RFCNB_Error_Strings[] = {
+ *
+ * "RFCNBE_OK: Routine completed successfully.",
+ * "RFCNBE_NoSpace: No space available for a malloc call.",
+ * "RFCNBE_BadName: NetBIOS name could not be translated to IP address.",
+ * "RFCNBE_BadRead: Read system call returned an error. Check errno.",
+ * "RFCNBE_BadWrite: Write system call returned an error. Check errno.",
+ * "RFCNBE_ProtErr: A protocol error has occurred.",
+ * "RFCNBE_ConGone: Connection dropped during a read or write system call.",
+ * "RFCNBE_BadHandle: Bad connection handle passed.",
+ * "RFCNBE_BadSocket: Problems creating socket.",
+ * "RFCNBE_ConnectFailed: Connection failed. See errno.",
+ * "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.",
+ * "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.",
+ * "RFCNBE_CallRejCNNP: Call rejected. Called name not present.",
+ * "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.",
+ * "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.",
+ * "RFCNBE_BadParam: Bad parameters passed to a routine.",
+ * "RFCNBE_Timeout: IO Operation timed out ..."
+ *
+ * };
+ */
#define RFCNB_Default_Port 139
-/* API Structures */
+ /* API Structures */
-typedef struct redirect_addr * redirect_ptr;
+ typedef struct redirect_addr * redirect_ptr;
-struct redirect_addr {
- struct in_addr ip_addr;
- int port;
- redirect_ptr next;
-};
+ struct redirect_addr {
+ struct in_addr ip_addr;
+ int port;
+ redirect_ptr next;
+ };
-typedef struct RFCNB_Con {
- int fd; /* File descripter for TCP/IP connection */
- int rfc_errno; /* last error */
- int timeout; /* How many milli-secs before IO times out */
- int redirects; /* How many times we were redirected */
- struct redirect_addr *redirect_list; /* First is first address */
- struct redirect_addr *last_addr;
-} RFCNB_Con;
+ typedef struct RFCNB_Con {
+ int fd; /* File descripter for TCP/IP connection */
+ int rfc_errno; /* last error */
+ int timeout; /* How many milli-secs before IO times out */
+ int redirects; /* How many times we were redirected */
+ struct redirect_addr *redirect_list; /* First is first address */
+ struct redirect_addr *last_addr;
+ } RFCNB_Con;
-typedef struct RFCNB_Pkt {
- char *data; /* The data in this portion */
- int len;
- struct RFCNB_Pkt *next;
-} RFCNB_Pkt;
+ typedef struct RFCNB_Pkt {
+ char *data; /* The data in this portion */
+ int len;
+ struct RFCNB_Pkt *next;
+ } RFCNB_Pkt;
-/* API Definition of routines we define */
+ /* API Definition of routines we define */
-void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port);
+ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port);
-int RFCNB_Send(RFCNB_Con *Con_Handle, RFCNB_Pkt *Data, int Length);
+ int RFCNB_Send(RFCNB_Con *Con_Handle, RFCNB_Pkt *Data, int Length);
-int RFCNB_Recv(void *Con_Handle, RFCNB_Pkt *Data, int Length);
+ int RFCNB_Recv(void *Con_Handle, RFCNB_Pkt *Data, int Length);
-int RFCNB_Hangup(RFCNB_Con *con_Handle);
+ int RFCNB_Hangup(RFCNB_Con *con_Handle);
-void *RFCNB_Listen(void);
+ void *RFCNB_Listen(void);
-void RFCNB_Get_Error(char *buffer, int buf_len);
+ void RFCNB_Get_Error(char *buffer, int buf_len);
-int RFCNB_Get_Last_Error(void);
+ int RFCNB_Get_Last_Error(void);
-RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
+ RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
-void RFCNB_Free_Pkt(RFCNB_Pkt *pkt);
+ void RFCNB_Free_Pkt(RFCNB_Pkt *pkt);
-int RFCNB_Set_Sock_NoDelay(RFCNB_Con *con_Handle, int yn);
+ int RFCNB_Set_Sock_NoDelay(RFCNB_Con *con_Handle, int yn);
#ifdef __cplusplus
};
extern "C" {
#endif
-/* To get the error class we want the first 8 bits */
-/* Because we just grab 4bytes from the SMB header, we have to re-order */
-/* here, but it makes the NtStatus part easier in future */
+ /* To get the error class we want the first 8 bits */
+ /* Because we just grab 4bytes from the SMB header, we have to re-order */
+ /* here, but it makes the NtStatus part easier in future */
#define SMBlib_Error_Class(p) (p & 0x000000FF)
-/* To get the error code, we want the bottom 16 bits */
+ /* To get the error code, we want the bottom 16 bits */
#define SMBlib_Error_Code(p) (((unsigned int)p & 0xFFFF0000) >>16)
-/* Error CLASS codes and etc ... */
+ /* Error CLASS codes and etc ... */
#define SMBC_SUCCESS 0
#define SMBC_ERRDOS 0x01
#define SMBC_ERRHRD 0x03
#define SMBC_ERRCMD 0xFF
-/* Success error codes */
+ /* Success error codes */
#define SMBS_BUFFERED 0x54
#define SMBS_LOGGED 0x55
#define SMBS_DISPLAYED 0x56
-/* ERRDOS Error codes */
+ /* ERRDOS Error codes */
#define SMBD_badfunc 0x01
#define SMBD_badfile 0x02
#define SMBD_errlock 0x21
#define SMBD_filexists 0x50
-/* Server errors ... */
+ /* Server errors ... */
#define SMBV_error 0x01 /* Generic error */
#define SMBV_badpw 0x02
#define SMBV_rmuns 0x57
#define SMBV_nosupport 0xFFFF
-/* Hardware error codes ... */
+ /* Hardware error codes ... */
#define SMBH_nowrite 0x13
#define SMBH_badunit 0x14
#define SMBH_general 0x1F
#define SMBH_badshare 0x20
-/* Access mode defines ... */
+ /* Access mode defines ... */
#define SMB_AMODE_WTRU 0x4000
#define SMB_AMODE_NOCACHE 0x1000
#define SMB_AMODE_LOCMRAN 0x0200
#define SMB_AMODE_LOCRAL 0x0300
-/* File attribute encoding ... */
+ /* File attribute encoding ... */
#define SMB_FA_ORD 0x00
#define SMB_FA_ROF 0x01
#define SMB_FA_DIR 0x10
#define SMB_FA_ARC 0x20
-/* Define the protocol types ... */
+ /* Define the protocol types ... */
#define SMB_P_Unknown -1 /* Hmmm, is this smart? */
#define SMB_P_Core 0
#define SMB_P_LanMan2_1 7
#define SMB_P_NT1 8
-/* SMBlib return codes */
-/* We want something that indicates whether or not the return code was a */
-/* remote error, a local error in SMBlib or returned from lower layer ... */
-/* Wonder if this will work ... */
-/* SMBlibE_Remote = 1 indicates remote error */
-/* SMBlibE_ values < 0 indicate local error with more info available */
-/* SMBlibE_ values >1 indicate local from SMBlib code errors? */
+ /* SMBlib return codes */
+ /* We want something that indicates whether or not the return code was a */
+ /* remote error, a local error in SMBlib or returned from lower layer ... */
+ /* Wonder if this will work ... */
+ /* SMBlibE_Remote = 1 indicates remote error */
+ /* SMBlibE_ values < 0 indicate local error with more info available */
+ /* SMBlibE_ values >1 indicate local from SMBlib code errors? */
#define SMBlibE_Success 0
#define SMBlibE_Remote 1 /* Remote error, get more info from con */
#define SMBlibE_ProtUnknown 12 /* Protocol unknown */
#define SMBlibE_NoSuchMsg 13 /* Keep this up to date */
-typedef struct { /* A structure for a Dirent */
+ typedef struct { /* A structure for a Dirent */
- unsigned char resume_key[21]; /* Don't touch this */
- unsigned char file_attributes; /* Attributes of file */
- unsigned int date_time; /* date and time of last mod */
- unsigned int size;
- char filename[13]; /* The name of the file */
-
-} SMB_CP_dirent;
+ unsigned char resume_key[21]; /* Don't touch this */
+ unsigned char file_attributes; /* Attributes of file */
+ unsigned int date_time; /* date and time of last mod */
+ unsigned int size;
+ char filename[13]; /* The name of the file */
+
+ } SMB_CP_dirent;
-/* Handle Structures */
-
-typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
-typedef struct SMB_Connect_Def * SMB_Handle_Type;
-
-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;
-};
-
-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 */
+ /* Handle Structures */
+
+ typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
+ typedef struct SMB_Connect_Def * SMB_Handle_Type;
+
+ 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;
+ };
+
+ 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];
+ /* 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 */
+ 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 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. */
+ 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! */
+ /* 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 */
- int16_t encrypt_passwords; /* TRUE/FALSE. 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];
-};
+ 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 */
+ int16_t encrypt_passwords; /* TRUE/FALSE. 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];
+ };
-/* Initialize the SMBlib package */
-int SMB_Init(void);
+ /* Initialize the SMBlib package */
+ int SMB_Init(void);
-/* Create a handle to allow us to set/override some parameters ... */
-SMB_Handle_Type SMB_Create_Con_Handle();
+ /* Create a handle to allow us to set/override some parameters ... */
+ SMB_Handle_Type SMB_Create_Con_Handle();
-/* Connect to a server, but do not do a tree con etc ... */
-SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
- char *server,
- char *NTdomain);
+ /* Connect to a server, but do not do a tree con etc ... */
+ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
+ char *server,
+ char *NTdomain);
-/* Connect to a server and give us back a handle. If Con == NULL, create */
-/* The handle and populate it with defaults */
-SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
- SMB_Tree_Handle * tree,
- char *service,
- char *username,
- char *password);
+ /* Connect to a server and give us back a handle. If Con == NULL, create */
+ /* The handle and populate it with defaults */
+ SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
+ SMB_Tree_Handle * tree,
+ char *service,
+ char *username,
+ char *password);
-int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
- char *UserName,
- char *PassWord,
- char *UserDomain,
- int precrypted);
+ int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
+ char *UserName,
+ char *PassWord,
+ char *UserDomain,
+ int precrypted);
-/* Negotiate a protocol */
-int SMB_Negotiate(SMB_Handle_Type con, char const *Prots[]);
+ /* Negotiate a protocol */
+ int SMB_Negotiate(SMB_Handle_Type con, char const *Prots[]);
-/* Connect to a tree ... */
-SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
- SMB_Tree_Handle tree,
- char *path,
- char *password,
- char const *device);
+ /* Connect to a tree ... */
+ SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
+ SMB_Tree_Handle tree,
+ char *path,
+ char *password,
+ char const *device);
-/* Disconnect a tree ... */
-int SMB_TreeDisconect(void *tree_handle);
+ /* Disconnect a tree ... */
+ int SMB_TreeDisconect(void *tree_handle);
-/* Open a file */
-void *SMB_Open(void *tree_handle,
- void *file_handle,
- char *file_name,
- unsigned short mode,
- unsigned short search);
+ /* Open a file */
+ void *SMB_Open(void *tree_handle,
+ void *file_handle,
+ char *file_name,
+ unsigned short mode,
+ unsigned short search);
-/* Close a file */
-int SMB_Close(void *file_handle);
-
-/* Disconnect from server. Has flag to specify whether or not we keep the */
-/* handle. */
-int SMB_Discon(SMB_Handle_Type Con,
- int KeepHandle);
-
-void *SMB_Create(void *Tree_Handle,
- void *File_Handle,
- char *file_name,
- short search);
-
-int SMB_Delete(void *tree,
- char *file_name,
- short search);
+ /* Close a file */
+ int SMB_Close(void *file_handle);
+
+ /* Disconnect from server. Has flag to specify whether or not we keep the */
+ /* handle. */
+ int SMB_Discon(SMB_Handle_Type Con,
+ int KeepHandle);
+
+ void *SMB_Create(void *Tree_Handle,
+ void *File_Handle,
+ char *file_name,
+ short search);
+
+ int SMB_Delete(void *tree,
+ char *file_name,
+ short search);
-int SMB_Create_Dir(void *tree,
- char *dir_name);
+ int SMB_Create_Dir(void *tree,
+ char *dir_name);
-int SMB_Delete_Dir(void *tree,
- char *dir_name);
+ int SMB_Delete_Dir(void *tree,
+ char *dir_name);
-int SMB_Check_Dir(void *tree,
- char *dir_name);
-
-int SMB_Get_Last_Error();
+ int SMB_Check_Dir(void *tree,
+ char *dir_name);
+
+ int SMB_Get_Last_Error();
-int SMB_Get_Last_SMB_Err();
-
-int SMB_Get_Error_Msg(int msg,
- char *msgbuf,
- int len);
-
-void *SMB_Logon_And_TCon(SMB_Handle_Type Con_Handle,
- void *tree,
- char *user,
- char *pass,
- char *service,
- char *st);
-
-/* Encryption Functions */
-
-void SMBencrypt(unsigned char * passwd,
- unsigned char * c8,
- unsigned char * p24);
-
-void SMBNTencrypt(unsigned char * passwd,
- unsigned char * c8,
- unsigned char * p24);
+ int SMB_Get_Last_SMB_Err();
+
+ int SMB_Get_Error_Msg(int msg,
+ char *msgbuf,
+ int len);
+
+ void *SMB_Logon_And_TCon(SMB_Handle_Type Con_Handle,
+ void *tree,
+ char *user,
+ char *pass,
+ char *service,
+ char *st);
+
+ /* Encryption Functions */
+
+ void SMBencrypt(unsigned char * passwd,
+ unsigned char * c8,
+ unsigned char * p24);
+
+ void SMBNTencrypt(unsigned char * passwd,
+ unsigned char * c8,
+ unsigned char * p24);
#ifdef __cplusplus
}