Feng Lu | 41f44a2 | 2015-05-22 11:39:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * VRF 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_VRF_H |
| 24 | #define _ZEBRA_VRF_H |
| 25 | |
| 26 | /* The default VRF ID */ |
| 27 | #define VRF_DEFAULT 0 |
| 28 | |
| 29 | /* |
| 30 | * VRF hooks |
| 31 | */ |
| 32 | |
| 33 | #define VRF_NEW_HOOK 0 /* a new VRF is just created */ |
| 34 | #define VRF_DELETE_HOOK 1 /* a VRF is to be deleted */ |
| 35 | |
| 36 | /* |
| 37 | * Add a specific hook to VRF module. |
| 38 | * @param1: hook type |
| 39 | * @param2: the callback function |
| 40 | * - param 1: the VRF ID |
| 41 | * - param 2: the address of the user data pointer (the user data |
| 42 | * can be stored in or freed from there) |
| 43 | */ |
| 44 | extern void vrf_add_hook (int, int (*)(vrf_id_t, void **)); |
| 45 | |
| 46 | /* |
| 47 | * VRF iteration |
| 48 | */ |
| 49 | |
| 50 | typedef void * vrf_iter_t; |
| 51 | #define VRF_ITER_INVALID NULL /* invalid value of the iterator */ |
| 52 | |
| 53 | /* |
| 54 | * VRF iteration utilities. Example for the usage: |
| 55 | * |
| 56 | * vrf_iter_t iter = vrf_first(); |
| 57 | * for (; iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 58 | * |
| 59 | * or |
| 60 | * |
| 61 | * vrf_iter_t iter = vrf_iterator (<a given VRF ID>); |
| 62 | * for (; iter != VRF_ITER_INVALID; iter = vrf_next (iter)) |
| 63 | */ |
| 64 | |
| 65 | /* Return the iterator of the first VRF. */ |
| 66 | extern vrf_iter_t vrf_first (void); |
| 67 | /* Return the next VRF iterator to the given iterator. */ |
| 68 | extern vrf_iter_t vrf_next (vrf_iter_t); |
| 69 | /* Return the VRF iterator of the given VRF ID. If it does not exist, |
| 70 | * the iterator of the next existing VRF is returned. */ |
| 71 | extern vrf_iter_t vrf_iterator (vrf_id_t); |
| 72 | |
| 73 | /* |
| 74 | * VRF iterator to properties |
| 75 | */ |
| 76 | extern vrf_id_t vrf_iter2id (vrf_iter_t); |
| 77 | extern void *vrf_iter2info (vrf_iter_t); |
| 78 | |
| 79 | /* |
| 80 | * Utilities to obtain the user data |
| 81 | */ |
| 82 | |
| 83 | /* Get the data pointer of the specified VRF. If not found, create one. */ |
| 84 | extern void *vrf_info_get (vrf_id_t); |
| 85 | /* Look up the data pointer of the specified VRF. */ |
| 86 | extern void *vrf_info_lookup (vrf_id_t); |
| 87 | |
| 88 | /* |
| 89 | * VRF initializer/destructor |
| 90 | */ |
| 91 | /* Please add hooks before calling vrf_init(). */ |
| 92 | extern void vrf_init (void); |
| 93 | extern void vrf_terminate (void); |
| 94 | |
| 95 | #endif /*_ZEBRA_VRF_H*/ |
| 96 | |