msg_translator.c File Reference

Create and translate SIP messages/ message contents More...

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "msg_translator.h"
#include "globals.h"
#include "error.h"
#include "mem/mem.h"
#include "dprint.h"
#include "config.h"
#include "md5utils.h"
#include "data_lump.h"
#include "data_lump_rpl.h"
#include "ip_addr.h"
#include "resolve.h"
#include "ut.h"
#include "pt.h"

Include dependency graph for msg_translator.c:

Go to the source code of this file.

Defines

#define get_ip_port_proto
#define ROUTE_LEN   (sizeof(ROUTE_STR)-1)
#define ROUTE_STR   "Route: "
 Save given Path body as Route header in message.
#define str_int_print(string, intval)
#define str_ipaddr_print(string, ipaddr_val)
#define str_lenpair_print(string, string_len, string2, string2_len)
#define str_pair_print(string, string2, string2_len)   str_lenpair_print((string), strlen((string)), (string2), (string2_len))
#define str_print(string, string_len)
#define SUBST_LUMP(subst_l)
#define SUBST_LUMP_LEN(subst_l)

Functions

static int adjust_clen (struct sip_msg *msg, int body_delta, int proto)
 Adjust/insert Content-Length if necessary.
int branch_builder (unsigned int hash_index, unsigned int label, char *char_v, int branch, char *branch_str, int *len)
 return number of chars printed or 0 if space exceeded; assumes buffer size of at least MAX_BRANCH_PARAM_LEN
char * build_req_buf_from_sip_req (struct sip_msg *msg, unsigned int *returned_len, struct socket_info *send_sock, int proto, unsigned int flags)
char * build_res_buf_from_sip_req (unsigned int code, str *text, str *new_tag, struct sip_msg *msg, unsigned int *returned_len, struct bookmark *bmark)
char * build_res_buf_from_sip_res (struct sip_msg *msg, unsigned int *returned_len)
static int check_via_address (struct ip_addr *ip, str *name, unsigned short port, unsigned short proto, int resolver)
 checks if ip is in host(name) and ?host(ip)=name? ip must be in network byte order! resolver = DO_DNS | DO_REV_DNS; if 0 no dns check is made
char * clen_builder (struct sip_msg *msg, int *clen_len, int diff)
char * id_builder (struct sip_msg *msg, unsigned int *id_len)
static int insert_path_as_route (struct sip_msg *msg, str *path)
static int lump_check_opt (struct lump *l, struct sip_msg *msg, struct socket_info *snd_s)
 * checks if a lump opt condition returns 1 if cond is true, 0 if false
static int lumps_len (struct sip_msg *msg, struct lump *lumps, struct socket_info *send_sock)
 computes the "unpacked" len of a lump list, code moved from build_req_from_req
static void process_lumps (struct sip_msg *msg, struct lump *lumps, char *new_buf, unsigned int *new_buf_offs, unsigned int *orig_offs, struct socket_info *send_sock)
 another helper functions, adds/Removes the lump, code moved form build_req_from_req
char * received_builder (struct sip_msg *msg, unsigned int *received_len)
int received_test (struct sip_msg *msg)
 check if IP address in Via != source IP address of signaling
char * rport_builder (struct sip_msg *msg, unsigned int *rport_len)
char * via_builder (unsigned int *len, struct socket_info *send_sock, str *branch, str *extra_params, int proto, struct hostport *hp)
static char * warning_builder (struct sip_msg *msg, unsigned int *returned_len)

Variables

char version []
int version_len


Detailed Description

Create and translate SIP messages/ message contents

Definition in file msg_translator.c.


Define Documentation

#define get_ip_port_proto

Referenced by lump_check_opt().

#define ROUTE_LEN   (sizeof(ROUTE_STR)-1)

Definition at line 1222 of file msg_translator.c.

Referenced by insert_path_as_route().

#define ROUTE_STR   "Route: "

Save given Path body as Route header in message.

If another Route HF is found, it's placed right before that. Otherwise, it's placed after the last Via HF. If also no Via HF is found, it's placed as first HF.

Definition at line 1221 of file msg_translator.c.

Referenced by insert_path_as_route().

#define str_int_print ( string,
intval   ) 

Value:

do{\
         t=int2str((intval), &print_len); \
         str_pair_print(string, t, print_len);\
      } while(0)

Referenced by warning_builder().

#define str_ipaddr_print ( string,
ipaddr_val   ) 

Value:

do{\
         t=ip_addr2a((ipaddr_val)); \
         print_len=strlen(t); \
         str_pair_print(string, t, print_len);\
      } while(0)

Referenced by warning_builder().

#define str_lenpair_print ( string,
string_len,
string2,
string2_len   ) 

Value:

do{ \
         str_print(string, string_len); \
         str_print(string2, string2_len);\
      }while(0)

Referenced by warning_builder().

#define str_pair_print ( string,
string2,
string2_len   )     str_lenpair_print((string), strlen((string)), (string2), (string2_len))

Referenced by warning_builder().

#define str_print ( string,
string_len   ) 

Referenced by warning_builder().

#define SUBST_LUMP ( subst_l   ) 

Referenced by process_lumps().

#define SUBST_LUMP_LEN ( subst_l   ) 

Referenced by lumps_len().


Function Documentation

static int adjust_clen ( struct sip_msg msg,
int  body_delta,
int  proto 
) [inline, static]

int branch_builder ( unsigned int  hash_index,
unsigned int  label,
char *  char_v,
int  branch,
char *  branch_str,
int *  len 
)

return number of chars printed or 0 if space exceeded; assumes buffer size of at least MAX_BRANCH_PARAM_LEN

Definition at line 1855 of file msg_translator.c.

References BRANCH_SEPARATOR, int2reverse_hex(), MAX_BRANCH_PARAM_LEN, MCOOKIE, MCOOKIE_LEN, and MD5_LEN.

Referenced by t_calc_branch().

char* build_req_buf_from_sip_req ( struct sip_msg msg,
unsigned int *  returned_len,
struct socket_info send_sock,
int  proto,
unsigned int  flags 
)

char* build_res_buf_from_sip_req ( unsigned int  code,
str text,
str new_tag,
struct sip_msg msg,
unsigned int *  returned_len,
struct bookmark bmark 
)

char* build_res_buf_from_sip_res ( struct sip_msg msg,
unsigned int *  returned_len 
)

static int check_via_address ( struct ip_addr ip,
str name,
unsigned short  port,
unsigned short  proto,
int  resolver 
) [static]

checks if ip is in host(name) and ?host(ip)=name? ip must be in network byte order! resolver = DO_DNS | DO_REV_DNS; if 0 no dns check is made

Returns:
0 if equal

Definition at line 147 of file msg_translator.c.

References ip_addr::addr, ip_addr::af, DO_DNS, DO_REV_DNS, ip_addr2a(), ip_addr::len, _str::len, len, LM_CRIT, LM_DBG, rev_resolvehost, _str::s, s, SIP_PORT, sip_resolvehost(), and ip_addr::u.

Referenced by received_test().

char* clen_builder ( struct sip_msg msg,
int *  clen_len,
int  diff 
)

char* id_builder ( struct sip_msg msg,
unsigned int *  id_len 
)

static int insert_path_as_route ( struct sip_msg msg,
str path 
) [inline, static]

static int lump_check_opt ( struct lump l,
struct sip_msg msg,
struct socket_info snd_s 
) [inline, static]

static int lumps_len ( struct sip_msg msg,
struct lump lumps,
struct socket_info send_sock 
) [inline, static]

static void process_lumps ( struct sip_msg msg,
struct lump lumps,
char *  new_buf,
unsigned int *  new_buf_offs,
unsigned int *  orig_offs,
struct socket_info send_sock 
) [inline, static]

char* received_builder ( struct sip_msg msg,
unsigned int *  received_len 
)

int received_test ( struct sip_msg msg  ) 

char* rport_builder ( struct sip_msg msg,
unsigned int *  rport_len 
)

char* via_builder ( unsigned int *  len,
struct socket_info send_sock,
str branch,
str extra_params,
int  proto,
struct hostport hp 
)

static char* warning_builder ( struct sip_msg msg,
unsigned int *  returned_len 
) [static]


Variable Documentation

char version[]


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