Esempio n. 1
0
/* Appends a string representation of the TCP flags value 'tcp_flags'
 * (e.g. obtained via packet_get_tcp_flags() or TCP_FLAGS) to 's', in the
 * format used by tcpdump. */
void
packet_format_tcp_flags(struct ds *s, uint8_t tcp_flags)
{
    if (!tcp_flags) {
        ds_put_cstr(s, "none");
        return;
    }

    if (tcp_flags & TCP_SYN) {
        ds_put_char(s, 'S');
    }
    if (tcp_flags & TCP_FIN) {
        ds_put_char(s, 'F');
    }
    if (tcp_flags & TCP_PSH) {
        ds_put_char(s, 'P');
    }
    if (tcp_flags & TCP_RST) {
        ds_put_char(s, 'R');
    }
    if (tcp_flags & TCP_URG) {
        ds_put_char(s, 'U');
    }
    if (tcp_flags & TCP_ACK) {
        ds_put_char(s, '.');
    }
    if (tcp_flags & 0x40) {
        ds_put_cstr(s, "[40]");
    }
    if (tcp_flags & 0x80) {
        ds_put_cstr(s, "[80]");
    }
}
char *
ovsdb_type_to_english(const struct ovsdb_type *type)
{
    const char *key = ovsdb_atomic_type_to_string(type->key.type);
    const char *value = ovsdb_atomic_type_to_string(type->value.type);
    if (ovsdb_type_is_scalar(type)) {
        return xstrdup(key);
    } else {
        struct ds s = DS_EMPTY_INITIALIZER;
        ds_put_cstr(&s, ovsdb_type_is_set(type) ? "set" : "map");
        if (type->n_max == UINT_MAX) {
            if (type->n_min) {
                ds_put_format(&s, " of %u or more", type->n_min);
            } else {
                ds_put_cstr(&s, " of");
            }
        } else if (type->n_min) {
            ds_put_format(&s, " of %u to %u", type->n_min, type->n_max);
        } else {
            ds_put_format(&s, " of up to %u", type->n_max);
        }
        if (ovsdb_type_is_set(type)) {
            ds_put_format(&s, " %ss", key);
        } else {
            ds_put_format(&s, " (%s, %s) pairs", key, value);
        }
        return ds_cstr(&s);
    }
}
Esempio n. 3
0
action_syntax_error(struct action_context *ctx, const char *message, ...)
{
    if (action_error_handle_common(ctx)) {
        return;
    }

    struct ds s;

    ds_init(&s);
    ds_put_cstr(&s, "Syntax error");
    if (ctx->lexer->token.type == LEX_T_END) {
        ds_put_cstr(&s, " at end of input");
    } else if (ctx->lexer->start) {
        ds_put_format(&s, " at `%.*s'",
                      (int) (ctx->lexer->input - ctx->lexer->start),
                      ctx->lexer->start);
    }

    if (message) {
        ds_put_char(&s, ' ');

        va_list args;
        va_start(args, message);
        ds_put_format_valist(&s, message, args);
        va_end(args);
    }
    ds_put_char(&s, '.');

    ctx->error = ds_steal_cstr(&s);
}
Esempio n. 4
0
static void
jsonrpc_log_msg(const struct jsonrpc *rpc, const char *title,
                const struct jsonrpc_msg *msg)
{
    if (VLOG_IS_DBG_ENABLED()) {
        struct ds s = DS_EMPTY_INITIALIZER;
        if (msg->method) {
            ds_put_format(&s, ", method=\"%s\"", msg->method);
        }
        if (msg->params) {
            ds_put_cstr(&s, ", params=");
            json_to_ds(msg->params, 0, &s);
        }
        if (msg->result) {
            ds_put_cstr(&s, ", result=");
            json_to_ds(msg->result, 0, &s);
        }
        if (msg->error) {
            ds_put_cstr(&s, ", error=");
            json_to_ds(msg->error, 0, &s);
        }
        if (msg->id) {
            ds_put_cstr(&s, ", id=");
            json_to_ds(msg->id, 0, &s);
        }
        VLOG_DBG("%s: %s %s%s", rpc->name, title,
                 jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s));
        ds_destroy(&s);
    }
}
Esempio n. 5
0
/* Given 'status', which is a process status in the form reported by waitpid(2)
 * and returned by process_status(), returns a string describing how the
 * process terminated.  The caller is responsible for freeing the string when
 * it is no longer needed. */
