XROAD
xroad_net_cfg.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <common/xroad_xml.h>
9 #include <common/xroad_string.h>
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
17 typedef struct
18 {
19  xroad_str_t uri;
20  int snd_buf_size;
21  int snd_buf_size_max;
22  int recv_buf_size;
23  int recv_buf_size_max;
25  int mcast_ttl;
28 
31 {
32  // TODO: consider making some args optional and connection type specific
34  {
35  .uri = xroad_xml_get_attr_s(tag, xroad_str("address")),
36  .snd_buf_size = (int)xroad_xml_get_attr_i(tag, xroad_str("snd_buf_size")),
37  .snd_buf_size_max = (int)xroad_xml_get_attr_i(tag, xroad_str("snd_buf_size_max")),
38  .recv_buf_size = (int)xroad_xml_get_attr_i(tag, xroad_str("recv_buf_size")),
39  .recv_buf_size_max = (int)xroad_xml_get_attr_i(tag, xroad_str("recv_buf_size_max")),
40  .max_tcp_connections = -1,
41  .mcast_ttl = -1,
42  .mcast_loopback = true
43  };
44  if (xroad_xml_has_attr(tag, xroad_str("max_client_conns")))
45  {
46  np.max_tcp_connections = (int)xroad_xml_get_attr_i(tag, xroad_str("max_client_conns"));
47  }
48  if (xroad_xml_has_attr(tag, xroad_str("mcast_ttl")))
49  {
50  np.mcast_ttl = (int)xroad_xml_get_attr_i(tag, xroad_str("mcast_ttl"));
51  }
52  if (xroad_xml_has_attr(tag, xroad_str("mcast_loopback")))
53  {
54  np.mcast_loopback = xroad_xml_get_attr_b(tag, xroad_str("mcast_loopback"));
55  }
56 
57  return np;
58 }
59 
60 #ifdef __cplusplus
61 }
62 #endif
Connection parameters.
Definition: xroad_net_cfg.h:18
int max_tcp_connections
Max number of TCP connection (-1 – not set)
Definition: xroad_net_cfg.h:24
bool mcast_loopback
Multicast loopback.
Definition: xroad_net_cfg.h:26
int mcast_ttl
Multicast TTL (-1 – not set)
Definition: xroad_net_cfg.h:25
Definition: xroad_string.h:29
xroad_net_params_t xroad_net_get_params_generic(xroad_xml_tag_t tag)
Basic network configuration helper.
Definition: xroad_net_cfg.h:30
#define xroad_str(str)
Definition: xroad_string.h:194
int64_t xroad_xml_get_attr_i(xroad_xml_tag_t tag, xroad_str_t attribute)
int32_t xroad_xml_has_attr(xroad_xml_tag_t tag, xroad_str_t attribute)
bool xroad_xml_get_attr_b(xroad_xml_tag_t tag, xroad_str_t attribute)
xroad_str_t xroad_xml_get_attr_s(xroad_xml_tag_t tag, xroad_str_t attribute)