runtime( "AS Path expected" );
as = 0;
- as_path_get_last(v1.val.ad, &as); /* really last */
+ as_path_get_first(v1.val.ad, &as);
res.type = T_INT;
res.val.i = as;
break;
runtime( "AS path expected" );
as = 0;
- as_path_get_first(v1.val.ad, &as); /* really first */
+ as_path_get_last(v1.val.ad, &as);
res.type = T_INT;
res.val.i = as;
break;
}
int
-as_path_get_first(struct adata *path, u32 *orig_as)
+as_path_get_last(struct adata *path, u32 *orig_as)
{
int bs = bgp_as4_support ? 4 : 2;
int found = 0;
case AS_PATH_SET:
if (len = *p++)
{
- found = 1;
- res = get_as(p);
+ found = 0;
p += bs * len;
}
break;
}
}
- *orig_as = res;
+ if (found)
+ *orig_as = res;
return found;
}
int
-as_path_get_last(struct adata *path, u32 *last_as)
+as_path_get_first(struct adata *path, u32 *last_as)
{
u8 *p = path->data;
eattr *e = ea_find(r->attrs->eattrs, EA_CODE(EAP_BGP, BA_AS_PATH));
u32 as;
- if (e && as_path_get_last(e->u.ptr, &as))
+ if (e && as_path_get_first(e->u.ptr, &as))
return as;
else
return ((struct bgp_proto *) r->attrs->proto)->remote_as;
u32 origas;
buf += bsprintf(buf, " (%d) [", e->pref);
- if (p && as_path_get_first(p->u.ptr, &origas))
+ if (p && as_path_get_last(p->u.ptr, &origas))
buf += bsprintf(buf, "AS%u", origas);
if (o)
buf += bsprintf(buf, "%c", "ie?"[o->u.data]);