msg_parser.h File Reference

SIP message parser. More...

#include "../str.h"
#include "../lump_struct.h"
#include "../flags.h"
#include "../ip_addr.h"
#include "../md5utils.h"
#include "../config.h"
#include "parse_def.h"
#include "parse_cseq.h"
#include "parse_via.h"
#include "parse_fline.h"
#include "hf.h"
#include "sdp/sdp.h"
#include "parse_to.h"

Include dependency graph for msg_parser.h:

Go to the source code of this file.

Data Structures

struct  sip_msg
struct  sip_uri

Defines

#define FAKED_REPLY   ((struct sip_msg *) -1)
#define FL_DO_KEEPALIVE   (1<<10)
#define FL_FORCE_ACTIVE   (1<<1)
#define FL_FORCE_LOCAL_RPORT   (1<<2)
#define FL_FORCE_RPORT   (1<<0)
#define FL_REQ_UPSTREAM   (1<<9)
#define FL_SDP_IP_AFS   (1<<3)
#define FL_SDP_PORT_AFS   (1<<4)
#define FL_SHM_CLONE   (1<<5)
#define FL_USE_MEDIA_PROXY   (1<<11)
#define FL_USE_UAC_CSEQ   (1<<8)
#define FL_USE_UAC_FROM   (1<<6)
#define FL_USE_UAC_TO   (1<<7)
#define GET_NEXT_HOP(m)
#define GET_RURI(m)   (((m)->new_uri.s && (m)->new_uri.len) ? (&(m)->new_uri) : (&(m)->first_line.u.request.uri))
#define IFISMETHOD(methodname, firstchar)
#define REPLY_CLASS(_reply)   ((_reply)->REPLY_STATUS/100)
#define REPLY_STATUS   first_line.u.reply.statuscode
#define REQ_LINE(_msg)   ((_msg)->first_line.u.request)
#define REQ_METHOD   first_line.u.request.method_value

Typedefs

typedef enum _uri_type uri_type

Enumerations

enum  _uri_type {
  ERROR_URI_T = 0, SIP_URI_T, SIPS_URI_T, TEL_URI_T,
  TELS_URI_T
}
enum  request_method {
  METHOD_UNDEF = 0, METHOD_INVITE = 1, METHOD_CANCEL = 2, METHOD_ACK = 4,
  METHOD_BYE = 8, METHOD_INFO = 16, METHOD_OPTIONS = 32, METHOD_UPDATE = 64,
  METHOD_REGISTER = 128, METHOD_MESSAGE = 256, METHOD_SUBSCRIBE = 512, METHOD_NOTIFY = 1024,
  METHOD_PRACK = 2048, METHOD_REFER = 4096, METHOD_PUBLISH = 8192, METHOD_OTHER = 16384
}

Functions

static int char_msg_val (struct sip_msg *msg, char *cv)
int check_transaction_quadruple (struct sip_msg *msg)
void free_sip_msg (struct sip_msg *msg)
static char * get_body (struct sip_msg *msg)
char * get_hdr_field (char *buf, char *end, struct hdr_field *hdr)
int parse_headers (struct sip_msg *msg, hdr_flags_t flags, int next)
int parse_msg (char *buf, unsigned int len, struct sip_msg *msg)
int set_dst_uri (struct sip_msg *msg, str *uri)
int set_path_vector (struct sip_msg *msg, str *path)

Variables

int via_cnt


Detailed Description

SIP message parser.

Definition in file msg_parser.h.


Define Documentation

#define FAKED_REPLY   ((struct sip_msg *) -1)

#define FL_DO_KEEPALIVE   (1<<10)

keepalive request's source after a positive reply

Definition at line 99 of file msg_parser.h.

Referenced by __dialog_created(), __sl_reply_out(), and NAT_Keepalive().

#define FL_FORCE_ACTIVE   (1<<1)

force active SDP

Definition at line 90 of file msg_parser.h.

Referenced by fix_nated_sdp_f().

#define FL_FORCE_LOCAL_RPORT   (1<<2)

force local rport (local via)

Definition at line 91 of file msg_parser.h.

Referenced by build_req_buf_from_sip_req(), and do_action().

#define FL_FORCE_RPORT   (1<<0)

force rport (top via)

Definition at line 89 of file msg_parser.h.

Referenced by build_req_buf_from_sip_req(), build_res_buf_from_sip_req(), do_action(), and update_sock_struct_from_via().

#define FL_REQ_UPSTREAM   (1<<9)

it's an upstream going request

Definition at line 98 of file msg_parser.h.

Referenced by acc_onreq(), and core2strar().

#define FL_SDP_IP_AFS   (1<<3)

SDP IP rewritten

Definition at line 92 of file msg_parser.h.

#define FL_SDP_PORT_AFS   (1<<4)

SDP port rewritten

