Sockets
[Application library]

Collaboration diagram for Sockets:

Data Structures

struct  socket
 Socket specific data. More...
struct  socket_client_globals
 Socket client library global data. More...
struct  socket_port
 Bound port sockets. More...
struct  socket_core
 Socket core. More...

Files

file  socket.h
 

Socket application program interface (API).


file  socket_codes.h
 

Socket codes and definitions.


file  socket_client.c
 

Socket application program interface (API) implementation.


file  socket_core.c
 

Socket common core implementation.


file  socket_core.h
 

Socket common core.


file  socket_messages.h
 

Socket messages.


Defines

#define SOCKET_INITIAL_RECEIVED_SIZE   4
 Initial received packet queue size.
#define SOCKET_MAX_RECEIVED_SIZE   0
 Maximum received packet queue size.
#define SOCKET_INITIAL_ACCEPTED_SIZE   1
 Initial waiting sockets queue size.
#define SOCKET_MAX_ACCEPTED_SIZE   0
 Maximum waiting sockets queue size.
#define SOCKET_CONNECT_TIMEOUT   (1 * 1000 * 1000)
 Default timeout for connections in microseconds.
#define SOCKET_ID_TRIES   100
 Maximum number of random attempts to find a new socket identifier before switching to the sequence.
#define SOCKET_ID_TRIES   100
 Maximum number of random attempts to find a new socket identifier before switching to the sequence.
#define SOCKET_INITIAL_RECEIVED_SIZE   4
 Initial size of the received packet queue.
#define SOCKET_MAX_RECEIVED_SIZE   0
 Maximum size of the received packet queue.
#define SOCKET_INITIAL_ACCEPTED_SIZE   1
 Initial size of the sockets for acceptance queue.
#define SOCKET_MAX_ACCEPTEDED_SIZE   0
 Maximum size of the sockets for acceptance queue.
#define SOCKET_MAP_KEY_LISTENING   "L"
 Listening sockets' port map key.

Typedefs

typedef enum sock_type sock_type_t
 Socket types.
typedef int32_t socklen_t
 Type definition of the socket length.
typedef struct socket socket_t
 Type definition of the socket specific data.
typedef socket_tsocket_ref
 Type definition of the socket specific data pointer.
typedef struct socket_core socket_core_t
 Type definition of the socket core.
typedef socket_core_tsocket_core_ref
 Type definition of the socket core pointer.
typedef struct socket_port socket_port_t
 Type definition of the socket port.
typedef socket_port_tsocket_port_ref
 Type definition of the socket port pointer.

Enumerations

enum  sock_type { SOCK_STREAM = 1, SOCK_DGRAM = 2, SOCK_RAW = 3 }
 

Socket types.

More...
enum  socket_messages {
  NET_SOCKET = NET_SOCKET_FIRST, NET_SOCKET_BIND, NET_SOCKET_LISTEN, NET_SOCKET_ACCEPT,
  NET_SOCKET_CONNECT, NET_SOCKET_CLOSE, NET_SOCKET_SEND, NET_SOCKET_SENDTO,
  NET_SOCKET_RECV, NET_SOCKET_RECVFROM, NET_SOCKET_GETSOCKOPT, NET_SOCKET_SETSOCKOPT,
  NET_SOCKET_ACCEPTED, NET_SOCKET_RECEIVED, NET_SOCKET_DATA_FRAGMENT_SIZE
}
 

Socket client messages.

More...

Functions

 INT_MAP_DECLARE (sockets, socket_t)
 Sockets map.
 INT_MAP_IMPLEMENT (sockets, socket_t)
static int socket_get_tcp_phone (void)
 Returns the TCP module phone.
static int socket_get_udp_phone (void)
 Returns the UDP module phone.
static sockets_ref socket_get_sockets (void)
 Returns the active sockets.
static int socket_generate_new_id (void)
 Tries to find a new free socket identifier.
void socket_connection (ipc_callid_t iid, ipc_call_t *icall)
 Default thread for new connections.
int socket_send_data (int socket_id, ipcarg_t message, ipcarg_t arg2, const void *data, size_t datalength)
 Sends message to the socket parent module with specified data.
void socket_initialize (socket_ref socket, int socket_id, int phone, services_t service)
 Initializes a new socket specific data.
void socket_destroy (socket_ref socket)
 Clears and destroys the socket.
int recvfrom_core (ipcarg_t message, int socket_id, void *data, size_t datalength, int flags, struct sockaddr *fromaddr, socklen_t *addrlen)
 Receives data via the socket.
int sendto_core (ipcarg_t message, int socket_id, const void *data, size_t datalength, int flags, const struct sockaddr *toaddr, socklen_t addrlen)
 Sends data via the socket to the remote address.
int socket_bind_insert (socket_ports_ref global_sockets, socket_core_ref socket, int port)
 Binds the socket to the port.
void socket_destroy_core (int packet_phone, socket_core_ref socket, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void(*socket_release)(socket_core_ref socket))
 Destroys the socket.
int socket_port_add_core (socket_port_ref socket_port, socket_core_ref socket, const char *key, size_t key_length)
 Adds the socket to a socket port.
static int socket_generate_new_id (socket_cores_ref local_sockets, int positive)
 Tries to find a new free socket identifier.
 INT_MAP_IMPLEMENT (socket_cores, socket_core_t)
 GENERIC_CHAR_MAP_IMPLEMENT (socket_port_map, socket_core_ref)
 INT_MAP_IMPLEMENT (socket_ports, socket_port_t)
void socket_cores_release (int packet_phone, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void(*socket_release)(socket_core_ref socket))
 Destroys local sockets.
int socket_bind (socket_cores_ref local_sockets, socket_ports_ref global_sockets, int socket_id, void *addr, size_t addrlen, int free_ports_start, int free_ports_end, int last_used_port)
 Binds the socket to the port.
int socket_bind_free_port (socket_ports_ref global_sockets, socket_core_ref socket, int free_ports_start, int free_ports_end, int last_used_port)
 Binds the socket to a free port.
int socket_create (socket_cores_ref local_sockets, int app_phone, void *specific_data, int *socket_id)
 Creates a new socket.
int socket_destroy (int packet_phone, int socket_id, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void(*socket_release)(socket_core_ref socket))
 Destroys the socket.
int socket_reply_packets (packet_t packet, size_t *length)
 Replies the packet or the packet queue data to the application via the socket.
socket_core_ref socket_port_find (socket_ports_ref global_sockets, int port, const char *key, size_t key_length)
 Finds the bound port socket.
void socket_port_release (socket_ports_ref global_sockets, socket_core_ref socket)
 Releases the socket port.
