Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
cfg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
20 #ifndef FACEMGR_CFG_H
21 #define FACEMGR_CFG_H
22 
23 #include <hicn/ctrl/face.h>
24 #include <hicn/facemgr/facelet.h>
25 #include <hicn/util/log.h>
26 
27 /* Face manager configuration */
28 
29 #ifdef __ANDROID__
30 #define FACEMGR_FACE_TYPE_DEFAULT FACEMGR_FACE_TYPE_OVERLAY_UDP
31 #else
32 #define FACEMGR_FACE_TYPE_DEFAULT FACEMGR_FACE_TYPE_NATIVE_TCP
33 #endif /* __ANDROID__ */
34 
35 #define DEFAULT_FACE_TYPE FACE_TYPE_AUTO
36 #define FACEMGR_CFG_DEFAULT_DISCOVERY true
37 //#define DEFAULT_IGNORE "lo"
38 #define FACEMGR_CFG_DEFAULT_IPV4 true
39 #define FACEMGR_CFG_DEFAULT_IPV6 false
40 
41 
42 
43 typedef struct facemgr_cfg_s facemgr_cfg_t;
44 
45 facemgr_cfg_t * facemgr_cfg_create();
46 void facemgr_cfg_free(facemgr_cfg_t * cfg);
47 int facemgr_cfg_initialize(facemgr_cfg_t * cfg);
48 int facemgr_cfg_finalize(facemgr_cfg_t * cfg);
49 void facemgr_cfg_dump(facemgr_cfg_t * cfg);
50 
51 /* Rules */
52 
53 typedef struct facemgr_cfg_rule_s facemgr_cfg_rule_t;
54 
55 facemgr_cfg_rule_t * facemgr_cfg_rule_create();
56 void facemgr_cfg_rule_free(facemgr_cfg_rule_t * rule);
57 int facemgr_cfg_rule_initialize(facemgr_cfg_rule_t * rule);
58 int facemgr_cfg_rule_finalize(facemgr_cfg_rule_t * rule);
59 
60 int facemgr_cfg_rule_set_match(facemgr_cfg_rule_t * rule,
61  const char * interface_name, netdevice_type_t interface_type);
62 
63 int facemgr_cfg_rule_set_face_type(facemgr_cfg_rule_t * cfg_rule, facemgr_face_type_t * face_type);
64 int facemgr_cfg_rule_unset_face_type(facemgr_cfg_rule_t * cfg_rule);
65 
66 int facemgr_cfg_rule_set_discovery(facemgr_cfg_rule_t * cfg_rule, bool status);
67 int facemgr_cfg_rule_unset_discovery(facemgr_cfg_rule_t * cfg_rule);
68 
69 int facemgr_cfg_rule_set_ignore(facemgr_cfg_rule_t * cfg_rule, bool status);
70 int facemgr_cfg_rule_unset_ignore(facemgr_cfg_rule_t * cfg_rule);
71 
72 int facemgr_cfg_rule_set_ipv4(facemgr_cfg_rule_t * cfg_rule, bool status);
73 int facemgr_cfg_rule_unset_ipv4(facemgr_cfg_rule_t * cfg_rule);
74 
75 int facemgr_cfg_rule_set_ipv6(facemgr_cfg_rule_t * cfg_rule, bool status);
76 int facemgr_cfg_rule_unset_ipv6(facemgr_cfg_rule_t * cfg_rule);
77 
78 int facemgr_cfg_rule_set_overlay(facemgr_cfg_rule_t * rule, int family,
79  ip_address_t * local_addr, uint16_t local_port,
80  ip_address_t * remote_addr, uint16_t remote_port);
81 int facemgr_rule_unset_overlay(facemgr_cfg_rule_t * rule, int family);
82 
83 /* General */
84 int facemgr_cfg_set_face_type(facemgr_cfg_t * cfg, facemgr_face_type_t * face_type);
85 int facemgr_cfg_unset_face_type(facemgr_cfg_t * cfg);
86 int facemgr_cfg_set_discovery(facemgr_cfg_t * cfg, bool status);
87 int facemgr_cfg_unset_discovery(facemgr_cfg_t * cfg);
88 int facemgr_cfg_set_ipv4(facemgr_cfg_t * cfg, bool status);
89 int facemgr_cfg_unset_ipv4(facemgr_cfg_t * cfg);
90 int facemgr_cfg_set_ipv6(facemgr_cfg_t * cfg, bool status);
91 int facemgr_cfg_unset_ipv6(facemgr_cfg_t * cfg);
92 
93 int facemgr_cfg_set_overlay(facemgr_cfg_t * cfg, int family,
94  ip_address_t * local_addr, uint16_t local_port,
95  ip_address_t * remote_addr, uint16_t remote_port);
96 int facemgr_cfg_unset_overlay(facemgr_cfg_t * cfg, int family);
97 
98 
99 int facemgr_cfg_add_rule(facemgr_cfg_t * cfg, facemgr_cfg_rule_t * rule);
100 int facemgr_cfg_del_rule(facemgr_cfg_t * cfg, facemgr_cfg_rule_t * rule);
101 int facemgr_cfg_get_rule(const facemgr_cfg_t * cfg, const char * interface_name,
102  netdevice_type_t interface_type, facemgr_cfg_rule_t ** rule);
103 
104 /* Log */
105 
106 /*
107  * Query API
108  *
109  * Takes the overrides into account
110  *
111  * TODO : interface_types are currently not taken into account by this API
112  */
113 
114 int facemgr_cfg_get_face_type(const facemgr_cfg_t * cfg,
115  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
116  facemgr_face_type_t * face_type);
117 int facemgr_cfg_get_discovery(const facemgr_cfg_t * cfg,
118  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
119  bool * discovery);
120 int facemgr_cfg_get_ignore(const facemgr_cfg_t * cfg,
121  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
122  bool * ignore);
123 int facemgr_cfg_get_ipv4(const facemgr_cfg_t * cfg,
124  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
125  bool * ipv4);
126 int facemgr_cfg_get_ipv6(const facemgr_cfg_t * cfg,
127  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
128  bool * ipv6);
129 int facemgr_cfg_get_overlay_local_addr(const facemgr_cfg_t * cfg,
130  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
131  int family, ip_address_t * addr);
132 int facemgr_cfg_get_overlay_local_port(const facemgr_cfg_t * cfg,
133  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
134  int family, u16 * port);
135 int facemgr_cfg_get_overlay_remote_addr(const facemgr_cfg_t * cfg,
136  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
137  int family, ip_address_t * addr);
138 int facemgr_cfg_get_overlay_remote_port(const facemgr_cfg_t * cfg,
139  const netdevice_t * netdevice, netdevice_type_t netdevice_type,
140  int family, u16 * port);
141 
142 int facemgr_cfg_rule_get(const facemgr_cfg_t * cfg, const netdevice_t netdevice,
143  netdevice_type_t netdevice_type, facemgr_cfg_rule_t ** rule);
144 int facemgr_cfg_rule_get_face_type(const facemgr_cfg_rule_t * cfg_rule, facemgr_face_type_t * face_type);
145 int facemgr_cfg_rule_get_discovery(const facemgr_cfg_rule_t * cfg_rule, bool * status);
146 int facemgr_cfg_rule_get_ignore(const facemgr_cfg_rule_t * cfg_rule, bool * status);
147 int facemgr_cfg_rule_get_ipv4(const facemgr_cfg_rule_t * cfg_rule, bool * status);
148 int facemgr_cfg_rule_get_ipv6(const facemgr_cfg_rule_t * cfg_rule, bool * status);
149 int facemgr_cfg_rule_get_overlay_local_addr(const facemgr_cfg_rule_t * rule, int family,
150  ip_address_t * addr);
151 int facemgr_cfg_rule_get_overlay_local_port(const facemgr_cfg_rule_t * rule, int family,
152  uint16_t * port);
153 int facemgr_cfg_rule_get_overlay_remote_addr(const facemgr_cfg_rule_t * rule, int family,
154  ip_address_t * addr);
155 int facemgr_cfg_rule_get_overlay_remote_port(const facemgr_cfg_rule_t * rule, int family,
156  uint16_t * port);
157 
158 int facemgr_cfg_add_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet);
159 int facemgr_cfg_remove_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet,
160  facelet_t ** removed_facelet);
161 int facemgr_cfg_get_static_facelet_array(const facemgr_cfg_t * cfg, facelet_t *** array);
162 
163 #endif /* FACEMGR_CFG_H */
ip_address_t
Definition: ip_address.h:68
netdevice_t
Netdevice type.
Definition: face.h:73
face.h
Face abstraction.
facelet.h
Facelet.
facemgr_face_type_t
Definition: facelet.h:69