#include "nmxp_data.h"
#include "nmxp_chan.h"
#include "nmxp_log.h"


Go to the source code of this file.
Defines | |
| #define | NMXP_BASE_H 1 |
| #define | NMXP_SLEEPMAX 60 |
| #define | NMXP_SOCKET_OK 0 |
| #define | NMXP_SOCKET_ERROR -1 |
Functions | |
| int | nmxp_openSocket (char *hostname, int portNum, int(*func_cond)(void)) |
| Looks up target host, opens a socket and connects. | |
| int | nmxp_closeSocket (int isock) |
| Close a socket. | |
| int | nmxp_send_ctrl (int isock, void *buffer, int length) |
| Sends a buffer on a socket. | |
| int | nmxp_setsockopt_RCVTIMEO (int isock, int timeoutsec) |
| Receives length bytes in a buffer from a socket. | |
| char * | nmxp_strerror (int errno_value) |
| Wrapper to strerror, strerror_r or WSAGetLastErrorMessage. | |
| int | nmxp_recv_ctrl (int isock, void *buffer, int length, int timeoutsec, int *recv_errno) |
| Receives length bytes in a buffer from a socket. | |
| int | nmxp_sendHeader (int isock, NMXP_MSG_CLIENT type, int32_t length) |
| Sends header of a message. | |
| int | nmxp_receiveHeader (int isock, NMXP_MSG_SERVER *type, int32_t *length, int timeoutsec, int *recv_errno) |
| Receives header of a message. | |
| int | nmxp_sendMessage (int isock, NMXP_MSG_CLIENT type, void *buffer, int32_t length) |
| Sends header and body of a message. | |
| int | nmxp_receiveMessage (int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t *length, int timeoutsec, int *recv_errno) |
| Receives header and body of a message. | |
| NMXP_DATA_PROCESS * | nmxp_processCompressedData (char *buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default) |
| Process Compressed Data message by function func_processData(). | |
| NMXP_DATA_PROCESS * | nmxp_processDecompressedData (char *buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default) |
| Process decompressed Data message by function func_processData(). | |
| unsigned int | nmxp_sleep (unsigned int sleep_time) |
| Wrapper for functions sleep on different platforms. | |
| unsigned int | nmxp_usleep (unsigned int sleep_time) |
| Wrapper for functions usleep on different platforms. | |
Author: Matteo Quintiliani Istituto Nazionale di Geofisica e Vulcanologia - Italy quintiliani@ingv.it
| #define NMXP_BASE_H 1 |
| #define NMXP_SLEEPMAX 60 |
Maximum time between connection attempts (seconds).
| #define NMXP_SOCKET_OK 0 |
Return message for succes on socket.
| #define NMXP_SOCKET_ERROR -1 |
Return message for error on socket.
| int nmxp_openSocket | ( | char * | hostname, | |
| int | portNum, | |||
| int(*)(void) | func_cond | |||
| ) |
Looks up target host, opens a socket and connects.
| hostname | hostname | |
| portNum | port number |
| sd | A descriptor referencing the socket. | |
| -1 | "Empty host name", "Cannot lookup host", ... |
| int nmxp_closeSocket | ( | int | isock | ) |
Close a socket.
| isock | A descriptor referencing the socket. |
| 0 | Success | |
| -1 | Error |
| int nmxp_send_ctrl | ( | int | isock, | |
| void * | buffer, | |||
| int | length | |||
| ) |
Sends a buffer on a socket.
| isock | A descriptor referencing the socket. | |
| buffer | Data buffer. | |
| length | Length in bytes. |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| int nmxp_setsockopt_RCVTIMEO | ( | int | isock, | |
| int | timeoutsec | |||
| ) |
Receives length bytes in a buffer from a socket.
| isock | A descriptor referencing the socket. | |
| timeoutsec | Time-out in seconds |
| char* nmxp_strerror | ( | int | errno_value | ) |
Wrapper to strerror, strerror_r or WSAGetLastErrorMessage.
| int nmxp_recv_ctrl | ( | int | isock, | |
| void * | buffer, | |||
| int | length, | |||
| int | timeoutsec, | |||
| int * | recv_errno | |||
| ) |
Receives length bytes in a buffer from a socket.
| isock | A descriptor referencing the socket. | |
| [out] | buffer | Data buffer. |
| length | Length in bytes. | |
| timeoutsec | Time-out in seconds | |
| [out] | recv_errno | errno value after recv() |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| int nmxp_sendHeader | ( | int | isock, | |
| NMXP_MSG_CLIENT | type, | |||
| int32_t | length | |||
| ) |
Sends header of a message.
| isock | A descriptor referencing the socket. | |
| type | Type of message within NMXP_MSG_CLIENT. | |
| length | Length in bytes. |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| int nmxp_receiveHeader | ( | int | isock, | |
| NMXP_MSG_SERVER * | type, | |||
| int32_t * | length, | |||
| int | timeoutsec, | |||
| int * | recv_errno | |||
| ) |
Receives header of a message.
| isock | A descriptor referencing the socket. | |
| [out] | type | Type of message within NMXP_MSG_CLIENT. |
| [out] | length | Length in bytes. |
| timeoutsec | Time-out in seconds | |
| [out] | recv_errno | errno value after recv() |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| int nmxp_sendMessage | ( | int | isock, | |
| NMXP_MSG_CLIENT | type, | |||
| void * | buffer, | |||
| int32_t | length | |||
| ) |
Sends header and body of a message.
| isock | A descriptor referencing the socket. | |
| type | Type of message within NMXP_MSG_CLIENT. | |
| buffer | Data buffer. It could be NULL. | |
| length | Length in bytes. It must be greater or equal to zero. |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| int nmxp_receiveMessage | ( | int | isock, | |
| NMXP_MSG_SERVER * | type, | |||
| void ** | buffer, | |||
| int32_t * | length, | |||
| int | timeoutsec, | |||
| int * | recv_errno | |||
| ) |
Receives header and body of a message.
| isock | A descriptor referencing the socket. | |
| [out] | type | Type of message within NMXP_MSG_SERVER. |
| [out] | buffer | Data buffer. It will need to be freed! |
| [out] | length | Length in bytes. |
| timeoutsec | Time-out in seconds | |
| [out] | recv_errno | errno value after recv() |
| NMXP_SOCKET_OK | on success | |
| NMXP_SOCKET_ERROR | on error |
| NMXP_DATA_PROCESS* nmxp_processCompressedData | ( | char * | buffer_data, | |
| int | length_data, | |||
| NMXP_CHAN_LIST_NET * | channelList, | |||
| const char * | network_code_default | |||
| ) |
Process Compressed Data message by function func_processData().
| buffer_data | Pointer to the data buffer containing Compressed Nanometrics packets. | |
| length_data | Buffer length in bytes. | |
| channelList | Pointer to the Channel List. | |
| network_code_default | Value of network code to assign returned structure. It should not be NULL. |
| NMXP_DATA_PROCESS* nmxp_processDecompressedData | ( | char * | buffer_data, | |
| int | length_data, | |||
| NMXP_CHAN_LIST_NET * | channelList, | |||
| const char * | network_code_default | |||
| ) |
Process decompressed Data message by function func_processData().
| buffer_data | Pointer to the data buffer containing Decompressed Nanometrics packets. | |
| length_data | Buffer length in bytes. | |
| channelList | Pointer to the Channel List. | |
| network_code_default | Value of network code to assign returned structure. It should not be NULL. |
| unsigned int nmxp_sleep | ( | unsigned int | sleep_time | ) |
Wrapper for functions sleep on different platforms.
| sleep_time | time in seconds |
| .... |
| unsigned int nmxp_usleep | ( | unsigned int | sleep_time | ) |
Wrapper for functions usleep on different platforms.
| usleep_time | time in microseconds |
| .... |
1.5.3