#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <float.h>
#include "sofia-sip/sip_parser.h"
#include <sofia-sip/sip_header.h>
#include <sofia-sip/sip_util.h>
#include <sofia-sip/sip_status.h>
Include dependency graph for sip_pref_util.c:
Functions | |
int | sip_prefs_parse (union sip_pref *sp, char const **in_out_s, int *return_negation) |
Parse a single preference. | |
int | sip_prefs_match (union sip_pref const *a, union sip_pref const *b) |
Match preferences. | |
int | sip_prefs_matching (char const *pvalue, char const *nvalue, int *return_parse_error) |
Check callerprefs. | |
int | sip_is_callerpref (char const *param) |
Check if the parameter is a valid feature tag. | |
int | sip_contact_is_immune (sip_contact_t const *m) |
Check if Contact is immune to callerprefs. | |
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 Contact matches by Accept-Contact. | |
int | sip_contact_reject (sip_contact_t const *m, sip_reject_contact_t const *reject) |
Check if Contact is rejected by Reject-Contact. | |
sip_contact_t * | sip_contact_immunize (su_home_t *home, sip_contact_t const *m) |
Immunize Contact to callerprefs. | |
int | sip_contact_score (sip_contact_t const *m, sip_accept_contact_t const *ac, sip_reject_contact_t const *rc) |
Calculate score for contact. |
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 Contact matches by Accept-Contact.
Matching Accept-Contact and Contact headers is done as explained in RFC 3841 section 7.2.4. The caller score can be calculated from the returned S and N values.
m | pointer to Contact header structure | |
cp | pointer to Accept-Contact header structure | |
return_N | return-value parameter for number of feature tags in Accept-Contact | |
return_S | return-value parameter for number of matching feature tags | |
return_error | return-value parameter for parsing error |
if (sip_contact_accept(contact, accept_contact, &S, &N, &error)) { if (N == 0) score == 1.0; else score = (double)S / (double)N; if (accept_contact->cp_explicit) { if (accept_contact->cp_require) goto drop; else score = 0.0; } } else if (!error) { score = 0.0; }
1 | if Contact matches |
return_N contains number of feature tags in Accept-Contact
0 | if Contact does not match |
sip_contact_t* sip_contact_immunize | ( | su_home_t * | home, | |
sip_contact_t const * | m | |||
) |
Immunize Contact to callerprefs.
Make a copy of Contact header m and remove all parameters which affect caller preferences.
home | home object used when allocating copy | |
m | pointer to Contact header structure to immunize |
pointer | to immunized copy if successful | |
NULL | upon an error |
int sip_contact_is_immune | ( | sip_contact_t const * | m | ) |
Check if Contact is immune to callerprefs.
int sip_contact_reject | ( | sip_contact_t const * | m, | |
sip_reject_contact_t const * | reject | |||
) |
Check if Contact is rejected by Reject-Contact.
m | pointer to Contact header | |
reject | pointer to Reject-Contact header |
1 | when rejecting | |
0 | when Contact does not match with Reject-Contact |
int sip_contact_score | ( | sip_contact_t const * | m, | |
sip_accept_contact_t const * | ac, | |||
sip_reject_contact_t const * | rc | |||
) |
Calculate score for contact.
The caller preference score is an integer in range of 0 to 1000.
-1 | if the contact is rejected | |
1000 | if contact is immune to caller preferences | |
0..1000 | reflecting RFC 3481 score in 0.000 - 1.000. |
int sip_is_callerpref | ( | char const * | param | ) |
Check if the parameter is a valid feature tag.
A feature tag is a parameter starting with a single plus, or a well-known feature tag listed in RFC 3841: "audio", "automata", "application", "class", "control", "duplex", "data", "description", "events", "isfocus", "language", "mobility", "methods", "priority", "schemes", "type", or "video". However, well-known feature tag can not start with plus. So, "+alarm" or "audio" is a feature tag, "alarm", "++alarm", or "+audio" are not.
1 | if string is a feature tag parameter | |
0 | otherwise |
int sip_prefs_matching | ( | char const * | pvalue, | |
char const * | nvalue, | |||
int * | return_parse_error | |||
) |
Check callerprefs.
Check if the given feature values match with each other.
pvalue | first feature parameter | |
nvalue | second feature parameter | |
return_parse_error | return-value parameter for error (may be NULL) |
1 | if given feature parameters match | |
0 | if there is no match or a parse or type error occurred. |