int socket_port_add (socket_ports_ref global_sockets, int port, socket_core_ref socket, const char *key, size_t key_length)
 Adds the socket to an already bound port.
 INT_MAP_DECLARE (socket_cores, socket_core_t)
 Sockets map.
 GENERIC_CHAR_MAP_DECLARE (socket_port_map, socket_core_ref)
 Bount port sockets map.
 INT_MAP_DECLARE (socket_ports, socket_port_t)
 Ports map.

Variables

static struct socket_client_globals socket_globals
 Socket client library global data.

Socket application programming interface



int socket (int domain, int type, int protocol)
 Creates a new socket.
int bind (int socket_id, const struct sockaddr *my_addr, socklen_t addrlen)
 Binds the socket to a port address.
int listen (int socket_id, int backlog)
 Sets the number of connections waiting to be accepted.
int accept (int socket_id, struct sockaddr *cliaddr, socklen_t *addrlen)
 Accepts waiting socket.
int connect (int socket_id, const struct sockaddr *serv_addr, socklen_t addrlen)
 Connects socket to the remote server.
int closesocket (int socket_id)
 Closes the socket.
int send (int socket_id, void *data, size_t datalength, int flags)
 Sends data via the socket.
int sendto (int socket_id, const void *data, size_t datalength, int flags, const struct sockaddr *toaddr, socklen_t addrlen)
 Sends data via the socket to the remote address.
int recv (int socket_id, void *data, size_t datalength, int flags)
 Receives data via the socket.
int recvfrom (int socket_id, void *data, size_t datalength, int flags, struct sockaddr *fromaddr, socklen_t *addrlen)
 Receives data via the socket.
int getsockopt (int socket_id, int level, int optname, void *value, size_t *optlen)
 Gets socket option.
int setsockopt (int socket_id, int level, int optname, const void *value, size_t optlen)
 Sets socket option.

Address families definitions



#define AF_UNSPEC   0
 Unspecified address family.
#define AF_UNIXL   1
 Unix domain sockets address family.
#define AF_LOCAL   1
 POSIX name for AF_UNIX address family.
#define AF_INET   2
 Internet IP Protocol address family.
#define AF_AX25   3
 Amateur Radio AX.25 address family.
#define AF_IPX   4
 Novell IPX address family.
#define AF_APPLETALK   5
 AppleTalk DDP address family.
#define AF_NETROM   6
 Amateur Radio NET/ROM address family.
#define AF_BRIDGE   7
 Multiprotocol bridge address family.
#define AF_ATMPVC   8
 ATM PVCs address family.
#define AF_X25   9
 Reserved for X.25 project address family.
#define AF_INET6   10
 IP version 6 address family.
#define AF_ROSE   11
 Amateur Radio X.25 PLP address family.
#define AF_DECnet   12
 Reserved for DECnet project address family.
#define AF_NETBEUI   13
 Reserved for 802.2LLC project address family.
#define AF_SECURITY   14
 Security callback pseudo AF address family.
#define AF_KEY   15
 PF_KEY key management API address family.
#define AF_NETLINK   16
 Alias to emulate 4.4BSD address family.
#define AF_PACKET   17
 Packet family address family.
#define AF_ASH   18
 Ash address family.
#define AF_ECONET   19
 Acorn Econet address family.
#define AF_ATMSVC   20
 ATM SVCs address family.
#define AF_SNA   22
 Linux SNA Project (nutters!) address family.
#define AF_IRDA   23
 IRDA sockets address family.
#define AF_PPPOX   24
 PPPoX sockets address family.
#define AF_WANPIPE   25
 Wanpipe API Sockets address family.
#define AF_LLC   26
 Linux LLC address family.
#define AF_CAN   29
 Controller Area Network address family.
#define AF_TIPC   30
 TIPC sockets address family.
#define AF_BLUETOOTH   31
 Bluetooth sockets address family.
#define AF_IUCV   32
 IUCV sockets address family.
#define AF_RXRPC   33
 RxRPC sockets address family.
#define AF_MAX   34
 Maximum address family.

Protocol families definitions

Same as address families.



#define PF_UNSPEC   AF_UNSPEC
 Unspecified protocol family.
#define PF_UNIXL   AF_UNIXL
 Unix domain sockets protocol family.
#define PF_LOCAL   AF_LOCAL
 POSIX name for AF_UNIX protocol family.
#define PF_INET   AF_INET
 Internet IP Protocol protocol family.
#define PF_AX25   AF_AX25
 Amateur Radio AX.25 protocol family.
#define PF_IPX   AF_IPX
 Novell IPX protocol family.
#define PF_APPLETALK   AF_APPLETALK
 AppleTalk DDP protocol family.
#define PF_NETROM   AF_NETROM
 Amateur Radio NET/ROM protocol family.
#define PF_BRIDGE   AF_BRIDGE
 Multiprotocol bridge protocol family.
#define PF_ATMPVC   AF_ATMPVC
 ATM PVCs protocol family.
#define PF_X25   AF_X25
 Reserved for X.25 project protocol family.
#define PF_INET6   AF_INET6
 IP version 6 protocol family.
#define PF_ROSE   AF_ROSE
 Amateur Radio X.25 PLP protocol family.
#define PF_DECnet   AF_DECnet
 Reserved for DECnet project protocol family.
#define PF_NETBEUI   AF_NETBEUI
 Reserved for 802.2LLC project protocol family.
#define PF_SECURITY   AF_SECURITY
 Security callback pseudo AF protocol family.
#define PF_KEY   AF_KEY
 PF_KEY key management API protocol family.
#define PF_NETLINK   AF_NETLINK
 Alias to emulate 4.4BSD protocol family.
#define PF_PACKET   AF_PACKET
 Packet family protocol family.
#define PF_ASH   AF_ASH
 Ash protocol family.
#define PF_ECONET   AF_ECONET
 Acorn Econet protocol family.
#define PF_ATMSVC   AF_ATMSVC
 ATM SVCs protocol family.
#define PF_SNA   AF_SNA
 Linux SNA Project (nutters!) protocol family.
#define PF_IRDA   AF_IRDA
 IRDA sockets protocol family.
#define PF_PPPOX   AF_PPPOX
 PPPoX sockets protocol family.
#define PF_WANPIPE   AF_WANPIPE
 Wanpipe API Sockets protocol family.
#define PF_LLC   AF_LLC
 Linux LLC protocol family.
#define PF_CAN   AF_CAN
 Controller Area Network protocol family.
#define PF_TIPC   AF_TIPC
 TIPC sockets protocol family.
#define PF_BLUETOOTH   AF_BLUETOOTH
 Bluetooth sockets protocol family.
#define PF_IUCV   AF_IUCV
 IUCV sockets protocol family.
#define PF_RXRPC   AF_RXRPC
 RxRPC sockets protocol family.
#define PF_MAX   AF_MAX
 Maximum protocol family.

Socket option levels definitions

Thanks to BSD these must match IPPROTO_xxx



#define SOL_IP   0
 IP socket option level.
#define SOL_ICMP   1
 ICMP socket option level.
#define SOL_TCP   6
 TCP socket option level.
#define SOL_UDP   17
 UDP socket option level.
#define SOL_IPV6   41
 IPV socket option level.
#define SOL_ICMPV6   58
 ICMPV socket option level.
#define SOL_SCTP   132
 SCTP socket option level.
#define SOL_UDPLITE   136
 UDP-Lite (RFC 3828) socket option level.
#define SOL_RAW   255
 RAW socket option level.
#define SOL_IPX   256
 IPX socket option level.
#define SOL_AX25   257
 AX socket option level.
#define SOL_ATALK   258
 ATALK socket option level.
#define SOL_NETROM   259
 NETROM socket option level.
#define SOL_ROSE   260
 ROSE socket option level.
#define SOL_DECNET   261
 DECNET socket option level.
#define SOL_X25   262
 X25 socket option level.
#define SOL_PACKET   263
 PACKET socket option level.
#define SOL_ATM   264
 ATM layer (cell level) socket option level.
#define SOL_AAL   265
 ATM Adaption Layer (packet level) socket option level.
#define SOL_IRDA   266
 IRDA socket option level.
#define SOL_NETBEUI   267
 NETBEUI socket option level.
#define SOL_LLC   268
 LLC socket option level.
#define SOL_DCCP   269
 DCCP socket option level.
#define SOL_NETLINK   270
 NETLINK socket option level.
#define SOL_TIPC   271
 TIPC socket option level.
#define SOL_RXRPC   272
 RXRPC socket option level.
#define SOL_PPPOL2TP   273
 PPPOL socket option level.
#define SOL_BLUETOOTH   274
 BLUETOOTH socket option level.

Socket specific message parameters definitions



#define SOCKET_SET_SOCKET_ID(answer)   (int *) &IPC_GET_ARG1(answer)
 Sets the socket identifier in the message answer.
#define SOCKET_GET_SOCKET_ID(call)   (int) IPC_GET_ARG1(call)
 Returns the socket identifier message parameter.
#define SOCKET_SET_READ_DATA_LENGTH(answer)   (int *) &IPC_GET_ARG1(answer)
 Sets the read data length in the message answer.
#define SOCKET_GET_READ_DATA_LENGTH(call)   (int) IPC_GET_ARG1(call)
 Returns the read data length message parameter.
#define SOCKET_GET_BACKLOG(call)   (int) IPC_GET_ARG2(call)
 Returns the backlog message parameter.
#define SOCKET_GET_OPT_LEVEL(call)   (int) IPC_GET_ARG2(call)
 Returns the option level message parameter.
#define SOCKET_GET_DATA_FRAGMENT_SIZE(call)   (size_t) IPC_GET_ARG2(call)
 Returns the data fragment size message parameter.
#define SOCKET_SET_DATA_FRAGMENT_SIZE(answer)   (size_t *) &IPC_GET_ARG2(answer)
 Sets the data fragment size in the message answer.
#define SOCKET_SET_ADDRESS_LENGTH(answer)   (socklen_t *) &IPC_GET_ARG3(answer)
 Sets the address length in the message answer.
#define SOCKET_GET_ADDRESS_LENGTH(call)   (socklen_t) IPC_GET_ARG3(call)
 Returns the address length message parameter.
#define SOCKET_SET_HEADER_SIZE(answer)   (int *) &IPC_GET_ARG3(answer)
 Sets the header size in the message answer.
#define SOCKET_GET_HEADER_SIZE(call)   (int) IPC_GET_ARG3(call)
 Returns the header size message parameter.
#define SOCKET_GET_FLAGS(call)   (int) IPC_GET_ARG4(call)
 Returns the flags message parameter.
#define SOCKET_GET_OPT_NAME(call)   (int) IPC_GET_ARG4(call)
 Returns the option name message parameter.
#define SOCKET_GET_DATA_FRAGMENTS(call)   (int) IPC_GET_ARG5(call)
 Returns the data fragments message parameter.
#define SOCKET_GET_NEW_SOCKET_ID(call)   (int) IPC_GET_ARG5(call)
 Returns the new socket identifier message parameter.

Define Documentation

#define AF_APPLETALK   5

AppleTalk DDP address family.

#define AF_ASH   18

Ash address family.

#define AF_ATMPVC   8

ATM PVCs address family.

#define AF_ATMSVC   20

ATM SVCs address family.

#define AF_AX25   3

Amateur Radio AX.25 address family.

#define AF_BLUETOOTH   31

Bluetooth sockets address family.

#define AF_BRIDGE   7

Multiprotocol bridge address family.

#define AF_CAN   29

Controller Area Network address family.

#define AF_DECnet   12

Reserved for DECnet project address family.

#define AF_ECONET   19

Acorn Econet address family.

#define AF_INET   2

Internet IP Protocol address family.

Referenced by inet_ntop(), inet_pton(), ip_deliver_local(), ip_netif_initialize(), ip_prepare_icmp(), ip_process_packet(), and main().

#define AF_INET6   10

IP version 6 address family.

Referenced by inet_ntop(), inet_pton(), and main().

#define AF_IPX   4

Novell IPX address family.

#define AF_IRDA   23

IRDA sockets address family.

#define AF_IUCV   32

IUCV sockets address family.

#define AF_KEY   15

PF_KEY key management API address family.

#define AF_LLC   26

Linux LLC address family.

#define AF_LOCAL   1

POSIX name for AF_UNIX address family.

#define AF_MAX   34

Maximum address family.

#define AF_NETBEUI   13

Reserved for 802.2LLC project address family.

#define AF_NETLINK   16

Alias to emulate 4.4BSD address family.

#define AF_NETROM   6

Amateur Radio NET/ROM address family.

#define AF_PACKET   17

Packet family address family.

#define AF_PPPOX   24

PPPoX sockets address family.

#define AF_ROSE   11

Amateur Radio X.25 PLP address family.

#define AF_RXRPC   33

RxRPC sockets address family.

#define AF_SECURITY   14

Security callback pseudo AF address family.

#define AF_SNA   22

Linux SNA Project (nutters!) address family.

#define AF_TIPC   30

TIPC sockets address family.

#define AF_UNIXL   1

Unix domain sockets address family.

#define AF_UNSPEC   0

Unspecified address family.

#define AF_WANPIPE   25

Wanpipe API Sockets address family.

#define AF_X25   9

Reserved for X.25 project address family.

#define PF_APPLETALK   AF_APPLETALK

AppleTalk DDP protocol family.

#define PF_ASH   AF_ASH

Ash protocol family.

#define PF_ATMPVC   AF_ATMPVC

ATM PVCs protocol family.

#define PF_ATMSVC   AF_ATMSVC

ATM SVCs protocol family.

#define PF_AX25   AF_AX25

Amateur Radio AX.25 protocol family.

