work, still have to tidy up a bit
This commit is contained in:
parent
d98bf1f888
commit
36de5701ce
2 changed files with 22 additions and 22 deletions
|
@ -24,7 +24,7 @@
|
|||
#include <metalsvm/fs.h>
|
||||
#include <metalsvm/spinlock.h>
|
||||
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
#include <lwip/mem.h>
|
||||
#include <lwip/raw.h>
|
||||
#include <lwip/icmp.h>
|
||||
|
@ -36,36 +36,36 @@
|
|||
#include <lwip/sockets.h>
|
||||
#include <lwip/inet.h>
|
||||
#include <lwip/err.h>
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
/* Implementation of a simple stdout device */
|
||||
|
||||
static ssize_t netchar_read(fildes_t* file, uint8_t* buffer, size_t size)
|
||||
{
|
||||
kprintf("\nlwip_read: %p with lenght %i and Socket %i", buffer, size, file->offset);
|
||||
//kprintf("\nlwip_read: %p with lenght %i and Socket %i", buffer, size, file->offset);
|
||||
|
||||
int ret;
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
ret = lwip_read((int)file->offset, buffer, size);
|
||||
|
||||
if (ret < 0)
|
||||
ret = -errno;
|
||||
#else
|
||||
ret = -EINVAL;
|
||||
#endif
|
||||
//#else
|
||||
//#endif
|
||||
kprintf("return size: %i", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t netchar_write(fildes_t* file, uint8_t* buffer, size_t size)
|
||||
{
|
||||
int ret;
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
ret = lwip_write(file->offset, buffer, size);
|
||||
if (ret < 0)
|
||||
ret = -errno;
|
||||
#else
|
||||
ret = -EINVAL;
|
||||
#endif
|
||||
//#else
|
||||
//#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -77,13 +77,13 @@ static int netchar_open(fildes_t* file, const char* name)
|
|||
static int netchar_close(vfs_node_t* node) //////////////change this in File!!!
|
||||
{
|
||||
int ret;
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
ret = lwip_close(file->offset);
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
// ret = lwip_close(file->offset);
|
||||
if (ret < 0)
|
||||
ret = -errno;
|
||||
#else
|
||||
//#else
|
||||
ret = 0;
|
||||
#endif
|
||||
//#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <metalsvm/time.h>
|
||||
#include <lwip/opt.h>
|
||||
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
#include <lwip/mem.h>
|
||||
#include <lwip/raw.h>
|
||||
#include <lwip/icmp.h>
|
||||
|
@ -40,7 +40,7 @@
|
|||
#include <lwip/inet.h>
|
||||
#include <lwip/err.h>
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
static int sys_open(const char* name, int flags, int mode)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ static int sys_open(const char* name, int flags, int mode)
|
|||
return fd;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
static int sys_socket(int domain, int type, int protocol)
|
||||
{
|
||||
int fd;
|
||||
|
@ -114,7 +114,7 @@ static int sys_accept(int s, struct sockaddr* addr, socklen_t* addrlen)
|
|||
return fd;
|
||||
}
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
static int sys_close(int fd)
|
||||
|
@ -275,7 +275,7 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
ret = sys_times(buffer, clock);
|
||||
break;
|
||||
}
|
||||
#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
//#if defined(CONFIG_LWIP) && LWIP_SOCKET
|
||||
case __NR_closesocket: {
|
||||
int fd = va_arg(vl, int);
|
||||
|
||||
|
@ -306,7 +306,7 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
ret = -ENOTSOCK;
|
||||
break;
|
||||
}
|
||||
kprintf("lwip_connect: %p with lenght %i and Socket %i", name, namelen, per_core(current_task)->fildes_table[fd].offset);
|
||||
//kprintf("lwip_connect: %p with lenght %i and Socket %i", name, namelen, per_core(current_task)->fildes_table[fd].offset);
|
||||
|
||||
|
||||
ret = lwip_connect(per_core(current_task)->fildes_table[fd].offset, name, namelen);
|
||||
|
@ -356,7 +356,7 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
ret = -errno;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
default:
|
||||
kputs("invalid system call\n");
|
||||
ret = -ENOSYS;
|
||||
|
|
Loading…
Add table
Reference in a new issue