" dump-flows SWITCH print all flow entries\n"
" dump-flows SWITCH FLOW print matching FLOWs\n"
" add-flows SWITCH FILE add flows from FILE\n"
+ " del-flows SWITCH FLOW delete matching FLOWs\n"
"where each SWITCH is an active OpenFlow connection method.\n",
program_name, program_name);
vconn_usage(true, false);
if (retval == EOF) {
fputs(": unexpected end of file\n", stderr);
} else {
- vfprintf(stderr, ": %s\n", strerror(retval));
+ fprintf(stderr, ": %s\n", strerror(retval));
}
exit(EXIT_FAILURE);
static void
do_dump_tables(int argc, char *argv[])
{
- dump_transaction(argv[1], OFPT_TABLE_STAT_REQUEST);
+ dump_transaction(argv[1], OFPT_TABLE_STATS_REQUEST);
}
static void
str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
- uint8_t *table_idx)
+ uint8_t *table_idx, uint16_t *priority)
{
struct field {
const char *name;
continue;
}
+ if (priority && !strcmp(name, "priority")) {
+ *priority = atoi(value);
+ continue;
+ }
+
for (f = fields; f < &fields[ARRAY_SIZE(fields)]; f++) {
if (!strcmp(f->name, name)) {
goto found;
{
struct vconn *vconn;
struct buffer *request, *reply;
- struct ofp_flow_stat_request *fsr;
+ struct ofp_flow_stats_request *fsr;
run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
- fsr = alloc_openflow_buffer(sizeof *fsr, OFPT_FLOW_STAT_REQUEST, &request);
- str_to_flow(argc > 2 ? argv[2] : "", &fsr->match, NULL, &fsr->table_id);
+ fsr = alloc_openflow_buffer(sizeof *fsr, OFPT_FLOW_STATS_REQUEST, &request);
+ str_to_flow(argc > 2 ? argv[2] : "", &fsr->match, NULL, &fsr->table_id,
+ NULL);
fsr->type = OFPFS_INDIV;
fsr->pad = 0;
reply = transact_openflow(vconn, request);
static void do_add_flows(int argc, char *argv[])
{
struct vconn *vconn;
- char vconn_name[16];
FILE *file;
char line[1024];
fatal(errno, "%s: open", argv[2]);
}
- run(vconn_open_block(vconn_name, &vconn), "connecting to %s", argv[1]);
+ run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
while (fgets(line, sizeof line, file)) {
struct buffer *buffer;
struct ofp_flow_mod *ofm;
+ uint16_t priority=0;
size_t size;
char *comment;
ofm->max_idle = htons(50);
ofm->buffer_id = htonl(UINT32_MAX);
ofm->group_id = htonl(0);
- str_to_flow(line, &ofm->match, &ofm->actions[0], NULL);
- run(vconn_send_block(vconn, buffer), "send OpenFlow packet");
+ str_to_flow(line, &ofm->match, &ofm->actions[0], NULL, &priority);
+ ofm->priority = htons(priority);
+
+ send_openflow_buffer(vconn, buffer);
}
vconn_close(vconn);
fclose(file);
}
+static void do_del_flows(int argc, char *argv[])
+{
+ struct vconn *vconn;
+
+ run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
+ struct buffer *buffer;
+ struct ofp_flow_mod *ofm;
+ size_t size;
+
+
+ /* Parse and send. */
+ size = sizeof *ofm;
+ ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
+ ofm->command = htons(OFPFC_DELETE);
+ ofm->max_idle = 0;
+ ofm->buffer_id = htonl(UINT32_MAX);
+ ofm->group_id = 0;
+ ofm->priority = 0;
+ str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL, NULL);
+
+ send_openflow_buffer(vconn, buffer);
+
+ vconn_close(vconn);
+}
+
static void
do_dump_ports(int argc, char *argv[])
{
- dump_transaction(argv[1], OFPT_PORT_STAT_REQUEST);
+ dump_transaction(argv[1], OFPT_PORT_STATS_REQUEST);
}
static void do_help(int argc UNUSED, char *argv[] UNUSED)
{ "dump-tables", 1, 1, do_dump_tables },
{ "dump-flows", 1, 2, do_dump_flows },
{ "add-flows", 2, 2, do_add_flows },
+ { "del-flows", 1, 2, do_del_flows },
{ "dump-ports", 1, 1, do_dump_ports },
};