| 1 |
/* |
| 2 |
* This file is part of the SSH Library |
| 3 |
* |
| 4 |
* Copyright (c) 2018 by Red Hat, Inc. |
| 5 |
* |
| 6 |
* Author: Anderson Toshiyuki Sasaki <[email protected]> |
| 7 |
* |
| 8 |
* The SSH Library is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2.1 of the License, or (at your |
| 11 |
* option) any later version. |
| 12 |
* |
| 13 |
* The SSH Library is distributed in the hope that it will be useful, but |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 15 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 16 |
* License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with the SSH Library; see the file COPYING. If not, write to |
| 20 |
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 21 |
* MA 02111-1307, USA. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "config.h" |
| 25 |
|
| 26 |
#include <stdbool.h> |
| 27 |
#include <fcntl.h> |
| 28 |
|
| 29 |
#include <libssh/libssh.h> |
| 30 |
#include <libssh/server.h> |
| 31 |
#include <libssh/callbacks.h> |
| 32 |
|
| 33 |
struct server_state_st { |
| 34 |
/* Arguments */ |
| 35 |
char *address; |
| 36 |
int port; |
| 37 |
|
| 38 |
char *ecdsa_key; |
| 39 |
char *ed25519_key; |
| 40 |
char *rsa_key; |
| 41 |
char *host_key; |
| 42 |
|
| 43 |
int verbosity; |
| 44 |
int auth_methods; |
| 45 |
bool with_pcap; |
| 46 |
|
| 47 |
char *pcap_file; |
| 48 |
|
| 49 |
char *expected_username; |
| 50 |
char *expected_password; |
| 51 |
|
| 52 |
char *config_file; |
| 53 |
bool parse_global_config; |
| 54 |
|
| 55 |
char *log_file; |
| 56 |
bool gssapi_key_exchange; |
| 57 |
const char *gssapi_key_exchange_algs; |
| 58 |
|
| 59 |
/* State */ |
| 60 |
int max_tries; |
| 61 |
int error; |
| 62 |
|
| 63 |
struct ssh_server_callbacks_struct *server_cb; |
| 64 |
struct ssh_channel_callbacks_struct *channel_cb; |
| 65 |
|
| 66 |
/* Callback to handle the session, should block until disconnected */ |
| 67 |
void (*handle_session)(ssh_event event, |
| 68 |
ssh_session session, |
| 69 |
struct server_state_st *state); |
| 70 |
}; |
| 71 |
|
| 72 |
/*TODO: Add documentation */ |
| 73 |
void free_server_state(struct server_state_st *state); |
| 74 |
|
| 75 |
/*TODO: Add documentation */ |
| 76 |
int run_server(struct server_state_st *state); |
| 77 |
|
| 78 |
/*TODO: Add documentation */ |
| 79 |
pid_t |
| 80 |
fork_run_server(struct server_state_st *state, |
| 81 |
void (*free_state) (void **userdata), |
| 82 |
void *userdata); |