0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Added as_path_get_first().

This commit is contained in:
Martin Mares 2000-05-19 11:01:06 +00:00
parent f7ad556f20
commit f49528a3df
2 changed files with 29 additions and 0 deletions

View File

@ -103,6 +103,34 @@ as_path_getlen(struct adata *path)
return res; return res;
} }
int
as_path_get_first(struct adata *path)
{
int res = -1;
u8 *p = path->data;
u8 *q = p+path->length;
int len;
while (p<q)
{
switch (*p++)
{
case AS_PATH_SET:
if (len = *p++)
res = get_u16(p);
p += 2*len;
break;
case AS_PATH_SEQUENCE:
if (len = *p++)
res = get_u16(p+2*(len-1));
p += 2*len;
break;
default: bug("as_path_get_first: Invalid path segment");
}
}
return res;
}
#define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \ #define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
asterisk = (mask->val == PM_ANY); \ asterisk = (mask->val == PM_ANY); \
if (asterisk) { mask = mask->next; if (!mask) { return 1; } } \ if (asterisk) { mask = mask->next; if (!mask) { return 1; } } \

View File

@ -17,6 +17,7 @@
struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as); struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as);
void as_path_format(struct adata *path, byte *buf, unsigned int size); void as_path_format(struct adata *path, byte *buf, unsigned int size);
int as_path_getlen(struct adata *path); int as_path_getlen(struct adata *path);
int as_path_get_first(struct adata *path);
struct f_path_mask { struct f_path_mask {
struct f_path_mask *next; struct f_path_mask *next;