~ubuntu-branches/ubuntu/vivid/postfix/vivid-proposed

« back to all changes in this revision

Viewing changes to src/dns/dns_rr.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 05:26:41 UTC
  • mto: (33.1.4 natty) (39.1.4 oneiric)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20110222052641-9kcxe1gt157c31j9
Tags: upstream-2.8.0
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
/*      DNS_RR  *list
32
32
/*      int     (*compar)(DNS_RR *, DNS_RR *);
33
33
/*
34
 
/*      int     dns_rr_compare_pref(DNS_RR *a, DNS_RR *b)
 
34
/*      int     dns_rr_compare_pref_ipv6(DNS_RR *a, DNS_RR *b)
 
35
/*      DNS_RR  *list
 
36
/*      DNS_RR  *list
 
37
/*
 
38
/*      int     dns_rr_compare_pref_ipv4(DNS_RR *a, DNS_RR *b)
 
39
/*      DNS_RR  *list
 
40
/*      DNS_RR  *list
 
41
/*
 
42
/*      int     dns_rr_compare_pref_any(DNS_RR *a, DNS_RR *b)
35
43
/*      DNS_RR  *list
36
44
/*      DNS_RR  *list
37
45
/*
65
73
/*      order according to a user-specified criterion. The result is the
66
74
/*      sorted list.
67
75
/*
68
 
/*      dns_rr_compare_pref() is a dns_rr_sort() helper to sort records
69
 
/*      by their MX preference.
 
76
/*      dns_rr_compare_pref_XXX() are dns_rr_sort() helpers to sort
 
77
/*      records by their MX preference and by their address family.
70
78
/*
71
79
/*      dns_rr_shuffle() randomly permutes a list of resource records.
72
80
/*
166
174
    return (list);
167
175
}
168
176
 
169
 
/* dns_rr_compare_pref - compare resource records by preference */
 
177
/* dns_rr_compare_pref_ipv6 - compare records by preference, ipv6 preferred */
 
178
 
 
179
int     dns_rr_compare_pref_ipv6(DNS_RR *a, DNS_RR *b)
 
180
{
 
181
    if (a->pref != b->pref)
 
182
        return (a->pref - b->pref);
 
183
#ifdef HAS_IPV6
 
184
    if (a->type == b->type)                     /* 200412 */
 
185
        return 0;
 
186
    if (a->type == T_AAAA)
 
187
        return (-1);
 
188
    if (b->type == T_AAAA)
 
189
        return (+1);
 
190
#endif
 
191
    return 0;
 
192
}
 
193
 
 
194
/* dns_rr_compare_pref_ipv4 - compare records by preference, ipv4 preferred */
 
195
 
 
196
int     dns_rr_compare_pref_ipv4(DNS_RR *a, DNS_RR *b)
 
197
{
 
198
    if (a->pref != b->pref)
 
199
        return (a->pref - b->pref);
 
200
#ifdef HAS_IPV6
 
201
    if (a->type == b->type)
 
202
        return 0;
 
203
    if (a->type == T_AAAA)
 
204
        return (+1);
 
205
    if (b->type == T_AAAA)
 
206
        return (-1);
 
207
#endif
 
208
    return 0;
 
209
}
 
210
 
 
211
/* dns_rr_compare_pref_any - compare records by preference, protocol-neutral */
 
212
 
 
213
int     dns_rr_compare_pref_any(DNS_RR *a, DNS_RR *b)
 
214
{
 
215
    if (a->pref != b->pref)
 
216
        return (a->pref - b->pref);
 
217
    return 0;
 
218
}
 
219
 
 
220
/* dns_rr_compare_pref - binary compatibility helper after name change */
170
221
 
171
222
int     dns_rr_compare_pref(DNS_RR *a, DNS_RR *b)
172
223
{
173
 
    if (a->pref != b->pref)
174
 
        return (a->pref - b->pref);
175
 
#ifdef HAS_IPV6
176
 
    if (a->type == b->type)                     /* 200412 */
177
 
        return 0;
178
 
    if (a->type == T_AAAA)
179
 
        return (-1);
180
 
    if (b->type == T_AAAA)
181
 
        return (+1);
182
 
#endif
183
 
    return 0;
 
224
    return (dns_rr_compare_pref_ipv6(a, b));
184
225
}
185
226
 
186
227
/* dns_rr_sort_callback - glue function */