net_helper.h File Reference
Communication facility interface for SOM.
More...
Go to the source code of this file.
Functions |
struct nodeID * | nodeid_dup (struct nodeID *s) |
| Duplicate a nodeID. This function provides a duplicate of the given nodeID.
|
int | nodeid_equal (const struct nodeID *s1, const struct nodeID *s2) |
| Test if two nodes are identical. Test if two nodeIDs can be considered identical (where the definition of identity is implementation dependent).
|
struct nodeID * | create_node (const char *IPaddr, int port) |
| Create a new nodeID. Create a new nodeID from a given IP address and port number.
|
void | nodeid_free (struct nodeID *s) |
| Delete a nodeID. Delete a nodeID and free the allocated resources.
|
struct nodeID * | net_helper_init (const char *IPaddr, int port) |
| Initialize all needed internal parameters. Initialize the parameters for the networking facilities and create a nodeID representing the caller.
|
void | bind_msg_type (uint8_t msgtype) |
| Map net_helper's ML callback to the given message type. To be used if ML support is needed. Register the common net_hepler callback for a msg_type.
|
int | send_to_peer (const struct nodeID *from, struct nodeID *to, const uint8_t *buffer_ptr, int buffer_size) |
| Send data to a remote peer. This function provides a transparently handles the sending routines.
|
int | recv_from_peer (const struct nodeID *local, struct nodeID **remote, uint8_t *buffer_ptr, int buffer_size) |
| Receive data from a remote peer. This function transparently handles the receiving routines.
|
int | wait4data (const struct nodeID *n, struct timeval *tout, fd_set *user_fds) |
| Check for newly arrived data. Check if some data arrived for a given nodeID. It sets a timeout to return at most after a given time.
|
const char * | node_addr (const struct nodeID *s) |
| Give a string representation of a nodeID. Give a string representation of a nodeID.
|
struct nodeID * | nodeid_undump (const uint8_t *b, int *len) |
| Create a nodeID structure from a serialized object. Read from a properly filled byte array (.
|
int | nodeid_dump (uint8_t *b, const struct nodeID *s) |
| Serialize a nodeID in a byte array. Serialize a nodeID in a byte array.
|
Detailed Description
Communication facility interface for SOM.
A clean interface is provided, through which all the communication procedures needed by SOM functions are handled. This way the different SOM functionalities are not dependent on any particular library with respect of the way they may call or be called by other applicative components.
Function Documentation
void bind_msg_type |
( |
uint8_t |
msgtype |
) |
|
Map net_helper's ML callback to the given message type. To be used if ML support is needed. Register the common net_hepler callback for a msg_type.
- Parameters:
-
[in] | mesType | The MSG_TYPE of the message the caller is interested in. |
struct nodeID* create_node |
( |
const char * |
IPaddr, |
|
|
int |
port | |
|
) |
| | [read] |
Create a new nodeID. Create a new nodeID from a given IP address and port number.
- Parameters:
-
[in] | IPaddr | The IP address in string form to be associated to the new nodeID. |
[in] | port | The port to be associated to the new nodeID. |
- Returns:
- A pointer to the new nodeID.
- Examples:
- topology_test.c.
struct nodeID* net_helper_init |
( |
const char * |
IPaddr, |
|
|
int |
port | |
|
) |
| | [read] |
Initialize all needed internal parameters. Initialize the parameters for the networking facilities and create a nodeID representing the caller.
- Parameters:
-
[in] | IPaddr | The IP in string form to be associated to the caller. |
[in] | port | The port to be associated to the caller. |
- Returns:
- A pointer to a nodeID representing the caller, initialized with all the necessary data.
- Examples:
- topology_test.c.
const char* node_addr |
( |
const struct nodeID * |
s |
) |
|
Give a string representation of a nodeID. Give a string representation of a nodeID.
- Parameters:
-
[in] | s | A pointer to the nodeID to be printed. |
- Returns:
- A string representing the nodeID.
- Examples:
- topology_test.c.
int nodeid_dump |
( |
uint8_t * |
b, |
|
|
const struct nodeID * |
s | |
|
) |
| | |
Serialize a nodeID in a byte array. Serialize a nodeID in a byte array.
- Parameters:
-
[in] | b | A pointer to the byte array that will contain the nodeID serialization. |
[in] | s | A pointer to the nodeID to be serialized. |
- Returns:
- The number of bytes written in the buffer.
struct nodeID* nodeid_dup |
( |
struct nodeID * |
s |
) |
[read] |
Duplicate a nodeID. This function provides a duplicate of the given nodeID.
- Parameters:
-
[in] | s | A pointer to the nodeID to be duplicated. |
- Returns:
- A pointer to the duplicate of the argument nodeID.
int nodeid_equal |
( |
const struct nodeID * |
s1, |
|
|
const struct nodeID * |
s2 | |
|
) |
| | |
Test if two nodes are identical. Test if two nodeIDs can be considered identical (where the definition of identity is implementation dependent).
- Parameters:
-
[in] | s1 | The first nodeID to be compared. |
[in] | s2 | The second nodeID to be compared. |
- Returns:
- 1 if the two nodeID are identical or 0 if they are not.
void nodeid_free |
( |
struct nodeID * |
s |
) |
|
Delete a nodeID. Delete a nodeID and free the allocated resources.
- Parameters:
-
[in] | s | A pointer to the nodeID to be deleted. |
- Examples:
- topology_test.c.
struct nodeID* nodeid_undump |
( |
const uint8_t * |
b, |
|
|
int * |
len | |
|
) |
| | [read] |
Create a nodeID structure from a serialized object. Read from a properly filled byte array (.
- See also:
- nodeid_dump) and build a new nodeID from its serialized representation in the buffer.
- Parameters:
-
[in] | b | A pointer to the byte array containing the data to be used. |
[in] | len | The number of bytes to be read from the buffer to build the new nodeID. |
- Returns:
- A pointer to the new nodeID.
int recv_from_peer |
( |
const struct nodeID * |
local, |
|
|
struct nodeID ** |
remote, |
|
|
uint8_t * |
buffer_ptr, |
|
|
int |
buffer_size | |
|
) |
| | |
Receive data from a remote peer. This function transparently handles the receiving routines.
- Parameters:
-
[in] | local | A pointer to the nodeID representing the caller. |
[out] | remote | The address to a pointer that has to be set to a new nodeID representing the sender peer. |
[out] | buffer_ptr | A pointer to the buffer containing the received data. |
[out] | buffer_size | The size of the data buffer. |
- Returns:
- The number of received bytes or -1 if some error occurred.
- Examples:
- topology_test.c.
int send_to_peer |
( |
const struct nodeID * |
from, |
|
|
struct nodeID * |
to, |
|
|
const uint8_t * |
buffer_ptr, |
|
|
int |
buffer_size | |
|
) |
| | |
Send data to a remote peer. This function provides a transparently handles the sending routines.
- Parameters:
-
[in] | from | A pointer to the nodeID representing the caller. |
[in] | to | A pointer to the nodeID representing the remote peer. |
[in] | buffer_ptr | A pointer to the buffer containing the data to be sent. |
[in] | buffer_size | The length of the data buffer. |
- Returns:
- The number of bytes sent or -1 if some error occurred.
int wait4data |
( |
const struct nodeID * |
n, |
|
|
struct timeval * |
tout, |
|
|
fd_set * |
user_fds | |
|
) |
| | |
Check for newly arrived data. Check if some data arrived for a given nodeID. It sets a timeout to return at most after a given time.
- Parameters:
-
[in] | n | A pointer to the nodeID representing the caller. |
[in] | tout | A pointer to a timer to be used to set the waiting timeout. |
[in] | user_fds | A pointer to a set of FDs to be monitored. |
- Returns:
- 1 if some data has arrived, 0 otherwise.
- Examples:
- topology_test.c.