#define PF_BLUETOOTH   AF_BLUETOOTH

Bluetooth sockets protocol family.

#define PF_BRIDGE   AF_BRIDGE

Multiprotocol bridge protocol family.

#define PF_CAN   AF_CAN

Controller Area Network protocol family.

#define PF_DECnet   AF_DECnet

Reserved for DECnet project protocol family.

#define PF_ECONET   AF_ECONET

Acorn Econet protocol family.

#define PF_INET   AF_INET

Internet IP Protocol protocol family.

Referenced by main(), and socket().

#define PF_INET6   AF_INET6

IP version 6 protocol family.

Referenced by main().

#define PF_IPX   AF_IPX

Novell IPX protocol family.

#define PF_IRDA   AF_IRDA

IRDA sockets protocol family.

#define PF_IUCV   AF_IUCV

IUCV sockets protocol family.

#define PF_KEY   AF_KEY

PF_KEY key management API protocol family.

#define PF_LLC   AF_LLC

Linux LLC protocol family.

#define PF_LOCAL   AF_LOCAL

POSIX name for AF_UNIX protocol family.

#define PF_MAX   AF_MAX

Maximum protocol family.

#define PF_NETBEUI   AF_NETBEUI

Reserved for 802.2LLC project protocol family.

#define PF_NETLINK   AF_NETLINK

Alias to emulate 4.4BSD protocol family.

#define PF_NETROM   AF_NETROM

Amateur Radio NET/ROM protocol family.

#define PF_PACKET   AF_PACKET

Packet family protocol family.

#define PF_PPPOX   AF_PPPOX

PPPoX sockets protocol family.

#define PF_ROSE   AF_ROSE

Amateur Radio X.25 PLP protocol family.

#define PF_RXRPC   AF_RXRPC

RxRPC sockets protocol family.

#define PF_SECURITY   AF_SECURITY

Security callback pseudo AF protocol family.

#define PF_SNA   AF_SNA

Linux SNA Project (nutters!) protocol family.

#define PF_TIPC   AF_TIPC

TIPC sockets protocol family.

#define PF_UNIXL   AF_UNIXL

Unix domain sockets protocol family.

#define PF_UNSPEC   AF_UNSPEC

Unspecified protocol family.

#define PF_WANPIPE   AF_WANPIPE

Wanpipe API Sockets protocol family.

#define PF_X25   AF_X25

Reserved for X.25 project protocol family.

#define SOCKET_CONNECT_TIMEOUT   (1 * 1000 * 1000)

Default timeout for connections in microseconds.

Referenced by socket_get_tcp_phone(), and socket_get_udp_phone().

#define SOCKET_GET_ADDRESS_LENGTH ( call   )     (socklen_t) IPC_GET_ARG3(call)

Returns the address length message parameter.

Parameters:
[in] call The message call structure.

Referenced by accept(), and recvfrom_core().

#define SOCKET_GET_BACKLOG ( call   )     (int) IPC_GET_ARG2(call)

Returns the backlog message parameter.

Parameters:
[in] call The message call structure.

Referenced by tcp_process_client_messages().

#define SOCKET_GET_DATA_FRAGMENT_SIZE ( call   )     (size_t) IPC_GET_ARG2(call)

Returns the data fragment size message parameter.

Parameters:
[in] call The message call structure.

Referenced by accept(), sendto_core(), and socket_connection().

#define SOCKET_GET_DATA_FRAGMENTS ( call   )     (int) IPC_GET_ARG5(call)

Returns the data fragments message parameter.

Parameters:
[in] call The message call structure.

Referenced by socket_connection(), tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_GET_FLAGS ( call   )     (int) IPC_GET_ARG4(call)

Returns the flags message parameter.

Parameters:
[in] call The message call structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_GET_HEADER_SIZE ( call   )     (int) IPC_GET_ARG3(call)

Returns the header size message parameter.

Parameters:
[in] call The message call structure.
#define SOCKET_GET_NEW_SOCKET_ID ( call   )     (int) IPC_GET_ARG5(call)

Returns the new socket identifier message parameter.

Parameters:
[in] call The message call structure.

Referenced by tcp_process_client_messages().

#define SOCKET_GET_OPT_LEVEL ( call   )     (int) IPC_GET_ARG2(call)

Returns the option level message parameter.

Parameters:
[in] call The message call structure.
#define SOCKET_GET_OPT_NAME ( call   )     (int) IPC_GET_ARG4(call)

Returns the option name message parameter.

Parameters:
[in] call The message call structure.
#define SOCKET_GET_READ_DATA_LENGTH ( call   )     (int) IPC_GET_ARG1(call)

Returns the read data length message parameter.

Parameters:
[in] call The message call structure.

Referenced by recvfrom_core().

#define SOCKET_GET_SOCKET_ID ( call   )     (int) IPC_GET_ARG1(call)

Returns the socket identifier message parameter.

Parameters:
[in] call The message call structure.

Referenced by socket_connection(), tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_ID_TRIES   100

Maximum number of random attempts to find a new socket identifier before switching to the sequence.

#define SOCKET_ID_TRIES   100

Maximum number of random attempts to find a new socket identifier before switching to the sequence.

Referenced by socket_generate_new_id().

#define SOCKET_INITIAL_ACCEPTED_SIZE   1

Initial size of the sockets for acceptance queue.

#define SOCKET_INITIAL_ACCEPTED_SIZE   1

Initial waiting sockets queue size.

Referenced by socket_initialize().

#define SOCKET_INITIAL_RECEIVED_SIZE   4

Initial size of the received packet queue.

#define SOCKET_INITIAL_RECEIVED_SIZE   4

Initial received packet queue size.

Referenced by socket_initialize().

#define SOCKET_MAP_KEY_LISTENING   "L"

Listening sockets' port map key.

Referenced by socket_bind_insert(), tcp_process_listen(), tcp_process_packet(), and udp_process_packet().

#define SOCKET_MAX_ACCEPTED_SIZE   0

Maximum waiting sockets queue size.

Referenced by socket_connection().

#define SOCKET_MAX_ACCEPTEDED_SIZE   0

Maximum size of the sockets for acceptance queue.

#define SOCKET_MAX_RECEIVED_SIZE   0

Maximum size of the received packet queue.

#define SOCKET_MAX_RECEIVED_SIZE   0

Maximum received packet queue size.

Referenced by socket_connection(), tcp_queue_received_packet(), and udp_process_packet().

#define SOCKET_SET_ADDRESS_LENGTH ( answer   )     (socklen_t *) &IPC_GET_ARG3(answer)

Sets the address length in the message answer.

Parameters:
[out] answer The message answer structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_SET_DATA_FRAGMENT_SIZE ( answer   )     (size_t *) &IPC_GET_ARG2(answer)

Sets the data fragment size in the message answer.

