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 | |
| 91 | void nc_tls_server_init(void); |
| 92 | |
| 93 | void nc_tls_server_destroy(void); |
| 94 | |
| 95 | #endif /* ENABLE_TLS */ |
| 96 | |
| 97 | #endif /* NC_SESSION_SERVER_H_ */ |