Definition at line 93 of file msg_parser.h.

Referenced by alter_mediaport().

#define FL_SHM_CLONE   (1<<5)

msg cloned in SHM as a single chunk

Definition at line 94 of file msg_parser.h.

Referenced by free_cell(), run_trans_callbacks(), shmcontact2dset(), and sip_msg_cloner().

#define FL_USE_MEDIA_PROXY   (1<<11)

use mediaproxy on all messages during a dialog

Definition at line 101 of file msg_parser.h.

Referenced by __dialog_created(), and EngageMediaProxy().

#define FL_USE_UAC_CSEQ   (1<<8)

take CSEQ hdr from UAC insteas of UAS

Definition at line 97 of file msg_parser.h.

Referenced by build_local(), and check_hdrs_changes().

#define FL_USE_UAC_FROM   (1<<6)

take FROM hdr from UAC insteas of UAS

Definition at line 95 of file msg_parser.h.

Referenced by build_local(), check_hdrs_changes(), replace_from(), and restore_from().

#define FL_USE_UAC_TO   (1<<7)

take TO hdr from UAC insteas of UAS

Definition at line 96 of file msg_parser.h.

Referenced by build_local(), check_hdrs_changes(), and restore_from().

#define GET_NEXT_HOP (  ) 

Value:

(((m)->dst_uri.s && (m)->dst_uri.len) ? (&(m)->dst_uri) : \
(((m)->new_uri.s && (m)->new_uri.len) ? (&(m)->new_uri) : (&(m)->first_line.u.request.uri)))
Return a URI to which the message should be really sent (not what should be in the Request URI. The following fields are tried in this order: 1) dst_uri 2) new_uri 3) first_line.u.request.uri

Definition at line 122 of file msg_parser.h.

Referenced by t_relay_to().

#define GET_RURI (  )     (((m)->new_uri.s && (m)->new_uri.len) ? (&(m)->new_uri) : (&(m)->first_line.u.request.uri))

Return the Reqeust URI of a message. The following fields are tried in this order: 1) new_uri 2) first_line.u.request.uri

Definition at line 133 of file msg_parser.h.

Referenced by ac_sl_msg(), add_uri_param(), assemble_msg(), decode_contact_header(), diameter_is_user_in(), ds_hash_ruri(), radius_authorize_sterman(), run_address_switch(), run_proxy(), t_forward_nonack(), t_load_contacts(), t_relay_to(), t_replicate(), and tel2sip().

#define IFISMETHOD ( methodname,
firstchar   ) 

Definition at line 104 of file msg_parser.h.

Referenced by parse_first_line().

#define REPLY_CLASS ( _reply   )     ((_reply)->REPLY_STATUS/100)

Definition at line 67 of file msg_parser.h.

#define REPLY_STATUS   first_line.u.reply.statuscode

Definition at line 66 of file msg_parser.h.

#define REQ_LINE ( _msg   )     ((_msg)->first_line.u.request)

#define REQ_METHOD   first_line.u.request.method_value

Definition at line 65 of file msg_parser.h.


Typedef Documentation

typedef enum _uri_type uri_type

Definition at line 138 of file msg_parser.h.


Enumeration Type Documentation

enum _uri_type

Enumerator:
ERROR_URI_T 
SIP_URI_T 
SIPS_URI_T 
TEL_URI_T 
TELS_URI_T 

Definition at line 137 of file msg_parser.h.

Enumerator:
METHOD_UNDEF 
METHOD_INVITE 
METHOD_CANCEL 
METHOD_ACK 
METHOD_BYE 
METHOD_INFO 
METHOD_OPTIONS 
METHOD_UPDATE 
METHOD_REGISTER 
METHOD_MESSAGE 
METHOD_SUBSCRIBE 
METHOD_NOTIFY 
METHOD_PRACK 
METHOD_REFER 
METHOD_PUBLISH 
METHOD_OTHER 

Definition at line 70 of file msg_parser.h.


Function Documentation

static int char_msg_val ( struct sip_msg msg,
char *  cv 
) [inline, static]

calculate characteristic value of a message -- this value is used to identify a transaction during the process of reply matching

Definition at line 307 of file msg_parser.h.

References hdr_field::body, via_body::branch, sip_msg::callid, check_transaction_quadruple(), sip_msg::first_line, sip_msg::from, get_cseq, via_body::host, LM_ERR, MD5_LEN, MD5StringArray(), via_body::port_str, msg_start::request, sip_msg::to, msg_start::u, via_param::value, and sip_msg::via1.

Referenced by append_fixed_vars(), and init_synonym_id().

int check_transaction_quadruple ( struct sip_msg msg  ) 

make sure all HFs needed for transaction identification have been parsed; return 0 if those HFs can't be found

Definition at line 680 of file msg_parser.c.

