Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 1 | /** |
| 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 | |
| 32 | int nc_server_init(struct ly_ctx *ctx); |
| 33 | |
| 34 | int nc_server_set_capab_withdefaults(NC_WD_MODE basic_mode, int also_supported); |
| 35 | |
| 36 | int nc_server_set_capab_interleave(int interleave_support); |
| 37 | |
| 38 | int nc_server_set_hello_timeout(uint16_t hello_timeout); |
| 39 | |
| 40 | int nc_server_set_idle_timeout(uint16_t idle_timeout); |
| 41 | |
| 42 | int nc_server_set_max_sessions(uint16_t max_sessions); |
| 43 | |
| 44 | struct nc_session *nc_accept_inout(int fdin, int fdout, const char *username); |
| 45 | |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 46 | struct nc_pollsession *nc_pollsession_new(void); |
| 47 | |
| 48 | void nc_pollsession_free(struct nc_pollsession *ps); |
| 49 | |
| 50 | int nc_pollsession_add_session(struct nc_pollsession *ps, struct nc_session *session); |
| 51 | |
| 52 | int nc_pollsession_poll(struct nc_pollsession *ps, int timeout); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 53 | |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 54 | #if defined(ENABLE_SSH) || defined(ENABLE_TLS) |
| 55 | |
| 56 | int nc_server_add_bind_listen(const char *address, uint16_t port, NC_TRANSPORT_IMPL ti); |
| 57 | |
| 58 | int nc_server_del_bind(const char *address, uint16_t port, NC_TRANSPORT_IMPL ti); |
| 59 | |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 60 | void nc_server_destroy_binds(void); |
| 61 | |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 62 | struct nc_session *nc_accept(int timeout); |
| 63 | |
Michal Vasko | fb89d77 | 2016-01-08 12:25:35 +0100 | [diff] [blame] | 64 | #endif /* ENABLE_SSH || ENABLE_TLS */ |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 65 | |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 66 | #ifdef ENABLE_SSH |
| 67 | |
Michal Vasko | d45e25a | 2016-01-08 15:48:44 +0100 | [diff] [blame] | 68 | /* one for each key */ |
| 69 | int nc_ssh_server_set_hostkey(const char *key_path); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 70 | |
| 71 | int nc_ssh_server_set_banner(const char *banner); |
| 72 | |
| 73 | int nc_ssh_server_set_auth_methods(int auth_methods); |
| 74 | |
| 75 | int nc_ssh_server_set_auth_attempts(uint16_t auth_attempts); |
| 76 | |
| 77 | int nc_ssh_server_set_auth_timeout(uint16_t auth_timeout); |
| 78 | |
| 79 | int nc_ssh_server_add_authkey(const char *keypath, const char *username); |
| 80 | |
| 81 | int nc_ssh_server_del_authkey(const char *keypath, const char *username); |
| 82 | |
Michal Vasko | 9e036d5 | 2016-01-08 10:49:26 +0100 | [diff] [blame] | 83 | void nc_ssh_server_free_opts(void); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 84 | |
| 85 | struct nc_session *nc_accept_ssh_channel(struct nc_session *session, int timeout); |
| 86 | |
| 87 | #endif /* ENABLE_SSH */ |
| 88 | |
| 89 | #ifdef ENABLE_TLS |
| 90 | |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 91 | int nc_tls_server_set_cert(const char *cert); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 92 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 93 | int nc_tls_server_set_cert_path(const char *cert_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 94 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 95 | int nc_tls_server_set_key(const char *privkey, int is_rsa); |
| 96 | |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 97 | int nc_tls_server_set_key_path(const char *privkey_path); |
| 98 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 99 | int nc_tls_server_add_trusted_cert(const char *cert); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 100 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 101 | int nc_tls_server_add_trusted_cert_path(const char *cert_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 102 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 103 | int nc_tls_server_set_trusted_cacert_locations(const char *cacert_file_path, const char *cacert_dir_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 104 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 105 | void nc_tls_server_destroy_certs(void); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 106 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 107 | int nc_tls_server_set_crl_locations(const char *crl_file_path, const char *crl_dir_path); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 108 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 109 | void nc_tls_server_destroy_crls(void); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 110 | |
Michal Vasko | c14e3c8 | 2016-01-11 16:14:30 +0100 | [diff] [blame^] | 111 | int nc_tls_server_add_ctn(uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
| 112 | |
| 113 | int nc_tls_server_del_ctn(int64_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 0457bb4 | 2016-01-08 15:49:13 +0100 | [diff] [blame] | 114 | |
| 115 | void nc_tls_server_free_opts(void); |
Michal Vasko | 086311b | 2016-01-08 09:53:11 +0100 | [diff] [blame] | 116 | |
| 117 | #endif /* ENABLE_TLS */ |
| 118 | |
| 119 | #endif /* NC_SESSION_SERVER_H_ */ |