record.c File Reference

Route & Record-Route module, loose routing support. More...

#include <string.h>
#include "../../mem/mem.h"
#include "../../dprint.h"
#include "../../parser/parse_uri.h"
#include "../../parser/parse_from.h"
#include "../../str.h"
#include "../../data_lump.h"
#include "record.h"
#include "rr_mod.h"

Include dependency graph for record.c:

Go to the source code of this file.

Defines

#define INBOUND   1
#define OUTBOUND   0
#define RR_FROMTAG   ";ftag="
#define RR_FROMTAG_LEN   (sizeof(RR_FROMTAG)-1)
#define RR_LR   ";lr"
#define RR_LR_FULL   ";lr=on"
#define RR_LR_FULL_LEN   (sizeof(RR_LR_FULL)-1)
#define RR_LR_LEN   (sizeof(RR_LR)-1)
#define RR_PARAM_BUF_SIZE   512
#define RR_PREFIX   "Record-Route: <sip:"
#define RR_PREFIX_LEN   (sizeof(RR_PREFIX)-1)
#define RR_R2   ";r2=on"
#define RR_R2_LEN   (sizeof(RR_R2)-1)
#define RR_TERM   ">"CRLF
#define RR_TERM_LEN   (sizeof(RR_TERM)-1)

Functions

int add_rr_param (struct sip_msg *msg, str *rr_param)
 Appends a new Record-Route parameter.
static int build_rr (struct lump *_l, struct lump *_l2, str *user, str *tag, str *params, int _inbound)
 Build a Record-Route header field.
static struct lumpget_rr_param_lump (struct lump **root)
 Get the RR parameter lump.
static int get_username (struct sip_msg *_m, str *_user)
 Extract username from the Request URI.
static struct lumpinsert_rr_param_lump (struct lump *before, char *s, int l)
 Insert RR parameter lump in new allocated private memory.
int record_route (struct sip_msg *_m, str *params)
 Insert a new Record-Route header field with lr parameter.
int record_route_preset (struct sip_msg *_m, str *_data)
 Insert manually created Record-Route header.

Variables

static str rr_param_buf = {rr_param_buf_ptr,0}
static char rr_param_buf_ptr [RR_PARAM_BUF_SIZE]
 RR param buffer.
static unsigned int rr_param_msg


Detailed Description

Route & Record-Route module, loose routing support.

Definition in file record.c.


Define Documentation

#define INBOUND   1

Insert inbound Record-Route

Definition at line 64 of file record.c.

Referenced by record_route().

#define OUTBOUND   0

Insert outbound Record-Route

Definition at line 65 of file record.c.

Referenced by record_route().

#define RR_FROMTAG   ";ftag="

Definition at line 55 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_FROMTAG_LEN   (sizeof(RR_FROMTAG)-1)

Definition at line 56 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_LR   ";lr"

Definition at line 49 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_LR_FULL   ";lr=on"

Definition at line 52 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_LR_FULL_LEN   (sizeof(RR_LR_FULL)-1)

Definition at line 53 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_LR_LEN   (sizeof(RR_LR)-1)

Definition at line 50 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_PARAM_BUF_SIZE   512

buffer for RR parameter

Definition at line 67 of file record.c.

Referenced by add_rr_param().

#define RR_PREFIX   "Record-Route: <sip:"

Definition at line 46 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_PREFIX_LEN   (sizeof(RR_PREFIX)-1)

Definition at line 47 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_R2   ";r2=on"

Definition at line 58 of file record.c.

Referenced by build_rr().

#define RR_R2_LEN   (sizeof(RR_R2)-1)

Definition at line 59 of file record.c.

Referenced by build_rr().

#define RR_TERM   ">"CRLF

Definition at line 61 of file record.c.

Referenced by build_rr(), and record_route_preset().

#define RR_TERM_LEN   (sizeof(RR_TERM)-1)

Definition at line 62 of file record.c.

Referenced by build_rr(), and record_route_preset().


Function Documentation

int add_rr_param ( struct sip_msg msg,
str rr_param 
)

Appends a new Record-Route parameter.

Parameters:
msg SIP message
rr_param RR parameter
Returns:
0 on success, -1 on failure

Definition at line 482 of file record.c.

References sip_msg::add_rm, enable_double_rr, get_rr_param_lump(), sip_msg::id, insert_rr_param_lump(), _str::len, LM_CRIT, LM_DBG, LM_ERR, root, RR_PARAM_BUF_SIZE, rr_param_msg, and _str::s.

Referenced by load_rr(), and w_add_rr_param().

static int build_rr ( struct lump _l,
struct lump _l2,
str user,
str tag,
str params,
int  _inbound 
) [inline, static]

Build a Record-Route header field.

Build a Record-Route header field, allocates new private memory for this.

Parameters:
_l first lump
_l2 second lump
tag tag parameter
params parameter
_inbound inbound request
Returns:
0 on success, negative on failure

