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