]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_snmp.c
Merge pull request #1825 from chiragshah6/ospfv3_dev
[mirror_frr.git] / zebra / zebra_snmp.c
index 2c59d2e07b1edb649e00e9b77e40a02d45f8294b..3ab208d30b545edde7eade49f45e2e093c49032b 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -142,7 +141,7 @@ static u_char *ipFwNumber(struct variable *v, oid objid[], size_t *objid_len,
        static int result;
        struct route_table *table;
        struct route_node *rn;
-       struct rib *rib;
+       struct route_entry *re;
 
        if (smux_header_generic(v, objid, objid_len, exact, val_len,
                                write_method)
@@ -156,8 +155,9 @@ static u_char *ipFwNumber(struct variable *v, oid objid[], size_t *objid_len,
        /* Return number of routing entries. */
        result = 0;
        for (rn = route_top(table); rn; rn = route_next(rn))
-               RNODE_FOREACH_RIB(rn, rib)
-       result++;
+               RNODE_FOREACH_RE (rn, re) {
+                       result++;
+               }
 
        return (u_char *)&result;
 }
@@ -169,7 +169,7 @@ static u_char *ipCidrNumber(struct variable *v, oid objid[], size_t *objid_len,
        static int result;
        struct route_table *table;
        struct route_node *rn;
-       struct rib *rib;
+       struct route_entry *re;
 
        if (smux_header_generic(v, objid, objid_len, exact, val_len,
                                write_method)
@@ -183,8 +183,9 @@ static u_char *ipCidrNumber(struct variable *v, oid objid[], size_t *objid_len,
        /* Return number of routing entries. */
        result = 0;
        for (rn = route_top(table); rn; rn = route_next(rn))
-               RNODE_FOREACH_RIB(rn, rib)
-       result++;
+               RNODE_FOREACH_RE (rn, re) {
+                       result++;
+               }
 
        return (u_char *)&result;
 }
@@ -254,14 +255,14 @@ static int proto_trans(int type)
        }
 }
 
-static void check_replace(struct route_node *np2, struct rib *rib2,
-                         struct route_node **np, struct rib **rib)
+static void check_replace(struct route_node *np2, struct route_entry *re2,
+                         struct route_node **np, struct route_entry **re)
 {
        int proto, proto2;
 
        if (!*np) {
                *np = np2;
-               *rib = rib2;
+               *re = re2;
                return;
        }
 
@@ -269,39 +270,40 @@ static void check_replace(struct route_node *np2, struct rib *rib2,
                return;
        if (in_addr_cmp(&(*np)->p.u.prefix, &np2->p.u.prefix) > 0) {
                *np = np2;
-               *rib = rib2;
+               *re = re2;
                return;
        }
 
-       proto = proto_trans((*rib)->type);
-       proto2 = proto_trans(rib2->type);
+       proto = proto_trans((*re)->type);
+       proto2 = proto_trans(re2->type);
 
        if (proto2 > proto)
                return;
        if (proto2 < proto) {
                *np = np2;
-               *rib = rib2;
+               *re = re2;
                return;
        }
 
-       if (in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4,
-                       (u_char *)&rib2->nexthop->gate.ipv4)
+       if (in_addr_cmp((u_char *)&(*re)->ng.nexthop->gate.ipv4,
+                       (u_char *)&re2->ng.nexthop->gate.ipv4)
            <= 0)
                return;
 
        *np = np2;
-       *rib = rib2;
+       *re = re2;
        return;
 }
 
 static void get_fwtable_route_node(struct variable *v, oid objid[],
                                   size_t *objid_len, int exact,
-                                  struct route_node **np, struct rib **rib)
+                                  struct route_node **np,
+                                  struct route_entry **re)
 {
        struct in_addr dest;
        struct route_table *table;
        struct route_node *np2;
-       struct rib *rib2;
+       struct route_entry *re2;
        int proto;
        int policy;
        struct in_addr nexthop;
@@ -324,7 +326,7 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],
        /* Init return variables */
 
        *np = NULL;
-       *rib = NULL;
+       *re = NULL;
 
        /* Short circuit exact matches of wrong length */
 
@@ -367,15 +369,13 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],
                        return;
                for (*np = route_top(table); *np; *np = route_next(*np)) {
                        if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest)) {
-                               RNODE_FOREACH_RIB(*np, *rib)
-                               {
-                                       if (!in_addr_cmp((u_char *)&(*rib)
-                                                                ->nexthop->gate
-                                                                .ipv4,
+                               RNODE_FOREACH_RE (*np, *re) {
+                                       if (!in_addr_cmp(
+                                                   (u_char *)&(*re)
+                                                   ->ng.nexthop->gate.ipv4,
                                                         (u_char *)&nexthop))
                                                if (proto
-                                                   == proto_trans(
-                                                              (*rib)->type))
+                                                   == proto_trans((*re)->type))
                                                        return;
                                }
                        }
@@ -389,35 +389,36 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],
 
                /* Check destination first */
                if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0)