Parameters:
[out] answer The message answer structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_SET_HEADER_SIZE ( answer   )     (int *) &IPC_GET_ARG3(answer)

Sets the header size in the message answer.

Parameters:
[out] answer The message answer structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_SET_READ_DATA_LENGTH ( answer   )     (int *) &IPC_GET_ARG1(answer)

Sets the read data length in the message answer.

Parameters:
[out] answer The message answer structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOCKET_SET_SOCKET_ID ( answer   )     (int *) &IPC_GET_ARG1(answer)

Sets the socket identifier in the message answer.

Parameters:
[out] answer The message answer structure.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

#define SOL_AAL   265

ATM Adaption Layer (packet level) socket option level.

#define SOL_ATALK   258

ATALK socket option level.

#define SOL_ATM   264

ATM layer (cell level) socket option level.

#define SOL_AX25   257

AX socket option level.

#define SOL_BLUETOOTH   274

BLUETOOTH socket option level.

#define SOL_DCCP   269

DCCP socket option level.

#define SOL_DECNET   261

DECNET socket option level.

#define SOL_ICMP   1

ICMP socket option level.

#define SOL_ICMPV6   58

ICMPV socket option level.

#define SOL_IP   0

IP socket option level.

#define SOL_IPV6   41

IPV socket option level.

#define SOL_IPX   256

IPX socket option level.

#define SOL_IRDA   266

IRDA socket option level.

#define SOL_LLC   268

LLC socket option level.

#define SOL_NETBEUI   267

NETBEUI socket option level.

#define SOL_NETLINK   270

NETLINK socket option level.

#define SOL_NETROM   259

NETROM socket option level.

#define SOL_PACKET   263

PACKET socket option level.

#define SOL_PPPOL2TP   273

PPPOL socket option level.

#define SOL_RAW   255

RAW socket option level.

#define SOL_ROSE   260

ROSE socket option level.

#define SOL_RXRPC   272

RXRPC socket option level.

#define SOL_SCTP   132

SCTP socket option level.

#define SOL_TCP   6

TCP socket option level.

#define SOL_TIPC   271

TIPC socket option level.

#define SOL_UDP   17

UDP socket option level.

#define SOL_UDPLITE   136

UDP-Lite (RFC 3828) socket option level.

#define SOL_X25   262

X25 socket option level.


Typedef Documentation

typedef enum sock_type sock_type_t

Socket types.

Type definition of the socket core pointer.

See also:
socket_core
typedef struct socket_core socket_core_t

Type definition of the socket core.

See also:
socket_core

Type definition of the socket port pointer.

See also:
socket_port
typedef struct socket_port socket_port_t

Type definition of the socket port.

See also:
socket_port
typedef socket_t* socket_ref

Type definition of the socket specific data pointer.

See also:
socket
typedef struct socket socket_t

Type definition of the socket specific data.

See also:
socket
typedef int32_t socklen_t

Type definition of the socket length.


Enumeration Type Documentation

enum sock_type

Socket types.

Enumerator:
SOCK_STREAM 

Stream (connection oriented) socket.

SOCK_DGRAM 

Datagram (connectionless oriented) socket.

SOCK_RAW 

Raw socket.

Socket client messages.

Enumerator:
NET_SOCKET 

Creates a new socket.

See also:
socket()
NET_SOCKET_BIND 

Binds the socket.

See also:
bind()
NET_SOCKET_LISTEN 

Creates a new socket.

See also:
socket()
NET_SOCKET_ACCEPT 

Accepts an incomming connection.

See also:
accept()
NET_SOCKET_CONNECT 

Connects the socket.

See also:
connect()
NET_SOCKET_CLOSE 

Closes the socket.

See also:
closesocket()
NET_SOCKET_SEND 

Sends data via the stream socket.

See also:
send()
NET_SOCKET_SENDTO 

Sends data via the datagram socket.

See also:
sendto()
NET_SOCKET_RECV 

Receives data from the stream socket.

See also:
socket()
NET_SOCKET_RECVFROM 

Receives data from the datagram socket.

See also:
socket()
NET_SOCKET_GETSOCKOPT 

Gets the socket option.

See also:
getsockopt()
NET_SOCKET_SETSOCKOPT 

Sets the socket option.

See also:
setsockopt()
NET_SOCKET_ACCEPTED 

New socket for acceptence notification message.

NET_SOCKET_RECEIVED 

New data received notification message.

NET_SOCKET_DATA_FRAGMENT_SIZE 

New socket data fragment size notification message.


Function Documentation

int accept ( int  socket_id,
struct sockaddr cliaddr,
socklen_t addrlen 
)

Accepts waiting socket.

Blocks until such a socket exists.

Parameters:
[in] socket_id Socket identifier.
[out] cliaddr The remote client address.
[in] addrlen The address length.
Returns:
EOK on success.
EBADMEM if the cliaddr or addrlen parameter is NULL.
EINVAL if the backlog parameter is not positive (<=0).
ENOTSOCK if the socket is not found.
Other error codes as defined for the NET_SOCKET_ACCEPT message.

References accept_lock, accept_signal, accepted, blocked, data_fragment_size, dyn_fifo_pop(), dyn_fifo_value(), ENOTSOCK, free, socket_client_globals::lock, NET_SOCKET_ACCEPT, phone, service, socket_generate_new_id(), SOCKET_GET_ADDRESS_LENGTH, SOCKET_GET_DATA_FRAGMENT_SIZE, socket_get_sockets(), socket_globals, socket_id, and socket_initialize().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int bind ( int  socket_id,
const struct sockaddr my_addr,
socklen_t  addrlen 
)

Binds the socket to a port address.

Parameters:
[in] socket_id Socket identifier.
[in] my_addr The port address.
[in] addrlen The address length.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the my_addr parameter is NULL.
NO_DATA if the addlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_BIND message.

References NET_SOCKET_BIND, and socket_send_data().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int closesocket ( int  socket_id  ) 

Closes the socket.

Parameters:
[in] socket_id Socket identifier.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EINPROGRESS if there is another blocking function in progress.
Other error codes as defined for the NET_SOCKET_CLOSE message.

References blocked, EINPROGRESS, ENOTSOCK, ERROR_DECLARE, ERROR_PROPAGATE, socket_client_globals::lock, NET_SOCKET_CLOSE, phone, service, socket_destroy(), socket_get_sockets(), socket_globals, and socket_id.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int connect ( int  socket_id,
const struct sockaddr serv_addr,
socklen_t  addrlen 
)

Connects socket to the remote server.

Parameters:
[in] socket_id Socket identifier.
[in] serv_addr The remote server address.
[in] addrlen The address length.
Returns:
EOK on success.
EBADMEM if the serv_addr parameter is NULL.
NO_DATA if the addlen parameter is zero (0).
ENOTSOCK if the socket is not found.
Other error codes as defined for the NET_SOCKET_CONNECT message.