char *
process_status_msg(int status)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
#ifndef _WIN32
    if (WIFEXITED(status)) {
        ds_put_format(&ds, "exit status %d", WEXITSTATUS(status));
    } else if (WIFSIGNALED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];

        ds_put_format(&ds, "killed (%s)",
                      signal_name(WTERMSIG(status), namebuf, sizeof namebuf));
    } else if (WIFSTOPPED(status)) {
        char namebuf[SIGNAL_NAME_BUFSIZE];

        ds_put_format(&ds, "stopped (%s)",
                      signal_name(WSTOPSIG(status), namebuf, sizeof namebuf));
    } else {
        ds_put_format(&ds, "terminated abnormally (%x)", status);
    }
    if (WCOREDUMP(status)) {
        ds_put_cstr(&ds, ", core dumped");
    }
#else
    ds_put_cstr(&ds, "function not supported.");
#endif
    return ds_cstr(&ds);
}
Esempio n. 6
0
/* Appends a human-readable representation of 'nab' to 's'. */
void
bundle_format(const struct nx_action_bundle *nab, struct ds *s)
{
    const char *action, *fields, *algorithm, *slave_type;
    size_t i;

    fields = flow_hash_fields_to_str(ntohs(nab->fields));

    switch (ntohs(nab->algorithm)) {
    case NX_BD_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_BD_ALG_ACTIVE_BACKUP:
        algorithm = "active_backup";
        break;
    default:
        algorithm = "<unknown>";
    }

    switch (ntohl(nab->slave_type)) {
    case NXM_OF_IN_PORT:
        slave_type = "ofport";
        break;
    default:
        slave_type = "<unknown>";
    }

    switch (ntohs(nab->subtype)) {
    case NXAST_BUNDLE:
        action = "bundle";
        break;
    case NXAST_BUNDLE_LOAD:
        action = "bundle_load";
        break;
    default:
        NOT_REACHED();
    }

    ds_put_format(s, "%s(%s,%"PRIu16",%s,%s,", action, fields,
                  ntohs(nab->basis), algorithm, slave_type);

    if (nab->subtype == htons(NXAST_BUNDLE_LOAD)) {
        nxm_format_field_bits(s, ntohl(nab->dst),
                              nxm_decode_ofs(nab->ofs_nbits),
                              nxm_decode_n_bits(nab->ofs_nbits));
        ds_put_cstr(s, ",");
    }

    ds_put_cstr(s, "slaves:");
    for (i = 0; i < ntohs(nab->n_slaves); i++) {
        if (i) {
            ds_put_cstr(s, ",");
        }

        ds_put_format(s, "%"PRIu16, bundle_get_slave(nab, i));
    }

    ds_put_cstr(s, ")");
}
Esempio n. 7
0
void
format_odp_flow(struct ds *ds, const struct odp_flow *f)
{
    flow_format(ds, &f->key);
    ds_put_cstr(ds, ", ");
    format_odp_flow_stats(ds, &f->stats);
    ds_put_cstr(ds, ", actions:");
    format_odp_actions(ds, f->actions, f->n_actions);
}
Esempio n. 8
0
static void
output_frequency_table (const struct two_sample_test *t2s,
			const struct sign_test_params *param,
			const struct dictionary *dict)
{
  int i;
  struct tab_table *table = tab_create (3, 1 + 4 * t2s->n_pairs);

  const struct variable *wv = dict_get_weight (dict);
  const struct fmt_spec *wfmt = wv ? var_get_print_format (wv) : & F_8_0;

  tab_set_format (table, RC_WEIGHT, wfmt);
  tab_title (table, _("Frequencies"));

  tab_headers (table, 2, 0, 1, 0);

  /* Vertical lines inside the box */
  tab_box (table, 0, 0, -1, TAL_1,
	   1, 0, tab_nc (table) - 1, tab_nr (table) - 1 );

  /* Box around entire table */
  tab_box (table, TAL_2, TAL_2, -1, -1,
	   0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );

  tab_text (table,  2, 0,  TAB_CENTER, _("N"));

  for (i = 0 ; i < t2s->n_pairs; ++i)
    {
      variable_pair *vp = &t2s->pairs[i];

      struct string pair_name;
      ds_init_cstr (&pair_name, var_to_string ((*vp)[0]));
      ds_put_cstr (&pair_name, " - ");
      ds_put_cstr (&pair_name, var_to_string ((*vp)[1]));


      tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name));

      ds_destroy (&pair_name);

      tab_hline (table, TAL_1, 0, tab_nc (table) - 1, 1 + i * 4);

      tab_text (table,  1, 1 + i * 4,  TAB_LEFT, _("Negative Differences"));
      tab_text (table,  1, 2 + i * 4,  TAB_LEFT, _("Positive Differences"));
      tab_text (table,  1, 3 + i * 4,  TAB_LEFT, _("Ties"));
      tab_text (table,  1, 4 + i * 4,  TAB_LEFT, _("Total"));

      tab_double (table, 2, 1 + i * 4, TAB_RIGHT, param[i].neg, NULL, RC_WEIGHT);
      tab_double (table, 2, 2 + i * 4, TAB_RIGHT, param[i].pos, NULL, RC_WEIGHT);
      tab_double (table, 2, 3 + i * 4, TAB_RIGHT, param[i].ties, NULL, RC_WEIGHT);
      tab_double (table, 2, 4 + i * 4, TAB_RIGHT,
		  param[i].ties + param[i].neg + param[i].pos, NULL, RC_WEIGHT);
    }

  tab_submit (table);
}
Esempio n. 9
0
static void
output_statistics_table (const struct two_sample_test *t2s,
			 const struct sign_test_params *param)
{
  int i;
  struct tab_table *table = tab_create (1 + t2s->n_pairs, 4);

  tab_title (table, _("Test Statistics"));

  tab_headers (table, 0, 1,  0, 1);

  tab_hline (table, TAL_2, 0, tab_nc (table) - 1, 1);
  tab_vline (table, TAL_2, 1, 0, tab_nr (table) - 1);


  /* Vertical lines inside the box */
  tab_box (table, -1, -1, -1, TAL_1,
	   0, 0,
	   tab_nc (table) - 1, tab_nr (table) - 1);

  /* Box around entire table */
  tab_box (table, TAL_2, TAL_2, -1, -1,
	   0, 0, tab_nc (table) - 1,
	   tab_nr (table) - 1);

  tab_text (table,  0, 1, TAT_TITLE | TAB_LEFT,
	    _("Exact Sig. (2-tailed)"));

  tab_text (table,  0, 2, TAT_TITLE | TAB_LEFT,
	    _("Exact Sig. (1-tailed)"));

  tab_text (table,  0, 3, TAT_TITLE | TAB_LEFT,
	    _("Point Probability"));

  for (i = 0 ; i < t2s->n_pairs; ++i)
    {
      variable_pair *vp = &t2s->pairs[i];

      struct string pair_name;
      ds_init_cstr (&pair_name, var_to_string ((*vp)[0]));
      ds_put_cstr (&pair_name, " - ");
      ds_put_cstr (&pair_name, var_to_string ((*vp)[1]));

      tab_text (table,  1 + i, 0, TAB_LEFT, ds_cstr (&pair_name));
      ds_destroy (&pair_name);

      tab_double (table, 1 + i, 1, TAB_RIGHT,
		  param[i].one_tailed_sig * 2, NULL, RC_PVALUE);

      tab_double (table, 1 + i, 2, TAB_RIGHT, param[i].one_tailed_sig, NULL, RC_PVALUE);
      tab_double (table, 1 + i, 3, TAB_RIGHT, param[i].point_prob, NULL, RC_PVALUE);
    }

  tab_submit (table);
}
Esempio n. 10
0
char *
svec_join(const struct svec *svec, const char *delimiter)
{
    struct ds ds;
    size_t i;

    ds_init(&ds);
    for (i = 0; i < svec->n; i++) {
        if (i) {
            ds_put_cstr(&ds, delimiter);
        }
        ds_put_cstr(&ds, svec->names[i]);
    }
    return ds_cstr(&ds);
}
Esempio n. 11
0
/* Given 'status', which is a process status in the form reported by waitpid(2)
 * and returned by process_status(), returns a string describing how the
 * process terminated.  The caller is responsible for freeing the string when
 * it is no longer needed. */
char *
process_status_msg(int status)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
    if (WIFEXITED(status)) {
        ds_put_format(&ds, "exit status %d", WEXITSTATUS(status));
    } else if (WIFSIGNALED(status) || WIFSTOPPED(status)) {
        int signr = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status);
        const char *name = NULL;
#ifdef HAVE_STRSIGNAL
        name = strsignal(signr);
#endif
        ds_put_format(&ds, "%s by signal %d",
                      WIFSIGNALED(status) ? "killed" : "stopped", signr);
        if (name) {
            ds_put_format(&ds, " (%s)", name);
        }
    } else {
        ds_put_format(&ds, "terminated abnormally (%x)", status);
    }
    if (WCOREDUMP(status)) {
        ds_put_cstr(&ds, ", core dumped");
    }
    return ds_cstr(&ds);
}
Esempio n. 12
0
static void
print_queue_stat(struct ds *string, const char *leader, uint64_t stat,
                 int more)
{
    ds_put_cstr(string, leader);
    if (stat != UINT64_MAX) {
        ds_put_format(string, "%"PRIu64, stat);
    } else {
        ds_put_char(string, '?');
    }
    if (more) {
        ds_put_cstr(string, ", ");
    } else {
        ds_put_cstr(string, "\n");
    }
}
Esempio n. 13
0
/* Returns a single string that consists of each of the strings in SA
   concatenated, separated from each other with SEPARATOR.

   The caller is responsible for freeing the returned string with free(). */
char *
string_array_join (const struct string_array *sa, const char *separator)
{
  struct string dst;
  const char *s;
  size_t i;

  ds_init_empty (&dst);
  STRING_ARRAY_FOR_EACH (s, i, sa)
    {
      if (i > 0)
        ds_put_cstr (&dst, separator);
      ds_put_cstr (&dst, s);
    }
  return ds_steal_cstr (&dst);
}
Esempio n. 14
0
void
handle_acl_log(const struct flow *headers, struct ofpbuf *userdata)
{
    if (!VLOG_IS_INFO_ENABLED()) {
        return;
    }

    struct log_pin_header *lph = ofpbuf_try_pull(userdata, sizeof *lph);
    if (!lph) {
        VLOG_WARN("log data missing");
        return;
    }

    size_t name_len = userdata->size;
    char *name = name_len ? xmemdup0(userdata->data, name_len) : NULL;

    struct ds ds = DS_EMPTY_INITIALIZER;
    ds_put_cstr(&ds, "name=");
    json_string_escape(name_len ? name : "<unnamed>", &ds);
    ds_put_format(&ds, ", verdict=%s, severity=%s: ",
                  log_verdict_to_string(lph->verdict),
                  log_severity_to_string(lph->severity));
    flow_format(&ds, headers, NULL);

    VLOG_INFO("%s", ds_cstr(&ds));
    ds_destroy(&ds);
    free(name);
}
Esempio n. 15
0
char *
process_escape_args(char **argv)
{
    struct ds ds = DS_EMPTY_INITIALIZER;
    char **argp;
    for (argp = argv; *argp; argp++) {
        const char *arg = *argp;
        const char *p;
        if (argp != argv) {
            ds_put_char(&ds, ' ');
        }
        if (arg[strcspn(arg, " \t\r\n\v\\\'\"")]) {
            ds_put_char(&ds, '"');
            for (p = arg; *p; p++) {
                if (*p == '\\' || *p == '\"') {
                    ds_put_char(&ds, '\\');
                }
                ds_put_char(&ds, *p);
            }
            ds_put_char(&ds, '"');
        } else {
            ds_put_cstr(&ds, arg);
        }
    }
    return ds_cstr(&ds);
}
Esempio n. 16
0
static int
new_pstream(char *suffix, const char *name, struct pstream **pstreamp,
            int dscp, char *unlink_path, bool kernel_print_port)
{
    struct sockaddr_storage ss;
    int error;
    int fd;

    fd = inet_open_passive(SOCK_STREAM, suffix, -1, &ss, dscp,
                           kernel_print_port);
    if (fd < 0) {
        return -fd;
    }

    struct ds bound_name = DS_EMPTY_INITIALIZER;
    if (!name) {
        ds_put_format(&bound_name, "ptcp:%"PRIu16":", ss_get_port(&ss));
        ss_format_address(&ss, &bound_name);
    } else {
        ds_put_cstr(&bound_name, name);
    }

    error = new_fd_pstream(ds_steal_cstr(&bound_name), fd,
                           ptcp_accept, unlink_path, pstreamp);
    if (!error) {
        pstream_set_bound_port(*pstreamp, htons(ss_get_port(&ss)));
    }
    return error;
}
void
classifierd_debug_dump_port_acl_info(struct ds *ds,
                                     const struct ovsrec_port *port_row)
{
    struct ovsrec_acl *acl;

    if(port_row)
    {
        acl = port_row->aclv4_in_applied;
        if(acl) {
            ds_put_cstr(ds, "aclv4_in: ");
            ds_put_format(ds, "name=%s",acl->name);
            ds_put_cstr(ds,"\n");
        }
    }
}
Esempio n. 18
0
static void
flow_format_mpls(const struct flow *flow, struct ds *s)
{
    if (flow->dl_type == htons(ETH_TYPE_MPLS)) {
        ds_put_cstr(s, "mpls");
    } else if (flow->dl_type == htons(ETH_TYPE_MPLS_MCAST)) {
        ds_put_cstr(s, "mplsm");
    } else {
        return;
    }

    ds_put_format(s, "(label:%"PRIu32",tc:%d,ttl:%d,bos:%d),",
                  mpls_lse_to_label(flow->mpls_lse),
                  mpls_lse_to_tc(flow->mpls_lse),
                  mpls_lse_to_ttl(flow->mpls_lse),
                  mpls_lse_to_bos(flow->mpls_lse));
}
Esempio n. 19
0
static void format_tunnel_flags(uint16_t flags, struct ds *ds)
{
    flags &= ~FLOW_TNL_F_KEY;

    if (flags & FLOW_TNL_F_DONT_FRAGMENT) {
        ds_put_cstr(ds, ",df");
        flags &= ~FLOW_TNL_F_DONT_FRAGMENT;
    }

    if (flags & FLOW_TNL_F_CSUM) {
        ds_put_cstr(ds, ",csum");
        flags &= ~FLOW_TNL_F_CSUM;
    }

    if (flags) {
        ds_put_format(ds, ",flags:%#"PRIx16, flags);
    }
}
Esempio n. 20
0
void
flow_format(struct ds *ds, const struct flow *flow)
{
    ds_put_format(ds, "priority:%"PRIu32
                      ",tunnel:%#"PRIx64
                      ",metadata:%#"PRIx64
                      ",in_port:%04"PRIx16,
                      flow->skb_priority,
                      ntohll(flow->tun_id),
                      ntohll(flow->metadata),
                      flow->in_port);

    ds_put_format(ds, ",tci(");
    if (flow->vlan_tci) {
        ds_put_format(ds, "vlan:%"PRIu16",pcp:%d",
                      vlan_tci_to_vid(flow->vlan_tci),
                      vlan_tci_to_pcp(flow->vlan_tci));
    } else {
        ds_put_char(ds, '0');
    }
    ds_put_format(ds, ") mac("ETH_ADDR_FMT"->"ETH_ADDR_FMT
                      ") type:%04"PRIx16,
                  ETH_ADDR_ARGS(flow->dl_src),
                  ETH_ADDR_ARGS(flow->dl_dst),
                  ntohs(flow->dl_type));

    if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
        ds_put_format(ds, " label:%#"PRIx32" proto:%"PRIu8" tos:%#"PRIx8
                          " ttl:%"PRIu8" ipv6(",
                      ntohl(flow->ipv6_label), flow->nw_proto,
                      flow->nw_tos, flow->nw_ttl);
        print_ipv6_addr(ds, &flow->ipv6_src);
        ds_put_cstr(ds, "->");
        print_ipv6_addr(ds, &flow->ipv6_dst);
        ds_put_char(ds, ')');
    } else {
        ds_put_format(ds, " proto:%"PRIu8" tos:%#"PRIx8" ttl:%"PRIu8
                          " ip("IP_FMT"->"IP_FMT")",
                          flow->nw_proto, flow->nw_tos, flow->nw_ttl,
                          IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst));
    }
    if (flow->nw_frag) {
        ds_put_format(ds, " frag(%s)",
                      flow->nw_frag == FLOW_NW_FRAG_ANY ? "first"
                      : flow->nw_frag == (FLOW_NW_FRAG_ANY | FLOW_NW_FRAG_LATER)
                      ? "later" : "<error>");
    }
    if (flow->tp_src || flow->tp_dst) {
        ds_put_format(ds, " port(%"PRIu16"->%"PRIu16")",
                ntohs(flow->tp_src), ntohs(flow->tp_dst));
    }
    if (!eth_addr_is_zero(flow->arp_sha) || !eth_addr_is_zero(flow->arp_tha)) {
        ds_put_format(ds, " arp_ha("ETH_ADDR_FMT"->"ETH_ADDR_FMT")",
                ETH_ADDR_ARGS(flow->arp_sha),
                ETH_ADDR_ARGS(flow->arp_tha));
    }
}
Esempio n. 21
0
static void
ofp_print_queue_name(struct ds *string, uint32_t queue_id)
{
    if (queue_id == OFPQ_ALL) {
        ds_put_cstr(string, "ALL");
    } else {
        ds_put_format(string, "%"PRIu32, queue_id);
    }
}
Esempio n. 22
0
/* Returns a string that represents 'protocols'.  The return value might be a
 * comma-separated list if 'protocols' doesn't have a simple name.  The return
 * value is "none" if 'protocols' is 0.
 *
 * The caller must free the returned string (with free()). */
