gboolean _dcb_enable (const char *iface, gboolean enable, DcbFunc run_func, gpointer user_data, GError **error) { if (enable) return do_helper (iface, DCBTOOL, run_func, user_data, error, "dcb on"); else return do_helper (iface, DCBTOOL, run_func, user_data, error, "dcb off"); }
gboolean _dcb_cleanup (const char *iface, DcbFunc run_func, gpointer user_data, GError **error) { const char *cmds[] = { "app:fcoe e:0", "app:iscsi e:0", "app:fip e:0", "pfc e:0", "pg e:0", NULL }; const char **iter = cmds; gboolean success = TRUE; /* Turn everything off and return first error we get (if any) */ while (iter && *iter) { if (!do_helper (iface, DCBTOOL, run_func, user_data, success ? error : NULL, "%s", *iter)) success = FALSE; iter++; } if (!_dcb_enable (iface, FALSE, run_func, user_data, success ? error : NULL)) success = FALSE; return success; }
gboolean _fcoe_cleanup (const char *iface, DcbFunc run_func, gpointer user_data, GError **error) { return do_helper (NULL, FCOEADM, run_func, user_data, error, "-d %s", iface); }
void operator()(WorldPacket& data, int32 loc_idx) { char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; va_copy(ap, *i_args); char str [2048]; vsnprintf(str, 2048, text, ap); va_end(ap); do_helper(data, &str[0]); } else do_helper(data, text); }
gboolean _fcoe_setup (const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, GError **error) { NMSettingDcbFlags flags; g_assert (s_dcb); flags = nm_setting_dcb_get_app_fcoe_flags (s_dcb); if (flags & NM_SETTING_DCB_FLAG_ENABLE) { const char *mode = nm_setting_dcb_get_app_fcoe_mode (s_dcb); if (!do_helper (NULL, FCOEADM, run_func, user_data, error, "-m %s -c %s", mode, iface)) return FALSE; } else { if (!do_helper (NULL, FCOEADM, run_func, user_data, error, "-d %s", iface)) return FALSE; } return TRUE; }
gboolean _dcb_setup (const char *iface, NMSettingDcb *s_dcb, DcbFunc run_func, gpointer user_data, GError **error) { NMSettingDcbFlags flags; guint i; g_assert (s_dcb); /* FCoE */ flags = nm_setting_dcb_get_app_fcoe_flags (s_dcb); SET_APP (flags, s_dcb, fcoe); /* iSCSI */ flags = nm_setting_dcb_get_app_iscsi_flags (s_dcb); SET_APP (flags, s_dcb, iscsi); /* FIP */ flags = nm_setting_dcb_get_app_fip_flags (s_dcb); SET_APP (flags, s_dcb, fip); /* Priority Flow Control */ flags = nm_setting_dcb_get_priority_flow_control_flags (s_dcb); SET_FLAGS (flags, "pfc"); if (flags & NM_SETTING_DCB_FLAG_ENABLE) { char buf[10]; for (i = 0; i < 8; i++) buf[i] = nm_setting_dcb_get_priority_flow_control (s_dcb, i) ? '1' : '0'; buf[i] = 0; if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pfc pfcup:%s", buf)) return FALSE; } /* Priority Groups */ flags = nm_setting_dcb_get_priority_group_flags (s_dcb); if (flags & NM_SETTING_DCB_FLAG_ENABLE) { GString *s; gboolean success; guint id; s = g_string_sized_new (150); g_string_append_printf (s, "pg e:1 a:%c w:%c", flags & NM_SETTING_DCB_FLAG_ADVERTISE ? '1' : '0', flags & NM_SETTING_DCB_FLAG_WILLING ? '1' : '0'); /* Priority Groups */ g_string_append (s, " pgid:"); for (i = 0; i < 8; i++) { id = nm_setting_dcb_get_priority_group_id (s_dcb, i); g_assert (id < 8 || id == 15); g_string_append_c (s, (id < 8) ? ('0' + id) : 'f'); } /* Priority Group Bandwidth */ g_string_append_printf (s, " pgpct:%u,%u,%u,%u,%u,%u,%u,%u", nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 0), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 1), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 2), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 3), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 4), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 5), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 6), nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 7)); /* Priority Bandwidth */ g_string_append_printf (s, " uppct:%u,%u,%u,%u,%u,%u,%u,%u", nm_setting_dcb_get_priority_bandwidth (s_dcb, 0), nm_setting_dcb_get_priority_bandwidth (s_dcb, 1), nm_setting_dcb_get_priority_bandwidth (s_dcb, 2), nm_setting_dcb_get_priority_bandwidth (s_dcb, 3), nm_setting_dcb_get_priority_bandwidth (s_dcb, 4), nm_setting_dcb_get_priority_bandwidth (s_dcb, 5), nm_setting_dcb_get_priority_bandwidth (s_dcb, 6), nm_setting_dcb_get_priority_bandwidth (s_dcb, 7)); /* Strict Bandwidth */ g_string_append (s, " strict:"); for (i = 0; i < 8; i++) g_string_append_c (s, nm_setting_dcb_get_priority_strict_bandwidth (s_dcb, i) ? '1' : '0'); /* Priority Traffic Class */ g_string_append (s, " up2tc:"); for (i = 0; i < 8; i++) { id = nm_setting_dcb_get_priority_traffic_class (s_dcb, i); g_assert (id < 8); g_string_append_c (s, '0' + id); } success = do_helper (iface, DCBTOOL, run_func, user_data, error, "%s", s->str); g_string_free (s, TRUE); if (!success) return FALSE; } else { /* Ignore disable failure since lldpad <= 0.9.46 does not support disabling * priority groups without specifying an entire PG config. */ (void) do_helper (iface, DCBTOOL, run_func, user_data, error, "pg e:0"); } return TRUE; }