@ -485,10 +485,10 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
if ( context . naptr_rrs_count > = context . position & & ! ( context . options & ENUMLOOKUP_OPTIONS_COUNT ) ) {
/* sort array by NAPTR order/preference */
/* sort array by NAPTR order/preference/tech */
for ( k = 0 ; k < context . naptr_rrs_count ; k + + ) {
for ( i = 0 ; i < context . naptr_rrs_count ; i + + ) {
/* use order first and then preference to compare */
/* Compare by order first. */
if ( ( ntohs ( context . naptr_rrs [ k ] . naptr . order ) < ntohs ( context . naptr_rrs [ i ] . naptr . order )
& & context . naptr_rrs [ k ] . sort_pos > context . naptr_rrs [ i ] . sort_pos )
| | ( ntohs ( context . naptr_rrs [ k ] . naptr . order ) > ntohs ( context . naptr_rrs [ i ] . naptr . order )
@ -496,10 +496,19 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
z = context . naptr_rrs [ k ] . sort_pos ;
context . naptr_rrs [ k ] . sort_pos = context . naptr_rrs [ i ] . sort_pos ;
context . naptr_rrs [ i ] . sort_pos = z ;
continue ;
} else if ( ntohs ( context . naptr_rrs [ k ] . naptr . order ) = = ntohs ( context . naptr_rrs [ i ] . naptr . order ) ) {
/* Order is the same, so sort by preference next */
if ( ntohs ( context . naptr_rrs [ k ] . naptr . pref ) = = ntohs ( context . naptr_rrs [ i ] . naptr . pref ) ) {
/* Preference is the same, so sort by tech */
if ( ( strcmp ( context . naptr_rrs [ k ] . tech , context . naptr_rrs [ i ] . tech ) < 0
& & context . naptr_rrs [ k ] . sort_pos > context . naptr_rrs [ i ] . sort_pos )
| | ( strcmp ( context . naptr_rrs [ k ] . tech , context . naptr_rrs [ i ] . tech ) > 0
& & context . naptr_rrs [ k ] . sort_pos < context . naptr_rrs [ i ] . sort_pos ) ) {
z = context . naptr_rrs [ k ] . sort_pos ;
context . naptr_rrs [ k ] . sort_pos = context . naptr_rrs [ i ] . sort_pos ;
context . naptr_rrs [ i ] . sort_pos = z ;
}
if ( ntohs ( context . naptr_rrs [ k ] . naptr . order ) = = ntohs ( context . naptr_rrs [ i ] . naptr . order ) ) {
if ( ( ntohs ( context . naptr_rrs [ k ] . naptr . pref ) < ntohs ( context . naptr_rrs [ i ] . naptr . pref )
} else if ( ( ntohs ( context . naptr_rrs [ k ] . naptr . pref ) < ntohs ( context . naptr_rrs [ i ] . naptr . pref )
& & context . naptr_rrs [ k ] . sort_pos > context . naptr_rrs [ i ] . sort_pos )
| | ( ntohs ( context . naptr_rrs [ k ] . naptr . pref ) > ntohs ( context . naptr_rrs [ i ] . naptr . pref )
& & context . naptr_rrs [ k ] . sort_pos < context . naptr_rrs [ i ] . sort_pos ) ) {