Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
socket.h File Reference
#include "ioforge/ioforge_nic.h"
#include "net/netdev.h"
#include <type.h>

Go to the source code of this file.

Data Structures

struct  sockaddr
 
struct  sockaddr_ll
 
struct  sockaddr_in
 
struct  socket_ops
 
struct  socket
 

Macros

#define SOL_SOCKET   1
 
#define IPPROTO_IP   0
 
#define IPPROTO_TCP   6
 
#define IPPROTO_UDP   17
 
#define SO_BINDTODEVICE   25 /* bind ke netdvev, default by route table */
 
#define SO_RCVBUF   8 /* ukuran RX buffer */
 
#define SO_SNDBUF   7 /* ukuran TX buffer */
 
#define SO_BROADCAST   6 /* izinkan broadcast */
 
#define SO_PROMISC   200 /* aktifkan promiscuous di NIC terikat */
 
#define SO_NONBLOCK   201 /* non-blocking mode */
 
#define SOCK_OK   0
 
#define SOCK_ERR_NOFD   -1 /* tidak ada file descriptor kosong */
 
#define SOCK_ERR_INVAL   -2 /* argumen tidak valid */
 
#define SOCK_ERR_NODEV   -3 /* NIC tidak ditemukan */
 
#define SOCK_ERR_AGAIN   -4 /* non-blocking, tidak ada data */
 
#define SOCK_ERR_NOMEM   -5 /* buffer pool habis */
 
#define SOCK_ERR_NOTCONN   -6 /* belum connect() */
 

Typedefs

typedef struct sockaddr sockaddr_t
 
typedef struct sockaddr_ll sockaddr_ll_t
 
typedef struct sockaddr_in sockaddr_in_t
 
typedef struct socket socket_t
 
typedef struct socket_ops socket_ops_t
 

Enumerations

enum  sock_family_t { AF_RAW = 0 , AF_INET = 2 , AF_INET6 = 10 , AF_PACKET = 17 }
 
enum  sock_type_t { SOCK_RAW = 0 , SOCK_DGRAM = 1 , SOCK_STREAM = 2 }
 

Functions

void vxSocket (sock_family_t family, sock_type_t type, uint16_t protocol, socket_t **socket)
 

Macro Definition Documentation

◆ IPPROTO_IP

#define IPPROTO_IP   0

Definition at line 85 of file socket.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP   6

Definition at line 86 of file socket.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP   17

Definition at line 87 of file socket.h.

◆ SO_BINDTODEVICE

#define SO_BINDTODEVICE   25 /* bind ke netdvev, default by route table */

Definition at line 89 of file socket.h.

Referenced by socket_set_sockopt().

◆ SO_BROADCAST

#define SO_BROADCAST   6 /* izinkan broadcast */

Definition at line 92 of file socket.h.

◆ SO_NONBLOCK

#define SO_NONBLOCK   201 /* non-blocking mode */

Definition at line 94 of file socket.h.

◆ SO_PROMISC

#define SO_PROMISC   200 /* aktifkan promiscuous di NIC terikat */

Definition at line 93 of file socket.h.

◆ SO_RCVBUF

#define SO_RCVBUF   8 /* ukuran RX buffer */

Definition at line 90 of file socket.h.

◆ SO_SNDBUF

#define SO_SNDBUF   7 /* ukuran TX buffer */

Definition at line 91 of file socket.h.

◆ SOCK_ERR_AGAIN

#define SOCK_ERR_AGAIN   -4 /* non-blocking, tidak ada data */

Definition at line 101 of file socket.h.

◆ SOCK_ERR_INVAL

#define SOCK_ERR_INVAL   -2 /* argumen tidak valid */

Definition at line 99 of file socket.h.

◆ SOCK_ERR_NODEV

#define SOCK_ERR_NODEV   -3 /* NIC tidak ditemukan */

Definition at line 100 of file socket.h.

Referenced by socket_receive(), and socket_set_sockopt().

◆ SOCK_ERR_NOFD

#define SOCK_ERR_NOFD   -1 /* tidak ada file descriptor kosong */

Definition at line 98 of file socket.h.

◆ SOCK_ERR_NOMEM

#define SOCK_ERR_NOMEM   -5 /* buffer pool habis */

Definition at line 102 of file socket.h.

◆ SOCK_ERR_NOTCONN

#define SOCK_ERR_NOTCONN   -6 /* belum connect() */

Definition at line 103 of file socket.h.

Referenced by socket_set_sockopt().

◆ SOCK_OK

#define SOCK_OK   0

Definition at line 97 of file socket.h.

Referenced by socket_set_sockopt().

◆ SOL_SOCKET

#define SOL_SOCKET   1

Definition at line 84 of file socket.h.

Referenced by socket_set_sockopt().

Typedef Documentation

◆ sockaddr_in_t

typedef struct sockaddr_in sockaddr_in_t

◆ sockaddr_ll_t

typedef struct sockaddr_ll sockaddr_ll_t

◆ sockaddr_t

typedef struct sockaddr sockaddr_t

◆ socket_ops_t

typedef struct socket_ops socket_ops_t

◆ socket_t

typedef struct socket socket_t

Definition at line 31 of file socket.h.

Enumeration Type Documentation

◆ sock_family_t

Enumerator
AF_RAW 
AF_INET 
AF_INET6 
AF_PACKET 

Definition at line 42 of file socket.h.

◆ sock_type_t

Enumerator
SOCK_RAW 
SOCK_DGRAM 
SOCK_STREAM 

Definition at line 49 of file socket.h.

Function Documentation

◆ vxSocket()

void vxSocket ( sock_family_t family,
sock_type_t type,
uint16_t protocol,
socket_t ** socket )

Definition at line 35 of file socket.c.

References socket::family, LOG2_WARN, protocol, socket_cache, type, vxCreateSlabCache(), and vxSlabAlloc().