References EDESTADDRREQ, NET_SOCKET_CONNECT, and socket_send_data().

Here is the call graph for this function:

GENERIC_CHAR_MAP_DECLARE ( socket_port_map  ,
socket_core_ref   
)

Bount port sockets map.

The listening socket has the SOCKET_MAP_KEY_LISTENING key identifier whereas the other use the remote addresses.

GENERIC_CHAR_MAP_IMPLEMENT ( socket_port_map  ,
socket_core_ref   
)
int getsockopt ( int  socket_id,
int  level,
int  optname,
void *  value,
size_t *  optlen 
)

Gets socket option.

Parameters:
[in] socket_id Socket identifier.
[in] level The socket options level.
[in] optname The socket option to be get.
[out] value The value buffer to be filled.
[in,out] optlen The value buffer length. The maximum length is read. The actual length is set.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the value or optlen parameter is NULL.
NO_DATA if the optlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_GETSOCKOPT message.

References ENOTSOCK, socket_client_globals::lock, NET_SOCKET_GETSOCKOPT, NO_DATA, phone, service, socket_get_sockets(), socket_globals, and socket_id.

Here is the call graph for this function:

INT_MAP_DECLARE ( socket_ports  ,
socket_port_t   
)

Ports map.

The key is the port number.

INT_MAP_DECLARE ( socket_cores  ,
socket_core_t   
)

Sockets map.

The key is the socket identifier.

INT_MAP_DECLARE ( sockets  ,
socket_t   
)

Sockets map.

Maps socket identifiers to the socket specific data.

See also:
int_map.h
INT_MAP_IMPLEMENT ( socket_ports  ,
socket_port_t   
)
INT_MAP_IMPLEMENT ( socket_cores  ,
socket_core_t   
)
INT_MAP_IMPLEMENT ( sockets  ,
socket_t   
)
int listen ( int  socket_id,
int  backlog 
)

Sets the number of connections waiting to be accepted.

Parameters:
[in] socket_id Socket identifier.
[in] backlog The maximum number of waiting sockets to be accepted.
Returns:
EOK on success.
EINVAL if the backlog parameter is not positive (<=0).
ENOTSOCK if the socket is not found.
Other error codes as defined for the NET_SOCKET_LISTEN message.

References ENOTSOCK, socket_client_globals::lock, NET_SOCKET_LISTEN, phone, service, socket_get_sockets(), socket_globals, and socket_id.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int recv ( int  socket_id,
void *  data,
size_t  datalength,
int  flags 
)

Receives data via the socket.

Parameters:
[in] socket_id Socket identifier.
[out] data The data buffer to be filled.
[in] datalength The data length.
[in] flags Various receive flags.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data parameter is NULL.
NO_DATA if the datalength parameter is zero (0).
Other error codes as defined for the NET_SOCKET_RECV message.

References NET_SOCKET_RECV, and recvfrom_core().

Here is the call graph for this function:

int recvfrom ( int  socket_id,
void *  data,
size_t  datalength,
int  flags,
struct sockaddr fromaddr,
socklen_t addrlen 
)

Receives data via the socket.

Parameters:
[in] socket_id Socket identifier.
[out] data The data buffer to be filled.
[in] datalength The data length.
[in] flags Various receive flags.
[out] fromaddr The source address.
[in,out] addrlen The address length. The maximum address length is read. The actual address length is set.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data or fromaddr parameter is NULL.
NO_DATA if the datalength or addrlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_RECVFROM message.

References NET_SOCKET_RECVFROM, NO_DATA, and recvfrom_core().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int recvfrom_core ( ipcarg_t  message,
int  socket_id,
void *  data,
size_t  datalength,
int  flags,
struct sockaddr fromaddr,
socklen_t addrlen 
)

Receives data via the socket.

Parameters:
[in] message The action message.
[in] socket_id Socket identifier.
[out] data The data buffer to be filled.
[in] datalength The data length.
[in] flags Various receive flags.
[out] fromaddr The source address. May be NULL for connected sockets.
[in,out] addrlen The address length. The maximum address length is read. The actual address length is set. Used only if fromaddr is not NULL.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data parameter is NULL.
NO_DATA if the datalength or addrlen parameter is zero (0).
Other error codes as defined for the spcific message.

References blocked, dyn_fifo_pop(), dyn_fifo_value(), ENOTSOCK, free, socket_client_globals::lock, NO_DATA, phone, receive_lock, receive_signal, received, service, SOCKET_GET_ADDRESS_LENGTH, SOCKET_GET_READ_DATA_LENGTH, socket_get_sockets(), socket_globals, and socket_id.

Referenced by recv(), and recvfrom().

Here is the call graph for this function:

Here is the caller graph for this function:

int send ( int  socket_id,
void *  data,
size_t  datalength,
int  flags 
)

Sends data via the socket.

Parameters:
[in] socket_id Socket identifier.
[in] data The data to be sent.
[in] datalength The data length.
[in] flags Various send flags.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data parameter is NULL.
NO_DATA if the datalength parameter is zero (0).
Other error codes as defined for the NET_SOCKET_SEND message.

References NET_SOCKET_SEND, and sendto_core().

Here is the call graph for this function:

int sendto ( int  socket_id,
const void *  data,
size_t  datalength,
int  flags,
const struct sockaddr toaddr,
socklen_t  addrlen 
)

Sends data via the socket to the remote address.

Binds the socket to a free port if not already connected/bound.

Parameters:
[in] socket_id Socket identifier.
[in] data The data to be sent.
[in] datalength The data length.
[in] flags Various send flags.
[in] toaddr The destination address.
[in] addrlen The address length.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data or toaddr parameter is NULL.
NO_DATA if the datalength or the addrlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_SENDTO message.

References EDESTADDRREQ, NET_SOCKET_SENDTO, and sendto_core().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int sendto_core ( ipcarg_t  message,
int  socket_id,
const void *  data,
size_t  datalength,
int  flags,
const struct sockaddr toaddr,
socklen_t  addrlen 
)

Sends data via the socket to the remote address.

Binds the socket to a free port if not already connected/bound.

Parameters:
[in] message The action message.
[in] socket_id Socket identifier.
[in] data The data to be sent.
[in] datalength The data length.
[in] flags Various send flags.
[in] toaddr The destination address. May be NULL for connected sockets.
[in] addrlen The address length. Used only if toaddr is not NULL.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data or toaddr parameter is NULL.
NO_DATA if the datalength or the addrlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_SENDTO message.

References data_fragment_size, ENOTSOCK, header_size, socket_client_globals::lock, NO_DATA, phone, sending_lock, service, SOCKET_GET_DATA_FRAGMENT_SIZE, socket_get_sockets(), socket_globals, and socket_id.

Referenced by send(), and sendto().

Here is the call graph for this function:

Here is the caller graph for this function:

