KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches

VFS Driver for adding a BSD-sockets-like filesystem. More...

Modules

 Flags
 Flags for Socket VFS.
 

Files

file  fs_socket.h
 Definitions for a sockets "filesystem".
 

Data Structures

struct  net_socket_t
 Internal representation of a socket for fs_socket. More...
 
struct  fs_socket_proto_t
 Internal sockets protocol handler. More...
 

Macros

#define FS_SOCKET_PROTO_ENTRY   { NULL, NULL }
 Initializer for the entry field in the fs_socket_proto_t struct.
 

Functions

net_socket_tfs_socket_open_sock (fs_socket_proto_t *proto)
 Open a socket without calling the protocol initializer.
 
int fs_socket_input (netif_t *src, int domain, int protocol, const void *hdr, const uint8 *data, size_t size)
 Input a packet into some socket family handler.
 
int fs_socket_proto_add (fs_socket_proto_t *proto)
 Add a new protocol for use with fs_socket.
 
int fs_socket_proto_remove (fs_socket_proto_t *proto)
 Unregister a protocol from fs_socket.
 

Detailed Description

VFS Driver for adding a BSD-sockets-like filesystem.

Macro Definition Documentation

◆ FS_SOCKET_PROTO_ENTRY

#define FS_SOCKET_PROTO_ENTRY   { NULL, NULL }

Initializer for the entry field in the fs_socket_proto_t struct.

Function Documentation

◆ fs_socket_input()

int fs_socket_input ( netif_t src,
int  domain,
int  protocol,
const void *  hdr,
const uint8 data,
size_t  size 
)

Input a packet into some socket family handler.

This function is used by the lower-level network protocol handlers to input packets for further processing by upper-level protocols. This will call the input function on the family handler, if one is found.

Parameters
srcThe network interface the packet came in on
domainThe low-level protocol used (AF_INET or AF_INET6)
protocolThe upper-level protocol that we're looking for
hdrThe low-level protocol header
dataThe upper-level packet, without any lower-level protocol headers, but with the upper-level ones intact
sizeThe size of the packet (the data parameter)
Return values
-2The protocol is not known
-1Protocol-level error processing packet
0On success

◆ fs_socket_open_sock()

net_socket_t * fs_socket_open_sock ( fs_socket_proto_t proto)

Open a socket without calling the protocol initializer.

This function creates a new socket, but does not call the protocol's socket() function. This is meant to be used for things like accepting an incoming connection, where calling the regular socket initializer could cause issues. You shouldn't really have any need to call this function unless you are implementing a new protocol handler.

Parameters
protoThe protocol to use for the socket.
Returns
The newly created socket on success, NULL on failure.
Error Conditions:
EWOULDBLOCK - if the function would block in an IRQ
ENOMEM - out of memory
EMFILE - too many files open

◆ fs_socket_proto_add()

int fs_socket_proto_add ( fs_socket_proto_t proto)

Add a new protocol for use with fs_socket.

This function registers a protocol handler with fs_socket for use when creating and using sockets. This protocol handler must implement all of the functions in the fs_socket_proto_t structure. See the code in kos/kernel/net/net_udp.c for an example of how to do this.

Warning
This function is NOT safe to call inside an interrupt.
Parameters
protoThe new protocol handler to register
Return values
0On success (no error conditions are currently defined)

◆ fs_socket_proto_remove()

int fs_socket_proto_remove ( fs_socket_proto_t proto)

Unregister a protocol from fs_socket.

This function does the exact opposite of fs_socket_proto_add, and removes a protocol from use with fs_socket.

Note
It is the programmer's responsibility to make sure that no sockets are still around that are registered with the protocol to be removed (as they will not work properly once the handler has been removed).
Parameters
protoThe protocol handler to remove
Return values
-1On error (This function does not directly change errno)
0On success