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

Fixes sorting in OSPF show state.

This commit is contained in:
Ondrej Zajicek 2012-10-29 20:39:03 +01:00
parent e4404cef0b
commit 8249ad9b30

View File

@ -953,8 +953,10 @@ lsa_compare_for_state(const void *p1, const void *p2)
struct ospf_lsa_header *lsa1 = &(he1->lsa); struct ospf_lsa_header *lsa1 = &(he1->lsa);
struct ospf_lsa_header *lsa2 = &(he2->lsa); struct ospf_lsa_header *lsa2 = &(he2->lsa);
if (he1->domain != he2->domain) if (he1->domain < he2->domain)
return he1->domain - he2->domain; return -1;
if (he1->domain > he2->domain)
return 1;
#ifdef OSPFv3 #ifdef OSPFv3
struct ospf_lsa_header lsatmp1, lsatmp2; struct ospf_lsa_header lsatmp1, lsatmp2;
@ -979,14 +981,18 @@ lsa_compare_for_state(const void *p1, const void *p2)
{ {
#ifdef OSPFv3 #ifdef OSPFv3
/* In OSPFv3, neworks are named base on ID of DR */ /* In OSPFv3, neworks are named base on ID of DR */
if (lsa1->rt != lsa2->rt) if (lsa1->rt < lsa2->rt)
return lsa1->rt - lsa2->rt; return -1;
if (lsa1->rt > lsa2->rt)
return 1;
#endif #endif
/* For OSPFv2, this is IP of the network, /* For OSPFv2, this is IP of the network,
for OSPFv3, this is interface ID */ for OSPFv3, this is interface ID */
if (lsa1->id != lsa2->id) if (lsa1->id < lsa2->id)
return lsa1->id - lsa2->id; return -1;
if (lsa1->id > lsa2->id)
return 1;
#ifdef OSPFv3 #ifdef OSPFv3
if (px1 != px2) if (px1 != px2)
@ -997,14 +1003,20 @@ lsa_compare_for_state(const void *p1, const void *p2)
} }
else else
{ {
if (lsa1->rt != lsa2->rt) if (lsa1->rt < lsa2->rt)
return lsa1->rt - lsa2->rt; return -1;
if (lsa1->rt > lsa2->rt)
return 1;
if (lsa1->type != lsa2->type) if (lsa1->type < lsa2->type)
return lsa1->type - lsa2->type; return -1;
if (lsa1->type > lsa2->type)
if (lsa1->id != lsa2->id) return 1;
return lsa1->id - lsa2->id;
if (lsa1->id < lsa2->id)
return -1;
if (lsa1->id > lsa2->id)
return 1;
#ifdef OSPFv3 #ifdef OSPFv3
if (px1 != px2) if (px1 != px2)
@ -1023,12 +1035,16 @@ ext_compare_for_state(const void *p1, const void *p2)
struct ospf_lsa_header *lsa1 = &(he1->lsa); struct ospf_lsa_header *lsa1 = &(he1->lsa);
struct ospf_lsa_header *lsa2 = &(he2->lsa); struct ospf_lsa_header *lsa2 = &(he2->lsa);
if (lsa1->rt != lsa2->rt) if (lsa1->rt < lsa2->rt)
return lsa1->rt - lsa2->rt; return -1;
if (lsa1->rt > lsa2->rt)
return 1;
if (lsa1->id < lsa2->id)
return -1;
if (lsa1->id > lsa2->id)
return 1;
if (lsa1->id != lsa2->id)
return lsa1->id - lsa2->id;
return lsa1->sn - lsa2->sn; return lsa1->sn - lsa2->sn;
} }