Commit 71e7434d authored by Jiří Klimeš's avatar Jiří Klimeš

cli: add 'bond' setting

parent 5cd9b1e2
......@@ -88,6 +88,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, 0), /* 14 */
SETTING_FIELD (NM_SETTING_WIMAX_SETTING_NAME, 0), /* 15 */
SETTING_FIELD (NM_SETTING_INFINIBAND_SETTING_NAME, 0), /* 16 */
SETTING_FIELD (NM_SETTING_BOND_SETTING_NAME, 0), /* 17 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTINGS_NAMES_ALL_X NM_SETTING_CONNECTION_SETTING_NAME","\
......@@ -105,7 +106,8 @@ static NmcOutputField nmc_fields_settings_names[] = {
NM_SETTING_BLUETOOTH_SETTING_NAME","\
NM_SETTING_OLPC_MESH_SETTING_NAME","\
NM_SETTING_VPN_SETTING_NAME","\
NM_SETTING_INFINIBAND_SETTING_NAME
NM_SETTING_INFINIBAND_SETTING_NAME","\
NM_SETTING_BOND_SETTING_NAME
#if WITH_WIMAX
#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X","\
NM_SETTING_WIMAX_SETTING_NAME
......@@ -408,6 +410,15 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[17].name)) {
NMSettingBond *s_bond = nm_connection_get_setting_bond (connection);
if (s_bond) {
setting_bond_details (s_bond, nmc);
was_output = TRUE;
continue;
}
}
}
if (print_settings_array)
......
......@@ -456,6 +456,18 @@ static NmcOutputField nmc_fields_setting_infiniband[] = {
NM_SETTING_INFINIBAND_TRANSPORT_MODE
#define NMC_FIELDS_SETTING_INFINIBAND_COMMON NMC_FIELDS_SETTING_INFINIBAND_ALL
/* Available fields for NM_SETTING_BOND_SETTING_NAME */
static NmcOutputField nmc_fields_setting_bond[] = {
SETTING_FIELD ("name", 8), /* 0 */
SETTING_FIELD (NM_SETTING_BOND_INTERFACE_NAME, 15), /* 1 */
SETTING_FIELD (NM_SETTING_BOND_OPTIONS, 30), /* 2 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_BOND_ALL "name"","\
NM_SETTING_BOND_INTERFACE_NAME","\
NM_SETTING_BOND_OPTIONS
#define NMC_FIELDS_SETTING_BOND_COMMON NMC_FIELDS_SETTING_BOND_ALL
static char *
wep_key_type_to_string (NMWepKeyType type)
......@@ -1559,3 +1571,40 @@ setting_infiniband_details (NMSettingInfiniband *s_infiniband, NmCli *nmc)
return TRUE;
}
gboolean
setting_bond_details (NMSettingBond *s_bond, NmCli *nmc)
{
GString *bond_options_s;
int i;
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE);
nmc->allowed_fields = nmc_fields_setting_bond;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTING_BOND_ALL, nmc->allowed_fields, NULL);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print field names */
bond_options_s = g_string_new (NULL);
for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) {
const char *key, *value;
nm_setting_bond_get_option (s_bond, i, &key, &value);
g_string_append_printf (bond_options_s, "%s=%s,", key, value);
}
g_string_truncate (bond_options_s, bond_options_s->len-1); /* chop off trailing ',' */
nmc->allowed_fields[0].value = NM_SETTING_BOND_SETTING_NAME;
nmc->allowed_fields[1].value = nm_setting_bond_get_interface_name (s_bond);
nmc->allowed_fields[2].value = bond_options_s->str;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
g_string_free (bond_options_s, TRUE);
return TRUE;
}
......@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2010 - 2011 Red Hat, Inc.
* (C) Copyright 2010 - 2012 Red Hat, Inc.
*/
#ifndef NMC_SETTINGS_H
......@@ -37,6 +37,7 @@
#include <nm-setting-vpn.h>
#include <nm-setting-wimax.h>
#include <nm-setting-infiniband.h>
#include <nm-setting-bond.h>
#include "nmcli.h"
#include "utils.h"
......@@ -59,5 +60,6 @@ gboolean setting_olpc_mesh_details (NMSettingOlpcMesh *s_olpc_mesh, NmCli *nmc);
gboolean setting_vpn_details (NMSettingVPN *s_vpn, NmCli *nmc);
gboolean setting_wimax_details (NMSettingWimax *s_wimax, NmCli *nmc);
gboolean setting_infiniband_details (NMSettingInfiniband *s_infiniband, NmCli *nmc);
gboolean setting_bond_details (NMSettingBond *s_bond, NmCli *nmc);
#endif /* NMC_SETTINGS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment