Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

SOFIAPUBFUN int sip_contact_accept ( sip_contact_t const *  m,
sip_accept_contact_t const *  cp,
unsigned *  return_S,
unsigned *  return_N,
int *  return_error 

Check if matches by .

Matching and headers is done as explained in section 7.2.4. The caller score can be calculated from the returned S and N values.

The header contains number of feature tag parameters. The count of feature tags is returned in return_N. For each feature tag in , the feature tag with same name is searched from the header. If both headers contain the feature tag with same name, their values are compared. If the value in does not match with the value in , there is mismatch and 0 is returned. If they match, S is increased by 1.
m pointer to header structure
cp pointer to header structure
return_N return-value parameter for number of feature tags in
return_S return-value parameter for number of matching feature tags
return_error return-value parameter for parsing error
For example,
 if (sip_contact_accept(contact, accept_contact, &S, &N, &error)) {
   if (N == 0)
     score == 1.0;
     score = (double)S / (double)N;
   if (accept_contact->cp_explicit) {
     if (accept_contact->cp_require)
       goto drop;
       score = 0.0;
 else if (!error) {
   score = 0.0;

Return values:
1 if matches
return_S contains number of matching feature tags

return_N contains number of feature tags in

Return values:
0 if does not match
return_error contains -1 if feature tag value was malformed
See also:
section 7.2.4, sip_contact_score(), sip_contact_reject(), sip_contact_is_immune(), sip_contact_immunize(), sip_is_callerpref(), sip_prefs_matching().

Definition at line 431 of file sip_pref_util.c.

References sip_caller_prefs_s::cp_params, and sip_contact_s::m_params.

  char const *cap, *acc;
  unsigned i, S, N;
  size_t eq;

  if (!return_N) return_N = &N;
  if (!return_S) return_S = &S;

  *return_S = 0, *return_N = 0;

  if (!m || !cp || !m->m_params || !cp->cp_params)
    return 1;

  for (i = 0, S = 0, N = 0; cp->cp_params[i]; i++) {
    acc = cp->cp_params[i];
    if (!sip_is_callerpref(acc))


    cap = msg_params_find(m->m_params, acc);

    if (cap) {
      eq = strcspn(acc, "=");
      acc += eq + (acc[eq] == '=');

      if (!sip_prefs_matching(cap, acc, return_error))
      return 0;


  *return_S = S; /* Matched feature tags */
  *return_N = N; /* Number of feature tags in @AcceptContact */

  return 1;

Generated by  Doxygen 1.6.0   Back to index