1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
24 #define STANDARD_NETCONF_PORT 830
25 #define STANDARD_FTP_PORT 21
26 #define STANDARD_SFTP_PORT 22
28 #define KS_KEY_NAME "melacon_server_key"
29 #define SERVER_PUBLIC_SSH_KEY_PATH "/home/netconf/.ssh/melacon.server.key.pub"
31 //filesystem functions
32 bool dir_exists(const char *path);
33 bool file_exists(const char *fname);
34 void file_touch(const char *fname, const char *content); //content can be null for just-touching
35 char *file_read_content(const char *fname);
37 int get_int_from_string_with_default(const char *string, int default_value);
38 char *get_current_date_and_time(void);
39 long int get_microseconds_since_epoch(void);
41 //networking functions
42 bool get_local_ips(const char *ifname, char **ipv4, char **ipv6);
43 bool check_port_open(const char *host, uint16_t port);
45 char *b64_encode(const unsigned char *data, size_t input_length);
46 char *str_replace(const char *orig, const char *rep, const char *with);
48 char *read_key(const char *filename);