[sr-dev] git:master: core: server signature value can be set via param

Klaus Darilion klaus.mailinglists at pernau.at
Thu Aug 20 12:20:03 CEST 2009


btw: I never understood in which case which header is used. Is there a 
simple rule?

regards
klaus



Daniel-Constantin Mierla schrieb:
> Module: sip-router
> Branch: master
> Commit: c745469fb8af0101b26de8bee82c4314dfcafab9
> URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c745469fb8af0101b26de8bee82c4314dfcafab9
> 
> Author: Daniel-Constantin Mierla <miconda at gmail.com>
> Committer: Daniel-Constantin Mierla <miconda at gmail.com>
> Date:   Thu Aug 20 11:49:14 2009 +0300
> 
> core: server signature value can be set via param
> 
> - server and user agent signature were only defines so far
> - two new parameters server_header and user_agent_header allow
> to define them via cfg parameters
> - default values are the same so far
> 
> ---
> 
>  cfg.lex          |    4 ++++
>  cfg.y            |   10 ++++++++++
>  globals.h        |    2 ++
>  main.c           |    2 ++
>  msg_translator.c |    6 +++---
>  5 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/cfg.lex b/cfg.lex
> index 32aed32..e15c71b 100644
> --- a/cfg.lex
> +++ b/cfg.lex
> @@ -329,6 +329,8 @@ MEMLOG		"memlog"|"mem_log"
>  MEMDBG		"memdbg"|"mem_dbg"
>  SIP_WARNING sip_warning
>  SERVER_SIGNATURE server_signature
> +SERVER_HEADER server_header
> +USER_AGENT_HEADER user_agent_header
>  REPLY_TO_VIA reply_to_via
>  USER		"user"|"uid"
>  GROUP		"group"|"gid"
> @@ -765,6 +767,8 @@ EAT_ABLE	[\ \t\b\r]
>  <INITIAL>{SCTP_MAX_BURST}	{ count(); yylval.strval=yytext;
>  										return SCTP_MAX_BURST; }
>  <INITIAL>{SERVER_SIGNATURE}	{ count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
> +<INITIAL>{SERVER_HEADER}	{ count(); yylval.strval=yytext; return SERVER_HEADER; }
> +<INITIAL>{USER_AGENT_HEADER}	{ count(); yylval.strval=yytext; return USER_AGENT_HEADER; }
>  <INITIAL>{REPLY_TO_VIA}	{ count(); yylval.strval=yytext; return REPLY_TO_VIA; }
>  <INITIAL>{ADVERTISED_ADDRESS}	{	count(); yylval.strval=yytext;
>  									return ADVERTISED_ADDRESS; }
> diff --git a/cfg.y b/cfg.y
> index e9e8d8a..8a240c6 100644
> --- a/cfg.y
> +++ b/cfg.y
> @@ -390,6 +390,8 @@ static int case_check_default(struct case_stms* stms);
>  %token MEMDBG
>  %token SIP_WARNING
>  %token SERVER_SIGNATURE
> +%token SERVER_HEADER
> +%token USER_AGENT_HEADER
>  %token REPLY_TO_VIA
>  %token LOADMODULE
>  %token LOADPATH
> @@ -1362,6 +1364,14 @@ assign_stm:
>  	| SCTP_MAX_BURST EQUAL error { yyerror("number expected"); }
>  	| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
>  	| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
> +	| SERVER_HEADER EQUAL STRING { server_hdr.s=$3;
> +			server_hdr.len=strlen(server_hdr.s);
> +	}
> +	| SERVER_HEADER EQUAL error { yyerror("string value expected"); }
> +	| USER_AGENT_HEADER EQUAL STRING { user_agent_hdr.s=$3;
> +			user_agent_hdr.len=strlen(user_agent_hdr.s);
> +	}
> +	| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
>  	| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
>  	| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
>  	| LISTEN EQUAL id_lst {
> diff --git a/globals.h b/globals.h
> index f7ef9f8..add1f40 100644
> --- a/globals.h
> +++ b/globals.h
> @@ -108,6 +108,8 @@ extern int syn_branch;
>  extern int child_rank;
>  extern int sip_warning;
>  extern int server_signature;
> +extern str server_hdr;
> +extern str user_agent_hdr;
>  extern char* user;
>  extern char* group;
>  extern char* sock_user;
> diff --git a/main.c b/main.c
> index 9a771f8..c975057 100644
> --- a/main.c
> +++ b/main.c
> @@ -345,6 +345,8 @@ int sip_warning = 1;
>     be default yes, good for trouble-shooting
>  */
>  int server_signature=1;
> +str server_hdr = {SERVER_HDR, SERVER_HDR_LEN};
> +str user_agent_hdr = {USER_AGENT, USER_AGENT_LEN};
>  /* should ser try to locate outbound interface on multihomed
>   * host? by default not -- too expensive
>   */
> diff --git a/msg_translator.c b/msg_translator.c
> index 2f14505..b6273b0 100644
> --- a/msg_translator.c
> +++ b/msg_translator.c
> @@ -1953,7 +1953,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
>  	}
>  	/* server header */
>  	if (server_signature)
> -		len += SERVER_HDR_LEN + CRLF_LEN;
> +		len += server_hdr.len + CRLF_LEN;
>  	/* warning hdr */
>  	if (sip_warning) {
>  		warning_buf = warning_builder(msg,&warning_len);
> @@ -2092,8 +2092,8 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
>  		}
>  	/* server header */
>  	if (server_signature) {
> -		memcpy( p, SERVER_HDR , SERVER_HDR_LEN );
> -		p+=SERVER_HDR_LEN;
> +		memcpy( p, server_hdr.s, server_hdr.len );
> +		p+=server_hdr.len;
>  		memcpy( p, CRLF, CRLF_LEN );
>  		p+=CRLF_LEN;
>  	}
> 
> 
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev



More information about the sr-dev mailing list