Skip to content

Commit

Permalink
Each protocol has its own default port parameter.
Browse files Browse the repository at this point in the history
Removed the global core parameter "port".
Each protocol exports a module parameter for setting the defaul port.
  • Loading branch information
bogdan-iancu committed Feb 19, 2015
1 parent eb3355a commit 172eea3
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 22 deletions.
2 changes: 0 additions & 2 deletions cfg.lex
Expand Up @@ -304,7 +304,6 @@ DNS_RETR_TIME dns_retr_time
DNS_RETR_NO dns_retr_no
DNS_SERVERS_NO dns_servers_no
DNS_USE_SEARCH dns_use_search_list
PORT port
MAXBUFFER maxbuffer
CHILDREN children
CHECK_VIA check_via
Expand Down Expand Up @@ -585,7 +584,6 @@ IMPORTFILE "import_file"
return DNS_SERVERS_NO; }
<INITIAL>{DNS_USE_SEARCH} { count(); yylval.strval=yytext;
return DNS_USE_SEARCH; }
<INITIAL>{PORT} { count(); yylval.strval=yytext; return PORT; }
<INITIAL>{MAX_WHILE_LOOPS} { count(); yylval.strval=yytext;
return MAX_WHILE_LOOPS; }
<INITIAL>{MAXBUFFER} { count(); yylval.strval=yytext; return MAXBUFFER; }
Expand Down
3 changes: 0 additions & 3 deletions cfg.y
Expand Up @@ -318,7 +318,6 @@ extern char *finame;
%token DNS_SERVERS_NO
%token DNS_USE_SEARCH
%token MAX_WHILE_LOOPS
%token PORT
%token CHILDREN
%token CHECK_VIA
%token SHM_HASH_SPLIT_PERCENTAGE
Expand Down Expand Up @@ -631,8 +630,6 @@ assign_stm: DEBUG EQUAL snumber {
| DNS_SERVERS_NO error { yyerror("number expected"); }
| DNS_USE_SEARCH EQUAL NUMBER { dns_search_list=$3; }
| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
| PORT EQUAL NUMBER { port_no=$3; }
| PORT EQUAL error { yyerror("number expected"); }
| MAX_WHILE_LOOPS EQUAL NUMBER { max_while_loops=$3; }
| MAX_WHILE_LOOPS EQUAL error { yyerror("number expected"); }
| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
Expand Down
3 changes: 0 additions & 3 deletions globals.h
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of opensips, a free SIP server.
Expand Down Expand Up @@ -39,7 +37,6 @@
extern char * cfg_file;
extern int config_check;
extern char *stat_file;
extern unsigned short port_no;

extern char* pid_file;
extern char* pgid_file;
Expand Down
4 changes: 0 additions & 4 deletions main.c
Expand Up @@ -254,8 +254,6 @@ int auto_aliases=1;
* disabled or not */
int sl_fwd_disabled=-1;

unsigned short port_no=0; /* default port*/

/* process number - 0 is the main process */
int process_no = 0;

Expand Down Expand Up @@ -1122,8 +1120,6 @@ int main(int argc, char** argv)
}

/* fix parameters */
if (port_no<=0) port_no=SIP_PORT;

if (children_no<=0) children_no=CHILD_NO;
#ifdef USE_TCP
if (!tcp_disable){
Expand Down
5 changes: 0 additions & 5 deletions modules/proto_tls/proto_tls.c
Expand Up @@ -837,10 +837,6 @@ static int mod_init(void)

LM_INFO("initializing TLS protocol\n");

/* just in case, if port change since (via modparam)
* since the module was loaded */
protos[PROTO_TLS].default_port = tls_port_no;

if (tls_domain_avp) {
s.s = tls_domain_avp;
s.len = strlen(s.s);
Expand Down Expand Up @@ -1320,4 +1316,3 @@ static int tls_read_req(struct tcp_connection* con, int* bytes_read)
return -1;
}


2 changes: 1 addition & 1 deletion modules/registrar/save.c
Expand Up @@ -151,7 +151,7 @@ static struct socket_info *get_sock_hdr(struct sip_msg *msg)
return 0;
}

LM_DBG("%d:<%.*s>:%d -> p=%p\n", proto,socks.len,socks.s,port_no,sock );
LM_DBG("%d:<%.*s>:%d -> p=%p\n", proto,socks.len,socks.s,port,sock );

return sock;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/siptrace/siptrace.c
Expand Up @@ -1992,7 +1992,7 @@ static int pipport2su (str *sproto, str *ip, unsigned short port,
}
else{
/*the address contains a port number*/
if (port_no<1024 || port_no>65536)
if (port<1024 || port>65536)
{
LM_ERR("invalid port number; must be in [1024,65536]\n");
return -1;
Expand Down
6 changes: 5 additions & 1 deletion net/proto_tcp/proto_tcp.c
Expand Up @@ -61,6 +61,9 @@ static int tcp_conn_init(struct tcp_connection* c);
static void tcp_conn_clean(struct tcp_connection* c);


/* default port for TCP protocol */
static int tcp_port = SIP_PORT;

/* 1 if TCP connect & write should be async */
static int tcp_async = 0;

Expand Down Expand Up @@ -121,6 +124,7 @@ static cmd_export_t cmds[] = {


static param_export_t params[] = {
{ "tcp_port", INT_PARAM, &tcp_port },
{ "tcp_max_msg_chunks", INT_PARAM, &tcp_max_msg_chunks },
{ "tcp_crlf_pingpong", INT_PARAM, &tcp_crlf_pingpong },
{ "tcp_crlf_drop", INT_PARAM, &tcp_crlf_drop },
Expand Down Expand Up @@ -156,7 +160,7 @@ struct module_exports proto_tcp_exports = {

static int proto_tcp_init(struct proto_info *pi)
{
pi->default_port = SIP_PORT;
pi->default_port = tcp_port;

pi->tran.init_listener = proto_tcp_init_listener;
pi->tran.send = proto_tcp_send;
Expand Down
6 changes: 4 additions & 2 deletions net/proto_udp/proto_udp.c
Expand Up @@ -31,7 +31,6 @@

#include "../../pt.h"
#include "../../timer.h"
#include "../../sr_module.h"
#include "../../socket_info.h"
#include "../../receive.h"
#include "../api_proto.h"
Expand All @@ -50,6 +49,8 @@ static int udp_read_req(struct socket_info *src, int* bytes_read);

static callback_list* cb_list = NULL;

static int udp_port = SIP_PORT;


static cmd_export_t cmds[] = {
{"proto_init", (cmd_function)proto_udp_init, 0, 0, 0, 0},
Expand All @@ -58,6 +59,7 @@ static cmd_export_t cmds[] = {


static param_export_t params[] = {
{ "udp_port", INT_PARAM, &udp_port },
{0, 0, 0}
};

Expand Down Expand Up @@ -91,7 +93,7 @@ static int mod_init(void)

static int proto_udp_init(struct proto_info *pi)
{
pi->default_port = SIP_PORT;
pi->default_port = udp_port;

pi->tran.init_listener = proto_udp_init_listener;
pi->tran.send = proto_udp_send;
Expand Down

0 comments on commit 172eea3

Please sign in to comment.