char *
ofputil_protocols_to_string(enum ofputil_protocol protocols)
{
    struct ds s;

    ovs_assert(!(protocols & ~OFPUTIL_P_ANY));
    if (protocols == 0) {
        return xstrdup("none");
    }

    ds_init(&s);
    while (protocols) {
        const struct proto_abbrev *p;
        int i;

        if (s.length) {
            ds_put_char(&s, ',');
        }

        for (p = proto_abbrevs; p < &proto_abbrevs[N_PROTO_ABBREVS]; p++) {
            if ((protocols & p->protocol) == p->protocol) {
                ds_put_cstr(&s, p->name);
                protocols &= ~p->protocol;
                goto match;
            }
        }

        for (i = 0; i < CHAR_BIT * sizeof(enum ofputil_protocol); i++) {
            enum ofputil_protocol bit = 1u << i;

            if (protocols & bit) {
                ds_put_cstr(&s, ofputil_protocol_to_string(bit));
                protocols &= ~bit;
                goto match;
            }
        }
        OVS_NOT_REACHED();

    match: ;
    }
    return ds_steal_cstr(&s);
}
Esempio n. 23
0
static void
acc (struct statistic *s, const struct ccase *cx,
     double c UNUSED, double cc UNUSED, double y)
{
  struct box_whisker *bw = UP_CAST (s, struct box_whisker, parent.parent);
  bool extreme;
  struct outlier *o;

  if ( y > bw->hinges[2] + bw->step) /* Upper outlier */
    {
      extreme = (y > bw->hinges[2] + 2 * bw->step) ;
    }

  else if (y < bw->hinges[0] - bw->step) /* Lower outlier */
    {
      extreme = (y < bw->hinges[0] - 2 * bw->step) ;
    }

  else /* Not an outlier */
    {
      if (bw->whiskers[0] == SYSMIS)
	bw->whiskers[0] = y;

      if (y > bw->whiskers[1])
	bw->whiskers[1] = y;
	  
      return;
    }

  /* y is an outlier */

  o = xzalloc (sizeof *o) ;
  o->value = y;
  o->extreme = extreme;
  ds_init_empty (&o->label);

  if (bw->id_var)
    {
      char *s = data_out (case_data_idx (cx, bw->id_idx),
                           var_get_encoding (bw->id_var),
                           var_get_print_format (bw->id_var));

      ds_put_cstr (&o->label, s);
      free (s);
    }
  else
    {
      ds_put_format (&o->label,
                     "%ld",
                     (casenumber) case_data_idx (cx, bw->id_idx)->f);
    }

  ll_push_head (&bw->outliers, &o->ll);
}
Esempio n. 24
0
enum ofperr
ofputil_queue_stats_reply_format(struct ds *string,
                                 const struct ofp_header *oh,
                                 const struct ofputil_port_map *port_map,
                                 int verbosity)
{
    ds_put_format(string, " %"PRIuSIZE" queues\n",
                  ofputil_count_queue_stats(oh));
    if (verbosity < 1) {
        return 0;
    }

    struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
    for (;;) {
        struct ofputil_queue_stats qs;
        int retval;

        retval = ofputil_decode_queue_stats(&qs, &b);
        if (retval) {
            return retval != EOF ? retval : 0;
        }

        ds_put_cstr(string, "  port ");
        ofputil_format_port(qs.port_no, port_map, string);
        ds_put_cstr(string, " queue ");
        ofp_print_queue_name(string, qs.queue_id);
        ds_put_cstr(string, ": ");

        print_queue_stat(string, "bytes=", qs.tx_bytes, 1);
        print_queue_stat(string, "pkts=", qs.tx_packets, 1);
        print_queue_stat(string, "errors=", qs.tx_errors, 1);

        ds_put_cstr(string, "duration=");
        if (qs.duration_sec != UINT32_MAX) {
            ofp_print_duration(string, qs.duration_sec, qs.duration_nsec);
        } else {
            ds_put_char(string, '?');
        }
        ds_put_char(string, '\n');
    }
}
void
classifierd_debug_dump_interface_info(struct ds *ds,
                                      struct ovsrec_interface *interface)
{
    if(interface == NULL) {
        VLOG_ERR("%s: NULL interface\n",__FUNCTION__);
        return;
    }

