• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/zebra/bgpd/

Lines Matching refs:aspath

51 /* Hash for aspath.  This is the top level structure of AS path. */
55 static struct aspath *
58 struct aspath *aspath;
60 aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
61 memset (aspath, 0, sizeof (struct aspath));
62 return aspath;
67 aspath_free (struct aspath *aspath)
69 if (!aspath)
71 if (aspath->data)
72 XFREE (MTYPE_AS_SEG, aspath->data);
73 if (aspath->str)
74 XFREE (MTYPE_AS_STR, aspath->str);
75 XFREE (MTYPE_AS_PATH, aspath);
78 /* Unintern aspath from AS path bucket. */
80 aspath_unintern (struct aspath *aspath)
82 struct aspath *ret;
84 if (aspath->refcnt)
85 aspath->refcnt--;
87 if (aspath->refcnt == 0)
89 /* This aspath must exist in aspath hash table. */
90 ret = hash_release (ashash, aspath);
92 aspath_free (aspath);
130 /* Convert aspath structure to string expression. */
132 aspath_make_str_count (struct aspath *as)
144 /* Empty aspath. */
257 struct aspath *
258 aspath_intern (struct aspath *aspath)
260 struct aspath *find;
263 assert (aspath->refcnt == 0);
266 find = hash_get (ashash, aspath, hash_alloc_intern);
268 if (find != aspath)
269 aspath_free (aspath);
279 /* Duplicate aspath structure. Created same aspath structure but
281 struct aspath *
282 aspath_dup (struct aspath *aspath)
284 struct aspath *new;
286 new = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
287 memset (new, 0, sizeof (struct aspath));
289 new->length = aspath->length;
293 new->data = XMALLOC (MTYPE_AS_SEG, aspath->length);
294 memcpy (new->data, aspath->data, aspath->length);
299 /* new->str = aspath_make_str_count (aspath); */
305 aspath_hash_alloc (struct aspath *arg)
307 struct aspath *aspath;
309 /* New aspath strucutre is needed. */
310 aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
311 memset ((void *) aspath, 0, sizeof (struct aspath));
312 aspath->length = arg->length;
314 /* In case of IBGP connection aspath's length can be zero. */
317 aspath->data = XMALLOC (MTYPE_AS_SEG, arg->length);
318 memcpy (aspath->data, arg->data, arg->length);
321 aspath->data = NULL;
324 aspath->str = aspath_make_str_count (aspath);
327 if (! aspath->str)
329 aspath_free (aspath);
333 return aspath;
339 struct aspath *
342 struct aspath as;
343 struct aspath *find;
349 /* Looking up aspath hash entry. */
353 /* If already same aspath exist then return it. */
366 struct aspath *
367 aspath_aggregate_segment_copy (struct aspath *aspath, struct assegment *seg,
372 if (! aspath->data)
374 aspath->data = XMALLOC (MTYPE_AS_SEG, ASSEGMENT_SIZE (i));
375 newseg = (struct assegment *) aspath->data;
376 aspath->length = ASSEGMENT_SIZE (i);
380 aspath->data = XREALLOC (MTYPE_AS_SEG, aspath->data,
381 aspath->length + ASSEGMENT_SIZE (i));
382 newseg = (struct assegment *) (aspath->data + aspath->length);
383 aspath->length += ASSEGMENT_SIZE (i);
390 return aspath;
394 aspath_aggregate_as_set_add (struct aspath *aspath, struct assegment *asset,
402 if (! aspath->data)
404 aspath->data = XMALLOC (MTYPE_AS_SEG, ASSEGMENT_SIZE (1));
405 asset = (struct assegment *) aspath->data;
406 aspath->length = ASSEGMENT_SIZE (1);
410 aspath->data = XREALLOC (MTYPE_AS_SEG, aspath->data,
411 aspath->length + ASSEGMENT_SIZE (1));
412 asset = (struct assegment *) (aspath->data + aspath->length);
413 aspath->length += ASSEGMENT_SIZE (1);
428 offset = (caddr_t) asset - (caddr_t) aspath->data;
429 aspath->data = XREALLOC (MTYPE_AS_SEG, aspath->data,
430 aspath->length + AS_VALUE_SIZE);
432 asset = (struct assegment *) (aspath->data + offset);
433 aspath->length += AS_VALUE_SIZE;
442 struct aspath *
443 aspath_aggregate (struct aspath *as1, struct aspath *as2)
456 struct aspath *aspath;
461 aspath = NULL;
487 if (! aspath)
488 aspath = aspath_new();
489 aspath = aspath_aggregate_segment_copy (aspath, seg1, match);
503 if (! aspath)
504 aspath = aspath_new();
513 asset = aspath_aggregate_as_set_add (aspath, asset, seg1->asval[i]);
525 asset = aspath_aggregate_as_set_add (aspath, asset, seg2->asval[i]);
531 return aspath;
538 aspath_firstas_check (struct aspath *aspath, as_t asno)
543 if (aspath == NULL)
546 pnt = aspath->data;
557 /* AS path loop check. If aspath contains asno then return 1. */
559 aspath_loop_check (struct aspath *aspath, as_t asno)
566 if (aspath == NULL)
569 pnt = aspath->data;
570 end = aspath->data + aspath->length;
588 aspath_private_as_check (struct aspath *aspath)
594 if (aspath == NULL)
597 if (aspath->length == 0)
600 pnt = aspath->data;
601 end = aspath->data + aspath->length;
619 /* Merge as1 to as2. as2 should be uninterned aspath. */
620 struct aspath *
621 aspath_merge (struct aspath *as1, struct aspath *as2)
639 /* Prepend as1 to as2. as2 should be uninterned aspath. */
640 struct aspath *
641 aspath_prepend (struct aspath *as1, struct aspath *as2)
709 /* Add specified AS to the leftmost of aspath. */
710 static struct aspath *
711 aspath_add_one_as (struct aspath *aspath, as_t asno, u_char type)
715 assegment = (struct assegment *) aspath->data;
717 /* In case of empty aspath. */
720 aspath->length = AS_HEADER_SIZE + AS_VALUE_SIZE;
723 aspath->data = XREALLOC (MTYPE_AS_SEG, aspath->data, aspath->length);
725 aspath->data = XMALLOC (MTYPE_AS_SEG, aspath->length);
727 assegment = (struct assegment *) aspath->data;
732 return aspath;
740 newdata = XMALLOC (MTYPE_AS_SEG, aspath->length + AS_VALUE_SIZE);
748 aspath->data + AS_HEADER_SIZE,
749 aspath->length - AS_HEADER_SIZE);
751 XFREE (MTYPE_AS_SEG, aspath->data);
753 aspath->data = newdata;
754 aspath->length += AS_VALUE_SIZE;
759 newdata = XMALLOC (MTYPE_AS_SEG, aspath->length + AS_VALUE_SIZE + AS_HEADER_SIZE);
767 aspath->data,
768 aspath->length);
770 XFREE (MTYPE_AS_SEG, aspath->data);
772 aspath->data = newdata;
773 aspath->length += AS_HEADER_SIZE + AS_VALUE_SIZE;
776 return aspath;
779 /* Add specified AS to the leftmost of aspath. */
780 struct aspath *
781 aspath_add_seq (struct aspath *aspath, as_t asno)
783 return aspath_add_one_as (aspath, asno, AS_SEQUENCE);
789 aspath_cmp_left (struct aspath *aspath1, struct aspath *aspath2)
825 aspath_cmp_left_confed (struct aspath *aspath1, struct aspath *aspath2)
855 /* Delete first sequential AS_CONFED_SEQUENCE from aspath. */
856 struct aspath *
857 aspath_delete_confed_seq (struct aspath *aspath)
862 if (! aspath)
863 return aspath;
865 assegment = (struct assegment *) aspath->data;
870 return aspath;
874 if (seglen == aspath->length)
876 XFREE (MTYPE_AS_SEG, aspath->data);
877 aspath->data = NULL;
878 aspath->length = 0;
882 memcpy (aspath->data, aspath->data + seglen,
883 aspath->length - seglen);
884 aspath->data = XREALLOC (MTYPE_AS_SEG, aspath->data,
885 aspath->length - seglen);
886 aspath->length -= seglen;
889 assegment = (struct assegment *) aspath->data;
891 return aspath;
894 /* Add new AS number to the leftmost part of the aspath as
896 struct aspath*
897 aspath_add_confed_seq (struct aspath *aspath, as_t asno)
899 return aspath_add_one_as (aspath, asno, AS_CONFED_SEQUENCE);
904 aspath_as_add (struct aspath *as, as_t asno)
934 aspath_segment_add (struct aspath *as, int type)
955 struct aspath *
961 struct aspath *
964 struct aspath *aspath;
966 aspath = aspath_new ();
967 aspath->str = aspath_make_str_count (aspath);
968 return aspath;
983 One BGP aspath size should be less than 4096 - BGP header size -
1060 struct aspath *
1066 struct aspath *aspath;
1069 aspath = aspath_new ();
1082 aspath_segment_add (aspath, as_type);
1085 aspath_as_add (aspath, asno);
1089 aspath_segment_add (aspath, as_type);
1098 aspath_segment_add (aspath, as_type);
1112 aspath->str = aspath_make_str_count (aspath);
1114 return aspath;
1118 /* Make hash value by raw aspath data. */
1120 aspath_key_make (struct aspath *aspath)
1126 length = aspath->length;
1127 pnt = aspath->data;
1135 /* If two aspath have same value then return 1 else return 0 */
1137 aspath_cmp (struct aspath *as1, struct aspath *as2)
1156 aspath_print (struct aspath *as)
1163 aspath_print_vty (struct vty *vty, struct aspath *as)
1171 struct aspath *as;
1173 as = (struct aspath *) backet->data;
1179 /* Print all aspath and hash information. This function is used from