]>
git.proxmox.com Git - mirror_frr.git/blob - lib/ns.h
3 * Copyright (C) 2014 6WIND S.A.
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2, or (at your
10 * option) any later version.
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
28 typedef u_int16_t ns_id_t
;
30 /* The default NS ID */
36 #define NS_RUN_DIR "/var/run/netns"
37 #define NS_CMD_STR "logical-router <0-65535>"
38 #define NS_CMD_HELP_STR "Specify the Logical-Router\nThe Logical-Router ID\n"
40 #define NS_ALL_CMD_STR "logical-router all"
41 #define NS_ALL_CMD_HELP_STR "Specify the logical-router\nAll logical-router's\n"
47 #define NS_NEW_HOOK 0 /* a new logical-router is just created */
48 #define NS_DELETE_HOOK 1 /* a logical-router is to be deleted */
49 #define NS_ENABLE_HOOK 2 /* a logical-router is ready to use */
50 #define NS_DISABLE_HOOK 3 /* a logical-router is to be unusable */
53 * Add a specific hook ns module.
55 * @param2: the callback function
56 * - param 1: the NS ID
57 * - param 2: the address of the user data pointer (the user data
58 * can be stored in or freed from there)
60 extern void ns_add_hook (int, int (*)(ns_id_t
, void **));
66 typedef void * ns_iter_t
;
67 #define NS_ITER_INVALID NULL /* invalid value of the iterator */
70 * NS iteration utilities. Example for the usage:
72 * ns_iter_t iter = ns_first();
73 * for (; iter != NS_ITER_INVALID; iter = ns_next (iter))
77 * ns_iter_t iter = ns_iterator (<a given NS ID>);
78 * for (; iter != NS_ITER_INVALID; iter = ns_next (iter))
81 /* Return the iterator of the first NS. */
82 extern ns_iter_t
ns_first (void);
83 /* Return the next NS iterator to the given iterator. */
84 extern ns_iter_t
ns_next (ns_iter_t
);
85 /* Return the NS iterator of the given NS ID. If it does not exist,
86 * the iterator of the next existing NS is returned. */
87 extern ns_iter_t
ns_iterator (ns_id_t
);
90 * NS iterator to properties
92 extern ns_id_t
ns_iter2id (ns_iter_t
);
93 extern void *ns_iter2info (ns_iter_t
);
94 extern struct list
*ns_iter2iflist (ns_iter_t
);
97 * Utilities to obtain the user data
100 /* Get the data pointer of the specified NS. If not found, create one. */
101 extern void *ns_info_get (ns_id_t
);
102 /* Look up the data pointer of the specified NS. */
103 extern void *ns_info_lookup (ns_id_t
);
106 * Utilities to obtain the interface list
109 /* Look up the interface list of the specified NS. */
110 extern struct list
*ns_iflist (ns_id_t
);
111 /* Get the interface list of the specified NS. Create one if not find. */
112 extern struct list
*ns_iflist_get (ns_id_t
);
115 * NS bit-map: maintaining flags, one bit per NS ID
118 typedef void * ns_bitmap_t
;
119 #define NS_BITMAP_NULL NULL
121 extern ns_bitmap_t
ns_bitmap_init (void);
122 extern void ns_bitmap_free (ns_bitmap_t
);
123 extern void ns_bitmap_set (ns_bitmap_t
, ns_id_t
);
124 extern void ns_bitmap_unset (ns_bitmap_t
, ns_id_t
);
125 extern int ns_bitmap_check (ns_bitmap_t
, ns_id_t
);
128 * NS initializer/destructor
130 /* Please add hooks before calling ns_init(). */
131 extern void ns_init (void);
132 extern void ns_terminate (void);
138 /* Create a socket serving for the given NS */
139 extern int ns_socket (int, int, int, ns_id_t
);
141 #endif /*_ZEBRA_NS_H*/