]> git.proxmox.com Git - mirror_frr.git/blob - lib/ns.h
Merge remote-tracking branch 'origin/stable/2.0'
[mirror_frr.git] / lib / ns.h
1 /*
2 * NS related header.
3 * Copyright (C) 2014 6WIND S.A.
4 *
5 * This file is part of GNU Zebra.
6 *
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.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _ZEBRA_NS_H
23 #define _ZEBRA_NS_H
24
25 #include "openbsd-tree.h"
26 #include "linklist.h"
27
28 typedef u_int16_t ns_id_t;
29
30 /* The default NS ID */
31 #define NS_DEFAULT 0
32
33 /* Default netns directory (Linux) */
34 #define NS_RUN_DIR "/var/run/netns"
35
36 struct ns
37 {
38 RB_ENTRY(ns) entry;
39
40 /* Identifier, same as the vector index */
41 ns_id_t ns_id;
42
43 /* Name */
44 char *name;
45
46 /* File descriptor */
47 int fd;
48
49 /* Master list of interfaces belonging to this NS */
50 struct list *iflist;
51
52 /* User data */
53 void *info;
54 };
55 RB_HEAD (ns_head, ns);
56 RB_PROTOTYPE (ns_head, ns, entry, ns_compare)
57
58 extern struct ns_head ns_tree;
59
60 /*
61 * NS hooks
62 */
63
64 #define NS_NEW_HOOK 0 /* a new logical-router is just created */
65 #define NS_DELETE_HOOK 1 /* a logical-router is to be deleted */
66 #define NS_ENABLE_HOOK 2 /* a logical-router is ready to use */
67 #define NS_DISABLE_HOOK 3 /* a logical-router is to be unusable */
68
69 /*
70 * Add a specific hook ns module.
71 * @param1: hook type
72 * @param2: the callback function
73 * - param 1: the NS ID
74 * - param 2: the address of the user data pointer (the user data
75 * can be stored in or freed from there)
76 */
77 extern void ns_add_hook (int, int (*)(ns_id_t, void **));
78
79 /*
80 * NS initializer/destructor
81 */
82 /* Please add hooks before calling ns_init(). */
83 extern void ns_init (void);
84 extern void ns_terminate (void);
85
86 /*
87 * NS utilities
88 */
89
90 /* Create a socket serving for the given NS */
91 extern int ns_socket (int, int, int, ns_id_t);
92
93 #endif /*_ZEBRA_NS_H*/
94