Data Structures | |
struct | sock_addr_t |
Macros | |
#define | OP_PROC_FLAGS 1 |
#define | OP_LIFETIME 2 |
#define | OP_BLOCK_FLAGS 3 |
#define | OP_DEST 4 |
#define | OP_SOURCE 5 |
#define | OP_REPORT 6 |
#define | OP_CUSTOM 7 |
#define | OP_LAST_TIMESTAMP 8 |
Functions | |
int | adtn_socket () |
Creates a adtn sockets to send or recv information using the adtn platform with the default configuration. More... | |
int | adtn_socket (const char *config_file) |
Creates a adtn sockets to send or recv information using the adtn platform. More... | |
int | adtn_setcodopt (int fd, int option_name, const char *code) |
Associate codes to a socket. More... | |
int | adtn_setcodopt (int fd, int option_name, const char *code, int from_file) |
Associate codes to a socket. More... | |
int | adtn_setcodopt (int fd, int option_name, const char *code, int from_file, int replace) |
Associate codes to a socket. More... | |
int | adtn_bind (int fd, sock_addr_t *addr) |
Associates the information given to the socket. More... | |
int | adtn_close (int fd) |
Closes an adtn_socket and frees the memory associated to the socket. More... | |
int | adtn_shutdown (int fd) |
Same as adtn_close(1), deleting also waiting data. More... | |
int | adtn_rmcodopt (int fd, const int option) |
Removes an associated code from a socket. More... | |
int | adtn_setsockopt (int fd, const int optname, const void *optval) |
Set message options. More... | |
int | adtn_getsockopt (int fd, const int optname, void *optval, int *optlen) |
Get message options. More... | |
int | adtn_sendto (int fd, const void *buffer, size_t buffer_l, const sock_addr_t addr) |
Sends a message over ADTN platform. More... | |
int | adtn_recv (int fd, void *buffer, size_t len) |
Recive a message. More... | |
int | adtn_recvfrom (int fd, void *buffer, size_t len, sock_addr_t *addr) |
Recive a message, filling sender information. More... | |
int adtn_bind | ( | int | fd, |
sock_addr_t * | address | ||
) |
Associates the information given to the socket.
When adtn socket is created with adtn_socket(1) it exist in the space name but has no address associated. adtn_bind(2) associates the information specified in the structure sock_addr_t of the second argument to the socket represented by the file descriptor.
fd | The file descriptor that identifies the adtn_socket. This value can be obtained calling adtn_socket(1). |
address | A sock_addr_t structure containing information about the address that must be associated with the socket. |
errno can take the values below:
int adtn_close | ( | int | fd | ) |
Closes an adtn_socket and frees the memory associated to the socket.
Closes an adtn_socket and frees the memory associated to the socket. The structures associated to the socket in adtn_bind(2) call are freed too.
fd | A file descriptor identifying the socket. |
errno can take the values below:
int adtn_getsockopt | ( | int | fd, |
const int | optname, | ||
void * | optval, | ||
int * | optlen | ||
) |
Get message options.
fd | A file descriptor identifying the socket. |
optname | determines the option to set, the possible values are listed below. |
optval | where to save the value obtined. |
optlen | number of bytes to get, after calling is set to the number of bytes returned. |
Options available:
OP_PROC_FLAGS Get the flags for the primary block. OP_LIFETIME Get the lifetime of the messages. OP_BLOCK_FLAGS Get the flags for the rest of blocks. OP_DEST Get the destination of the messages. OP_SOURCE Get the source of the message. OP_REPORT Get the report of the message. OP_CUSTOM Get the custom value of the message. OP_LAST_TIMESTAMP Get the last message timestamp.
errno can take the values below:
int adtn_recv | ( | int | fd, |
void * | buffer, | ||
size_t | len | ||
) |
Recive a message.
Recive a message from adtn_socket. If at the moment of perform the call there are no messages adtn_recv(3) will block until can retrieve a message. After get a message it will be deleted from the socket queue.
fd | A file descriptor identifying the socket. |
buffer | array where the mssg value will be stored. |
len | The maximum number of bytes that will be written into buffer. |
errno can take the values below:
int adtn_recvfrom | ( | int | fd, |
void * | buffer, | ||
size_t | len, | ||
sock_addr_t * | addr | ||
) |
Recive a message, filling sender information.
Recive a message from adtn_socket. If at the moment of perform the call there are no messages adtn_recvfrom(4) will block until can retrieve a message. After get a message it will be deleted from the socket queue. A sock_addr_t struct will be fill with sender information like ip or port.
fd | A file descriptor identifying the socket. |
buffer | array where the mssg value will be stored. |
len | The maximum number of bytes that will be written into buffer. |
addr | An empty structure that will be filled with information about the sender. |
errno can take the values below:
int adtn_rmcodopt | ( | int | fd, |
const int | option | ||
) |
Removes an associated code from a socket.
Allows to remove an associated code from a socket. See documentation of adtn_setcodopt(1) for more information.
fd | A file descriptor identifying the socket. |
option_name | determines what kind of code will be removed. If the code doesn't exist nothing happens. |
errno can take the values below:
int adtn_sendto | ( | int | fd, |
const void * | buffer, | ||
size_t | buffer_l, | ||
const sock_addr_t | addr | ||
) |
Sends a message over ADTN platform.
Sends a message over ADTN platform. The fact that adtn_sendto call returns a success value doesn't mean that the message has been sent through the network. adtn_sendto(3) only puts the message in queue to be sent. The platform will manage the send through the network. In opportunistic networks the time until adtn_sendto(3) returns a succes value and the message is really send is impossible to determine.
fd | A file descriptor identifying the socket. |
buffer | A buffer with the message to send. |
buffer_l | the length to send of the buffer. |
addr | sock_addr_t structure containing the destination information. Must contain, the application port and ip of the destination. |
errno can take the values below:
int adtn_setcodopt | ( | int | fd, |
int | option_name, | ||
const char * | code | ||
) |
Associate codes to a socket.
Over ADTN platform the messages can carry codes with him to perform different tasks. This function allows to add code options to the socket. Each code linked with the socket will be added to outcoming messages sent through the socket. The kind of code associated to the socket is specified by the parameter option_name.
fd | A file descriptor identifying the socket. |
option_name | determines what kind of code will be associated to the socket. R_CODE will add a routing code. This code will be executed in each hop of the network to determine the next hop. L_CODE will add a life time code. This code will be executed in each node of the network to decide if the message is lapsed or not. P_CODE will add a prioritzation code. This code will affect only to the messages in other nodes that pertain to same application. Is not possible for a code to priorize messages from other applications. |
code | This parameter must contain the full code to associate to socket. |
errno can take the values below:
int adtn_setcodopt | ( | int | fd, |
int | option_name, | ||
const char * | code, | ||
int | from_file | ||
) |
Associate codes to a socket.
Over ADTN platform the messages can carry codes with him to perform different tasks. This function allows to add code options to the socket. Each code linked with the socket will be added to outcoming messages sent through the socket. The kind of code associated to the socket is specified by the parameter option_name.
fd | A file descriptor identifying the socket. |
option_name | determines what kind of code will be associated to the socket. R_CODE will add a routing code. This code will be executed in each hop of the network to determine the next hop. L_CODE will add a life time code. This code will be executed in each node of the network to decide if the message is lapsed or not. P_CODE will add a prioritzation code. This code will affect only to the messages in other nodes that pertain to same application. Is not possible for a code to priorize messages from other applications. |
code | This parameter must contain a filename where the code is stored or the full code to associate to socket. The content of this parameter is associated with parameter from_file. |
from_file | If is set to 1 the param code will contain a filename where the routing code is stored. If is set to 0 the param code must contain all code. Default value is 0. |
errno can take the values below:
int adtn_setcodopt | ( | int | fd, |
int | option_name, | ||
const char * | code, | ||
int | from_file, | ||
int | replace | ||
) |
Associate codes to a socket.
Over ADTN platform the messages can carry codes with him to perform different tasks. This function allows to add code options to the socket. Each code linked with the socket will be added to outcoming messages sent through the socket. The kind of code associated to the socket is specified by the parameter option_name.
fd | A file descriptor identifying the socket. |
option_name | determines what kind of code will be associated to the socket. R_CODE will add a routing code. This code will be executed in each hop of the network to determine the next hop. L_CODE will add a life time code. This code will be executed in each node of the network to decide if the message is lapsed or not. P_CODE will add a prioritzation code. This code will affect only to the messages in other nodes that pertain to same application. Is not possible for a code to priorize messages from other applications. |
code | This parameter must contain a filename where the code is stored or the full code to associate to socket. The content of this parameter is associated with parameter from_file. |
from_file | If is set to 1 the param code will contain a filename where the routing code is stored. If is set to 0 the param code must contain all code. Default value is 0. |
replace | If is set to 1 and exists an older code associated to the socket it will be replaced. If is set to 0 and a code is already binded with the socket this function will return an error. Replace is 0 by default. |
errno can take the values below:
int adtn_setsockopt | ( | int | fd, |
const int | optname, | ||
const void * | optval | ||
) |
Set message options.
In ADTN messages is posible specify the lifetime of the message and diferents options for headers. These options can be associated to a socket using this function. After calling it, all messages send through the socket will ahve the specified options.
fd | A file descriptor identifying the socket. |
optname | determines the option to set, the possible values are listed below. |
optval | the value to set. |
Options available:
OP_PROC_FLAGS Set the flags for the primary block. OP_LIFETIME Set the lifetime of the messages. OP_BLOCK_FLAGS Set the flags for the rest of blocks. OP_DEST Set the destination of the messages. OP_SOURCE Set the source of the message. OP_REPORT Set the report of the message. OP_CUSTOM Set the custom value of the message.
errno can take the values below:
int adtn_shutdown | ( | int | fd | ) |
Same as adtn_close(1), deleting also waiting data.
Closes an adtn_socket and frees the memory associated to the socket. The structures associated to the socket in adtn_bind(2) call are freed too. If some data are waiting to be readed it will be deleted.
fd | A file descriptor identifying the socket. |
errno can take the values below:
int adtn_socket | ( | ) |
Creates a adtn sockets to send or recv information using the adtn platform with the default configuration.
aDTN is divided in two parts, one is the API for developers that allow to use functions to send and receive messages. The other one is the core that manages and sends the messages.
The Core makes posible resilience to delay, disruptions and big taxes of errors. The implementation of the platform allow more than one core to cohexist in the same node(device).
errno can take the values below:
int adtn_socket | ( | const char * | config_file | ) |
Creates a adtn sockets to send or recv information using the adtn platform.
aDTN is divided in two parts, one is the API for developers that allow to use functions to send and receive messages. The other one is the core that manages and sends the messages.
The Core makes posible resilience to delay, disruptions and big taxes of errors. The implementation of the platform allow more than one core to cohexist in the same node(device).
config_file | The configuration file path. |
errno can take the values below: