36 lines
866 B
C
36 lines
866 B
C
#ifndef NETSOCK_NETSOCK_H_
|
|
#define NETSOCK_NETSOCK_H_
|
|
|
|
#include <stdbool.h>
|
|
#include "spinlock/spinlock.h"
|
|
#include "pico_socket.h"
|
|
#include "ipc/pipe/pipe.h"
|
|
#include "rbuf/rbuf.h"
|
|
|
|
typedef uint16_t IpcNetSockEventBuffer;
|
|
#define IPC_NETSOCK_EVENTBUFFER_MAX 512
|
|
|
|
typedef struct IpcNetSock {
|
|
struct IpcNetSock *next;
|
|
struct pico_socket *picosock;
|
|
IpcPipe *datapipe;
|
|
RBufT eventbuffer;
|
|
SpinLock spinlock;
|
|
uint64_t ownerpid;
|
|
} IpcNetSock;
|
|
|
|
typedef struct {
|
|
IpcNetSock *netsocks;
|
|
SpinLock spinlock;
|
|
} IpcNetSocks;
|
|
|
|
extern IpcNetSocks IPC_NETSOCKS;
|
|
|
|
void ipc_netsockinit(void);
|
|
IpcNetSock *ipc_netsockmake(uint16_t net, uint16_t proto, uint16_t port, uint64_t pid);
|
|
int32_t ipc_netsocklisten(IpcNetSock *netsock, size_t maxlisteners);
|
|
int32_t ipc_netsockdelete(IpcNetSock *netsock);
|
|
void ipc_netsock_cleanup_dangling(void);
|
|
|
|
#endif // NETSOCK_NETSOCK_H_
|