    ds_put_cstr(ds, "interface: ");
    ds_put_format(ds, "name=%s ",interface->name);

    /* @todo this needs to be updated to print hw_ready_state once
     * updated schema is available after port state pecking order
     * changes.
     */
    if(interface->admin_state) {
        ds_put_format(ds, "admin_state=%s ", interface->admin_state);
    }
    ds_put_cstr(ds,"\n");
}
Esempio n. 26
0
enum ofperr
ofputil_queue_stats_request_format(struct ds *string,
                                   const struct ofp_header *oh,
                                   const struct ofputil_port_map *port_map)
{
    struct ofputil_queue_stats_request oqsr;
    enum ofperr error;

    error = ofputil_decode_queue_stats_request(oh, &oqsr);
    if (error) {
        return error;
    }

    ds_put_cstr(string, " port=");
    ofputil_format_port(oqsr.port_no, port_map, string);

    ds_put_cstr(string, " queue=");
    ofp_print_queue_name(string, oqsr.queue_id);

    return 0;
}
Esempio n. 27
0
/* Appends a human-readable representation of 'nab' to 's'. */
void
bundle_format(const struct ofpact_bundle *bundle, struct ds *s)
{
    const char *action, *fields, *algorithm;
    size_t i;

    fields = flow_hash_fields_to_str(bundle->fields);

    switch (bundle->algorithm) {
    case NX_BD_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_BD_ALG_ACTIVE_BACKUP:
        algorithm = "active_backup";
        break;
    default:
        algorithm = "<unknown>";
    }

    action = bundle->dst.field ? "bundle_load" : "bundle";

    ds_put_format(s, "%s(%s,%"PRIu16",%s,%s,", action, fields,
                  bundle->basis, algorithm, "ofport");

    if (bundle->dst.field) {
        mf_format_subfield(&bundle->dst, s);
        ds_put_cstr(s, ",");
    }

    ds_put_cstr(s, "slaves:");
    for (i = 0; i < bundle->n_slaves; i++) {
        if (i) {
            ds_put_cstr(s, ",");
        }

        ofputil_format_port(bundle->slaves[i], s);
    }

    ds_put_cstr(s, ")");
}
Esempio n. 28
0
static void
do_parse_commands (struct substring s, enum segmenter_mode mode,
                   struct hmap *dummies,
                   struct string *outputs, size_t n_outputs)
{
  struct segmenter segmenter;

