aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/includes/hicn/facemgr/cfg.h
blob: 84d63fe73d657b12346d5e5e11395e3911df52fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * \file cfg.h
 * \brief Face manager configuration
 */
#ifndef FACEMGR_CFG_H
#define FACEMGR_CFG_H

#include <hicn/ctrl/face.h>
#include <hicn/facemgr/facelet.h>
#include <hicn/util/log.h>

/* Face manager configuration */

#ifdef __ANDROID__
#define FACEMGR_FACE_TYPE_DEFAULT FACEMGR_FACE_TYPE_OVERLAY_UDP
#else
#define FACEMGR_FACE_TYPE_DEFAULT FACEMGR_FACE_TYPE_NATIVE_TCP
#endif /* __ANDROID__ */

#define DEFAULT_FACE_TYPE FACE_TYPE_AUTO
#define FACEMGR_CFG_DEFAULT_DISCOVERY true
//#define DEFAULT_IGNORE "lo"
#define FACEMGR_CFG_DEFAULT_IPV4 true
#define FACEMGR_CFG_DEFAULT_IPV6 false



typedef struct facemgr_cfg_s facemgr_cfg_t;

facemgr_cfg_t * facemgr_cfg_create();
void facemgr_cfg_free(facemgr_cfg_t * cfg);
int facemgr_cfg_initialize(facemgr_cfg_t * cfg);
int facemgr_cfg_finalize(facemgr_cfg_t * cfg);
void facemgr_cfg_dump(facemgr_cfg_t * cfg);

/* Rules */

typedef struct facemgr_cfg_rule_s facemgr_cfg_rule_t;

facemgr_cfg_rule_t * facemgr_cfg_rule_create();
void facemgr_cfg_rule_free(facemgr_cfg_rule_t * rule);
int facemgr_cfg_rule_initialize(facemgr_cfg_rule_t * rule);
int facemgr_cfg_rule_finalize(facemgr_cfg_rule_t * rule);

int facemgr_cfg_rule_set_match(facemgr_cfg_rule_t * rule,
        const char * interface_name, netdevice_type_t interface_type);

int facemgr_cfg_rule_set_face_type(facemgr_cfg_rule_t * cfg_rule, facemgr_face_type_t * face_type);
int facemgr_cfg_rule_unset_face_type(facemgr_cfg_rule_t * cfg_rule);

int facemgr_cfg_rule_set_discovery(facemgr_cfg_rule_t * cfg_rule, bool status);
int facemgr_cfg_rule_unset_discovery(facemgr_cfg_rule_t * cfg_rule);

int facemgr_cfg_rule_set_ignore(facemgr_cfg_rule_t * cfg_rule, bool status);
int facemgr_cfg_rule_unset_ignore(facemgr_cfg_rule_t * cfg_rule);

int facemgr_cfg_rule_set_ipv4(facemgr_cfg_rule_t * cfg_rule, bool status);
int facemgr_cfg_rule_unset_ipv4(facemgr_cfg_rule_t * cfg_rule);

int facemgr_cfg_rule_set_ipv6(facemgr_cfg_rule_t * cfg_rule, bool status);
int facemgr_cfg_rule_unset_ipv6(facemgr_cfg_rule_t * cfg_rule);

int facemgr_cfg_rule_set_overlay(facemgr_cfg_rule_t * rule, int family,
    ip_address_t * local_addr, uint16_t local_port,
    ip_address_t * remote_addr, uint16_t remote_port);
int facemgr_rule_unset_overlay(facemgr_cfg_rule_t * rule, int family);