int setsockopt ( int  socket_id,
int  level,
int  optname,
const void *  value,
size_t  optlen 
)

Sets socket option.

Parameters:
[in] socket_id Socket identifier.
[in] level The socket options level.
[in] optname The socket option to be set.
[in] value The value to be set.
[in] optlen The value length.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the value parameter is NULL.
NO_DATA if the optlen parameter is zero (0).
Other error codes as defined for the NET_SOCKET_SETSOCKOPT message.

References NET_SOCKET_SETSOCKOPT, and socket_send_data().

Here is the call graph for this function:

int socket ( int  domain,
int  type,
int  protocol 
)

Creates a new socket.

Parameters:
[in] domain The socket protocol family.
[in] type Socket type.
[in] protocol Socket protocol.
Returns:
The socket identifier on success.
EPFNOTSUPPORT if the protocol family is not supported.
ESOCKNOTSUPPORT if the socket type is not supported.
EPROTONOSUPPORT if the protocol is not supported.
ENOMEM if there is not enough memory left.
ELIMIT if there was not a free socket identifier found this time.
Other error codes as defined for the NET_SOCKET message.
Other error codes as defined for the bind_service_timeout() function.

References accepted, data_fragment_size, dyn_fifo_destroy(), EPFNOSUPPORT, EPROTONOSUPPORT, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, ESOCKTNOSUPPORT, free, header_size, IPPROTO_TCP, IPPROTO_UDP, socket_client_globals::lock, NET_SOCKET, NET_SOCKET_CLOSE, PF_INET, received, SOCK_DGRAM, SOCK_RAW, SOCK_STREAM, socket_generate_new_id(), socket_get_sockets(), socket_get_tcp_phone(), socket_get_udp_phone(), socket_globals, and socket_initialize().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int socket_bind ( socket_cores_ref  local_sockets,
socket_ports_ref  global_sockets,
int  socket_id,
void *  addr,
size_t  addrlen,
int  free_ports_start,
int  free_ports_end,
int  last_used_port 
)

Binds the socket to the port.

The address port is used if set, a free port is used if not.

Parameters:
[in] local_sockets The local sockets to be searched.
[in,out] global_sockets The global sockets to be updated.
[in] socket_id The new socket identifier.
[in] addr The address to be bound to.
[in] addrlen The address length.
[in] free_ports_start The minimum free port.
[in] free_ports_end The maximum free port.
[in] last_used_port The last used free port.
Returns:
EOK on success.
ENOTSOCK if the socket was not found.
EAFNOSUPPORT if the address family is not supported.
EADDRINUSE if the port is already in use.
Other error codes as defined for the socket_bind_free_port() function.
Other error codes as defined for the socket_bind_insert() function.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

Here is the caller graph for this function:

int socket_bind_free_port ( socket_ports_ref  global_sockets,
socket_core_ref  socket,
int  free_ports_start,
int  free_ports_end,
int  last_used_port 
)

Binds the socket to a free port.

The first free port is used.

Parameters:
[in,out] global_sockets The global sockets to be updated.
[in,out] socket The socket to be bound.
[in] free_ports_start The minimum free port.
[in] free_ports_end The maximum free port.
[in] last_used_port The last used free port.
Returns:
EOK on success.
ENOTCONN if no free port was found.
Other error codes as defined for the socket_bind_insert() function.

Referenced by tcp_connect_core(), and udp_sendto_message().

Here is the caller graph for this function:

int socket_bind_insert ( socket_ports_ref  global_sockets,
socket_core_ref  socket,
int  port 
)

Binds the socket to the port.

The SOCKET_MAP_KEY_LISTENING key identifier is used.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] socket The socket to be added.
[in] port The port number to be bound to.
Returns:
EOK on success.
ENOMEM if there is not enough memory left.
Other error codes as defined for the socket_ports_add() function.

References socket_port::count, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, free, socket_port::map, socket_core::port, SOCKET_MAP_KEY_LISTENING, and socket_port_add_core().

Here is the call graph for this function:

void socket_connection ( ipc_callid_t  iid,
ipc_call_t *  icall 
)

Default thread for new connections.

Parameters:
[in] iid The initial message identifier.
[in] icall The initial message call structure.

References accept_lock, accept_signal, accepted, data_fragment_size, dyn_fifo_push(), ENOTSOCK, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, socket_client_globals::lock, NET_SOCKET_ACCEPTED, NET_SOCKET_DATA_FRAGMENT_SIZE, NET_SOCKET_RECEIVED, receive_lock, receive_signal, received, sending_lock, SOCKET_GET_DATA_FRAGMENT_SIZE, SOCKET_GET_DATA_FRAGMENTS, SOCKET_GET_SOCKET_ID, socket_get_sockets(), socket_globals, SOCKET_MAX_ACCEPTED_SIZE, and SOCKET_MAX_RECEIVED_SIZE.

Referenced by socket_get_tcp_phone(), and socket_get_udp_phone().

Here is the call graph for this function:

Here is the caller graph for this function:

void socket_cores_release ( int  packet_phone,
socket_cores_ref  local_sockets,
socket_ports_ref  global_sockets,
void(*)(socket_core_ref socket socket_release 
)

Destroys local sockets.

Releases all buffered packets and calls the release function for each of the sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] local_sockets The local sockets to be destroyed.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.

Referenced by tcp_process_client_messages(), and udp_process_client_messages().

Here is the caller graph for this function:

int socket_create ( socket_cores_ref  local_sockets,
int  app_phone,
void *  specific_data,
int *  socket_id 
)

Creates a new socket.

Parameters:
[in,out] local_sockets The local sockets to be updated.
[in] app_phone The application phone.
[in] specific_data The socket specific data.
[in,out] socket_id The new socket identifier. A new identifier is chosen if set to zero (0) or negative. A negative identifier is chosen if set to negative.
Returns:
EOK on success.
EINVAL if the socket_id parameter is NULL.
ENOMEM if there is not enough memory left.

Referenced by tcp_process_client_messages(), tcp_process_listen(), and udp_process_client_messages().

Here is the caller graph for this function:

int socket_destroy ( int  packet_phone,
int  socket_id,
socket_cores_ref  local_sockets,
socket_ports_ref  global_sockets,
void(*)(socket_core_ref socket socket_release 
)

Destroys the socket.

If the socket is bound, the port is released. Releases all buffered packets, calls the release function and removes the socket from the local sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] socket_id The socket identifier.
[in,out] local_sockets The local sockets to be updated.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
void socket_destroy ( socket_ref  socket  ) 

Clears and destroys the socket.

Parameters:
[in] socket The socket to be destroyed.

References accepted, dyn_fifo_destroy(), dyn_fifo_pop(), received, socket_get_sockets(), and socket_id.

Referenced by closesocket(), tcp_close_message(), tcp_process_listen(), tcp_release_after_timeout(), and udp_process_client_messages().

