-static void
-send_default_flows(struct lswitch *sw, struct rconn *rconn,
- FILE *default_flows)
-{
- char line[1024];
-
- while (fgets(line, sizeof line, default_flows)) {
- struct ofpbuf *b;
- struct ofp_flow_mod *ofm;
- uint16_t priority, idle_timeout, hard_timeout;
- uint64_t cookie;
- struct ofp_match match;
-
- char *comment;
-
- /* Delete comments. */
- comment = strchr(line, '#');
- if (comment) {
- *comment = '\0';
- }
-
- /* Drop empty lines. */
- if (line[strspn(line, " \t\n")] == '\0') {
- continue;
- }
-
- /* Parse and send. str_to_flow() will expand and reallocate the data
- * in 'buffer', so we can't keep pointers to across the str_to_flow()
- * call. */
- make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &b);
- parse_ofp_str(line, &match, b,
- NULL, NULL, &priority, &idle_timeout, &hard_timeout,
- &cookie);
- ofm = b->data;
- ofm->match = match;
- ofm->command = htons(OFPFC_ADD);
- ofm->cookie = htonll(cookie);
- ofm->idle_timeout = htons(idle_timeout);
- ofm->hard_timeout = htons(hard_timeout);
- ofm->buffer_id = htonl(UINT32_MAX);
- ofm->priority = htons(priority);
-
- update_openflow_length(b);
- queue_tx(sw, rconn, b);
- }
-}
-