  segmenter_init (&segmenter, mode);

  while (!ss_is_empty (s))
    {
      enum segment_type type;
      int n;

      n = segmenter_push (&segmenter, s.string, s.length, &type);
      assert (n >= 0);

      if (type == SEG_DO_REPEAT_COMMAND)
        {
          for (;;)
            {
              int k;

              k = segmenter_push (&segmenter, s.string + n, s.length - n,
                                  &type);
              if (type != SEG_NEWLINE && type != SEG_DO_REPEAT_COMMAND)
                break;

              n += k;
            }

          do_parse_commands (ss_head (s, n), mode, dummies,
                             outputs, n_outputs);
        }
      else if (type != SEG_END)
        {
          const struct dummy_var *dv;
          size_t i;

          dv = (type == SEG_IDENTIFIER
                ? find_dummy_var (dummies, s.string, n)
                : NULL);
          for (i = 0; i < n_outputs; i++)
            if (dv != NULL)
              ds_put_cstr (&outputs[i], dv->values[i]);
            else
              ds_put_substring (&outputs[i], ss_head (s, n));
        }

      ss_advance (&s, n);
    }
}
Esempio n. 29
0
static void
ofputil_format_version_bitmap__(struct ds *msg, uint32_t bitmap,
                                void (*format_version)(struct ds *msg,
                                                       enum ofp_version))
{
    while (bitmap) {
        format_version(msg, raw_ctz(bitmap));
        bitmap = zero_rightmost_1bit(bitmap);
        if (bitmap) {
            ds_put_cstr(msg, ", ");
        }
    }
}
void
classifierd_debug_dump(struct ds *ds, int argc, const char *argv[])

