Basic low-level networking interface. More...
Data Structures | |
struct | GNUNET_NETWORK_FDSet |
collection of IO descriptors More... | |
Functions | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_test_pf (int pf) |
Test if the given protocol family is supported by this system. More... | |
char * | GNUNET_NETWORK_shorten_unixpath (char *unixpath) |
Given a unixpath that is too long (larger than UNIX_PATH_MAX), shorten it to an acceptable length while keeping it unique and making sure it remains a valid filename (if possible). More... | |
void | GNUNET_NETWORK_unix_precheck (const struct sockaddr_un *un) |
If services crash, they can leave a unix domain socket file on the disk. More... | |
struct GNUNET_NETWORK_Handle * | GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, struct sockaddr *address, socklen_t *address_len) |
Accept a new connection on a socket. More... | |
struct GNUNET_NETWORK_Handle * | GNUNET_NETWORK_socket_box_native (int fd) |
Box a native socket (and check that it is a socket). More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock) |
Set if a socket should use blocking or non-blocking IO. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len) |
Bind a socket to a particular address. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) |
Close a socket. More... | |
void | GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc) |
Only free memory of a socket, keep the file descriptor untouched. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len) |
Connect a socket to some remote address. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, int level, int optname, void *optval, socklen_t *optlen) |
Get socket options. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, int backlog) |
Listen on a socket. More... | |
ssize_t | GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle *desc) |
How much data is available to be read on this descriptor? More... | |
ssize_t | GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length, struct sockaddr *src_addr, socklen_t *addrlen) |
Read data from a socket (always non-blocking). More... | |
ssize_t | GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length) |
Read data from a connected socket (always non-blocking). More... | |
int | GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *efds, struct GNUNET_TIME_Relative timeout) |
Check if sockets meet certain conditions. More... | |
ssize_t | GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc, const void *buffer, size_t length) |
Send data (always non-blocking). More... | |
ssize_t | GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, const void *message, size_t length, const struct sockaddr *dest_addr, socklen_t dest_len) |
Send data to a particular destination (always non-blocking). More... | |
int | GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int level, int option_name, const void *option_value, socklen_t option_len) |
Set socket option. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how) |
Shut down socket operations. More... | |
enum GNUNET_GenericReturnValue | GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc) |
Disable the "CORK" feature for communication with the given socket, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages. More... | |
struct GNUNET_NETWORK_Handle * | GNUNET_NETWORK_socket_create (int domain, int type, int protocol) |
Create a new socket. More... | |
void | GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds) |
Reset FD set (clears all file descriptors). More... | |
void | GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_NETWORK_Handle *desc) |
Add a socket to the FD set. More... | |
int | GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_NETWORK_Handle *desc) |
Check whether a socket is part of the fd set. More... | |
void | GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, const struct GNUNET_NETWORK_FDSet *src) |
Add one fd set to another (computes the union). More... | |
void | GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, const struct GNUNET_NETWORK_FDSet *from) |
Copy one fd set to another. More... | |
int | GNUNET_NETWORK_get_fd (const struct GNUNET_NETWORK_Handle *desc) |
Return file descriptor for this network handle. More... | |
struct sockaddr * | GNUNET_NETWORK_get_addr (const struct GNUNET_NETWORK_Handle *desc) |
Return the sockaddr for this network handle. More... | |
socklen_t | GNUNET_NETWORK_get_addrlen (const struct GNUNET_NETWORK_Handle *desc) |
Return sockaddr length for this network handle. More... | |
void | GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds) |
Copy a native fd set into the GNUnet representation. More... | |
void | GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd) |
Set a native fd in a set. More... | |
int | GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to, int nfd) |
Test native fd in a set. More... | |
void | GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_DISK_FileHandle *h) |
Add a file handle to the fd set. More... | |
void | GNUNET_NETWORK_fdset_handle_set_first (struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_DISK_FileHandle *h) |
Add a file handle to the fd set On W32: ensure that the handle is first in the array. More... | |
int | GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, const struct GNUNET_DISK_FileHandle *h) |
Check if a file handle is part of an fd set. More... | |
int | GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, const struct GNUNET_NETWORK_FDSet *fds2) |
Checks if two fd sets overlap. More... | |
struct GNUNET_NETWORK_FDSet * | GNUNET_NETWORK_fdset_create (void) |
Creates an fd set. More... | |
void | GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds) |
Releases the associated memory of an fd set. More... | |
int | GNUNET_NETWORK_test_port_free (int ipproto, uint16_t port) |
Test if the given port is available. More... | |
Basic low-level networking interface.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_test_pf | ( | int | pf | ) |
Test if the given protocol family is supported by this system.
pf | protocol family to test (PF_INET, PF_INET6, PF_UNIX) |
Definition at line 79 of file network.c.
References GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and ret.
Referenced by DHTU_ip_init(), get_server_addresses(), handle_gns_result(), parse_ip_options(), run(), and udp_address_to_sockaddr().
char * GNUNET_NETWORK_shorten_unixpath | ( | char * | unixpath | ) |
Given a unixpath that is too long (larger than UNIX_PATH_MAX), shorten it to an acceptable length while keeping it unique and making sure it remains a valid filename (if possible).
unixpath | long path, will be freed (or same pointer returned with moved 0-termination). |
Definition at line 143 of file network.c.
References _, dummy, GNUNET_CRYPTO_HashAsciiEncoded::encoding, end, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_to_enc(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, and sh.
Referenced by get_server_addresses(), and try_unixpath().
void GNUNET_NETWORK_unix_precheck | ( | const struct sockaddr_un * | un | ) |
If services crash, they can leave a unix domain socket file on the disk.
This needs to be manually removed, because otherwise both bind() and connect() for the respective address will fail. In this function, we test if such a left-over file exists, and if so, remove it (unless there is a listening service at the address).
un | unix domain socket address to check |
Definition at line 178 of file network.c.
References GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, and ret.
Referenced by create_listen_socket(), and GNUNET_NETWORK_socket_bind().
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_accept | ( | const struct GNUNET_NETWORK_Handle * | desc, |
struct sockaddr * | address, | ||
socklen_t * | address_len | ||
) |
Accept a new connection on a socket.
Configure it for non-blocking IO and mark it as non-inheritable to child processes (set the close-on-exec flag).
desc | bound socket |
address | address of the connecting peer, may be NULL |
address_len | length of address |
Definition at line 392 of file network.c.
References address, GNUNET_NETWORK_Handle::af, GNUNET_NETWORK_Handle::fd, GNUNET_a2s(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_OK, initialize_network_handle(), LOG, name, and ret.
Referenced by accept_client(), do_accept(), and listen_cb().
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_box_native | ( | int | fd | ) |
Box a native socket (and check that it is a socket).
fd | socket to box |
Definition at line 580 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_new, and ret.
Referenced by DHTU_ip_init(), extract_handles(), scheduler_fd_cb(), and setup_service().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_set_blocking | ( | struct GNUNET_NETWORK_Handle * | fd, |
int | doBlock | ||
) |
Set if a socket should use blocking or non-blocking IO.
fd | socket |
doBlock | blocking mode |
Definition at line 224 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, and LOG_STRERROR.
Referenced by initialize_network_handle().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_bind | ( | struct GNUNET_NETWORK_Handle * | desc, |
const struct sockaddr * | address, | ||
socklen_t | address_len | ||
) |
Bind a socket to a particular address.
desc | socket to bind |
address | address to be bound |
address_len | length of address |
Definition at line 439 of file network.c.
References GNUNET_NETWORK_Handle::addr, address, GNUNET_NETWORK_Handle::addrlen, GNUNET_NETWORK_Handle::af, GNUNET_NETWORK_Handle::fd, GNUNET_ERROR_TYPE_DEBUG, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_unix_precheck(), GNUNET_OK, GNUNET_SYSERR, LOG_STRERROR, ret, and GNUNET_NETWORK_Handle::type.
Referenced by bind_v4(), bind_v6(), create_listen_socket(), create_udp_socket(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_test_start(), GNUNET_NETWORK_test_port_free(), GNUNET_TESTBED_reserve_port(), init_socket(), open_listen_socket(), open_socket(), read_send(), and run().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close | ( | struct GNUNET_NETWORK_Handle * | desc | ) |
Close a socket.
desc | socket to close |
Definition at line 508 of file network.c.
References GNUNET_NETWORK_Handle::addr, GNUNET_NETWORK_Handle::af, DIR_SEPARATOR, GNUNET_NETWORK_Handle::fd, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_NETWORK_socket_free_memory_only_(), GNUNET_OK, GNUNET_strndup, GNUNET_SYSERR, LOG_STRERROR_FILE, and ret.
Referenced by accept_client(), bind_v4(), bind_v6(), cancel_aps(), cleanup_ar(), cleanup_rs(), cleanup_s5r(), connect_probe_continuation(), connection_client_destroy_impl(), create_listen_socket(), create_proto_queue(), create_udp_socket(), DHTU_ip_done(), do_accept(), do_dns_read(), do_read(), do_shutdown(), do_udp_read(), finish_client_drop(), free_proto_queue(), get_lt_delete_it(), get_server_addresses(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_AUTO_test_stop(), GNUNET_NAT_test_start(), GNUNET_NAT_test_stop(), GNUNET_NETWORK_test_port_free(), GNUNET_stop_burst(), GNUNET_TESTBED_reserve_port(), init_socket(), initialize_network_handle(), kill_httpd(), mq_init(), open_listen_socket(), open_socket(), queue_destroy(), read_send(), receiver_destroy(), run(), setup_service(), shutdown_task(), stop_stun(), tcp_send(), teardown_service(), timeout_task_cb(), try_connect_using_address(), try_send_tcp(), try_send_udp(), and try_unixpath().
void GNUNET_NETWORK_socket_free_memory_only_ | ( | struct GNUNET_NETWORK_Handle * | desc | ) |
Only free memory of a socket, keep the file descriptor untouched.
desc | socket |
Definition at line 566 of file network.c.
References GNUNET_NETWORK_Handle::addr, and GNUNET_free.
Referenced by cleanup_ar(), cleanup_s5r(), destroy_task(), finish_client_drop(), and GNUNET_NETWORK_socket_close().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_connect | ( | const struct GNUNET_NETWORK_Handle * | desc, |
const struct sockaddr * | address, | ||
socklen_t | address_len | ||
) |
Connect a socket to some remote address.
desc | socket to connect |
address | peer address |
address_len | of address |
desc | socket |
address | peer address |
address_len | length of address |
Definition at line 602 of file network.c.
References address, GNUNET_NETWORK_Handle::fd, GNUNET_OK, GNUNET_SYSERR, and ret.
Referenced by create_proto_queue(), mq_init(), try_connect_using_address(), try_send_tcp(), and try_unixpath().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_getsockopt | ( | const struct GNUNET_NETWORK_Handle * | desc, |
int | level, | ||
int | optname, | ||
void * | optval, | ||
socklen_t * | optlen | ||
) |
Get socket options.
desc | socket to inspect |
level | protocol level of the option |
optname | identifier of the option |
optval | options |
optlen | length of optval |
desc | socket |
level | protocol level of the option |
optname | identifier of the option |
optval | options |
optlen | length of optval |
Definition at line 627 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_OK, GNUNET_SYSERR, and ret.
Referenced by connect_probe_continuation(), and select_write_cb().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_listen | ( | const struct GNUNET_NETWORK_Handle * | desc, |
int | backlog | ||
) |
Listen on a socket.
desc | socket to start listening on |
backlog | length of the listen queue |
desc | socket |
backlog | length of the listen queue |
Definition at line 652 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_OK, GNUNET_SYSERR, and ret.
Referenced by create_listen_socket(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_test_start(), init_socket(), open_listen_socket(), and run().
ssize_t GNUNET_NETWORK_socket_recvfrom_amount | ( | const struct GNUNET_NETWORK_Handle * | desc | ) |
How much data is available to be read on this descriptor?
desc | socket |
Definition at line 671 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_SYSERR, and pending.
Referenced by read_dns4(), read_dns6(), and stun_read_task().
ssize_t GNUNET_NETWORK_socket_recvfrom | ( | const struct GNUNET_NETWORK_Handle * | desc, |
void * | buffer, | ||
size_t | length, | ||
struct sockaddr * | src_addr, | ||
socklen_t * | addrlen | ||
) |
Read data from a socket (always non-blocking).
desc | socket |
buffer | buffer |
length | length of buffer |
src_addr | either the source to recv from, or all zeroes to be filled in by recvfrom |
addrlen | length of the addr |
Definition at line 688 of file network.c.
References GNUNET_NETWORK_Handle::addrlen, and GNUNET_NETWORK_Handle::fd.
Referenced by do_dns_read(), read_dns4(), read_dns6(), select_read_cb(), sock_read(), and stun_read_task().
ssize_t GNUNET_NETWORK_socket_recv | ( | const struct GNUNET_NETWORK_Handle * | desc, |
void * | buffer, | ||
size_t | length | ||
) |
Read data from a connected socket (always non-blocking).
desc | socket |
buffer | buffer |
length | length of buffer |
desc | socket |
buffer | buffer |
length | length of buffer |
Definition at line 717 of file network.c.
References GNUNET_NETWORK_Handle::fd, and ret.
Referenced by do_read(), do_s5r_read(), do_udp_read(), GNUNET_MST_read(), proto_read_kx(), queue_read(), and queue_read_kx().
int GNUNET_NETWORK_socket_select | ( | struct GNUNET_NETWORK_FDSet * | rfds, |
struct GNUNET_NETWORK_FDSet * | wfds, | ||
struct GNUNET_NETWORK_FDSet * | efds, | ||
const struct GNUNET_TIME_Relative | timeout | ||
) |
Check if sockets meet certain conditions.
rfds | set of sockets to be checked for readability |
wfds | set of sockets to be checked for writability |
efds | set of sockets to be checked for exceptions |
timeout | relative value when to return |
Check if sockets meet certain conditions.
rfds | set of sockets or pipes to be checked for readability |
wfds | set of sockets or pipes to be checked for writability |
efds | set of sockets or pipes to be checked for exceptions |
timeout | relative value when to return |
Definition at line 1259 of file network.c.
References _, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_MAX, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_SECONDS, LOG, GNUNET_NETWORK_FDSet::nsds, GNUNET_TIME_Relative::rel_value_us, GNUNET_NETWORK_FDSet::sds, and timeout.
Referenced by select_loop().
ssize_t GNUNET_NETWORK_socket_send | ( | const struct GNUNET_NETWORK_Handle * | desc, |
const void * | buffer, | ||
size_t | length | ||
) |
Send data (always non-blocking).
desc | socket |
buffer | data to send |
length | size of the buffer |
Definition at line 738 of file network.c.
References GNUNET_NETWORK_Handle::fd, and ret.
Referenced by do_send(), do_write(), proto_queue_write(), queue_write(), tcp_send(), and transmit_ready().
ssize_t GNUNET_NETWORK_socket_sendto | ( | const struct GNUNET_NETWORK_Handle * | desc, |
const void * | message, | ||
size_t | length, | ||
const struct sockaddr * | dest_addr, | ||
socklen_t | dest_len | ||
) |
Send data to a particular destination (always non-blocking).
This function only works for UDP sockets.
desc | socket |
message | data to send |
length | size of the data in message |
dest_addr | destination address |
dest_len | length of dest_addr |
This function only works for UDP sockets.
desc | socket |
message | data to send |
length | size of the message |
dest_addr | destination address |
dest_len | length of address |
Definition at line 772 of file network.c.
References GNUNET_NETWORK_Handle::fd.
Referenced by flush_egress(), GNUNET_get_udp_socket(), ifc_broadcast(), ip_send(), mq_send_d(), read_send(), select_write_cb(), send_msg_with_kx(), send_packet(), send_response(), sock_read(), stun_dns_callback(), transmit_query(), and try_send_udp().
int GNUNET_NETWORK_socket_setsockopt | ( | struct GNUNET_NETWORK_Handle * | fd, |
int | level, | ||
int | option_name, | ||
const void * | option_value, | ||
socklen_t | option_len | ||
) |
Set socket option.
fd | socket |
level | protocol level of the option |
option_name | option identifier |
option_value | value to set |
option_len | size of option_value |
Definition at line 806 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_OK, and GNUNET_SYSERR.
Referenced by bi_destroy(), create_listen_socket(), iface_proc(), ifc_broadcast(), and select_write_cb().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_shutdown | ( | struct GNUNET_NETWORK_Handle * | desc, |
int | how | ||
) |
Shut down socket operations.
desc | socket |
how | type of shutdown |
Definition at line 861 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_OK, GNUNET_SYSERR, and ret.
Referenced by tcp_send().
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_disable_corking | ( | struct GNUNET_NETWORK_Handle * | desc | ) |
Disable the "CORK" feature for communication with the given socket, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages.
Essentially reduces the OS send buffers to zero.
desc | socket |
Definition at line 882 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, LOG_STRERROR, ret, and value.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create | ( | int | domain, |
int | type, | ||
int | protocol | ||
) |
Create a new socket.
Configure it for non-blocking IO and mark it as non-inheritable to child processes (set the close-on-exec flag).
domain | domain of the socket |
type | socket type |
protocol | network protocol |
Definition at line 833 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_new, GNUNET_OK, initialize_network_handle(), ret, and type.
Referenced by bind_v4(), bind_v6(), create_listen_socket(), create_proto_queue(), create_udp_socket(), get_server_addresses(), GNUNET_NAT_AUTO_test_start(), GNUNET_NAT_test_start(), GNUNET_NETWORK_test_port_free(), GNUNET_TESTBED_reserve_port(), init_socket(), mq_init(), open_listen_socket(), open_socket(), read_send(), run(), try_connect_using_address(), try_send_tcp(), try_send_udp(), and try_unixpath().
void GNUNET_NETWORK_fdset_zero | ( | struct GNUNET_NETWORK_FDSet * | fds | ) |
Reset FD set (clears all file descriptors).
fds | fd set to clear |
Reset FD set (clears all file descriptors).
fds | fd set |
Definition at line 918 of file network.c.
References GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
Referenced by GNUNET_NETWORK_fdset_create(), GNUNET_SCHEDULER_do_work(), and select_loop().
void GNUNET_NETWORK_fdset_set | ( | struct GNUNET_NETWORK_FDSet * | fds, |
const struct GNUNET_NETWORK_Handle * | desc | ||
) |
Add a socket to the FD set.
fds | fd set |
desc | socket to add |
Definition at line 932 of file network.c.
References GNUNET_NETWORK_Handle::fd, GNUNET_MAX, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
Referenced by schedule_read().
int GNUNET_NETWORK_fdset_isset | ( | const struct GNUNET_NETWORK_FDSet * | fds, |
const struct GNUNET_NETWORK_Handle * | desc | ||
) |
Check whether a socket is part of the fd set.
fds | fd set |
desc | socket |
fds | fd set |
desc | socket |
Definition at line 950 of file network.c.
References GNUNET_NETWORK_Handle::fd, and GNUNET_NETWORK_FDSet::sds.
Referenced by do_read(), do_s5r_read(), do_udp_read(), read_response(), and tcp_send().
void GNUNET_NETWORK_fdset_add | ( | struct GNUNET_NETWORK_FDSet * | dst, |
const struct GNUNET_NETWORK_FDSet * | src | ||
) |
Add one fd set to another (computes the union).
dst | the fd set to add to |
src | the fd set to add from |
Add one fd set to another (computes the union).
dst | the fd set to add to |
src | the fd set to add from |
Definition at line 965 of file network.c.
References GNUNET_MAX, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
void GNUNET_NETWORK_fdset_copy | ( | struct GNUNET_NETWORK_FDSet * | to, |
const struct GNUNET_NETWORK_FDSet * | from | ||
) |
Copy one fd set to another.
to | destination |
from | source |
Definition at line 985 of file network.c.
References FD_COPY, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
int GNUNET_NETWORK_get_fd | ( | const struct GNUNET_NETWORK_Handle * | desc | ) |
Return file descriptor for this network handle.
desc | wrapper to process |
Definition at line 1001 of file network.c.
References GNUNET_NETWORK_Handle::fd.
Referenced by add_without_sets(), create_udp_socket(), do_accept(), do_dns_read(), GNUNET_SCHEDULER_add_net_with_priority(), init_fd_info(), init_socket(), mhd_connection_cb(), queue_destroy(), read_cb(), run(), setup_data_transfer(), and start_process().
struct sockaddr * GNUNET_NETWORK_get_addr | ( | const struct GNUNET_NETWORK_Handle * | desc | ) |
Return the sockaddr for this network handle.
desc | wrapper to process |
Return the sockaddr for this network handle.
desc | wrapper to process |
Definition at line 1014 of file network.c.
References GNUNET_NETWORK_Handle::addr.
Referenced by do_accept(), and setup_data_transfer().
socklen_t GNUNET_NETWORK_get_addrlen | ( | const struct GNUNET_NETWORK_Handle * | desc | ) |
Return sockaddr length for this network handle.
desc | wrapper to process |
Definition at line 1027 of file network.c.
References GNUNET_NETWORK_Handle::addrlen.
Referenced by do_accept(), and setup_data_transfer().
void GNUNET_NETWORK_fdset_copy_native | ( | struct GNUNET_NETWORK_FDSet * | to, |
const fd_set * | from, | ||
int | nfds | ||
) |
Copy a native fd set into the GNUnet representation.
to | destination |
from | native source set |
nfds | the biggest socket number in from + 1 |
Copy a native fd set into the GNUnet representation.
to | destination |
from | native source set |
nfds | the biggest socket number in from + 1 |
Definition at line 1041 of file network.c.
References FD_COPY, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
Referenced by context_task(), curl_download_prepare(), download_prepare(), prepare_daemon(), run_httpd(), and schedule_httpd().
void GNUNET_NETWORK_fdset_set_native | ( | struct GNUNET_NETWORK_FDSet * | to, |
int | nfd | ||
) |
Set a native fd in a set.
to | destination |
nfd | native FD to set |
Definition at line 1058 of file network.c.
References GNUNET_assert, GNUNET_MAX, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
Referenced by GNUNET_SCHEDULER_do_work(), listen_stdio(), and select_loop().
int GNUNET_NETWORK_fdset_test_native | ( | const struct GNUNET_NETWORK_FDSet * | to, |
int | nfd | ||
) |
Test native fd in a set.
to | set to test, NULL for empty set |
nfd | native FD to test, -1 for none |
to | set to test, NULL for empty set |
nfd | native FD to test, or -1 for none |
Definition at line 1076 of file network.c.
References GNUNET_NO, GNUNET_YES, and GNUNET_NETWORK_FDSet::sds.
Referenced by extract_handles(), and select_loop().
void GNUNET_NETWORK_fdset_handle_set | ( | struct GNUNET_NETWORK_FDSet * | fds, |
const struct GNUNET_DISK_FileHandle * | h | ||
) |
Add a file handle to the fd set.
fds | fd set |
h | the file handle to add |
Definition at line 1092 of file network.c.
References GNUNET_assert, GNUNET_DISK_internal_file_handle_(), GNUNET_MAX, GNUNET_OK, h, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
Referenced by GNUNET_NETWORK_fdset_handle_set_first(), and GNUNET_SCHEDULER_driver_init().
void GNUNET_NETWORK_fdset_handle_set_first | ( | struct GNUNET_NETWORK_FDSet * | fds, |
const struct GNUNET_DISK_FileHandle * | h | ||
) |
Add a file handle to the fd set On W32: ensure that the handle is first in the array.
fds | fd set |
h | the file handle to add |
Add a file handle to the fd set On W32: ensure that the handle is first in the array.
fds | fd set |
h | the file handle to add |
Definition at line 1112 of file network.c.
References GNUNET_NETWORK_fdset_handle_set(), and h.
int GNUNET_NETWORK_fdset_handle_isset | ( | const struct GNUNET_NETWORK_FDSet * | fds, |
const struct GNUNET_DISK_FileHandle * | h | ||
) |
Check if a file handle is part of an fd set.
fds | fd set |
h | file handle |
Definition at line 1127 of file network.c.
References h, and GNUNET_NETWORK_FDSet::sds.
Referenced by cmd_read().
int GNUNET_NETWORK_fdset_overlap | ( | const struct GNUNET_NETWORK_FDSet * | fds1, |
const struct GNUNET_NETWORK_FDSet * | fds2 | ||
) |
Checks if two fd sets overlap.
fds1 | first fd set |
fds2 | second fd set |
Definition at line 1143 of file network.c.
References GNUNET_MIN, GNUNET_NO, GNUNET_YES, GNUNET_NETWORK_FDSet::nsds, and GNUNET_NETWORK_FDSet::sds.
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create | ( | void | ) |
Creates an fd set.
Definition at line 1169 of file network.c.
References GNUNET_NETWORK_fdset_zero(), and GNUNET_new.
Referenced by context_task(), curl_download_prepare(), download_prepare(), GNUNET_SCHEDULER_driver_init(), listen_stdio(), prepare_daemon(), run_httpd(), schedule_httpd(), schedule_read(), and select_loop().
void GNUNET_NETWORK_fdset_destroy | ( | struct GNUNET_NETWORK_FDSet * | fds | ) |
Releases the associated memory of an fd set.
fds | fd set |
Definition at line 1185 of file network.c.
References GNUNET_free.
Referenced by context_task(), curl_download_prepare(), download_prepare(), GNUNET_SCHEDULER_driver_done(), listen_stdio(), prepare_daemon(), run_httpd(), schedule_httpd(), schedule_read(), and select_loop().
int GNUNET_NETWORK_test_port_free | ( | int | ipproto, |
uint16_t | port | ||
) |
Test if the given port is available.
ipproto | transport protocol to test (e.g. IPPROTO_TCP) |
port | port number to test |
Definition at line 1199 of file network.c.
References ai, AI_NUMERICSERV, GNUNET_assert, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NO, GNUNET_OK, GNUNET_snprintf(), port, and ret.