data_lump.c File Reference

Kamailio Lump (internal message manipulation) functions. More...

#include "data_lump.h"
#include "dprint.h"
#include "mem/mem.h"
#include "globals.h"
#include "error.h"
#include <stdlib.h>
#include <string.h>

Include dependency graph for data_lump.c:

Go to the source code of this file.

Enumerations

enum  lump_dir { LD_NEXT, LD_BEFORE, LD_AFTER }

Functions

struct lumpanchor_lump (struct sip_msg *msg, unsigned int offset, int unsigned len, enum _hdr_types_t type)
 add an anchor WARNING: this function adds the lump either to the msg->add_rm or msg->body_lumps list, depending on the offset being greater than msg->eoh, so msg->eoh must be parsed (parse with HDR_EOH) if you think your lump might affect the body!!
struct lumpappend_new_lump (struct lump **list, char *new_hdr, unsigned int len, enum _hdr_types_t type)
 adds a header to the end
static int compare_flaged_lumps (const enum lump_flag flag1, const enum lump_flag flag2)
static int compare_not_flaged_lumps (const enum lump_flag flag1, const enum lump_flag flag2)
void del_flaged_lumps (struct lump **lump_list, const enum lump_flag flags)
 Delete flagged lumps.
static void del_flaged_lumps_helper (struct lump **lump_list, const enum lump_flag flags, int(*compare_lump_flags)(const enum lump_flag flag1, const enum lump_flag flag2))
 helper method for flagged lump deletion
struct lumpdel_lump (struct sip_msg *msg, unsigned int offset, unsigned int len, enum _hdr_types_t type)
 removes an already existing header/data lump
void del_notflaged_lumps (struct lump **lump_list, const enum lump_flag not_flags)
 Delete not flagged lumps.
struct lumpdup_lump_list (struct lump *l)
 shallow pkg copy of a lump list
static struct lumpdup_lump_list_r (struct lump *l, enum lump_dir dir, int *error)
 * duplicate (shallow-ly) a lump list into pkg memory
void free_duped_lump_list (struct lump *l)
 Free duplicated lump list.
void free_lump (struct lump *lmp)
 frees the content of a lump struct
void free_lump_list (struct lump *l)
 frees an entire lump list, recursively
static void free_shallow_lump (struct lump *l)
 free (shallow-ly) a lump and its after/before lists
struct lumpinsert_cond_lump_after (struct lump *after, enum lump_conditions c, enum _hdr_types_t type)
 inserts a cond lump immediately after hdr
struct lumpinsert_cond_lump_before (struct lump *before, enum lump_conditions c, enum _hdr_types_t type)
 inserts a conditional lump immediately before "before"
struct lumpinsert_new_lump (struct lump **list, char *new_hdr, unsigned int len, enum _hdr_types_t type)
 inserts a header to the beginning
struct lumpinsert_new_lump_after (struct lump *after, char *new_hdr, unsigned int len, enum _hdr_types_t type)
 inserts a header/data lump immediately after hdr
struct lumpinsert_new_lump_before (struct lump *before, char *new_hdr, unsigned int len, enum _hdr_types_t type)
 inserts a header/data lump immediately before "before"
struct lumpinsert_subst_lump_after (struct lump *after, enum lump_subst subst, enum _hdr_types_t type)
 inserts a subst lump immediately after hdr
struct lumpinsert_subst_lump_before (struct lump *before, enum lump_subst subst, enum _hdr_types_t type)
 inserts a subst lump immediately before "before"

Variables

int init_lump_flags = 0


Detailed Description

Kamailio Lump (internal message manipulation) functions.

Definition in file data_lump.c.


Enumeration Type Documentation

enum lump_dir

Note:
WARNING: all lump add/insert operations expect a pkg_malloc'ed char* pointer the will be DEALLOCATED when the sip_msg is destroyed!
Enumerator:
LD_NEXT 
LD_BEFORE 
LD_AFTER 

Definition at line 56 of file data_lump.c.


Function Documentation

struct lump* anchor_lump ( struct sip_msg msg,
unsigned int  offset,
int unsigned  len,
enum _hdr_types_t  type 
) [read]

struct lump* append_new_lump ( struct lump **  list,
char *  new_hdr,
unsigned int  len,
enum _hdr_types_t  type 
) [read]

adds a header to the end

Returns:
returns pointer on success, 0 on error

Definition at line 62 of file data_lump.c.

References lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD, lump::op, pkg_malloc, lump::type, lump::u, and lump::value.

static int compare_flaged_lumps ( const enum lump_flag  flag1,
const enum lump_flag  flag2 
) [inline, static]

Definition at line 557 of file data_lump.c.

Referenced by del_flaged_lumps().

static int compare_not_flaged_lumps ( const enum lump_flag  flag1,
const enum lump_flag  flag2 
) [inline, static]

Definition at line 563 of file data_lump.c.

Referenced by del_notflaged_lumps().

void del_flaged_lumps ( struct lump **  lump_list,
const enum lump_flag  flags 
)

Delete flagged lumps.

remove all flagged lumps from the list

Parameters:
lump_list list of lumps
flags flags for lumps that should be deleted

Definition at line 635 of file data_lump.c.

References compare_flaged_lumps(), and del_flaged_lumps_helper().

Referenced by post_print_uac_request().

static void del_flaged_lumps_helper ( struct lump **  lump_list,
const enum lump_flag  flags,
int(*)(const enum lump_flag flag1, const enum lump_flag flag2)  compare_lump_flags 
) [static]

helper method for flagged lump deletion