{
    bool list_all_ports = true;
    const char *port_name;
    const struct ovsrec_port *port_row = NULL;
    unsigned int iface_idx;
    struct ovsrec_interface *interface;


    if (argc > 1) {
        list_all_ports = false;
        port_name = argv[1];
    }

    OVSREC_PORT_FOR_EACH (port_row, idl) {
        if (list_all_ports
            || (!strcmp(port_name, port_row->name))) {

            if(port_row->n_interfaces == 0) {
                VLOG_DBG("No interfaces assigned yet..\n");
                continue;
            }

            if(port_row->n_interfaces == 1) {
                VLOG_DBG("single interface assigned to port..\n");
                interface = port_row->interfaces[0];
                ds_put_format(ds, "Port: name=%s\n", port_row->name);
                classifierd_debug_dump_port_acl_info(ds,port_row);
                classifierd_debug_dump_interface_info(ds, interface);
                ds_put_format(ds,"\n");
            } else {   /* LAG */
                VLOG_DBG("LAG interfaces ..\n");
                ds_put_format(ds, "LAG name=%s\n", port_row->name);
                classifierd_debug_dump_port_acl_info(ds,port_row);
                for(iface_idx = 0;
                        iface_idx < port_row->n_interfaces;iface_idx++) {
                    interface = port_row->interfaces[iface_idx];
                    classifierd_debug_dump_interface_info(ds, interface);
                } /* end for loop */
            } /* LAG */

            /* line between port row entries */
            ds_put_cstr(ds,"\n");
        } /* if list_all_ports or matching name */
    } /* for each ROW */

} /* classifierd_debug_dump */