extern "C" {
#endif
-/* A data structure we need */
+ /* A data structure we need */
-typedef struct RFCNB_Pkt {
+ typedef struct RFCNB_Pkt {
- char * data; /* The data in this portion */
- int len;
- struct RFCNB_Pkt *next;
+ char * data; /* The data in this portion */
+ int len;
+ struct RFCNB_Pkt *next;
-} RFCNB_Pkt;
+ } RFCNB_Pkt;
#ifdef __cplusplus
}
extern "C" {
#endif
-/* Error responses */
+ /* Error responses */
#define RFCNBE_Bad -1 /* Bad response */
#define RFCNBE_OK 0
-/* these should follow the spec ... is there one ?*/
+ /* these should follow the spec ... is there one ?*/
#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */
#define RFCNBE_BadName 2 /* Could not translate a name */
#define RFCNBE_BadParam 15/* Bad parameters passed ... */
#define RFCNBE_Timeout 16/* IO Timed out */
-/* Text strings for the error responses */
+ /* Text strings for the error responses */
-extern const char *RFCNB_Error_Strings[];
+ extern const char *RFCNB_Error_Strings[];
#ifdef __cplusplus
}
#else
struct sigvec invec, outvec;
#endif
-
+
RFCNB_Timeout = seconds;
if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */
if (sigaction(SIGALRM, &inact, &outact) < 0)
return (-1);
#else
- invec.sv_handler = (void (*)()) rfcnb_alarm;
- invec.sv_mask = 0;
- invec.sv_flags = SV_INTERRUPT;
+ invec.sv_handler = (void (*)()) rfcnb_alarm;
+ invec.sv_mask = 0;
+ invec.sv_flags = SV_INTERRUPT;
- if (sigvec(SIGALRM, &invec, &outvec) < 0)
- return (-1);
+ if (sigvec(SIGALRM, &invec, &outvec) < 0)
+ return (-1);
#endif
#endif
extern void (*Prot_Print_Routine)(); /* Pointer to protocol print routine */
const 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_CallRejUnSpec: Call rejected. Unspecified error.",
"RFCNBE_BadParam: Bad parameters passed to a routine.",
"RFCNBE_Timeout: IO Operation timed out ..."
-
-};
+
+};
/* Convert name and pad to 16 chars as needed */
/* Name 1 is a C string with null termination, name 2 may not be */
extern "C" {
#endif
-/* Defines we need */
+ /* Defines we need */
#define RFCNB_Default_Port 139
-struct RFCNB_Con;
+ struct RFCNB_Con;
-/* Definition of routines we define */
+ /* 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(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length);
+ int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length);
-int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
+ int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
-int RFCNB_Hangup(struct RFCNB_Con *con_Handle);
+ int RFCNB_Hangup(struct RFCNB_Con *con_Handle);
-void *RFCNB_Listen();
+ void *RFCNB_Listen();
-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);
-void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
+ void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
-int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, int yn);
+ int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, int yn);
-struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
+ struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
#ifdef __cplusplus
}
snprintf(buffer, (buf_len-1) ,"%s", RFCNB_Error_Strings[RFCNB_errno]);
} else {
snprintf(buffer, (buf_len-1), "%s\n\terrno:%s", RFCNB_Error_Strings[RFCNB_errno],
- strerror(RFCNB_saved_errno));
+ strerror(RFCNB_saved_errno));
}
}
extern "C" {
#endif
-void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
-void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
-void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16);
+ void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+ void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+ void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16);
#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 */
-/* the default SMB protocols supported by this library. */
-extern const char *SMB_Prots[];
-
-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;
-
-typedef struct SMB_Connect_Def * SMB_Handle_Type;
-
-typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
-
-/* 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;
-
-};
-
-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 */
- int encrypt_passwords; /* 1 = do , 0 = 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];
-};
+ /* the default SMB protocols supported by this library. */
+ extern const char *SMB_Prots[];
+
+ 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;
+
+ typedef struct SMB_Connect_Def * SMB_Handle_Type;
+
+ typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
+
+ /* 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;
+
+ };
+
+ 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 */
+ int encrypt_passwords; /* 1 = do , 0 = 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];
+ };
#ifdef __cplusplus
}
DOS_year = ((DOS_time & 0xFE000000) >> 25) + 80;
snprintf(SMB_Time_Temp, 48, "%2d/%02d/%2d %2d:%02d:%02d", DOS_day, DOS_month,
- DOS_year, DOS_hour, DOS_min, DOS_sec);
+ DOS_year, DOS_hour, DOS_min, DOS_sec);
return(SMB_Time_Temp);
char *address;
/* only keep the portion up to the first "." */
if (NULL != (address = strchr(name, '.'))) {
- *address = '\0'; /* truncate at first '.' */
+ *address = '\0'; /* truncate at first '.' */
}
}
}
SMB_State_Types SMBlib_State;
const 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
- };
+ "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
+ };
int SMB_Term(void);
int SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn);
extern "C" {
#endif
-/* Just define all the entry points */
+ /* Just define all the entry points */
-/* Create a handle to allow us to set/override some parameters ... */
+ /* Create a handle to allow us to set/override some parameters ... */
-SMB_Handle_Type SMB_Create_Con_Handle(void);
+ SMB_Handle_Type SMB_Create_Con_Handle(void);
-/* Connect to a server, but do not do a tree con etc ... */
+ /* 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,
- const char *NTdomain);
+ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
+ char *server,
+ const char *NTdomain);
-/* Connect to a server and give us back a handle. If Con == NULL, create */
-/* The handle and populate it with defaults */
+ /* 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);
+ SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
+ SMB_Tree_Handle *tree,
+ char *service,
+ char *username,
+ char *password);
-int SMB_Init(void);
+ int SMB_Init(void);
-int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
- char *UserName,
- char *PassWord,
- const char *NtDomain,
- int PreCrypted);
+ int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
+ char *UserName,
+ char *PassWord,
+ const char *NtDomain,
+ int PreCrypted);
-/* Negotiate a protocol */
+ /* Negotiate a protocol */
-int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[]);
+ int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[]);
-/* Connect to a tree ... */
+ /* Connect to a tree ... */
-SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
- SMB_Tree_Handle tree,
- const char *path,
- const char *password,
- const char *dev);
+ SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
+ SMB_Tree_Handle tree,
+ const char *path,
+ const char *password,
+ const char *dev);
-/* Disconnect a tree ... */
+ /* Disconnect a tree ... */
-int SMB_TreeDisconect(void *tree_handle);
+ int SMB_TreeDisconect(void *tree_handle);
-/* Open a file */
+ /* Open a file */
-void *SMB_Open(void *tree_handle,
- void *file_handle,
- char *file_name,
- unsigned short mode,
- unsigned short search);
+ void *SMB_Open(void *tree_handle,
+ void *file_handle,
+ char *file_name,
+ unsigned short mode,
+ unsigned short search);
-/* Close a file */
+ /* Close a file */
-int SMB_Close(void *file_handle);
+ int SMB_Close(void *file_handle);
-/* Disconnect from server. Has flag to specify whether or not we keep the */
-/* handle. */
+ /* Disconnect from server. Has flag to specify whether or not we keep the */
+ /* handle. */
-int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
+ int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
-void *SMB_Create(void *Tree_Handle,
- void *File_Handle,
- char *file_name,
- short search);
+ 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_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_Check_Dir(void *tree, char *dir_name);
-int SMB_Get_Last_Error(void);
+ int SMB_Get_Last_Error(void);
-int SMB_Get_Last_SMB_Err(void);
+ int SMB_Get_Last_SMB_Err(void);
-void SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
+ void SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
-void *SMB_Logon_And_TCon(void *con, void *tree, char *user, char *pass,
- char *service, char *st);
+ void *SMB_Logon_And_TCon(void *con, void *tree, char *user, char *pass,
+ char *service, char *st);
#ifdef __cplusplus
}