2012-01-06 13:51:33 +01:00
|
|
|
/*
|
|
|
|
|
* nmcli - command-line tool for controlling NetworkManager
|
|
|
|
|
* Common functions and data shared between files.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
2014-11-20 12:36:14 +01:00
|
|
|
* Copyright 2012 - 2014 Red Hat, Inc.
|
2012-01-06 13:51:33 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NMC_COMMON_H
|
|
|
|
|
#define NMC_COMMON_H
|
|
|
|
|
|
|
|
|
|
#include "nmcli.h"
|
2014-11-20 12:36:14 +01:00
|
|
|
#include "nm-secret-agent-simple.h"
|
2012-01-06 13:51:33 +01:00
|
|
|
|
2017-04-06 15:14:23 +02:00
|
|
|
gboolean print_ip4_config (NMIPConfig *cfg4, const NmcConfig *nmc_config, const char *one_field);
|
2017-03-30 14:56:19 +02:00
|
|
|
gboolean print_ip6_config (NMIPConfig *cfg6, const NmcConfig *nmc_config, const char *group_prefix, const char *one_field);
|
2018-04-21 13:15:58 +02:00
|
|
|
gboolean print_dhcp_config (NMDhcpConfig *dhcp, const NmcConfig *nmc_config, const char *group_prefix, const char *one_field);
|
2012-01-06 13:51:33 +01:00
|
|
|
|
2014-10-22 12:32:46 -04:00
|
|
|
NMConnection *nmc_find_connection (const GPtrArray *connections,
|
2014-04-16 18:23:50 +02:00
|
|
|
const char *filter_type,
|
|
|
|
|
const char *filter_val,
|
2016-07-07 14:53:34 +02:00
|
|
|
int *start,
|
|
|
|
|
gboolean complete);
|
2014-04-16 18:23:50 +02:00
|
|
|
|
2018-04-21 11:22:53 +02:00
|
|
|
NMActiveConnection *nmc_find_active_connection (const GPtrArray *active_cons,
|
|
|
|
|
const char *filter_type,
|
|
|
|
|
const char *filter_val,
|
|
|
|
|
int *idx,
|
|
|
|
|
gboolean complete);
|
|
|
|
|
|
2014-11-20 12:36:14 +01:00
|
|
|
void nmc_secrets_requested (NMSecretAgentSimple *agent,
|
|
|
|
|
const char *request_id,
|
|
|
|
|
const char *title,
|
|
|
|
|
const char *msg,
|
|
|
|
|
GPtrArray *secrets,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2015-10-05 15:12:14 +02:00
|
|
|
char *nmc_unique_connection_name (const GPtrArray *connections,
|
|
|
|
|
const char *try_name);
|
|
|
|
|
|
2014-05-15 10:31:09 +02:00
|
|
|
void nmc_cleanup_readline (void);
|
2014-06-02 10:18:13 +02:00
|
|
|
char *nmc_readline (const char *prompt_fmt, ...) G_GNUC_PRINTF (1, 2);
|
2015-12-04 12:57:31 +01:00
|
|
|
char *nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) G_GNUC_PRINTF (2, 3);
|
2017-04-11 15:48:04 +02:00
|
|
|
NmcCompEntryFunc nmc_rl_compentry_func_wrap (const char *const*values);
|
2017-03-25 13:20:11 +01:00
|
|
|
char *nmc_rl_gen_func_basic (const char *text, int state, const char *const*words);
|
2016-09-15 01:20:53 +02:00
|
|
|
char *nmc_rl_gen_func_ifnames (const char *text, int state);
|
2014-06-16 08:30:22 +02:00
|
|
|
gboolean nmc_get_in_readline (void);
|
|
|
|
|
void nmc_set_in_readline (gboolean in_readline);
|
2014-05-15 10:31:09 +02:00
|
|
|
|
2014-11-20 12:36:14 +01:00
|
|
|
/* for pre-filling a string to readline prompt */
|
|
|
|
|
extern char *nmc_rl_pre_input_deftext;
|
|
|
|
|
int nmc_rl_set_deftext (void);
|
|
|
|
|
|
2015-11-10 14:06:02 +01:00
|
|
|
char *nmc_parse_lldp_capabilities (guint value);
|
|
|
|
|
|
2016-06-23 12:18:52 +02:00
|
|
|
typedef struct {
|
|
|
|
|
const char *cmd;
|
|
|
|
|
NMCResultCode (*func) (NmCli *nmc, int argc, char **argv);
|
|
|
|
|
void (*usage) (void);
|
2016-08-31 21:04:33 +02:00
|
|
|
gboolean needs_client;
|
|
|
|
|
gboolean needs_nm_running;
|
2016-06-23 12:18:52 +02:00
|
|
|
} NMCCommand;
|
|
|
|
|
|
2016-08-31 21:04:33 +02:00
|
|
|
void nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char **argv);
|
2016-06-23 12:18:52 +02:00
|
|
|
|
2016-06-24 18:36:14 +02:00
|
|
|
void nmc_complete_strings (const char *prefix, ...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
2016-06-24 18:56:36 +02:00
|
|
|
void nmc_complete_bool (const char *prefix);
|
|
|
|
|
|
2016-08-19 11:56:58 +02:00
|
|
|
const char *nmc_error_get_simple_message (GError *error);
|
|
|
|
|
|
2017-04-06 15:14:23 +02:00
|
|
|
extern const NmcMetaGenericInfo *const metagen_ip4_config[];
|
cli: split tracking of meta data out of NmcOutputField
When generating output data, nmcli iterates over a list of
property-descriptors (nmc_fields_ip4_config), creates an intermediate
array (output_data) and finally prints it.
However, previously both the meta data (nmc_fields_ip4_config) and
the intermediate format use the same type NmcOutputField. This means,
certain fields are relevant to describe a property, and other fields
are output/formatting fields.
Split this up. Now, the meta data is tracked in form of an NMMetaAbstractInfo
lists. This separates the information about properties from intermediate steps
during creation of the output.
Note that currently functions like print_ip4_config() still have all the
knowledge about how to generate the output. That is wrong, instead, the
meta data (NMMetaAbstractInfo) should describe how to create the output
and then all those functions could be replaced. This means, later we want
to add more knowledge to the NMMetaAbstractInfo, so it is important to
keep them separate from NmcOutputField.
2017-03-31 19:18:16 +02:00
|
|
|
extern const NmcMetaGenericInfo *const nmc_fields_ip6_config[];
|
2018-04-21 13:15:58 +02:00
|
|
|
extern const NmcMetaGenericInfo *const nmc_fields_dhcp_config[];
|
2016-07-27 16:24:30 +02:00
|
|
|
|
2012-01-06 13:51:33 +01:00
|
|
|
#endif /* NMC_COMMON_H */
|