diff --git a/README b/README index 4253e9d7..dfa71c20 100644 --- a/README +++ b/README @@ -280,3 +280,27 @@ KallistiOS toolchain install location addons folder. NOTE: There is not yet a kos-ports entry for libsmb2 but once a versioned release that includes Dreamcast support is created installing from kos-ports will become the preferred method of installation. + +Xbox (Xbox XDK) +---------------------- +Xbox CPU is acustom Intel Pentium III Coppermine-based processor which only supports litlle endian values. +To compile libsmb2 for the Xbox, first install the Xbox XDK(with all features), Microsoft Visual C++ 2003 Professional and Windows XP. + +Then to build libsmb2, go to Xbox folder +and open the provided .sln file, Then hit the green button to build: + +The process will result a libsmb2.lib. So you can copy the include files +and the .lib file to your Xbox project. + +Xbox 360 (Xbox 360 SDK) +---------------------- +Xbox 360 CPU is a PPC(PowerPC) Xenon which only supports only big endian values. +To compile libsmb2 for the Xbox 360, first install the Xbox 360 SDK(with all features), Microsoft Visual C++ 2010 Ultimate and Windows XP(Recommended) or Windows 7. + +Then to build libsmb2, go to Xbox 360 folder +and open the provided .sln file, Then hit the green button to build: + +The process will result a libsmb2.lib. So you can copy the include files +and the .lib file to your Xbox 360 project. + +NOTE: Both ports was based on XBMC-360 port by BDC(Brent De Cartet) and now being updated to libsmb2 standards to best performance. diff --git a/Xbox 360/libsmb2.sln b/Xbox 360/libsmb2.sln new file mode 100644 index 00000000..9f351e11 --- /dev/null +++ b/Xbox 360/libsmb2.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsmb2", "libsmb2.vcxproj", "{B2F1D3EE-7D56-4862-9286-5937E1A554A4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + CodeAnalysis|Xbox 360 = CodeAnalysis|Xbox 360 + Debug|Xbox 360 = Debug|Xbox 360 + Profile_FastCap|Xbox 360 = Profile_FastCap|Xbox 360 + Profile|Xbox 360 = Profile|Xbox 360 + Release_LTCG|Xbox 360 = Release_LTCG|Xbox 360 + Release|Xbox 360 = Release|Xbox 360 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.CodeAnalysis|Xbox 360.ActiveCfg = CodeAnalysis|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.CodeAnalysis|Xbox 360.Build.0 = CodeAnalysis|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Debug|Xbox 360.Build.0 = Debug|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Profile_FastCap|Xbox 360.ActiveCfg = Profile_FastCap|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Profile_FastCap|Xbox 360.Build.0 = Profile_FastCap|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Profile|Xbox 360.ActiveCfg = Profile|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Profile|Xbox 360.Build.0 = Profile|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Release_LTCG|Xbox 360.ActiveCfg = Release_LTCG|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Release_LTCG|Xbox 360.Build.0 = Release_LTCG|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Release|Xbox 360.ActiveCfg = Release|Xbox 360 + {B2F1D3EE-7D56-4862-9286-5937E1A554A4}.Release|Xbox 360.Build.0 = Release|Xbox 360 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Xbox 360/libsmb2.vcxproj b/Xbox 360/libsmb2.vcxproj new file mode 100644 index 00000000..904966d3 --- /dev/null +++ b/Xbox 360/libsmb2.vcxproj @@ -0,0 +1,317 @@ + + + + + CodeAnalysis + Xbox 360 + + + Debug + Xbox 360 + + + Profile + Xbox 360 + + + Profile_FastCap + Xbox 360 + + + Release + Xbox 360 + + + Release_LTCG + Xbox 360 + + + + {B2F1D3EE-7D56-4862-9286-5937E1A554A4} + Xbox360Proj + + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + + + StaticLibrary + MultiByte + true + + + StaticLibrary + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + + NotUsing + Level3 + ProgramDatabase + Disabled + false + true + false + $(OutDir)$(ProjectName).pch + MultiThreadedDebug + _DEBUG;_XBOX;_LIB;NEED_POLL;XBOX_360_PLATFORM;HAVE_CONFIG_H + Callcap + CompileAsC + ..\include\;..\include\smb2;..\include\msvc;..\include\msvc\sys;..\include\xbox 360 + AnySuitable + + + true + + + + + NotUsing + Level4 + ProgramDatabase + Disabled + false + true + AnalyzeOnly + false + $(OutDir)$(ProjectName).pch + MultiThreadedDebug + _DEBUG;_XBOX;_LIB + Callcap + + + true + + + + + Level3 + NotUsing + Full + true + false + true + ProgramDatabase + Size + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;PROFILE;_LIB + Callcap + + + true + false + xapilib.lib + true + + + + + Level3 + NotUsing + Full + true + false + true + ProgramDatabase + Fastcap + Size + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;PROFILE;FASTCAP;_LIB + + + true + false + true + + + + + Level3 + NotUsing + Full + true + true + ProgramDatabase + Size + false + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;_LIB;NEED_POLL;XBOX_360_PLATFORM;HAVE_CONFIG_H + ..\include\;..\include\smb2;..\include\msvc;..\include\msvc\sys;..\include\xbox 360 + CompileAsC + AnySuitable + + + true + true + true + + + + + Level3 + NotUsing + Full + true + true + ProgramDatabase + Size + false + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;LTCG;_LIB + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xbox 360/libsmb2.vcxproj.filters b/Xbox 360/libsmb2.vcxproj.filters new file mode 100644 index 00000000..e7d51e9d --- /dev/null +++ b/Xbox 360/libsmb2.vcxproj.filters @@ -0,0 +1,259 @@ + + + + + include + + + lib + + + + + + + {028f1ea9-92cf-4908-a035-80459a8cf956} + + + {28810bac-fb60-4810-8ce9-1d5c989d4c75} + + + {8f3e89d9-a92f-4650-a970-3af5fddd92fe} + + + {84dc3fac-09d1-446a-97da-fc0fee2bf6c3} + + + {afbefc44-9daf-45e5-aacd-fe33021175a2} + + + {6c01c6cd-316c-4bff-82ea-f611e60057e9} + + + + + include\smb2 + + + include\smb2 + + + include\smb2 + + + include\smb2 + + + include\smb2 + + + include\smb2 + + + include\smb2 + + + include + + + include + + + include + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + include + + + include\msvc + + + include\msvc\sys + + + include\xbox 360 + + + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + lib + + + \ No newline at end of file diff --git a/Xbox/libsmb2.sln b/Xbox/libsmb2.sln new file mode 100644 index 00000000..d5b20889 --- /dev/null +++ b/Xbox/libsmb2.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsmb2", "libsmb2.vcproj", "{7326DFF9-17C3-478F-9EAB-15FC697DC053}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Profile = Profile + Profile_FastCap = Profile_FastCap + Release = Release + Release_LTCG = Release_LTCG + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Debug.ActiveCfg = Debug|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Debug.Build.0 = Debug|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Profile.ActiveCfg = Profile|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Profile.Build.0 = Profile|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Release.ActiveCfg = Release|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Release.Build.0 = Release|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox + {7326DFF9-17C3-478F-9EAB-15FC697DC053}.Release_LTCG.Build.0 = Release_LTCG|Xbox + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Xbox/libsmb2.vcproj b/Xbox/libsmb2.vcproj new file mode 100644 index 00000000..2a1eab7e --- /dev/null +++ b/Xbox/libsmb2.vcproj @@ -0,0 +1,450 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/asprintf.h b/include/asprintf.h index 8c4d804a..e020b18d 100644 --- a/include/asprintf.h +++ b/include/asprintf.h @@ -7,6 +7,11 @@ #include #include +#ifdef _XBOX +#define inline __inline +#endif + +#ifndef _XBOX #ifndef _vscprintf /* For some reason, MSVC fails to honour this #ifndef. */ /* Hence function renamed to _vscprintf_so(). */ @@ -19,14 +24,25 @@ static inline int _vscprintf_so(const char * format, va_list pargs) { return retval; } #endif /* _vscprintf */ +#endif #ifndef vasprintf static inline int vasprintf(char **strp, const char *fmt, va_list ap) { +#ifdef _XBOX + int len = _vscprintf(fmt, ap); +#else int len = _vscprintf_so(fmt, ap); +#endif + char *str; + int r; if (len == -1) return -1; - char *str = malloc((size_t)len + 1); + str = malloc((size_t)len + 1); if (!str) return -1; - int r = vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */ +#ifdef _XBOX + r = _vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */ +#else + r = vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */ +#endif if (r == -1) return free(str), -1; *strp = str; return r; @@ -35,9 +51,10 @@ static inline int vasprintf(char **strp, const char *fmt, va_list ap) { #ifndef asprintf static inline int asprintf(char *strp[], const char *fmt, ...) { + int r; va_list ap; va_start(ap, fmt); - int r = vasprintf(strp, fmt, ap); + r = vasprintf(strp, fmt, ap); va_end(ap); return r; } diff --git a/include/msvc/sys/socket.h b/include/msvc/sys/socket.h index e81a2e56..85a7237f 100644 --- a/include/msvc/sys/socket.h +++ b/include/msvc/sys/socket.h @@ -1,4 +1,3 @@ - #ifndef _MSVC_SYS_SOCKET_H_ #define _MSVC_SYS_SOCKET_H_ @@ -6,6 +5,9 @@ extern "C" { #endif +#ifdef _XBOX +#include "..\..\..\lib\compat.h" +#else #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif // !WIN32_LEAN_AND_MEAN @@ -13,6 +15,7 @@ extern "C" { #include #include #include +#endif #include diff --git a/include/portable-endian.h b/include/portable-endian.h index dcd154b8..967b25d9 100644 --- a/include/portable-endian.h +++ b/include/portable-endian.h @@ -7,10 +7,8 @@ #ifndef PORTABLE_ENDIAN_H__ #define PORTABLE_ENDIAN_H__ -#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) - -# define __WINDOWS__ - +#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) && !defined(_XBOX) +#define __WINDOWS__ #endif #if defined(ESP_PLATFORM) @@ -169,7 +167,7 @@ # define be64toh(x) (x) # define le64toh(x) __builtin_bswap64(x) -#elif defined(__WINDOWS__) +#elif defined(__WINDOWS__) # include @@ -190,7 +188,6 @@ # define htole64(x) (x) # define be64toh(x) _byteswap_uint64(x) # define le64toh(x) (x) - # elif defined(__GNUC__) || defined(__clang__) # define htobe16(x) __builtin_bswap16(x) @@ -212,6 +209,72 @@ # error platform not supported # endif +#elif defined(XBOX_360_PLATFORM) +# include + +# include + +# define htobe16(x) (x) +# define htole16(x) _byteswap_ushort(x) +# define be16toh(x) (x) +# define le16toh(x) _byteswap_ushort(x) + +# define htobe32(x) (x) +# define htole32(x) _byteswap_ulong(x) +# define be32toh(x) (x) +# define le32toh(x) _byteswap_ulong(x) + +# define htobe64(x) (x) +# define htole64(x) _byteswap_uint64(x) +# define be64toh(x) (x) +# define le64toh(x) _byteswap_uint64(x) + +# define __BYTE_ORDER BYTE_ORDER +# define __BIG_ENDIAN BIG_ENDIAN +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __PDP_ENDIAN PDP_ENDIAN + +# elif defined(XBOX_PLATFORM) +# include + +# include + +# define htobe16(x) (x) +# define htole16(x) _byteswap_ushort(x) +# define be16toh(x) (x) +# define le16toh(x) _byteswap_ushort(x) + +# define htobe32(x) (x) +# define htole32(x) _byteswap_ulong(x) +# define be32toh(x) (x) +# define le32toh(x) _byteswap_ulong(x) + +# define htobe64(x) (x) +# define htole64(x) _byteswap_uint64(x) +# define be64toh(x) (x) +# define le64toh(x) _byteswap_uint64(x) + +/* # define __BYTE_ORDER BYTE_ORDER */ +# define __LITTLE_ENDIAN LITTLE_ENDIAN +/* # define __PDP_ENDIAN PDP_ENDIAN */ + +# elif defined(__GNUC__) || defined(__clang__) + +# define htobe16(x) __builtin_bswap16(x) +# define htole16(x) (x) +# define be16toh(x) __builtin_bswap16(x) +# define le16toh(x) (x) + +# define htobe32(x) __builtin_bswap32(x) +# define htole32(x) (x) +# define be32toh(x) __builtin_bswap32(x) +# define le32toh(x) (x) + +# define htobe64(x) __builtin_bswap64(x) +# define htole64(x) (x) +# define be64toh(x) __builtin_bswap64(x) +# define le64toh(x) (x) + #else # error platform not supported #endif diff --git a/include/smb2/libsmb2.h b/include/smb2/libsmb2.h index 46889544..4ba1173c 100644 --- a/include/smb2/libsmb2.h +++ b/include/smb2/libsmb2.h @@ -76,13 +76,18 @@ struct smb2dirent { struct smb2_stat_64 st; }; -#ifdef _MSC_VER +#if defined(_WINDOWS) #include +#elif defined(_XBOX) +#include +#include +#endif + +#if defined(_WINDOWS) || defined(_XBOX) typedef SOCKET t_socket; #else typedef int t_socket; #endif - /* * Create an SMB2 context. * Function returns diff --git a/include/xbox 360/config.h b/include/xbox 360/config.h new file mode 100644 index 00000000..711aed81 --- /dev/null +++ b/include/xbox 360/config.h @@ -0,0 +1,128 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Whether or not TCP sockets should be allowed to linger after closure */ +#define CONFIGURE_OPTION_TCP_LINGER 1 +#define _U_ /* __attribute__((unused)) */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_ARPA_INET_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_DLFCN_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FCNTL_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_GSSAPI_GSSAPI_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_INTTYPES_H 1 */ + +/* Whether we use gssapi_krb5 or not */ +/* #define HAVE_LIBKRB5 1 */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETDB_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETINET_IN_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETINET_TCP_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_POLL_H 1 */ + +/* Whether sockaddr struct has sa_len */ +/* #undef HAVE_SOCKADDR_LEN */ + +/* Whether we have sockaddr_Storage */ +/* #define HAVE_SOCKADDR_STORAGE 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_STRINGS_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_IOCTL_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_POLL_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_UIO_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UNISTD_H 1 */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libsmb2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "ronniesahlberg@gmail.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libsmb2" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libsmb2 4.0.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libsmb2" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.0.0" + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "4.0.0" diff --git a/include/xbox/config.h b/include/xbox/config.h new file mode 100644 index 00000000..9d430efb --- /dev/null +++ b/include/xbox/config.h @@ -0,0 +1,128 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Whether or not TCP sockets should be allowed to linger after closure */ +#define CONFIGURE_OPTION_TCP_LINGER 1 +#define _U_ /* __attribute__((unused)) */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_ARPA_INET_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_DLFCN_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_FCNTL_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_GSSAPI_GSSAPI_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_INTTYPES_H 1 */ + +/* Whether we use gssapi_krb5 or not */ +/* #define HAVE_LIBKRB5 1 */ + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define to 1 if you have the `socket' library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETDB_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETINET_IN_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_NETINET_TCP_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_POLL_H 1 */ + +/* Whether sockaddr struct has sa_len */ +/* #undef HAVE_SOCKADDR_LEN */ + +/* Whether we have sockaddr_Storage */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_STDINT_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_STRINGS_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_IOCTL_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_POLL_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_UIO_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UNISTD_H 1 */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libsmb2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "ronniesahlberg@gmail.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libsmb2" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libsmb2 4.0.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libsmb2" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.0.0" + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "4.0.0" diff --git a/lib/compat.c b/lib/compat.c index 8e154644..0b3c48fc 100644 --- a/lib/compat.c +++ b/lib/compat.c @@ -42,6 +42,42 @@ #endif /* PICO_PLATFORM */ +#ifdef _XBOX + +int smb2_getaddrinfo(const char *node, const char*service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + struct sockaddr_in *sin; + + sin = malloc(sizeof(struct sockaddr_in)); + sin->sin_family=AF_INET; + + /* Some error checking would be nice */ + sin->sin_addr.s_addr = inet_addr(node); + + sin->sin_port=0; + if (service) { + sin->sin_port=htons(atoi(service)); + } + + *res = malloc(sizeof(struct addrinfo)); + + (*res)->ai_family = AF_INET; + (*res)->ai_addrlen = sizeof(struct sockaddr_in); + (*res)->ai_addr = (struct sockaddr *)sin; + + return 0; +} + +void smb2_freeaddrinfo(struct addrinfo *res) +{ + free(res->ai_addr); + free(res); +} + +#endif + #ifdef PS2_EE_PLATFORM #include diff --git a/lib/compat.h b/lib/compat.h index 9244c7de..2869d18f 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -19,6 +19,137 @@ #ifndef _COMPAT_H_ #define _COMPAT_H_ +#ifdef _XBOX + +/* XBOX Defs begin */ +#include +#include + +#ifdef XBOX_PLATFORM /* MSVC 2003 Doesn´t have stdint.h header */ +typedef char int8_t; +typedef short int16_t; +typedef short int_least16_t; +typedef int int32_t; +typedef long long int64_t; +typedef int intptr_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned int uint_t; +typedef unsigned int uintptr_t; +#endif + +#include + +#ifndef ENETRESET +#define ENETRESET WSAENETRESET +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT WSAETIMEDOUT +#endif + +#ifndef ECONNRESET +#define ECONNRESET WSAECONNRESET +#endif + +#ifndef ENODATA +#define ENODATA WSANO_DATA +#endif + +#ifndef ETXTBSY +#define ETXTBSY 139 +#endif + +#ifndef ENOLINK +#define ENOLINK 121 +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif + +#define snprintf _snprintf + +#define EAI_AGAIN EAGAIN +#define EAI_FAIL 4 +#define EAI_MEMORY 6 +#define EAI_NONAME 8 +#define EAI_SERVICE 9 + +typedef int socklen_t; + +#ifndef POLLIN +#define POLLIN 0x0001 /* There is data to read */ +#endif +#ifndef POLLPRI +#define POLLPRI 0x0002 /* There is urgent data to read */ +#endif +#ifndef POLLOUT +#define POLLOUT 0x0004 /* Writing now will not block */ +#endif +#ifndef POLLERR +#define POLLERR 0x0008 /* Error condition */ +#endif +#ifndef POLLHUP +#define POLLHUP 0x0010 /* Hung up */ +#endif + +#ifndef SO_ERROR +#define SO_ERROR 0x1007 +#endif + +struct sockaddr_storage { +#ifdef HAVE_SOCKADDR_SA_LEN + unsigned char ss_len; +#endif /* HAVE_SOCKADDR_SA_LEN */ + unsigned char ss_family; + unsigned char fill[127]; +}; + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +/* XBOX Defs end */ +struct pollfd { + int fd; + short events; + short revents; +}; + +#define SOL_TCP 6 + +#define inline __inline + +int poll(struct pollfd *fds, unsigned int nfds, int timo); + +int smb2_getaddrinfo(const char *node, const char*service, + const struct addrinfo *hints, + struct addrinfo **res); +void smb2_freeaddrinfo(struct addrinfo *res); + +#define getaddrinfo smb2_getaddrinfo +#define freeaddrinfo smb2_freeaddrinfo + +/* just pretend they are the same so we compile */ +#define sockaddr_in6 sockaddr_in + +#endif /* _XBOX */ + #ifdef PICO_PLATFORM #include "lwip/netdb.h" diff --git a/lib/hmac-md5.h b/lib/hmac-md5.h index 196dde9a..be6d92b8 100644 --- a/lib/hmac-md5.h +++ b/lib/hmac-md5.h @@ -15,7 +15,7 @@ #include #endif -#if (__BYTE_ORDER == __BIG_ENDIAN) +#if (__BYTE_ORDER == __BIG_ENDIAN) || defined(XBOX_360_PLATFORM) # define WORDS_BIGENDIAN 1 #endif diff --git a/lib/init.c b/lib/init.c index aa256e4f..38b68baa 100644 --- a/lib/init.c +++ b/lib/init.c @@ -79,7 +79,9 @@ #define getlogin_r(a,b) ENXIO #define srandom srand #define random rand +#ifndef _XBOX #define getpid GetCurrentProcessId +#endif #endif /* _MSC_VER */ #ifdef ESP_PLATFORM @@ -287,9 +289,11 @@ struct smb2_context *smb2_init_context(void) char buf[1024] _U_; int i, ret; static int ctr; - +#ifdef _XBOX + srandom(time(NULL) ^ ctr++); +#else srandom(time(NULL) ^ getpid() ^ ctr++); - +#endif smb2 = calloc(1, sizeof(struct smb2_context)); if (smb2 == NULL) { return NULL; @@ -421,9 +425,12 @@ struct smb2_iovec *smb2_add_iovector(struct smb2_context *smb2, static void smb2_set_error_string(struct smb2_context *smb2, const char * error_string, va_list args) { char errstr[MAX_ERROR_SIZE] = {0}; - - if (vsnprintf(errstr, MAX_ERROR_SIZE, error_string, args) < 0) { - strncpy(errstr, "could not format error string!", +#ifdef _XBOX + if (_vsnprintf(errstr, MAX_ERROR_SIZE, error_string, args) < 0) { +#else + if (vsnprintf(errstr, MAX_ERROR_SIZE, error_string, args) < 0) { +#endif + strncpy(errstr, "could not format error string!", MAX_ERROR_SIZE); } strncpy(smb2->error_string, errstr, MAX_ERROR_SIZE); @@ -481,7 +488,7 @@ void smb2_set_security_mode(struct smb2_context *smb2, uint16_t security_mode) smb2->security_mode = security_mode; } -#ifndef PS2_IOP_PLATFORM +#if !defined(_XBOX) && !defined(PS2_IOP_PLATFORM) static void smb2_set_password_from_file(struct smb2_context *smb2) { char *name = NULL; @@ -569,7 +576,7 @@ void smb2_set_user(struct smb2_context *smb2, const char *user) return; } smb2->user = strdup(user); -#if !defined(PS2_IOP_PLATFORM) +#if !defined(_XBOX) && !defined(PS2_IOP_PLATFORM) smb2_set_password_from_file(smb2); #endif } diff --git a/lib/libsmb2.c b/lib/libsmb2.c index e15146de..ce8271e1 100644 --- a/lib/libsmb2.c +++ b/lib/libsmb2.c @@ -84,7 +84,7 @@ #include #endif -#ifdef _WIN32 +#if defined(_WIN32) || defined(_XBOX) #include "asprintf.h" #endif diff --git a/lib/md5.h b/lib/md5.h index 2311994d..03dd7cbb 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -38,7 +38,7 @@ #include #endif -#if !defined(_WIN32) && (__BYTE_ORDER == __BIG_ENDIAN) +#if !defined(_WIN32) && (__BYTE_ORDER == __BIG_ENDIAN) || defined(XBOX_360_PLATFORM) # define WORDS_BIGENDIAN 1 #endif diff --git a/lib/socket.c b/lib/socket.c index 1d8b57c0..6ed760c0 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -341,7 +341,7 @@ static int smb2_read_data(struct smb2_context *smb2, read_func func, /* Read into our trimmed iovectors */ count = func(smb2, tmpiov, niov); if (count < 0) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(_XBOX) int err = WSAGetLastError(); if (err == WSAEINTR || err == WSAEWOULDBLOCK) { #else @@ -842,7 +842,7 @@ smb2_service(struct smb2_context *smb2, int revents) static void set_nonblocking(t_socket fd) { -#if defined(WIN32) || defined(PS2_EE_PLATFORM) && defined(PS2IPS) +#if defined(WIN32) || defined(_XBOX) || defined(PS2_EE_PLATFORM) && defined(PS2IPS) unsigned long opt = 1; ioctlsocket(fd, FIONBIO, &opt); #else @@ -856,9 +856,8 @@ static int set_tcp_sockopt(t_socket sockfd, int optname, int value) { int level; -#ifndef SOL_TCP +#if !defined(SOL_TCP) struct protoent *buf; - if ((buf = getprotobyname("tcp")) != NULL) { level = buf->p_proto; } else { @@ -881,6 +880,9 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o #if 0 == CONFIGURE_OPTION_TCP_LINGER int const yes = 1; struct LingerStruct const lin = { 1, 0 }; /* if l_linger is zero, sends RST after FIN */ +#endif +#ifdef _XBOX + BOOL bBroadcast = TRUE; #endif memset(&ss, 0, sizeof(ss)); switch (ai->ai_family) { @@ -891,6 +893,7 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o ((struct sockaddr_in *)&ss)->sin_len = socksize; #endif break; +#ifndef _XBOX case AF_INET6: #if !defined(PICO_PLATFORM) || defined(LWIP_INETV6) socksize = sizeof(struct sockaddr_in6); @@ -898,6 +901,7 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o #ifdef HAVE_SOCK_SIN_LEN ((struct sockaddr_in6 *)&ss)->sin6_len = socksize; #endif +#endif #endif break; default: @@ -916,9 +920,23 @@ connect_async_ai(struct smb2_context *smb2, const struct addrinfo *ai, int *fd_o return -EIO; } +#ifdef _XBOX + if(setsockopt(fd, SOL_SOCKET, 0x5801, (PCSTR)&bBroadcast, sizeof(BOOL) ) != 0 ) + { +#if 0 + return 0; +#endif + } + if(setsockopt(fd, SOL_SOCKET, 0x5802, (PCSTR)&bBroadcast, sizeof(BOOL)) != 0) + { +#if 0 + return 0; +#endif + } +#endif + set_nonblocking(fd); set_tcp_sockopt(fd, TCP_NODELAY, 1); - #if 0 == CONFIGURE_OPTION_TCP_LINGER setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); setsockopt(fd, SOL_SOCKET, SO_LINGER, &lin, sizeof lin); @@ -1058,7 +1076,7 @@ smb2_connect_async(struct smb2_context *smb2, const char *server, if (err != 0) { #endif free(addr); -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(_XBOX) if (err == WSANOTINITIALISED) { smb2_set_error(smb2, "Winsock was not initialized. "