Here is the call graph for this function:

Here is the caller graph for this function:

void socket_destroy_core ( int  packet_phone,
socket_core_ref  socket,
socket_cores_ref  local_sockets,
socket_ports_ref  global_sockets,
void(*)(socket_core_ref socket socket_release 
)

Destroys the socket.

If the socket is bound, the port is released. Releases all buffered packets, calls the release function and removes the socket from the local sockets.

Parameters:
[in] packet_phone The packet server phone to release buffered packets.
[in] socket The socket to be destroyed.
[in,out] local_sockets The local sockets to be updated.
[in,out] global_sockets The global sockets to be updated.
[in] socket_release The client release callback function.

References socket_core::accepted, dyn_fifo_destroy(), dyn_fifo_pop(), socket_core::port, pq_release(), socket_core::received, socket_core::socket_id, and socket_port_release().

Here is the call graph for this function:

static int socket_generate_new_id ( socket_cores_ref  local_sockets,
int  positive 
) [static]

Tries to find a new free socket identifier.

Parameters:
[in] local_sockets The local sockets to be searched.
[in] positive A value indicating whether a positive identifier is requested. A negative identifier is requested if set to false.
Returns:
The new socket identifier.
ELIMIT if there is no socket identifier available.

References count, and SOCKET_ID_TRIES.

static int socket_generate_new_id ( void   )  [static]

Tries to find a new free socket identifier.

Returns:
The new socket identifier.
ELIMIT if there is no socket identifier available.

References count, socket_get_sockets(), and SOCKET_ID_TRIES.

Referenced by accept(), and socket().

Here is the call graph for this function:

Here is the caller graph for this function:

static sockets_ref socket_get_sockets ( void   )  [static]

Returns the active sockets.

Returns:
The active sockets.

References free, socket_globals, and socket_client_globals::sockets.

Referenced by accept(), closesocket(), getsockopt(), listen(), recvfrom_core(), sendto_core(), socket(), socket_connection(), socket_destroy(), socket_generate_new_id(), and socket_send_data().

Here is the caller graph for this function:

static int socket_get_tcp_phone ( void   )  [static]

Returns the TCP module phone.

Connects to the TCP module if necessary.

Returns:
The TCP module phone.
Other error codes as defined for the bind_service_timeout() function.

References bind_service_timeout(), SOCKET_CONNECT_TIMEOUT, socket_connection(), socket_globals, and socket_client_globals::tcp_phone.

Referenced by socket().

Here is the call graph for this function:

Here is the caller graph for this function:

static int socket_get_udp_phone ( void   )  [static]

Returns the UDP module phone.

Connects to the UDP module if necessary.

Returns:
The UDP module phone.
Other error codes as defined for the bind_service_timeout() function.

References bind_service_timeout(), SOCKET_CONNECT_TIMEOUT, socket_connection(), socket_globals, and socket_client_globals::udp_phone.

Referenced by socket().

Here is the call graph for this function:

Here is the caller graph for this function:

void socket_initialize ( socket_ref  socket,
int  socket_id,
int  phone,
services_t  service 
)

Initializes a new socket specific data.

Parameters:
[in,out] socket The socket to be initialized.
[in] socket_id The new socket identifier.
[in] phone The parent module phone.
[in] service The parent module service.

References accept_lock, accept_signal, accepted, dyn_fifo_initialize(), phone, receive_lock, receive_signal, received, sending_lock, service, socket_id, SOCKET_INITIAL_ACCEPTED_SIZE, and SOCKET_INITIAL_RECEIVED_SIZE.

Referenced by accept(), and socket().

Here is the call graph for this function:

Here is the caller graph for this function:

int socket_port_add ( socket_ports_ref  global_sockets,
int  port,
socket_core_ref  socket,
const char *  key,
size_t  key_length 
)

Adds the socket to an already bound port.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] port The port number to be bound to.
[in] socket The socket to be added.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
EOK on success.
ENOENT if the port is not already used.
Other error codes as defined for the socket_port_add_core() function.

Referenced by tcp_process_listen().

Here is the caller graph for this function:

int socket_port_add_core ( socket_port_ref  socket_port,
socket_core_ref  socket,
const char *  key,
size_t  key_length 
)

Adds the socket to a socket port.

Parameters:
[in,out] socket_port The socket port structure.
[in] socket The socket to be added.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
EOK on success.
ENOMEM if there is not enough memory left.

References socket_port::count, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, free, socket_core::key, socket_core::key_length, and socket_port::map.

Referenced by socket_bind_insert().

Here is the caller graph for this function:

socket_core_ref socket_port_find ( socket_ports_ref  global_sockets,
int  port,
const char *  key,
size_t  key_length 
)

Finds the bound port socket.

Parameters:
[in] global_sockets The global sockets to be searched.
[in] port The port number.
[in] key The socket key identifier.
[in] key_length The socket key length.
Returns:
The found socket.
NULL if no socket was found.

Referenced by tcp_process_listen(), tcp_process_packet(), tcp_release_after_timeout(), tcp_timeout(), and udp_process_packet().

Here is the caller graph for this function:

void socket_port_release ( socket_ports_ref  global_sockets,
socket_core_ref  socket 
)

Releases the socket port.

If the socket is bound the port entry is released. If there are no more port entries the port is release.

Parameters:
[in] global_sockets The global sockets to be updated.
[in] socket The socket to be unbound.

Referenced by socket_destroy_core().

Here is the caller graph for this function:

int socket_reply_packets ( packet_t  packet,
size_t *  length 
)

Replies the packet or the packet queue data to the application via the socket.

Uses the current message processing fibril.

Parameters:
[in] packet The packet to be transfered.
[out] length The total data length.
Returns:
EOK on success.
EBADMEM if the length parameter is NULL.
ENOMEM if there is not enough memory left.
Other error codes as defined for the data_reply() function.

Referenced by tcp_recvfrom_message(), and udp_recvfrom_message().

Here is the caller graph for this function:

int socket_send_data ( int  socket_id,
ipcarg_t  message,
ipcarg_t  arg2,
const void *  data,
size_t  datalength 
)

Sends message to the socket parent module with specified data.

Parameters:
[in] socket_id Socket identifier.
[in] message The action message.
[in] arg2 The second message parameter.
[in] data The data to be sent.
[in] datalength The data length.
Returns:
EOK on success.
ENOTSOCK if the socket is not found.
EBADMEM if the data parameter is NULL.
NO_DATA if the datalength parameter is zero (0).
Other error codes as defined for the spcific message.

References ENOTSOCK, socket_client_globals::lock, NO_DATA, phone, service, socket_get_sockets(), socket_globals, and socket_id.

Referenced by bind(), connect(), and setsockopt().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation


Generated on Thu Mar 11 20:48:26 2010 for Networking and TCP/IP stack for HelenOS system by  doxygen 1.6.1