X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-ofctl.c;h=61ca23e3b3c0c1dd7b97b81aff9ae1587f69495e;hb=36775dad3505929f8370166c33e8e0f04ca96c1c;hp=934c274129dfeddcabd8af4727a7385a258a54a2;hpb=675febfa2f31372e45e2a6a28ce19256b22106d7;p=openvswitch diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 934c2741..61ca23e3 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -44,9 +44,9 @@ #include "packets.h" #include "random.h" #include "socket-util.h" +#include "stream-ssl.h" #include "timeval.h" #include "util.h" -#include "vconn-ssl.h" #include "vconn.h" #include "vlog.h" @@ -91,7 +91,7 @@ parse_options(int argc, char *argv[]) {"strict", no_argument, 0, OPT_STRICT}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, - VCONN_SSL_LONG_OPTIONS + STREAM_SSL_LONG_OPTIONS {0, 0, 0, 0}, }; char *short_options = long_options_to_short_options(long_options); @@ -131,7 +131,7 @@ parse_options(int argc, char *argv[]) strict = true; break; - VCONN_SSL_OPTION_HANDLERS + STREAM_SSL_OPTION_HANDLERS case '?': exit(EXIT_FAILURE); @@ -164,7 +164,6 @@ usage(void) " mod-flows SWITCH FLOW modify actions of matching FLOWs\n" " del-flows SWITCH [FLOW] delete matching FLOWs\n" " monitor SWITCH MISSLEN EXP print packets received from SWITCH\n" - " execute SWITCH CMD [ARG...] execute CMD with ARGS on SWITCH\n" "\nFor OpenFlow switches and controllers:\n" " probe VCONN probe whether VCONN is up\n" " ping VCONN [N] latency of N-byte echos\n" @@ -556,6 +555,22 @@ str_to_action(char *str, struct ofpbuf *b) put_dl_addr_action(b, OFPAT_SET_DL_SRC, arg); } else if (!strcasecmp(act, "mod_dl_dst")) { put_dl_addr_action(b, OFPAT_SET_DL_DST, arg); + } else if (!strcasecmp(act, "mod_nw_src")) { + struct ofp_action_nw_addr *na; + na = put_action(b, sizeof *na, OFPAT_SET_NW_SRC); + str_to_ip(arg, &na->nw_addr); + } else if (!strcasecmp(act, "mod_nw_dst")) { + struct ofp_action_nw_addr *na; + na = put_action(b, sizeof *na, OFPAT_SET_NW_DST); + str_to_ip(arg, &na->nw_addr); + } else if (!strcasecmp(act, "mod_tp_src")) { + struct ofp_action_tp_port *ta; + ta = put_action(b, sizeof *ta, OFPAT_SET_TP_SRC); + ta->tp_port = htons(str_to_u32(arg)); + } else if (!strcasecmp(act, "mod_tp_dst")) { + struct ofp_action_tp_port *ta; + ta = put_action(b, sizeof *ta, OFPAT_SET_TP_DST); + ta->tp_port = htons(str_to_u32(arg)); } else if (!strcasecmp(act, "output")) { put_output_action(b, str_to_u32(arg)); } else if (!strcasecmp(act, "drop")) { @@ -1094,7 +1109,7 @@ do_ping(int argc, char *argv[]) printf("Reply:\n"); ofp_print(stdout, reply, reply->size, 2); } - printf("%d bytes from %s: xid=%08"PRIx32" time=%.1f ms\n", + printf("%zu bytes from %s: xid=%08"PRIx32" time=%.1f ms\n", reply->size - sizeof *rpy_hdr, argv[1], rpy_hdr->xid, (1000*(double)(end.tv_sec - start.tv_sec)) + (.001*(end.tv_usec - start.tv_usec))); @@ -1147,71 +1162,6 @@ do_benchmark(int argc UNUSED, char *argv[]) count * message_size / (duration / 1000.0)); } -static void -do_execute(int argc, char *argv[]) -{ - struct vconn *vconn; - struct ofpbuf *request; - struct nicira_header *nicira; - struct nx_command_reply *ncr; - uint32_t xid; - int i; - - nicira = make_openflow(sizeof *nicira, OFPT_VENDOR, &request); - xid = nicira->header.xid; - nicira->vendor = htonl(NX_VENDOR_ID); - nicira->subtype = htonl(NXT_COMMAND_REQUEST); - ofpbuf_put(request, argv[2], strlen(argv[2])); - for (i = 3; i < argc; i++) { - ofpbuf_put_zeros(request, 1); - ofpbuf_put(request, argv[i], strlen(argv[i])); - } - update_openflow_length(request); - - open_vconn(argv[1], &vconn); - run(vconn_send_block(vconn, request), "send"); - - for (;;) { - struct ofpbuf *reply; - uint32_t status; - - run(vconn_recv_xid(vconn, xid, &reply), "recv_xid"); - if (reply->size < sizeof *ncr) { - ovs_fatal(0, "reply is too short (%zu bytes < %zu bytes)", - reply->size, sizeof *ncr); - } - ncr = reply->data; - if (ncr->nxh.header.type != OFPT_VENDOR - || ncr->nxh.vendor != htonl(NX_VENDOR_ID) - || ncr->nxh.subtype != htonl(NXT_COMMAND_REPLY)) { - ovs_fatal(0, "reply is invalid"); - } - - status = ntohl(ncr->status); - if (status & NXT_STATUS_STARTED) { - /* Wait for a second reply. */ - continue; - } else if (status & NXT_STATUS_EXITED) { - fprintf(stderr, "process terminated normally with exit code %d", - status & NXT_STATUS_EXITSTATUS); - } else if (status & NXT_STATUS_SIGNALED) { - fprintf(stderr, "process terminated by signal %d", - status & NXT_STATUS_TERMSIG); - } else if (status & NXT_STATUS_ERROR) { - fprintf(stderr, "error executing command"); - } else { - fprintf(stderr, "process terminated for unknown reason"); - } - if (status & NXT_STATUS_COREDUMP) { - fprintf(stderr, " (core dumped)"); - } - putc('\n', stderr); - - fwrite(ncr + 1, reply->size - sizeof *ncr, 1, stdout); - break; - } -} - static void do_help(int argc UNUSED, char *argv[] UNUSED) { @@ -1235,7 +1185,6 @@ static const struct command all_commands[] = { { "probe", 1, 1, do_probe }, { "ping", 1, 2, do_ping }, { "benchmark", 3, 3, do_benchmark }, - { "execute", 2, INT_MAX, do_execute }, { "help", 0, INT_MAX, do_help }, { NULL, 0, 0, NULL }, };