blob: 2baa67e4cc3e7e5e0cdddd8b3ada50e99add12c5 [file] [log] [blame]
Michal Vasko086311b2016-01-08 09:53:11 +01001/**
2 * \file session_server.h
3 * \author Michal Vasko <mvasko@cesnet.cz>
4 * \brief libnetconf2 session server manipulation
5 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 */
22
23#ifndef NC_SESSION_SERVER_H_
24#define NC_SESSION_SERVER_H_
25
26#include <stdint.h>
27
28#include "session.h"
29#include "messages.h"
30#include "netconf.h"
31
32int nc_server_init(struct ly_ctx *ctx);
33
34int nc_server_set_capab_withdefaults(NC_WD_MODE basic_mode, int also_supported);
35
36int nc_server_set_capab_interleave(int interleave_support);
37
38int nc_server_set_hello_timeout(uint16_t hello_timeout);
39
40int nc_server_set_idle_timeout(uint16_t idle_timeout);
41
42int nc_server_set_max_sessions(uint16_t max_sessions);
43
44struct nc_session *nc_accept_inout(int fdin, int fdout, const char *username);
45
Michal Vaskofb89d772016-01-08 12:25:35 +010046struct nc_pollsession *nc_pollsession_new(void);
47
48void nc_pollsession_free(struct nc_pollsession *ps);
49
50int nc_pollsession_add_session(struct nc_pollsession *ps, struct nc_session *session);
51
52int nc_pollsession_poll(struct nc_pollsession *ps, int timeout);
Michal Vasko086311b2016-01-08 09:53:11 +010053
Michal Vasko9e036d52016-01-08 10:49:26 +010054#if defined(ENABLE_SSH) || defined(ENABLE_TLS)
55
56int nc_server_add_bind_listen(const char *address, uint16_t port, NC_TRANSPORT_IMPL ti);
57
58int nc_server_del_bind(const char *address, uint16_t port, NC_TRANSPORT_IMPL ti);
59
Michal Vaskofb89d772016-01-08 12:25:35 +010060void nc_server_destroy_binds(void);
61
Michal Vasko9e036d52016-01-08 10:49:26 +010062struct nc_session *nc_accept(int timeout);
63
Michal Vaskofb89d772016-01-08 12:25:35 +010064#endif /* ENABLE_SSH || ENABLE_TLS */
Michal Vasko9e036d52016-01-08 10:49:26 +010065
Michal Vasko086311b2016-01-08 09:53:11 +010066#ifdef ENABLE_SSH
67
Michal Vaskod45e25a2016-01-08 15:48:44 +010068/* one for each key */
69int nc_ssh_server_set_hostkey(const char *key_path);
Michal Vasko086311b2016-01-08 09:53:11 +010070
71int nc_ssh_server_set_banner(const char *banner);
72
73int nc_ssh_server_set_auth_methods(int auth_methods);
74
75int nc_ssh_server_set_auth_attempts(uint16_t auth_attempts);
76
77int nc_ssh_server_set_auth_timeout(uint16_t auth_timeout);
78
79int nc_ssh_server_add_authkey(const char *keypath, const char *username);
80
81int nc_ssh_server_del_authkey(const char *keypath, const char *username);
82
Michal Vasko9e036d52016-01-08 10:49:26 +010083void nc_ssh_server_free_opts(void);
Michal Vasko086311b2016-01-08 09:53:11 +010084
85struct nc_session *nc_accept_ssh_channel(struct nc_session *session, int timeout);
86
87#endif /* ENABLE_SSH */
88
89#ifdef ENABLE_TLS
90
Michal Vasko0457bb42016-01-08 15:49:13 +010091int nc_tls_server_set_cert(const char *cert);
Michal Vasko086311b2016-01-08 09:53:11 +010092
Michal Vaskoc14e3c82016-01-11 16:14:30 +010093int nc_tls_server_set_cert_path(const char *cert_path);
Michal Vasko0457bb42016-01-08 15:49:13 +010094
Michal Vaskoc14e3c82016-01-11 16:14:30 +010095int nc_tls_server_set_key(const char *privkey, int is_rsa);
96
Michal Vasko0457bb42016-01-08 15:49:13 +010097int nc_tls_server_set_key_path(const char *privkey_path);
98
Michal Vaskoc14e3c82016-01-11 16:14:30 +010099int nc_tls_server_add_trusted_cert(const char *cert);
Michal Vasko0457bb42016-01-08 15:49:13 +0100100
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100101int nc_tls_server_add_trusted_cert_path(const char *cert_path);
Michal Vasko0457bb42016-01-08 15:49:13 +0100102
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100103int nc_tls_server_set_trusted_cacert_locations(const char *cacert_file_path, const char *cacert_dir_path);
Michal Vasko0457bb42016-01-08 15:49:13 +0100104
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100105void nc_tls_server_destroy_certs(void);
Michal Vasko0457bb42016-01-08 15:49:13 +0100106
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100107int nc_tls_server_set_crl_locations(const char *crl_file_path, const char *crl_dir_path);
Michal Vasko0457bb42016-01-08 15:49:13 +0100108
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100109void nc_tls_server_destroy_crls(void);
Michal Vasko0457bb42016-01-08 15:49:13 +0100110
Michal Vaskoc14e3c82016-01-11 16:14:30 +0100111int nc_tls_server_add_ctn(uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name);
112
113int nc_tls_server_del_ctn(int64_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name);
Michal Vasko0457bb42016-01-08 15:49:13 +0100114
115void nc_tls_server_free_opts(void);
Michal Vasko086311b2016-01-08 09:53:11 +0100116
117#endif /* ENABLE_TLS */
118
119#endif /* NC_SESSION_SERVER_H_ */