]> git.proxmox.com Git - mirror_frr.git/blame - lib/ns.h
zebra: zns context is filled in when vrf is enabled
[mirror_frr.git] / lib / ns.h
CommitLineData
32bcb8b0
DS
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 *
896014f4
DL
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
32bcb8b0
DS
20 */
21
22#ifndef _ZEBRA_NS_H
23#define _ZEBRA_NS_H
24
c7fdd84f 25#include "openbsd-tree.h"
32bcb8b0
DS
26#include "linklist.h"
27
3eca551f 28typedef u_int32_t ns_id_t;
32bcb8b0 29
3eca551f 30/* the default NS ID */
32bcb8b0 31#define NS_DEFAULT 0
3eca551f 32#define NS_UNKNOWN UINT32_MAX
32bcb8b0 33
1fbe3e58 34/* Default netns directory (Linux) */
13460c44 35#define NS_RUN_DIR "/var/run/netns"
32bcb8b0 36
d62a17ae 37struct ns {
38 RB_ENTRY(ns) entry;
c7fdd84f 39
d62a17ae 40 /* Identifier, same as the vector index */
41 ns_id_t ns_id;
c7fdd84f 42
d62a17ae 43 /* Name */
44 char *name;
c7fdd84f 45
d62a17ae 46 /* File descriptor */
47 int fd;
f30c50b9 48
d62a17ae 49 /* Master list of interfaces belonging to this NS */
50 struct list *iflist;
f30c50b9 51
b95c1883
PG
52 /* Back Pointer to VRF */
53 void *vrf_ctxt;
54
d62a17ae 55 /* User data */
56 void *info;
f30c50b9 57};
d62a17ae 58RB_HEAD(ns_head, ns);
59RB_PROTOTYPE(ns_head, ns, entry, ns_compare)
c7fdd84f
RW
60
61extern struct ns_head ns_tree;
f30c50b9 62
32bcb8b0
DS
63/*
64 * NS hooks
65 */
66
67#define NS_NEW_HOOK 0 /* a new logical-router is just created */
68#define NS_DELETE_HOOK 1 /* a logical-router is to be deleted */
69#define NS_ENABLE_HOOK 2 /* a logical-router is ready to use */
70#define NS_DISABLE_HOOK 3 /* a logical-router is to be unusable */
71
72/*
73 * Add a specific hook ns module.
74 * @param1: hook type
75 * @param2: the callback function
76 * - param 1: the NS ID
77 * - param 2: the address of the user data pointer (the user data
78 * can be stored in or freed from there)
79 */
d62a17ae 80extern void ns_add_hook(int, int (*)(ns_id_t, void **));
32bcb8b0 81
32bcb8b0
DS
82/*
83 * NS initializer/destructor
84 */
85/* Please add hooks before calling ns_init(). */
d62a17ae 86extern void ns_init(void);
87extern void ns_terminate(void);
32bcb8b0
DS
88
89/*
90 * NS utilities
91 */
92
93/* Create a socket serving for the given NS */
d62a17ae 94extern int ns_socket(int, int, int, ns_id_t);
b95c1883 95extern void ns_cmd_init(void);
32bcb8b0
DS
96
97#endif /*_ZEBRA_NS_H*/