|
Asterisk - The Open Source Telephony Project GIT-master-4f2b068
|
#include <pjsip.h>

Go to the source code of this file.
Macros | |
| #define | AST_SIP_MAX_REDIRECT_CONTACTS 20 |
| Maximum number of redirect contacts to process. | |
| #define | AST_SIP_MAX_REDIRECT_HOPS 5 |
| Maximum number of redirect hops allowed. | |
Functions | |
| int | ast_sip_redirect_check_loop (const struct ast_sip_redirect_state *state, const char *uri) |
| Check if a URI would create a redirect loop. | |
| struct ast_sip_endpoint * | ast_sip_redirect_get_endpoint (const struct ast_sip_redirect_state *state) |
| Get the endpoint from the redirect state. | |
| int | ast_sip_redirect_get_hop_count (const struct ast_sip_redirect_state *state) |
| Get the current hop count. | |
| int | ast_sip_redirect_get_next_uri (struct ast_sip_redirect_state *state, char **uri_out) |
| Get the next redirect URI to try. | |
| int | ast_sip_redirect_parse_3xx (pjsip_rx_data *rdata, struct ast_sip_redirect_state *state) |
| Parse a 3xx redirect response and extract contacts. | |
| struct ast_sip_redirect_state * | ast_sip_redirect_state_create (struct ast_sip_endpoint *endpoint, const char *initial_uri) |
| Create a new redirect state. | |
| void | ast_sip_redirect_state_destroy (struct ast_sip_redirect_state *state) |
| Destroy a redirect state and free all resources. | |
| int | ast_sip_should_redirect (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) |
| Check if redirect should be followed based on endpoint configuration. | |
| #define AST_SIP_MAX_REDIRECT_CONTACTS 20 |
Maximum number of redirect contacts to process.
Definition at line 32 of file res_pjsip_redirect.h.
| #define AST_SIP_MAX_REDIRECT_HOPS 5 |
Maximum number of redirect hops allowed.
Definition at line 27 of file res_pjsip_redirect.h.
| int ast_sip_redirect_check_loop | ( | const struct ast_sip_redirect_state * | state, |
| const char * | uri | ||
| ) |
Check if a URI would create a redirect loop.
| state | The redirect state |
| uri | The URI to check |
| 0 | if URI is safe (not visited) |
| 1 | if URI would create a loop (already visited) |
Definition at line 429 of file redirect.c.
References is_uri_visited(), and redirect_contact::uri.
| struct ast_sip_endpoint * ast_sip_redirect_get_endpoint | ( | const struct ast_sip_redirect_state * | state | ) |
Get the endpoint from the redirect state.
| state | The redirect state |
Definition at line 439 of file redirect.c.
Referenced by handle_message_redirect(), msg_response_callback(), and send_message_to_uri().
| int ast_sip_redirect_get_hop_count | ( | const struct ast_sip_redirect_state * | state | ) |
Get the current hop count.
| state | The redirect state |
Definition at line 434 of file redirect.c.
Referenced by handle_message_redirect(), and send_message_to_uri().
| int ast_sip_redirect_get_next_uri | ( | struct ast_sip_redirect_state * | state, |
| char ** | uri_out | ||
| ) |
Get the next redirect URI to try.
This function returns the next contact URI from the redirect response, ordered by q-value (highest first). It also marks the URI as visited to prevent loops on subsequent redirects.
| state | The redirect state |
| uri_out | Pointer to store the URI string (caller must free) |
| -1 | if no more URIs available |
| 0 | on success |
Definition at line 398 of file redirect.c.
References add_visited_uri(), ast_free, AST_LIST_REMOVE_HEAD, ast_log, ast_sorcery_object_get_id(), ast_strdup, redirect_contact::list, LOG_WARNING, and redirect_contact::uri.
Referenced by handle_message_redirect(), and msg_response_callback().
| int ast_sip_redirect_parse_3xx | ( | pjsip_rx_data * | rdata, |
| struct ast_sip_redirect_state * | state | ||
| ) |
Parse a 3xx redirect response and extract contacts.
This function parses all Contact headers from a 3xx response, extracts q-values, sorts contacts by priority (highest q-value first), and filters out URIs that would create loops.
| rdata | The redirect response data |
| state | The redirect state |
| -1 | on failure (hop limit reached, no valid contacts, etc.) |
| 0 | on success (at least one valid contact available) |
Definition at line 338 of file redirect.c.
References ast_debug, ast_free, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_SIP_MAX_REDIRECT_HOPS, ast_sip_should_redirect(), ast_sorcery_object_get_id(), is_uri_visited(), redirect_contact::list, LOG_WARNING, parse_redirect_contacts(), and redirect_contact::uri.
Referenced by handle_message_redirect().
| struct ast_sip_redirect_state * ast_sip_redirect_state_create | ( | struct ast_sip_endpoint * | endpoint, |
| const char * | initial_uri | ||
| ) |
Create a new redirect state.
| endpoint | The SIP endpoint |
| initial_uri | The initial URI being contacted (for loop detection) |
| NULL | on failure |
| A | new redirect state on success |
Definition at line 59 of file redirect.c.
References ao2_bump, ast_calloc, ast_copy_string(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_HEAD, ast_log, ast_sorcery_object_get_id(), visited_uri::list, LOG_WARNING, NULL, and visited_uri::uri.
Referenced by message_response_data_create().
| void ast_sip_redirect_state_destroy | ( | struct ast_sip_redirect_state * | state | ) |
Destroy a redirect state and free all resources.
| state | The redirect state to destroy |
Definition at line 444 of file redirect.c.
References ao2_cleanup, ast_free, AST_LIST_REMOVE_HEAD, and redirect_contact::list.
Referenced by message_response_data_destroy().
| int ast_sip_should_redirect | ( | struct ast_sip_endpoint * | endpoint, |
| pjsip_rx_data * | rdata | ||
| ) |
Check if redirect should be followed based on endpoint configuration.
| endpoint | The SIP endpoint |
| rdata | The redirect response data containing the 3xx response |
| 0 | if redirect should not be followed |
| 1 | if redirect should be followed |
Definition at line 140 of file redirect.c.
References ast_log, ast_sorcery_object_get_id(), LOG_WARNING, and method_allowed_for_redirect().
Referenced by ast_sip_redirect_parse_3xx().