YAMI4Industry
network_utils.h
Go to the documentation of this file.
1 /* Copyright Inspirel Sp. z o.o. 2013-2015.
2  * This file is part of YAMI4.
3  *
4  * YAMI4 is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * YAMI4 is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef YAMI4INDUSTRY_NETWORK_UTILS_H
19 #define YAMI4INDUSTRY_NETWORK_UTILS_H
20 
21 #include "callbacks.h"
22 #include "channel.h"
23 #include "common.h"
24 #include "limits.h"
25 #include "options.h"
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 enum yami_result yami_create_listener(const char target[],
31  const struct yami_options * options,
32  int32_t * out_socket, enum yami_protocol * out_protocol,
33  yami_io_error_function io_error_callback);
34 
35 enum yami_result yami_clean_listener(int32_t sock,
36  yami_io_error_function io_error_callback);
37 
38 enum yami_result yami_create_outgoing_connection(const char target[],
39  const struct yami_options * options,
40  int32_t * out_socket, enum yami_protocol * out_protocol,
41  uint32_t * out_host, uint16_t * out_port,
42  yami_io_error_function io_error_callback);
43 
44 enum yami_result yami_accept_tcp(int32_t listening_sock,
45  const struct yami_options * options, char out_target[],
46  int32_t * out_socket,
47  yami_io_error_function io_error_callback);
48 
49 enum yami_result yami_clean_connection(int32_t sock,
50  yami_io_error_function io_error_callback);
51 
52 enum yami_result yami_write_tcp(int32_t sock,
53  const uint8_t data[], size_t from, size_t to, size_t * out_written,
54  yami_io_error_function io_error_callback);
55 
56 enum yami_result yami_send_udp(int32_t sock, uint32_t host, uint16_t port,
57  const uint8_t data[], size_t size,
58  yami_io_error_function io_error_callback);
59 
60 enum yami_result yami_read_tcp(int32_t sock,
61  uint8_t out_data[], size_t from, size_t to, size_t * out_readn,
62  yami_io_error_function io_error_callback);
63 
64 enum yami_result yami_receive_udp(const int32_t sock,
65  char out_target[], int32_t format_target,
66  uint8_t out_data[], const size_t size, size_t * const out_readn,
67  const yami_io_error_function io_error_callback);
68 
70  struct yami_channel channels[], size_t channels_array_size,
71  int32_t listening_sock, int32_t * out_listening_sock_ready,
72  size_t timeout,
73  yami_io_error_function io_error_callback);
74 
75 #endif /* YAMI4INDUSTRY_NETWORK_UTILS_H */
enum yami_result yami_accept_tcp(int32_t listening_sock, const struct yami_options *options, char out_target[], int32_t *out_socket, yami_io_error_function io_error_callback)
Definition: network_utils.c:889
void(* yami_io_error_function)(int32_t error_code, const char description[])
Definition: callbacks.h:81
Definition: options.h:30
enum yami_result yami_clean_listener(int32_t sock, yami_io_error_function io_error_callback)
Definition: network_utils.c:572
yami_result
Definition: common.h:28
enum yami_result yami_read_tcp(int32_t sock, uint8_t out_data[], size_t from, size_t to, size_t *out_readn, yami_io_error_function io_error_callback)
Definition: network_utils.c:1076
enum yami_result yami_wait_for_work(struct yami_channel channels[], size_t channels_array_size, int32_t listening_sock, int32_t *out_listening_sock_ready, size_t timeout, yami_io_error_function io_error_callback)
Definition: network_utils.c:1180
enum yami_result yami_create_listener(const char target[], const struct yami_options *options, int32_t *out_socket, enum yami_protocol *out_protocol, yami_io_error_function io_error_callback)
Definition: network_utils.c:540
enum yami_result yami_create_outgoing_connection(const char target[], const struct yami_options *options, int32_t *out_socket, enum yami_protocol *out_protocol, uint32_t *out_host, uint16_t *out_port, yami_io_error_function io_error_callback)
Definition: network_utils.c:856
enum yami_result yami_send_udp(int32_t sock, uint32_t host, uint16_t port, const uint8_t data[], size_t size, yami_io_error_function io_error_callback)
Definition: network_utils.c:1032
Definition: channel.h:36
enum yami_result yami_write_tcp(int32_t sock, const uint8_t data[], size_t from, size_t to, size_t *out_written, yami_io_error_function io_error_callback)
Definition: network_utils.c:992
enum yami_result yami_receive_udp(const int32_t sock, char out_target[], int32_t format_target, uint8_t out_data[], const size_t size, size_t *const out_readn, const yami_io_error_function io_error_callback)
Definition: network_utils.c:1131
enum yami_result yami_clean_connection(int32_t sock, yami_io_error_function io_error_callback)
Definition: network_utils.c:965
yami_protocol
Definition: channel.h:34