summaryrefslogtreecommitdiffstats
path: root/lib/netns_other.c
blob: 4c7be05fab2524b393fb8e3c34cae919fa5b7afe (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
164
165
166
167
168
169
170
/*
 * NetNS backend for non Linux systems
 * Copyright (C) 2018 6WIND S.A.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; see the file COPYING; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */


#if !defined(GNU_LINUX) && (defined(SUNOS_5) || defined(OPEN_BSD))
/* SUNOS_5 or OPEN_BSD */

#include <zebra.h>
#include "ns.h"
#include "log.h"
#include "memory.h"

DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context")
DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name")


static inline int ns_compare(const struct ns *ns, const struct ns *ns2);

RB_GENERATE(ns_head, ns, entry, ns_compare)

struct ns_head ns_tree = RB_INITIALIZER(&ns_tree);

static inline int ns_compare(const struct ns *a, const struct ns *b)
{
	return (a->ns_id - b->ns_id);
}

void ns_terminate(void)
{
}

/* API to initialize NETNS managerment
 * parameter is the default ns_id
 */
void ns_init_management(ns_id_t ns_id)
{
}


/*
 * NS utilities
 */

/* Create a socket serving for the given NS
 */
int ns_socket(int domain, int type, int protocol, ns_id_t ns_id)
{
	return -1;
}

/* return the path of the NETNS */
char *ns_netns_pathname(struct vty *vty, const char *name)
{
	return NULL;
}

/* Parse and execute a function on all the NETNS */
void ns_walk_func(int (*func)(struct ns *))
{
}

/* API to get the NETNS name, from the ns pointer */
const char *ns_get_name(struct ns *ns)
{
	return NULL;
}

/* only called from vrf ( when removing netns from vrf)
 * or at VRF or logical router termination
 */
void ns_delete(struct ns *ns)
{
}

/* return > 0 if netns is available
 * called by VRF to check netns backend is available for VRF
 */
int ns_have_netns(void)
{
	return 0;
}

/* API to get context information of a NS */
void *ns_info_lookup(ns_id_t ns_id)
{
	return NULL;
}

/*
 * NS init routine
 * should be called from backendx
 */
void ns_init(void)
{
}

/* API to retrieve default NS */
ns_id_t ns_get_default_id(void)
{
	return NS_UNKNOWN;
}


/* API that can be used to change from NS */
int ns_switchback_to_initial(void)
{
	return 0;
}
int ns_switch_to_netns(const char *netns_name)
{
	return 0;
}

/*
 * NS handling routines.
 * called by modules that use NS backend
 */

/* API to search for already present NETNS */
struct ns *ns_lookup(ns_id_t ns_id)
{
	return NULL;
}

struct ns *ns_lookup_name(const char *name)
{
	return NULL;
}

/* API to handle NS : creation, enable, disable
 * for enable, a callback function is passed as parameter
 * the callback belongs to the module that uses NS as backend
 * upon enabling the NETNS, the upper layer is informed
 */
int ns_enable(struct ns *ns, int (*func)(ns_id_t, void *))
{
	return 0;
}

ns_id_t ns_map_nsid_with_external(ns_id_t ns_id, bool maporunmap)
{
	return NS_UNKNOWN;
}

struct ns *ns_get_created(struct ns *ns, char *name, ns_id_t ns_id)
{
	return NULL;
}

void ns_disable(struct ns *ns)
{
}

#endif /* !GNU_LINUX */