-                       RNODE_FOREACH_RIB(np2, rib2)
-               check_replace(np2, rib2, np, rib);
+                       RNODE_FOREACH_RE (np2, re2) {
+                               check_replace(np2, re2, np, re);
+                       }
 
                if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest)
-                   == 0) { /* have to look at each rib individually */
-                       RNODE_FOREACH_RIB(np2, rib2)
-                       {
+                   == 0) { /* have to look at each re individually */
+                       RNODE_FOREACH_RE (np2, re2) {
                                int proto2, policy2;
 
-                               proto2 = proto_trans(rib2->type);
+                               proto2 = proto_trans(re2->type);
                                policy2 = 0;
 
                                if ((policy < policy2)
                                    || ((policy == policy2) && (proto < proto2))
                                    || ((policy == policy2) && (proto == proto2)
-                                       && (in_addr_cmp((u_char *)&rib2->nexthop
-                                                               ->gate.ipv4,
-                                                       (u_char *)&nexthop)
+                                       && (in_addr_cmp(
+                                                   (u_char *)&re2->ng.nexthop
+                                                   ->gate.ipv4,
+                                                   (u_char *)&nexthop)
                                            >= 0)))
-                                       check_replace(np2, rib2, np, rib);
+                                       check_replace(np2, re2, np, re);
                        }
                }
        }
 
-       if (!*rib)
+       if (!*re)
                return;
 
        policy = 0;
-       proto = proto_trans((*rib)->type);
+       proto = proto_trans((*re)->type);
 
        *objid_len = v->namelen + 10;
        pnt = (u_char *)&(*np)->p.u.prefix;
@@ -430,7 +431,7 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],
        {
                struct nexthop *nexthop;
 
-               nexthop = (*rib)->nexthop;
+               nexthop = (*re)->ng.nexthop;
                if (nexthop) {
                        pnt = (u_char *)&nexthop->gate.ipv4;
                        for (i = 0; i < 4; i++)
@@ -445,7 +446,7 @@ static u_char *ipFwTable(struct variable *v, oid objid[], size_t *objid_len,
                         int exact, size_t *val_len, WriteMethod **write_method)
 {
        struct route_node *np;
-       struct rib *rib;
+       struct route_entry *re;
        static int result;
        static int resarr[2];
        static struct in_addr netmask;
@@ -455,11 +456,11 @@ static u_char *ipFwTable(struct variable *v, oid objid[], size_t *objid_len,
            == MATCH_FAILED)
                return NULL;
 
-       get_fwtable_route_node(v, objid, objid_len, exact, &np, &rib);
+       get_fwtable_route_node(v, objid, objid_len, exact, &np, &re);
        if (!np)
                return NULL;
 
-       nexthop = rib->nexthop;
+       nexthop = re->ng.nexthop;
        if (!nexthop)
                return NULL;
 
@@ -495,7 +496,7 @@ static u_char *ipFwTable(struct variable *v, oid objid[], size_t *objid_len,
                return (u_char *)&result;
                break;
        case IPFORWARDPROTO:
-               result = proto_trans(rib->type);
+               result = proto_trans(re->type);
                *val_len = sizeof(int);
                return (u_char *)&result;
                break;