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