#include "vfer.h"
#include "vfer_packet.h"
#include "vfer_datagram.h"
#include "vfer_func_rel.h"
Go to the source code of this file.
Functions | |
int | Control_Accept (vfer_sock *skt, vfer_sock *ret_skt) |
void | Control_Add_Socket (vfer_sock *sock, packet *request, packet *response, packet *ack, char client) |
int | Control_Close (vfer_sock *sock) |
int | Control_Connect (vfer_sock *sock) |
int | Control_Recv (vfer_sock *sock, void *buffer, int len) |
void | Control_Register_Socket (vfer_sock *sock) |
size_t | Control_Send (vfer_sock *sock, const void *buffer, int len) |
void | Control_Unregister_Socket (vfer_sock *sock) |
Definition in file vfer_control.h.
Returns the top connection on te accept queue for a socket.
This function changes the state of ret_sock to CONN_ACCEPTING and blocks in a cond_wait until ControlT threads goes through the handshake, changes the state of ret_sock to CONN_CONNECTED (or something else on error) and signals to this thread to wake up.
sock | a pointer to a socket structure | |
ret_sock | a pointer to a socket structure that is 'connected' as a result of this call |
Definition at line 73 of file vfer_control.c.
void Control_Add_Socket | ( | vfer_sock * | sock, | |
packet * | request, | |||
packet * | response, | |||
packet * | ack, | |||
char | client | |||
) |
Sets up the socket structure with default parameters based on the initial handshake packets (request/response/ack). It sets the state of the socket to CONN_CONNECTED.
sock | socket pointer to a vfer_sock | |
request | request packet corresponding to the new connection | |
response | packet corresponding to the new connection | |
ack | ack corresponding to the new connection | |
client | specifies whether this connection was initiated with a request (client == 1) OR replied to and accepted with a response (client != 1) |
Definition at line 2181 of file vfer_control.c.
int Control_Close | ( | vfer_sock * | sock | ) |
Sets the socket's state to DISCONNECTED and blocks (if blocking socket) until ControlT thread set socket's state to DISCONNECTED or returns if nonblocking socket Socket's mutex must be locked before calling this function Socket's state must be CONN_CONNECTED before calling this function, this function does not unlock the mutex of the socket
sock | is a socket pointer |
Definition at line 265 of file vfer_control.c.
int Control_Connect | ( | vfer_sock * | sock | ) |
This function changes the state of the socket to CONN_CONNECTING and either return immediately if the socket is non blocking or blocks waiting on a condition variable for the ControlT thread to signal on it indicating that the socket is connected and is in CONN_CONNECTED state. Follows CONNECT_TIMEOUT (defined in globals.h) for timing out.
sock | is a pointer to a socket structure on which to connect. The socket must have its addr field set to the address to connect to. |
Definition at line 184 of file vfer_control.c.
int Control_Recv | ( | vfer_sock * | sock, | |
void * | buffer, | |||
int | len | |||
) |
Receive data on a socket. This is a function that is called by the client via the api call vfer_recv. The socket's mutex should be locked before calling this function. This function unlocks the socket's mutex before returning. Socket's state must be conn_connected/conn_disconnected/conn_disconnecting on entry
sock | a socket pointer | |
buffer | a pointer to buffer to which to write received data | |
len | buffer size |
Definition at line 393 of file vfer_control.c.
void Control_Register_Socket | ( | vfer_sock * | sock | ) |
This is a helper function that makes the socket passed as argument 'active' so that the ConnectT thread will pay attention to it. It also maintains the sockets.max_fd and the sockets.fds vars which are used as args to the select() call in ControlT thread
sock | socket pointer to socket we would like listed as active |
Definition at line 463 of file vfer_control.c.
size_t Control_Send | ( | vfer_sock * | sock, | |
const void * | buffer, | |||
int | len | |||
) |
Sends data on a socket. This function is called by the client via the api vfer_send call. The socket should be locked before the call to this function. This function unlocks the socket before returning.
sock | a socket pointer | |
buffer | a pointer to data to send | |
len | the length of data in this buffer to send |
Definition at line 313 of file vfer_control.c.
void Control_Unregister_Socket | ( | vfer_sock * | sock | ) |
This function removes socket sock from the 'active' list of sockets that are observed by the ControlT thread. This thread takes care to maintain sockets.max_fd and sockets.fds vars
sock | is a socket pointer that will be removed from the 'active' list of sockets |
Definition at line 498 of file vfer_control.c.