#include <string.h>
#include "../../mem/shm_mem.h"
#include "../../dprint.h"
#include "../../parser/contact/parse_contact.h"
#include "../../parser/parse_to.h"
#include "../../parser/parse_from.h"
#include "../../parser/parse_uri.h"
#include "../../trim.h"
#include "../../ut.h"
#include "../../config.h"
#include "dlg.h"
#include "t_reply.h"
#include "../../parser/parser_f.h"

Go to the source code of this file.
Defines | |
| #define | NORMAL_ORDER 0 |
| #define | REVERSE_ORDER 1 |
| #define | ROUTE_PREFIX "Route: " |
| #define | ROUTE_PREFIX_LEN (sizeof(ROUTE_PREFIX) - 1) |
| #define | ROUTE_SEPARATOR "," CRLF " " |
| #define | ROUTE_SEPARATOR_LEN (sizeof(ROUTE_SEPARATOR) - 1) |
Functions | |
| static int | calculate_hooks (dlg_t *_d) |
| Calculate dialog hooks. | |
| int | calculate_routeset_length (dlg_t *_d) |
| Calculate length of the route set. | |
| int | dlg_add_extra (dlg_t *_d, str *_ldname, str *_rdname) |
| Store display names into a dialog. | |
| static int | dlg_confirmed_resp_uac (dlg_t *_d, struct sip_msg *_m) |
| Handle dialog in DLG_CONFIRMED state. | |
| static int | dlg_early_resp_uac (dlg_t *_d, struct sip_msg *_m) |
| Handle dialog in DLG_EARLY state. | |
| static int | dlg_new_resp_uac (dlg_t *_d, struct sip_msg *_m) |
| Handle dialog in DLG_NEW state. | |
| int | dlg_request_uas (dlg_t *_d, struct sip_msg *_m) |
| UAS side - update a dialog from a request. | |
| int | dlg_response_uac (dlg_t *_d, struct sip_msg *_m) |
| A response arrived, update dialog. | |
| void | free_dlg (dlg_t *_d) |
| Destroy a dialog state. | |
| static int | get_callid (struct sip_msg *_m, str *_cid) |
| Extract Call-ID value. | |
| static int | get_contact_uri (struct sip_msg *_m, str *_uri) |
| Parse Contact header field body and extract URI. | |
| static int | get_cseq_method (struct sip_msg *_m, str *_method) |
| Extract method from CSeq header field. | |
| static int | get_cseq_value (struct sip_msg *_m, unsigned int *_cs) |
| Get CSeq number. | |
| static int | get_dlg_uri (struct hdr_field *_h, str *_s) |
| Copy To or From URI without tag parameter. | |
| static int | get_from_tag (struct sip_msg *_m, str *_tag) |
| Extract tag from From header field of a request. | |
| void | get_raw_uri (str *_s) |
| This function skips a name part in a URI. | |
| static int | get_route_set (struct sip_msg *_m, rr_t **_rs, unsigned char _order) |
| Create a copy of route set either in normal or reverse order. | |
| static int | get_to_tag (struct sip_msg *_m, str *_tag) |
| Extract tag from To header field of a response. | |
| int | new_dlg_uac (str *_cid, str *_ltag, unsigned int _lseq, str *_luri, str *_ruri, dlg_t **_d) |
| Create a new dialog. | |
| int | new_dlg_uas (struct sip_msg *_req, int _code, dlg_t **_d) |
| Establishing a new dialog from the UAS side. | |
| void | print_dlg (FILE *out, dlg_t *_d) |
| Print a dialog structure, just for debugging. | |
| char * | print_routeset (char *buf, dlg_t *_d) |
| Print the route set. | |
| static int | request2dlg (struct sip_msg *_m, dlg_t *_d) |
| Extract all information from request and update dialog structure. | |
| static int | response2dlg (struct sip_msg *_m, dlg_t *_d) |
| Extract necessary information from response and insert it into dialog. | |
| int | w_calculate_hooks (dlg_t *_d) |
| Small wrapper to calculate_hooks. | |
Definition in file dlg.c.
| #define NORMAL_ORDER 0 |
Create route set in normal order - UAS
Definition at line 54 of file dlg.c.
Referenced by get_route_set(), and request2dlg().
| #define REVERSE_ORDER 1 |
Create route set in reverse order - UAC
Definition at line 55 of file dlg.c.
Referenced by response2dlg().
| #define ROUTE_SEPARATOR "," CRLF " " |
| #define ROUTE_SEPARATOR_LEN (sizeof(ROUTE_SEPARATOR) - 1) |
Definition at line 61 of file dlg.c.
Referenced by calc_routeset_len(), calculate_routeset_length(), print_routeset(), and print_rs().
| static int calculate_hooks | ( | dlg_t * | _d | ) | [inline, static] |
Calculate dialog hooks.
| _d | dialog state |
Definition at line 92 of file dlg.c.
References dlg_hooks::first_route, get_raw_uri(), dlg::hooks, dlg_hooks::last_route, _str::len, LM_ERR, sip_uri::lr, rr::nameaddr, rr::next, dlg_hooks::next_hop, dlg_hooks::nh, NULL, parse_uri(), dlg::rem_target, dlg::rem_uri, dlg_hooks::request_uri, dlg::route_set, dlg_hooks::ru, _str::s, and name_addr::uri.
| int calculate_routeset_length | ( | dlg_t * | _d | ) |
Calculate length of the route set.
| _d | dialog set |
Definition at line 896 of file dlg.c.
References CRLF_LEN, dlg_hooks::first_route, dlg::hooks, dlg_hooks::last_route, _str::len, rr::len, len, rr::next, ROUTE_PREFIX_LEN, and ROUTE_SEPARATOR_LEN.
Referenced by build_uac_req().
Store display names into a dialog.
| _d | dialog state | |
| _ldname | local display name | |
| _rdname | remote display name |
Definition at line 211 of file dlg.c.
References LM_ERR, dlg::loc_dname, dlg::rem_dname, and shm_str_dup().
Referenced by load_tm().
Handle dialog in DLG_CONFIRMED state.
Handle dialog in DLG_CONFIRMED state, we will be processing a response to a request sent within a dialog.
| _d | dialog state | |
| _m | SIP message |
Definition at line 546 of file dlg.c.
References DLG_DESTROYED, sip_msg::first_line, get_contact_uri(), get_cseq_method(), HDR_CONTACT_F, _str::len, LM_ERR, parse_headers(), dlg::rem_target, msg_start::reply, _str::s, shm_free, shm_str_dup(), dlg::state, and msg_start::u.
Referenced by dlg_response_uac().
Handle dialog in DLG_EARLY state.
Handle dialog in DLG_EARLY state we will be processing either next provisional response or a final response.
| _d | dialog state | |
| _m | SIP message |
Definition at line 487 of file dlg.c.
References calculate_hooks(), DLG_CONFIRMED, DLG_DESTROYED, sip_msg::first_line, LM_ERR, msg_start::reply, response2dlg(), dlg::state, and msg_start::u.
Referenced by dlg_response_uac().
Handle dialog in DLG_NEW state.
Handle dialog in DLG_NEW state, we will be processing the first response
| _d | dialog state | |
| _m | SIP message |
Definition at line 432 of file dlg.c.
References calculate_hooks(), DLG_CONFIRMED, DLG_DESTROYED, sip_msg::first_line, LM_ERR, msg_start::reply, response2dlg(), dlg::state, and msg_start::u.
Referenced by dlg_response_uac().
UAS side - update a dialog from a request.
| _d | dialog state | |
| _m | SIP request |
Definition at line 846 of file dlg.c.
References sip_msg::first_line, get_contact_uri(), get_cseq_value(), HDR_CONTACT_F, HDR_CSEQ_F, dlg_seq::is_set, _str::len, LM_ERR, METHOD_INVITE, parse_headers(), dlg::rem_seq, dlg::rem_target, msg_start::request, _str::s, shm_free, shm_str_dup(), msg_start::u, and dlg_seq::value.
Referenced by load_tm().
A response arrived, update dialog.
| _d | dialog state | |
| _m | SIP message |
Definition at line 605 of file dlg.c.
References DLG_CONFIRMED, dlg_confirmed_resp_uac(), DLG_DESTROYED, DLG_EARLY, dlg_early_resp_uac(), DLG_NEW, dlg_new_resp_uac(), LM_ERR, and dlg::state.
Referenced by load_tm(), and mi_print_uris().
| void free_dlg | ( | dlg_t * | _d | ) |
Destroy a dialog state.
| _d | dialog state |
Definition at line 978 of file dlg.c.
References dlg_id::call_id, dlg::id, dlg::loc_dname, dlg_id::loc_tag, dlg::loc_uri, dlg::rem_dname, dlg_id::rem_tag, dlg::rem_target, dlg::rem_uri, dlg::route_set, _str::s, shm_free, and shm_free_rr().
Referenced by load_tm(), mi_print_uris(), new_dlg_uas(), and request().
Extract Call-ID value.
| _m | SIP message | |
| _cid | Callid |
Definition at line 317 of file dlg.c.
References hdr_field::body, sip_msg::callid, _str::len, LM_ERR, _str::s, and trim().
Parse Contact header field body and extract URI.
| _m | SIP message | |
| _uri | SIP URI |
Definition at line 235 of file dlg.c.
References sip_msg::contact, _str::len, LM_ERR, parse_contact(), hdr_field::parsed, _str::s, and contact::uri.
Extract method from CSeq header field.
| _m | SIP message | |
| _method | SIP method |
Definition at line 524 of file dlg.c.
References sip_msg::cseq, get_cseq, HDR_CSEQ_F, _str::len, LM_ERR, parse_headers(), and _str::s.
Referenced by dlg_confirmed_resp_uac().
| static int get_cseq_value | ( | struct sip_msg * | _m, | |
| unsigned int * | _cs | |||
| ) | [inline, static] |
Get CSeq number.
| _m | SIP message | |
| _cs | CSeq number |
Definition at line 640 of file dlg.c.
References sip_msg::cseq, get_cseq, _str::len, LM_ERR, _str::s, str2int(), and trim_leading().
Referenced by dlg_request_uas(), and request2dlg().
Copy To or From URI without tag parameter.
| _h | SIP header | |
| _s | target string |
Definition at line 667 of file dlg.c.
References hdr_field::body, to_body::body, _str::len, len, LM_ERR, to_param::next, to_body::param_lst, hdr_field::parsed, _str::s, shm_malloc(), TAG_PARAM, to_param::type, and to_param::value.
Referenced by request2dlg().
| void get_raw_uri | ( | str * | _s | ) |
This function skips a name part in a URI.
This function skips a name part in a URI. The URI parsed by parse_contact must be used (the URI must not contain any leading or trailing part and if angle bracket were used, right angle bracket must be the last character in the string)
| _s | URI, will be modified so it should be a temporary copy |
Definition at line 76 of file dlg.c.
References find_not_quoted(), _str::len, and _str::s.
| static int get_route_set | ( | struct sip_msg * | _m, | |
| rr_t ** | _rs, | |||
| unsigned char | _order | |||
| ) | [inline, static] |
Create a copy of route set either in normal or reverse order.
| _m | SIP message | |
| _rs | Route set | |
| _order | how to order the copy, set to NORMAL_ORDER for normal copy |
Definition at line 338 of file dlg.c.
References HDR_RECORDROUTE_T, LM_ERR, hdr_field::next, rr::next, NORMAL_ORDER, parse_rr(), hdr_field::parsed, sip_msg::record_route, shm_duplicate_rr(), shm_free_rr(), and hdr_field::type.
Referenced by request2dlg(), and response2dlg().
| int new_dlg_uac | ( | str * | _cid, | |
| str * | _ltag, | |||
| unsigned int | _lseq, | |||
| str * | _luri, | |||
| str * | _ruri, | |||
| dlg_t ** | _d | |||
| ) |
Create a new dialog.
| _cid | Callid | |
| _ltag | local tag (usually From tag) | |
| _lseq | local sequence (usually CSeq) | |
| _luri | local URI (usually From) | |
| _ruri | remote URI (usually To) | |
| _d | dialog state |
Definition at line 160 of file dlg.c.
References calculate_hooks(), dlg_id::call_id, dlg::id, dlg_seq::is_set, LM_ERR, dlg::loc_seq, dlg_id::loc_tag, dlg::loc_uri, dlg::rem_uri, shm_free, shm_malloc(), shm_str_dup(), and dlg_seq::value.
Referenced by load_tm(), req_outside(), and request().
Establishing a new dialog from the UAS side.
| _req | SIP request | |
| _code | request code | |
| _d | dialog state |
Definition at line 791 of file dlg.c.
References calc_crc_suffix(), calculate_hooks(), DLG_CONFIRMED, free_dlg(), dlg::id, _str::len, LM_DBG, LM_ERR, dlg_id::loc_tag, request2dlg(), _str::s, shm_free, shm_malloc(), shm_str_dup(), dlg::state, tm_tag_suffix, tm_tags, and TOTAG_VALUE_LEN.
Referenced by load_tm().
| void print_dlg | ( | FILE * | out, | |
| dlg_t * | _d | |||
| ) |
Print a dialog structure, just for debugging.
| out | file | |
| _d | dialog state |
Definition at line 1005 of file dlg.c.
References dlg_id::call_id, DLG_CONFIRMED, DLG_DESTROYED, DLG_EARLY, DLG_NEW, dlg_hooks::first_route, dlg::hooks, dlg::id, dlg_seq::is_set, dlg_hooks::last_route, rr::len, _str::len, dlg::loc_dname, dlg::loc_seq, dlg_id::loc_tag, dlg::loc_uri, name_addr::name, rr::nameaddr, dlg_hooks::next_hop, print_rr(), dlg::rem_dname, dlg::rem_seq, dlg_id::rem_tag, dlg::rem_target, dlg::rem_uri, dlg_hooks::request_uri, dlg::route_set, _str::s, dlg::state, and dlg_seq::value.
Referenced by load_tm().
| char* print_routeset | ( | char * | buf, | |
| dlg_t * | _d | |||
| ) |
Print the route set.
| buf | buffer | |
| _d | dialog state |
Definition at line 930 of file dlg.c.
References CRLF, CRLF_LEN, dlg_hooks::first_route, dlg::hooks, dlg_hooks::last_route, _str::len, rr::len, name_addr::name, rr::nameaddr, rr::next, ROUTE_PREFIX, ROUTE_PREFIX_LEN, ROUTE_SEPARATOR, ROUTE_SEPARATOR_LEN, and _str::s.
Referenced by build_uac_req().
Extract all information from request and update dialog structure.
| _m | SIP message | |
| _d | dialog state |
Definition at line 733 of file dlg.c.
References dlg_id::call_id, sip_msg::from, get_callid(), get_contact_uri(), get_cseq_value(), get_dlg_uri(), get_from_tag(), get_route_set(), HDR_EOH_F, dlg::id, dlg_seq::is_set, _str::len, LM_ERR, dlg::loc_uri, NORMAL_ORDER, parse_headers(), dlg::rem_seq, dlg_id::rem_tag, dlg::rem_target, dlg::rem_uri, dlg::route_set, _str::s, shm_free, shm_str_dup(), sip_msg::to, and dlg_seq::value.
Referenced by new_dlg_uas().
Extract necessary information from response and insert it into dialog.
Extract all necessary information from a response and put it in a dialog structure
| _m | SIP message | |
| _d | dialog state |
Definition at line 392 of file dlg.c.
References get_contact_uri(), get_route_set(), get_to_tag(), HDR_EOH_F, dlg::id, _str::len, LM_ERR, parse_headers(), dlg_id::rem_tag, dlg::rem_target, REVERSE_ORDER, dlg::route_set, _str::s, shm_free, and shm_str_dup().
Referenced by dlg_early_resp_uac(), and dlg_new_resp_uac().
| int w_calculate_hooks | ( | dlg_t * | _d | ) |
1.5.6