#include <string.h>
#include "buffer.h"
#include "chain.h"
-#include "controller.h"
#include "flow.h"
#include "netdev.h"
#include "packets.h"
#include "poll-loop.h"
+#include "rconn.h"
#include "table.h"
#include "xtoxll.h"
};
struct datapath {
- struct controller_connection *cc;
+ struct rconn *rconn;
time_t last_timeout;
}
int
-dp_new(struct datapath **dp_, uint64_t dpid, struct controller_connection *cc)
+dp_new(struct datapath **dp_, uint64_t dpid, struct rconn *rconn)
{
struct datapath *dp;
}
dp->last_timeout = time(0);
- dp->cc = cc;
+ dp->rconn = rconn;
dp->id = dpid <= UINT64_C(0xffffffffffff) ? dpid : gen_datapath_id();
dp->chain = chain_create();
if (!dp->chain) {
}
buffer_delete(buffer);
+ /* Process a number of commands from the controller, but cap it at a
+ * reasonable number so that other processing doesn't starve. */
for (i = 0; i < 50; i++) {
- struct buffer *buffer = controller_recv(dp->cc);
+ struct buffer *buffer = rconn_recv(dp->rconn);
if (!buffer) {
break;
}
buffer_delete(buffer);
}
- controller_run(dp->cc);
+ rconn_run(dp->rconn);
}
void
LIST_FOR_EACH (p, struct sw_port, node, &dp->port_list) {
netdev_recv_wait(p->netdev);
}
- controller_recv_wait(dp->cc);
+ rconn_recv_wait(dp->rconn);
}
/* Delete 'p' from switch. */
}
}
-/* Takes ownership of 'buffer' and transmits it to 'dp''s controller. If
- * 'buffer_id' != -1, then only the first 64 bytes of 'buffer' are sent;
- * otherwise, all of 'buffer' is sent. 'reason' indicates why 'buffer' is
- * being sent. 'max_len' sets the maximum number of bytes that the caller wants
- * to be sent; a value of 0 indicates the entire packet should be sent. */
+/* Takes ownership of 'buffer' and transmits it to 'dp''s controller. If the
+ * packet can be saved in a buffer, then only the first max_len bytes of
+ * 'buffer' are sent; otherwise, all of 'buffer' is sent. 'reason' indicates
+ * why 'buffer' is being sent. 'max_len' sets the maximum number of bytes that
+ * the caller wants to be sent; a value of 0 indicates the entire packet should
+ * be sent. */
void
dp_output_control(struct datapath *dp, struct buffer *buffer, int in_port,
size_t max_len, int reason)
buffer_id = save_buffer(buffer);
total_len = buffer->size;
- if (buffer_id != UINT32_MAX && max_len > buffer->size) {
+ if (buffer_id != UINT32_MAX && buffer->size > max_len) {
buffer->size = max_len;
}
opi->in_port = htons(in_port);
opi->reason = reason;
opi->pad = 0;
- controller_send(dp->cc, buffer);
+ rconn_send(dp->rconn, buffer);
}
static void fill_port_desc(struct datapath *dp, struct sw_port *p,
}
odh = buffer_at_assert(buffer, 0, sizeof *odh);
odh->header.length = htons(buffer->size);
- controller_send(dp->cc, buffer);
+ rconn_send(dp->rconn, buffer);
}
void
ops->header.xid = htonl(0);
ops->reason = status;
fill_port_desc(p->dp, p, &ops->desc);
- controller_send(p->dp->cc, buffer);
+ rconn_send(p->dp->rconn, buffer);
}
void
ofe->duration = htonl(flow->timeout - flow->max_idle - flow->created);
ofe->packet_count = htonll(flow->packet_count);
ofe->byte_count = htonll(flow->byte_count);
- controller_send(dp->cc, buffer);
+ rconn_send(dp->rconn, buffer);
}
\f
/* 'buffer' was received on 'in_port', a physical switch port between 0 and