References sip_msg::callid, sip_msg::cseq, E_BAD_TUPEL, sip_msg::from, HDR_CALLID_F, HDR_CSEQ_F, HDR_FROM_F, HDR_TO_F, parse_headers(), ser_error, and sip_msg::to.

Referenced by ac_uac_req(), char_msg_val(), t_check_trans(), and t_lookup_request().

void free_sip_msg ( struct sip_msg msg  ) 

static char* get_body ( struct sip_msg msg  )  [inline, static]

char* get_hdr_field ( char *  buf,
char *  end,
struct hdr_field hdr 
)

int parse_headers ( struct sip_msg msg,
hdr_flags_t  flags,
int  next 
)

parse the headers and adds them to msg->headers and msg->to, from etc. It stops when all the headers requested in flags were parsed, on error (bad header) or end of headers

Note:
: it continues where it previously stopped and goes ahead until end is encountered or desired HFs are found; if you call it twice for the same HF which is present only once, it will fail the second time; if you call it twice and the HF is found on second time too, it's not replaced in the well-known HF pointer but just added to header list; if you want to use a dumb convenience function which will give you the first occurrence of a header you are interested in, look at check_transaction_quadruple

Definition at line 287 of file msg_parser.c.

References allow, hdr_field::body, sip_msg::buf, sip_msg::callid, sip_msg::content_disposition, sip_msg::content_length, sip_msg::content_type, sip_msg::cseq, E_BAD_REQ, E_OUT_OF_MEM, sip_msg::eoh, sip_msg::expires, sip_msg::from, get_hdr_field(), sip_msg::h_via1, sip_msg::h_via2, HDR_ACCEPT_F, HDR_ACCEPT_T, HDR_ACCEPTDISPOSITION_F, HDR_ACCEPTDISPOSITION_T, HDR_ACCEPTLANGUAGE_F, HDR_ACCEPTLANGUAGE_T, HDR_ALLOW_F, HDR_ALLOW_T, HDR_AUTHORIZATION_F, HDR_AUTHORIZATION_T, HDR_CALLID_F, HDR_CALLID_T, HDR_CONTACT_F, HDR_CONTACT_T, HDR_CONTENTDISPOSITION_F, HDR_CONTENTDISPOSITION_T, HDR_CONTENTLENGTH_F, HDR_CONTENTLENGTH_T, HDR_CONTENTTYPE_F, HDR_CONTENTTYPE_T, HDR_CSEQ_F, HDR_CSEQ_T, HDR_DIVERSION_F, HDR_DIVERSION_T, HDR_EOH_F, HDR_EOH_T, HDR_ERROR_T, HDR_EVENT_F, HDR_EVENT_T, HDR_EXPIRES_F, HDR_EXPIRES_T, HDR_FROM_F, HDR_FROM_T, HDR_MAXFORWARDS_F, HDR_MAXFORWARDS_T, HDR_MIN_SE_F, HDR_MIN_SE_T, HDR_ORGANIZATION_F, HDR_ORGANIZATION_T, HDR_OTHER_T, HDR_PAI_F, HDR_PAI_T, HDR_PATH_F, HDR_PATH_T, HDR_PPI_F, HDR_PPI_T, HDR_PRIORITY_F, HDR_PRIORITY_T, HDR_PRIVACY_F, HDR_PRIVACY_T, HDR_PROXYAUTH_F, HDR_PROXYAUTH_T, HDR_PROXYREQUIRE_F, HDR_PROXYREQUIRE_T, HDR_RECORDROUTE_F, HDR_RECORDROUTE_T, HDR_REFER_TO_F, HDR_REFER_TO_T, HDR_RETRY_AFTER_T, HDR_ROUTE_F, HDR_ROUTE_T, HDR_RPID_F, HDR_RPID_T, HDR_SESSION_EXPIRES_F, HDR_SESSION_EXPIRES_T, HDR_SUBJECT_F, HDR_SUBJECT_T, HDR_SUPPORTED_F, HDR_SUPPORTED_T, HDR_TO_F, HDR_TO_T, HDR_UNSUPPORTED_F, HDR_UNSUPPORTED_T, HDR_USERAGENT_F, HDR_USERAGENT_T, HDR_VIA2_F, HDR_VIA_F, HDR_VIA_T, sip_msg::headers, sip_msg::last_header, _str::len, sip_msg::len, link_sibling_hdr, LM_CRIT, LM_DBG, LM_ERR, LM_INFO, sip_msg::maxforwards, sip_msg::min_se, hdr_field::name, hdr_field::next, via_body::next, sip_msg::organization, sip_msg::pai, hdr_field::parsed, sip_msg::parsed_flag, pkg_free, pkg_malloc, sip_msg::ppi, sip_msg::priority, sip_msg::privacy, record_route(), sip_msg::refer_to, sip_msg::rpid, _str::s, ser_error, sip_msg::session_expires, sip_msg::subject, sip_msg::to, hdr_field::type, sip_msg::unparsed, sip_msg::user_agent, sip_msg::via1, sip_msg::via2, and ZSW.