Definition at line 159 of file record.c.

References COND_IF_DIFF_REALMS, enable_double_rr, enable_full_lr, HDR_RECORDROUTE_T, insert_cond_lump_after(), insert_new_lump_after(), insert_new_lump_before(), insert_rr_param_lump(), insert_subst_lump_after(), _str::len, LM_ERR, pkg_free, pkg_malloc, prefix, RR_FROMTAG, RR_FROMTAG_LEN, RR_LR, RR_LR_FULL, RR_LR_FULL_LEN, RR_LR_LEN, RR_PREFIX, RR_PREFIX_LEN, RR_R2, RR_R2_LEN, RR_TERM, RR_TERM_LEN, _str::s, SUBST_RCV_ALL, SUBST_SND_ALL, and suffix.

Referenced by record_route().

static struct lump* get_rr_param_lump ( struct lump **  root  )  [static, read]

Get the RR parameter lump.

Parameters:
root root of the lump list
Returns:
pointer to the RR parameter lump, or NULL if not found

Definition at line 457 of file record.c.

References lump::before, HDR_RECORDROUTE_T, LUMP_ADD, lump::next, lump::op, and lump::type.

Referenced by add_rr_param().

static int get_username ( struct sip_msg _m,
str _user 
) [inline, static]

Extract username from the Request URI.

Extract username from the Request URI. First try to look at the original Request URI and if there is no username use the new Request URI.

Parameters:
_m SIP message
_user username
Returns:
0 on success, negative on errors

Definition at line 88 of file record.c.

References sip_msg::first_line, _str::len, LM_ERR, sip_msg::new_uri, parse_uri(), msg_start::request, _str::s, msg_start::u, and sip_uri::user.

Referenced by record_route(), and record_route_preset().

static struct lump* insert_rr_param_lump ( struct lump before,
char *  s,
int  l 
) [static, read]

Insert RR parameter lump in new allocated private memory.

Parameters:
before lump list
s parameter string
l parameter string length
Returns:
pointer to new lump on success, NULL on failure

Definition at line 123 of file record.c.

References HDR_RECORDROUTE_T, insert_new_lump_before(), LM_ERR, pkg_free, and pkg_malloc.

Referenced by add_rr_param(), and build_rr().

int record_route ( struct sip_msg _m,
str params 
)

Insert a new Record-Route header field with lr parameter.

Insert a new Record-Route header field and also 2nd one if it is enabled and the realm changed so the 2nd record-route header will be necessary.

Parameters:
_m SIP message
params RR parameter
Returns:
0 on success, negative on failure

Definition at line 277 of file record.c.

References add_username, anchor_lump(), append_fromtag, sip_msg::buf, build_rr(), COND_IF_DIFF_REALMS, enable_double_rr, sip_msg::from, get_username(), HDR_RECORDROUTE_T, sip_msg::headers, sip_msg::id, INBOUND, insert_cond_lump_after(), insert_cond_lump_before(), _str::len, LM_ERR, hdr_field::name, NULL, OUTBOUND, parse_from_header(), hdr_field::parsed, rr_param_msg, _str::s, to_body::tag_value, and user.

Referenced by assemble_msg(), db_restore(), get_database_info(), parse_headers(), sip_msg_cloner(), subs_cback_func(), and w_record_route().

int record_route_preset ( struct sip_msg _m,
str _data 
)

Insert manually created Record-Route header.

Insert manually created Record-Route header, no checks, no restrictions, always adds lr parameter, only fromtag is added automatically when requested. Allocates new private memory for this.

Parameters:
_m SIP message
_data manually created RR header
Returns:
1 on success, negative on failure

Definition at line 356 of file record.c.

References add_username, anchor_lump(), append_fromtag, sip_msg::buf, enable_full_lr, sip_msg::from, get_username(), HDR_RECORDROUTE_T, sip_msg::headers, insert_new_lump_after(), _str::len, LM_ERR, hdr_field::name, parse_from_header(), hdr_field::parsed, pkg_free, pkg_malloc, RR_FROMTAG, RR_FROMTAG_LEN, RR_LR, RR_LR_FULL, RR_LR_FULL_LEN, RR_LR_LEN, RR_PREFIX, RR_PREFIX_LEN, RR_TERM, RR_TERM_LEN, _str::s, to_body::tag_value, and user.

Referenced by w_record_route_preset().


Variable Documentation

Definition at line 75 of file record.c.

char rr_param_buf_ptr[RR_PARAM_BUF_SIZE] [static]

RR param buffer.

Note:
used for storing RR param which are added before RR insertion

Definition at line 74 of file record.c.

unsigned int rr_param_msg [static]

Definition at line 76 of file record.c.

Referenced by add_rr_param(), and record_route().


Generated on Thu May 24 10:00:42 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6