It is conventional for Unix tools to read from standard input if "-" is
specified as a file name. It's easy for "ovs-ofctl add-flows" to behave
this way, too, so this commit implements it.
Suggested-by: Paul Ingram <paul@nicira.com>
OFPROTO_START
AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS], [0], [NXST_FLOW reply:
])
-AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=0])
+AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl add-flows br0 -])
AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION], [0], [dnl
NXST_FLOW reply:
.
.TP
\fBadd\-flows \fIswitch file\fR
-Add flow entries as described in \fIfile\fR to \fIswitch\fR's
+Add the flow entries listed in \fIfile\fR, or supplied on \fBstdin\fR
+if \fIfile\fR is \fB\-\fR, to \fIswitch\fR's
tables. Each line in \fIfile\fR is a flow entry in the format
described in \fBFlow Syntax\fR, below.
.
struct vconn *vconn;
FILE *file;
- file = fopen(argv[2], "r");
+ file = !strcmp(argv[2], "-") ? stdin : fopen(argv[2], "r");
if (file == NULL) {
ovs_fatal(errno, "%s: open", argv[2]);
}
}
vconn_close(vconn);
- fclose(file);
+ if (file != stdin) {
+ fclose(file);
+ }
}
static void