Referenced by ac_cancel(), ac_uac_req(), acc_onreply_in(), acc_preparse_req(), add_cisco_vsa(), add_contacts_to_loc_set(), add_diversion_helper(), add_hf_helper(), add_sdp(), add_sock_hdr(), adjust_clen(), allow_uri(), append_header(), append_rpid_helper(), apply_urihdr_changes(), assemble_msg(), bla_handle_notify(), bla_set_flag(), build_path_vector(), build_res_buf_from_sip_req(), check_message_support(), check_register(), check_routing(), check_to(), check_transaction_quadruple(), cmd_send_message(), contact_iterator(), decode_contact_header(), decode_msg(), dlg_bridge_tm_callback(), dlg_confirmed_resp_uac(), dlg_new_dialog(), dlg_onreply(), dlg_onroute(), dlg_request_uas(), do_load_gws(), do_script_action(), ds_hash_authusername(), ds_hash_callid(), ds_hash_touri(), encode_contact(), encode_msg(), eval_elem(), extract_parsed_hdrs(), find_credentials(), find_first_route(), find_next_route(), find_rem_target(), forward_reply(), func_handle_publish(), func_handle_subscribe(), func_send_message(), get_autenticate_hdr(), get_body(), get_callid(), get_contact_uri(), get_cseq_method(), get_cseq_number(), get_dest_user(), get_expires(), get_realm(), get_register_expire(), get_sl_branch(), get_sock_hdr(), get_source_uri(), get_to_uri(), get_uri(), get_user_agent(), handle_publish(), handle_subscribe(), has_body_f(), has_totag(), is_maxfwd_present(), is_method_f(), is_preloaded(), is_present_hf_f(), is_present_hf_re_f(), m_dump(), mi_tm_uac_dlg(), NAT_Keepalive(), Notify2Xmpp(), ospAppendHeader(), ospGetOspHeader(), ospGetToUserpart(), pack_ci(), parse_ac_msg(), parse_accept_hdr(), parse_allow(), parse_content_disposition(), parse_content_type_hdr(), parse_diversion_header(), parse_dlg(), parse_from_header(), parse_message(), parse_msg(), parse_pai_header(), parse_ppi_header(), parse_privacy(), parse_refer_to_header(), parse_rpid_header(), parse_supported(), patch_content_length(), pike_check_req(), populate_leg_info(), pre_match_parse(), prepend_path(), preprocess_request(), print_msg_info(), publ_cback_func(), push_on_network(), remove_header(), remove_hf_f(), remove_hf_re_f(), remove_sdp(), replace_from(), reply_received(), request2dlg(), response2dlg(), restore_from(), restore_to_reply(), ring_filter(), ring_insert_callid(), rls_handle_notify(), rls_handle_subscribe(), run_address_switch(), run_language_switch(), run_priority_switch(), run_proxy(), run_string_switch(), save_ruri(), send_ack(), set_env(), shmcontact2dset(), should_acc_reply(), sip_trace(), sipping_rpl_filter(), sl_filter_ACK(), sl_send_reply_helper(), sst_dialog_response_fwded_CB(), subs_cback_func(), t_check(), t_newtran(), t_reply_matching(), trace_onreply_in(), trace_onreply_out(), trace_onreq_in(), trace_onreq_out(), trace_sl_onreply_out(), unmatched_totag(), update_contact(), update_cseqs(), validate_msg(), verify_destination(), verify_source(), w_dlg_manage(), and xjab_manage_sipmsg().

int parse_msg ( char *  buf,
unsigned int  len,
struct sip_msg msg 
)

int set_dst_uri ( struct sip_msg msg,
str uri 
)

Make a private copy of the string and assign it to dst_uri

Definition at line 695 of file msg_parser.c.

References sip_msg::dst_uri, _str::len, LM_ERR, pkg_free, pkg_malloc, and _str::s.

Referenced by after_loose(), after_strict(), do_action(), dp_apply_policy(), ds_update_dst(), lookup(), ops_pushto_avp(), path_rr_callback(), t_next_contacts(), and t_replicate().

int set_path_vector ( struct sip_msg msg,
str path 
)

Make a private copy of the string and assign it to path_vec

Definition at line 725 of file msg_parser.c.

References _str::len, LM_ERR, sip_msg::path_vec, pkg_free, pkg_malloc, and _str::s.

Referenced by lookup(), pack_ci(), and t_next_contacts().


Variable Documentation

int via_cnt

number of via's encountered

Definition at line 74 of file msg_parser.c.

Referenced by get_hdr_field(), receive_msg(), and warning_builder().


Generated on Wed May 23 20:00:40 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6