/* General */
int facemgr_cfg_set_face_type(facemgr_cfg_t * cfg, facemgr_face_type_t * face_type);
int facemgr_cfg_unset_face_type(facemgr_cfg_t * cfg);
int facemgr_cfg_set_discovery(facemgr_cfg_t * cfg, bool status);
int facemgr_cfg_unset_discovery(facemgr_cfg_t * cfg);
int facemgr_cfg_set_ipv4(facemgr_cfg_t * cfg, bool status);
int facemgr_cfg_unset_ipv4(facemgr_cfg_t * cfg);
int facemgr_cfg_set_ipv6(facemgr_cfg_t * cfg, bool status);
int facemgr_cfg_unset_ipv6(facemgr_cfg_t * cfg);

int facemgr_cfg_set_overlay(facemgr_cfg_t * cfg, int family,
    ip_address_t * local_addr, uint16_t local_port,
    ip_address_t * remote_addr, uint16_t remote_port);
int facemgr_cfg_unset_overlay(facemgr_cfg_t * cfg, int family);


int facemgr_cfg_add_rule(facemgr_cfg_t * cfg, facemgr_cfg_rule_t * rule);
int facemgr_cfg_del_rule(facemgr_cfg_t * cfg, facemgr_cfg_rule_t * rule);
int facemgr_cfg_get_rule(const facemgr_cfg_t * cfg, const char * interface_name,
        netdevice_type_t interface_type, facemgr_cfg_rule_t ** rule);

/* Log */

/*
 * Query API
 *
 * Takes the overrides into account
 *
 * TODO : interface_types are currently not taken into account by this API
 */

int facemgr_cfg_get_face_type(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        facemgr_face_type_t * face_type);
int facemgr_cfg_get_discovery(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        bool * discovery);
int facemgr_cfg_get_ignore(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        bool * ignore);
int facemgr_cfg_get_ipv4(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        bool * ipv4);
int facemgr_cfg_get_ipv6(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        bool * ipv6);
int facemgr_cfg_get_overlay_local_addr(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        int family, ip_address_t * addr);
int facemgr_cfg_get_overlay_local_port(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        int family, u16 * port);
int facemgr_cfg_get_overlay_remote_addr(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        int family, ip_address_t * addr);
int facemgr_cfg_get_overlay_remote_port(const facemgr_cfg_t * cfg,
        const netdevice_t * netdevice, netdevice_type_t netdevice_type,
        int family, u16 * port);

int facemgr_cfg_rule_get(const facemgr_cfg_t * cfg, const netdevice_t netdevice,
        netdevice_type_t netdevice_type, facemgr_cfg_rule_t ** rule);
int facemgr_cfg_rule_get_face_type(const facemgr_cfg_rule_t * cfg_rule, facemgr_face_type_t * face_type);
int facemgr_cfg_rule_get_discovery(const facemgr_cfg_rule_t * cfg_rule, bool * status);
int facemgr_cfg_rule_get_ignore(const facemgr_cfg_rule_t * cfg_rule, bool * status);
int facemgr_cfg_rule_get_ipv4(const facemgr_cfg_rule_t * cfg_rule, bool * status);
int facemgr_cfg_rule_get_ipv6(const facemgr_cfg_rule_t * cfg_rule, bool * status);
int facemgr_cfg_rule_get_overlay_local_addr(const facemgr_cfg_rule_t * rule, int family,
        ip_address_t * addr);
int facemgr_cfg_rule_get_overlay_local_port(const facemgr_cfg_rule_t * rule, int family,
        uint16_t * port);
int facemgr_cfg_rule_get_overlay_remote_addr(const facemgr_cfg_rule_t * rule, int family,
        ip_address_t * addr);
int facemgr_cfg_rule_get_overlay_remote_port(const facemgr_cfg_rule_t * rule, int family,
        uint16_t * port);

int facemgr_cfg_add_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet);
int facemgr_cfg_remove_static_facelet(facemgr_cfg_t * cfg, facelet_t * facelet,
        facelet_t ** removed_facelet);
int facemgr_cfg_get_static_facelet_array(const facemgr_cfg_t * cfg, facelet_t *** array);

#endif /* FACEMGR_CFG_H */