# &develguide;

## API Functions

### find_server_domain

struct tls_domain *find_server_domain(struct ip_addr *ip, unsigned short port);

Find a TLS server domain with given ip and port (local listening socket).

### find_client_domain

struct tls_domain *find_client_domain(struct ip_addr *ip, unsigned short port);

Find TLS client domain.

### get_handshake_timeout

int get_handshake_timeout(void);

Returns the handshanke timeout.

### get_send_timeout

int get_send_timeout(void);

Returns the send timeout.

## TLS_CONFIG

It contains configuration variables for &osips;'s TLS (timeouts, file paths, etc).

## TLS_INIT

Initialization related functions and parameters.

### ssl context

extern SSL_CTX *default_client_ctx;

The ssl context is a member of the TLS domain strcuture. Thus, every TLS domain, default and virtual - servers and clients, have its own SSL context.

### pre_init_tls

int init_tls(void);

Called once to pre_initialize the tls subsystem, from the main(). Called before parsing the configuration file.

### init_tls

int init_tls(void);

Called once to initialize the tls subsystem, from the main(). Called after parsing the configuration file.

### destroy_tls

void destroy_tls(void);

Called once, just before cleanup.

### tls_init

int tls_init(struct socket_info *c);

Called once for each tls socket created, from main.c

### os_malloc, os_realloc, os_free

Wrapper functions around the shm_* functions. OpenSSL uses non-shared memory to create its objects, thus it would not work in &osips;. By creating these wrappers and configuring OpenSSL to use them instead of its default memory functions, we have all OpenSSL objects in shared memory, ready to use.

## TLS_DOMAIN

### tls_domains

extern struct tls_domain *tls_default_server_domain;

The default TLS server domain.

extern struct tls_domain *tls_default_client_domain;

The default TLS client domain.

extern struct tls_domain *tls_server_domains;

List with defined server domains.

extern struct tls_domain *tls_client_domains;

List with defined client domains.

### tls_find_server_domain

struct tls_domain *tls_find_server_domain(struct ip_addr *ip, unsigned short port);

Find a TLS server domain with given ip and port (local listening socket).

### tls_find_client_domain

struct tls_domain *tls_find_client_domain(struct ip_addr *ip, unsigned short port);

Find TLS client domain.

### tls_find_client_domain_addr

struct tls_domain *tls_find_client_domain_addr(struct ip_addr *ip, unsigned short port);

Find TLS client domain with given ip and port (socket of the remote destination).

### tls_find_client_domain_name

struct tls_domain *tls_find_client_name(str name);

Find TLS client domain with given name.

### tls_new__domain

struct tls_domain *tls_new_domain(int type);

Creates new TLS: allocate memory, set the type and initialize members

### tls_new_server_domain

int tls_new_server_domain(struct ip_addr *ip, unsigned short port);

Creates and adds to the list of TLS server domains a new domain.

### tls_new_client_domain

int tls_new_client_domain(struct ip_addr *ip, unsigned short port);

Creates and adds to the list of TLS client domains a new socket based domain.

### tls_new_client_domain_name

int tls_new_client_domain_name(char *s, int len);

Creates and adds to the list of TLS client domains a new name based domain.

### tls_free_domains

void tls_free_domains(void);

Cleans up the entire domain lists.