Josh Bailey | 165b5ff | 2011-07-20 20:43:22 -0700 | [diff] [blame] | 1 | /* $QuaggaId: Format:%an, %ai, %h$ $ |
| 2 | * |
| 3 | * BGP Multipath |
| 4 | * Copyright (C) 2010 Google Inc. |
| 5 | * |
| 6 | * This file is part of Quagga |
| 7 | * |
| 8 | * Quagga is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2, or (at your option) any |
| 11 | * later version. |
| 12 | * |
| 13 | * Quagga is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with Quagga; see the file COPYING. If not, write to the Free |
| 20 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 21 | * 02111-1307, USA. |
| 22 | */ |
| 23 | |
| 24 | #include <zebra.h> |
| 25 | |
| 26 | #include "command.h" |
| 27 | |
| 28 | #include "bgpd/bgpd.h" |
| 29 | #include "bgpd/bgp_mpath.h" |
| 30 | |
| 31 | /* |
| 32 | * bgp_maximum_paths_set |
| 33 | * |
| 34 | * Record maximum-paths configuration for BGP instance |
| 35 | */ |
| 36 | int |
| 37 | bgp_maximum_paths_set (struct bgp *bgp, afi_t afi, safi_t safi, |
| 38 | int peertype, u_int16_t maxpaths) |
| 39 | { |
| 40 | if (!bgp || (afi >= AFI_MAX) || (safi >= SAFI_MAX)) |
| 41 | return -1; |
| 42 | |
| 43 | switch (peertype) |
| 44 | { |
| 45 | case BGP_PEER_IBGP: |
| 46 | bgp->maxpaths[afi][safi].maxpaths_ibgp = maxpaths; |
| 47 | break; |
| 48 | case BGP_PEER_EBGP: |
| 49 | bgp->maxpaths[afi][safi].maxpaths_ebgp = maxpaths; |
| 50 | break; |
| 51 | default: |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * bgp_maximum_paths_unset |
| 60 | * |
| 61 | * Remove maximum-paths configuration from BGP instance |
| 62 | */ |
| 63 | int |
| 64 | bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi, |
| 65 | int peertype) |
| 66 | { |
| 67 | if (!bgp || (afi >= AFI_MAX) || (safi >= SAFI_MAX)) |
| 68 | return -1; |
| 69 | |
| 70 | switch (peertype) |
| 71 | { |
| 72 | case BGP_PEER_IBGP: |
| 73 | bgp->maxpaths[afi][safi].maxpaths_ibgp = BGP_DEFAULT_MAXPATHS; |
| 74 | break; |
| 75 | case BGP_PEER_EBGP: |
| 76 | bgp->maxpaths[afi][safi].maxpaths_ebgp = BGP_DEFAULT_MAXPATHS; |
| 77 | break; |
| 78 | default: |
| 79 | return -1; |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | } |