diff --git a/include/portable-endian.h b/include/portable-endian.h index 20086fde..dcd154b8 100644 --- a/include/portable-endian.h +++ b/include/portable-endian.h @@ -84,6 +84,25 @@ # define htole64(x) (x) # define le64toh(x) (x) +#elif defined(DC_KOS_PLATFORM) + +# include + +# define be16toh(x) __builtin_bswap16(x) +# define htobe16(x) __builtin_bswap16(x) +# define htole16(x) (x) +# define le16toh(x) (x) + +# define be32toh(x) __builtin_bswap32(x) +# define htobe32(x) __builtin_bswap32(x) +# define htole32(x) (x) +# define le32toh(x) (x) + +# define be64toh(x) __builtin_bswap64(x) +# define htobe64(x) __builtin_bswap64(x) +# define htole64(x) (x) +# define le64toh(x) (x) + #elif defined(__linux__) || defined(__CYGWIN__) # include diff --git a/lib/Makefile.DC_KOS b/lib/Makefile.DC_KOS new file mode 100644 index 00000000..8602620a --- /dev/null +++ b/lib/Makefile.DC_KOS @@ -0,0 +1,68 @@ +KOS_CFLAGS = -DDC_KOS_PLATFORM -DNEED_WRITEV -DNEED_READV -DHAVE_STDINT_H -DHAVE_STRING_H \ + -DHAVE_SYS_TYPES_H -DHAVE_UNISTD_H -DHAVE_SYS_STAT_H -DHAVE_TIME_H -DHAVE_NETINET_IN_H \ + -DHAVE_SYS_SOCKET_H -D HAVE_NETDB_H -DHAVE_POLL_H -DHAVE_STDLIB_H \ + -D_U_=/**/ -I../include -I../include/smb2 $(KOS_INC_PATHS) + +TARGET = libsmb2.a +OBJS = aes128ccm.o \ + aes.o \ + alloc.o \ + compat.o \ + dcerpc.o \ + dcerpc-lsa.o \ + dcerpc-srvsvc.o \ + errors.o \ + hmac.o \ + hmac-md5.o \ + init.o \ + krb5-wrapper.o \ + libsmb2.o \ + md4c.o \ + md5.o \ + ntlmssp.o \ + pdu.o \ + sha1.o \ + sha224-256.o \ + sha384-512.o \ + smb2-cmd-close.o \ + smb2-cmd-create.o \ + smb2-cmd-echo.o \ + smb2-cmd-error.o \ + smb2-cmd-flush.o \ + smb2-cmd-ioctl.o \ + smb2-cmd-logoff.o \ + smb2-cmd-negotiate.o \ + smb2-cmd-query-directory.o \ + smb2-cmd-query-info.o \ + smb2-cmd-read.o \ + smb2-cmd-session-setup.o \ + smb2-cmd-set-info.o \ + smb2-cmd-tree-connect.o \ + smb2-cmd-tree-disconnect.o \ + smb2-cmd-write.o \ + smb2-data-file-info.o \ + smb2-data-filesystem-info.o \ + smb2-data-security-descriptor.o \ + smb2-data-reparse-point.o \ + smb2-share-enum.o \ + smb3-seal.o \ + smb2-signing.o \ + timestamps.o \ + unicode.o \ + usha.o \ + socket.o \ + sync.o + +install: defaultall +ifeq ($(KOS_BASE),) + @echo "$KOS_BASE is not set. Can not install libsmb2." + @exit 1 +endif + @echo Copying... + @[ -d $(KOS_BASE)/addons/include/smb2 ] || mkdir -p $(KOS_BASE)/addons/include/smb2 + @cp -frv ../include/smb2/*.h $(KOS_BASE)/addons/include/smb2 + @chmod 0644 $(TARGET) + @cp -frv $(TARGET) $(KOS_BASE)/addons/lib/dreamcast + @echo Done! + +include ${KOS_PORTS}/scripts/lib.mk diff --git a/lib/compat.h b/lib/compat.h index 3ef3361e..3b67db29 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -73,6 +73,24 @@ long long int be64toh(long long int x); #endif /* PS2_EE_PLATFORM */ +#ifdef DC_KOS_PLATFORM + +#include +#include +#include +#include +#include +#include + +#define getlogin_r(a,b) ENXIO + +#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ +#define SOL_TCP IPPROTO_TCP + +ssize_t writev(int fd, const struct iovec *iov, int iovcnt); +ssize_t readv(int fd, const struct iovec *iov, int iovcnt); + +#endif /* DC_KOS_PLATFORM */ #ifdef PS2_IOP_PLATFORM diff --git a/lib/sync.c b/lib/sync.c index 7a34a00a..8560aca8 100644 --- a/lib/sync.c +++ b/lib/sync.c @@ -66,7 +66,8 @@ static int wait_for_reply(struct smb2_context *smb2, time_t t = time(NULL); while (!cb_data->is_finished) { - struct pollfd pfd; + struct pollfd pfd; + memset(&pfd, 0, sizeof(struct pollfd)); pfd.fd = smb2_get_fd(smb2); pfd.events = smb2_which_events(smb2);