Parameters:
lump_list list of lumps
flags flags for lumps that should be deleted
compare_lump_flags helper function that compares two lump flags

Definition at line 575 of file data_lump.c.

References lump::after, lump::before, lump::flags, free_lump(), free_lump_list(), lump::next, and pkg_free.

Referenced by del_flaged_lumps(), and del_notflaged_lumps().

struct lump* del_lump ( struct sip_msg msg,
unsigned int  offset,
unsigned int  len,
enum _hdr_types_t  type 
) [read]

void del_notflaged_lumps ( struct lump **  lump_list,
const enum lump_flag  not_flags 
)

Delete not flagged lumps.

remove all unflagged lumps from the list

Parameters:
lump_list list of lumps
not_flags flags for lumps that should not deleted

Definition at line 646 of file data_lump.c.

References compare_not_flaged_lumps(), and del_flaged_lumps_helper().

Referenced by free_faked_req().

struct lump* dup_lump_list ( struct lump l  )  [read]

shallow pkg copy of a lump list

duplicates a lump list shallowly in pkg-mem

Returns:
if either original list empty or error occur returns, 0 is returned, pointer to the copy otherwise

Definition at line 511 of file data_lump.c.

References dup_lump_list_r(), and LD_NEXT.

static struct lump* dup_lump_list_r ( struct lump l,
enum lump_dir  dir,
int *  error 
) [static, read]

* duplicate (shallow-ly) a lump list into pkg memory

Definition at line 452 of file data_lump.c.

References lump::after, lump::before, lump::flags, free_shallow_lump(), init_lump_flags, LD_AFTER, LD_BEFORE, LD_NEXT, LM_CRIT, LM_ERR, LUMPFLAG_DUPED, lump::next, and pkg_malloc.

Referenced by dup_lump_list().

void free_duped_lump_list ( struct lump l  ) 

Free duplicated lump list.

frees a shallowly duplicated lump list

Definition at line 523 of file data_lump.c.

References lump::after, lump::before, lump::flags, free_lump(), LUMPFLAG_DUPED, lump::next, and pkg_free.

void free_lump ( struct lump lmp  ) 

void free_lump_list ( struct lump l  ) 

frees an entire lump list, recursively

Definition at line 406 of file data_lump.c.

References lump::after, lump::before, free_lump(), lump::next, and pkg_free.

Referenced by del_flaged_lumps_helper(), free_sip_msg(), free_sip_msg_lite(), and set_body_f().

static void free_shallow_lump ( struct lump l  )  [static]

free (shallow-ly) a lump and its after/before lists

Definition at line 434 of file data_lump.c.

References lump::after, lump::before, and pkg_free.

Referenced by dup_lump_list_r().

struct lump* insert_cond_lump_after ( struct lump after,
enum lump_conditions  c,
enum _hdr_types_t  type 
) [read]

inserts a cond lump immediately after hdr

conditional lumps - insert

Returns:
returns pointer on success, 0 on error

Definition at line 220 of file data_lump.c.

References lump::after, lump::cond, E_OUT_OF_MEM, lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD_OPT, lump::op, pkg_malloc, ser_error, lump::type, and lump::u.

Referenced by build_rr(), and record_route().

struct lump* insert_cond_lump_before ( struct lump before,
enum lump_conditions  c,
enum _hdr_types_t  type 
) [read]

inserts a conditional lump immediately before "before"

conditional lumps - before

Returns:
returns pointer on success, 0 on error

Definition at line 246 of file data_lump.c.

References lump::before, lump::cond, E_OUT_OF_MEM, lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD_OPT, lump::op, pkg_malloc, ser_error, lump::type, and lump::u.

Referenced by record_route().

struct lump* insert_new_lump ( struct lump **  list,
char *  new_hdr,
unsigned int  len,
enum _hdr_types_t  type 
) [read]

inserts a header to the beginning

Returns:
returns pointer if success, 0 on error

Definition at line 90 of file data_lump.c.

References lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD, lump::next, lump::op, pkg_malloc, lump::type, lump::u, and lump::value.

struct lump* insert_new_lump_after ( struct lump after,
char *  new_hdr,
unsigned int  len,
enum _hdr_types_t  type 
) [read]

struct lump* insert_new_lump_before ( struct lump before,
char *  new_hdr,
unsigned int  len,
enum _hdr_types_t  type 
) [read]

struct lump* insert_subst_lump_after ( struct lump after,
enum lump_subst  subst,
enum _hdr_types_t  type 
) [read]

inserts a subst lump immediately after hdr

substitutions (replace with ip address, port etc) - after

Returns:
returns pointer on success, 0 on error

Definition at line 167 of file data_lump.c.

References lump::after, E_OUT_OF_MEM, lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD_SUBST, lump::op, pkg_malloc, ser_error, lump::subst, lump::type, and lump::u.

Referenced by build_rr().

struct lump* insert_subst_lump_before ( struct lump before,
enum lump_subst  subst,
enum _hdr_types_t  type 
) [read]

inserts a subst lump immediately before "before"

substitutions (replace with ip address, port etc) - before

Returns:
returns pointer on success, 0 on error

Definition at line 193 of file data_lump.c.

References lump::before, E_OUT_OF_MEM, lump::flags, init_lump_flags, lump::len, LM_ERR, LUMP_ADD_SUBST, lump::op, pkg_malloc, ser_error, lump::subst, lump::type, and lump::u.

Referenced by prepend_path().


Variable Documentation

int init_lump_flags = 0


Generated on Mon May 21 18:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6