Skip to content

Commit

Permalink
More on re-arranging the TLS code
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Feb 13, 2015
1 parent d8cfac6 commit e8158cd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 67 deletions.
44 changes: 0 additions & 44 deletions main.c
Expand Up @@ -129,9 +129,6 @@
#include "poll_types.h"
#include "net/net_tcp.h"
#include "net/net_udp.h"
#ifdef USE_TLS
#include "tls/tls_init.h"
#endif

#ifdef USE_SCTP
#include "sctp_server.h"
Expand Down Expand Up @@ -184,9 +181,6 @@ int tcp_max_msg_time = TCP_CHILD_MAX_MSG_TIME; /* Max number of seconds that
will lead to the connection to
closed */
#endif
#ifdef USE_TLS
int tls_disable = 1; /* 1 if tls is disabled */
#endif
#ifdef USE_SCTP
int sctp_disable = 0; /* 1 if sctp is disabled */
#endif
Expand Down Expand Up @@ -257,20 +251,6 @@ int tos = IPTOS_LOWDELAY;

struct socket_info* bind_address=0; /* pointer to the crt. proc.
listening address*/
struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
struct socket_info* sendipv6; /* same as above for ipv6 */
#ifdef USE_TCP
struct socket_info* sendipv4_tcp;
struct socket_info* sendipv6_tcp;
#endif
#ifdef USE_TLS
struct socket_info* sendipv4_tls;
struct socket_info* sendipv6_tls;
#endif
#ifdef USE_SCTP
struct socket_info* sendipv4_sctp;
struct socket_info* sendipv6_sctp;
#endif


/* if aliases should be automatically discovered and added
Expand All @@ -282,9 +262,6 @@ int auto_aliases=1;
int sl_fwd_disabled=-1;

unsigned short port_no=0; /* default port*/
#ifdef USE_TLS
unsigned short tls_port_no=0; /* default port */
#endif

/* process number - 0 is the main process */
int process_no = 0;
Expand Down Expand Up @@ -362,9 +339,6 @@ void cleanup(int show_status)
destroy_modules();
udp_destroy();
tcp_destroy();
#ifdef USE_TLS
destroy_tls();
#endif
destroy_timer();
destroy_stats_collector();
destroy_script_cb();
Expand Down Expand Up @@ -684,10 +658,7 @@ static int main_loop(void)
{
static int chd_rank;
int rc;
//pid_t pid;
//struct socket_info* si;
int* startup_done = NULL;
//stat_var *load_p = NULL;

chd_rank=0;

Expand All @@ -712,8 +683,6 @@ static int main_loop(void)
// FIXME UDP
//if (udp_init(udp_listen)==-1) goto error;
bind_address=protos[PROTO_UDP].listeners;
sendipv4=bind_address;
sendipv6=bind_address; /*FIXME*/
if (protos[PROTO_UDP].listeners->next) {
LM_WARN("using only the first listen address (no fork)\n");
}
Expand Down Expand Up @@ -1104,15 +1073,6 @@ int main(int argc, char** argv)
/*register builtin modules*/
register_builtin_modules();

#ifdef USE_TLS
/* initialize default TLS domains,
must be done before reading the config */
if (pre_init_tls()<0){
LM_CRIT("could not pre_init_tls, exiting...\n");
goto error00;
}
#endif /* USE_TLS */

if (preinit_black_lists()!=0) {
LM_CRIT("failed to alloc black list's anchor\n");
goto error00;
Expand Down Expand Up @@ -1164,10 +1124,6 @@ int main(int argc, char** argv)

/* fix parameters */
if (port_no<=0) port_no=SIP_PORT;
#ifdef USE_TLS
if (tls_port_no<=0) tls_port_no=SIPS_PORT;
#endif


if (children_no<=0) children_no=CHILD_NO;
#ifdef USE_TCP
Expand Down
4 changes: 1 addition & 3 deletions modules/proto_tls/tls_config.c
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2004,2005 Free Software Foundation, Inc.
* Copyright (C) 2006 enum.at
Expand All @@ -24,7 +22,7 @@


#include "tls_config.h"
#include "../config.h"
#include "../../config.h"

int tls_log;

Expand Down
4 changes: 0 additions & 4 deletions modules/proto_tls/tls_config.h
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2004,2005 Free Software Foundation, Inc.
*
Expand All @@ -24,8 +22,6 @@
#ifndef tls_config_h
#define tls_config_h

#include "../tcp_conn.h"

enum tls_method {
TLS_METHOD_UNSPEC = 0,
TLS_USE_TLSv1_cli,
Expand Down
4 changes: 1 addition & 3 deletions modules/proto_tls/tls_domain.c
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2004,2005 Free Software Foundation, Inc.
* Copyright (C) 2006 enum.at
Expand All @@ -22,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "tls_server.h"
#include "../../mem/mem.h"
#include "tls_domain.h"
#include <stdlib.h>

Expand Down
22 changes: 10 additions & 12 deletions modules/proto_tls/tls_domain.h
@@ -1,6 +1,4 @@
/*
* $Id$
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2004,2005 Free Software Foundation, Inc.
* Copyright (C) 2005,2006 iptelorg GmbH
Expand All @@ -26,19 +24,19 @@
#ifndef TLS_DOMAIN_H
#define TLS_DOMAIN_H

#include "../str.h"
#include "../ip_addr.h"
#include "../../str.h"
#include "../../ip_addr.h"
#include "tls_config.h"
#include <openssl/ssl.h>

/*
* TLS configuration domain type
*/
enum tls_domain_type {
TLS_DOMAIN_DEF = (1 << 0), /* Default domain */
TLS_DOMAIN_SRV = (1 << 1), /* Server domain */
TLS_DOMAIN_CLI = (1 << 2), /* Client domain */
TLS_DOMAIN_NAME= (1 << 3) /* Name based TLS domain */
TLS_DOMAIN_DEF = (1 << 0), /* Default domain */
TLS_DOMAIN_SRV = (1 << 1), /* Server domain */
TLS_DOMAIN_CLI = (1 << 2), /* Client domain */
TLS_DOMAIN_NAME= (1 << 3) /* Name based TLS domain */
};

/*
Expand Down Expand Up @@ -88,17 +86,17 @@ struct tls_domain *tls_find_client_domain_name(str name);
/*
* create a new server domain (identified by socket)
*/
int tls_new_server_domain(struct ip_addr *ip, unsigned short port);
int tls_new_server_domain(struct ip_addr *ip, unsigned short port);

/*
* create a new client domain (identified by socket)
*/
int tls_new_client_domain(struct ip_addr *ip, unsigned short port);
int tls_new_client_domain(struct ip_addr *ip, unsigned short port);

/*
* create a new client domain (identified by string)
*/
int tls_new_client_domain_name(char *s, int len);
int tls_new_client_domain_name(char *s, int len);

/*
* allocate memory and set default values for
Expand All @@ -109,6 +107,6 @@ struct tls_domain *tls_new_domain(int type);
/*
* clean up
*/
void tls_free_domains(void);
void tls_free_domains(void);

#endif
1 change: 0 additions & 1 deletion net/net_tcp.c
Expand Up @@ -271,7 +271,6 @@ int tcp_init_listener(struct socket_info *si)
#endif

addr = &si->su;
/* sock_info->proto=PROTO_TCP; */
if (init_su(addr, &si->address, si->port_no)<0){
LM_ERR("could no init sockaddr_union\n");
goto error;
Expand Down

0 comments on commit e8158cd

Please sign in to comment.