just all finished
This commit is contained in:
@@ -162,12 +162,20 @@ handle_opfmsg_features_request(struct ofp_buffer *ofpbuf)
|
||||
|
||||
//TODO
|
||||
/* 构建feature回应报文,把交换机的功能信息发送给控制器(指针变量feature_reply_msg赋值) */
|
||||
feature_reply_msg->datapath_id = htonll(0x1234 << 48);
|
||||
feature_reply_msg->n_buffers = 0x100; // 256
|
||||
feature_reply_msg->n_tables = 1;
|
||||
feature_reply_msg->auxiliary_id = 0;
|
||||
feature_reply_msg->capabilities = htonl(0x0007);
|
||||
feature_reply_msg->reserved = htonl(0x0000);
|
||||
feature_reply_msg->datapath_id = 0x6655443322110000;
|
||||
feature_reply_msg->n_buffers = 0x100;
|
||||
feature_reply_msg->n_tables = 0x02;
|
||||
feature_reply_msg->auxiliary_id = 0;
|
||||
feature_reply_msg->capabilities = htonl(0x0000004f);
|
||||
feature_reply_msg->reserved = htonl(0x00000000);
|
||||
|
||||
|
||||
// feature_reply_msg->datapath_id = htonll(0x1234 << 48);
|
||||
// feature_reply_msg->n_buffers = 0x100; // 256
|
||||
// feature_reply_msg->n_tables = 1;
|
||||
// feature_reply_msg->auxiliary_id = 0;
|
||||
// feature_reply_msg->capabilities = htonl(0x0007);
|
||||
// feature_reply_msg->reserved = htonl(0x0000);
|
||||
//调用系统发送接口,发送回应报文
|
||||
send_openflow_message(ofpbuf_reply,feature_reply_len);
|
||||
|
||||
@@ -247,78 +255,41 @@ handle_ofpmsg_desc(struct ofp_buffer *ofpbuf)
|
||||
static enum ofperr
|
||||
handle_ofpmsg_flow_stats(struct ofp_buffer *ofpbuf)
|
||||
{
|
||||
int i = 0, reply_len = 0, flow_stats_offset;
|
||||
struct ofp_flow_stats *current_flow_stats = NULL;
|
||||
struct ofp_buffer *reply_buffer = NULL;
|
||||
struct ofp_multipart *multipart_reply = NULL;
|
||||
int i = 0, reply_len = 0, flow_stats_offset;
|
||||
struct ofp_flow_stats *current_flow_stats = NULL;
|
||||
struct ofp_buffer *reply_buffer = NULL;
|
||||
struct ofp_multipart *multipart_reply = NULL;
|
||||
|
||||
// 计算长度
|
||||
for (; i < FAST_RULE_CNT; i++) {
|
||||
if (flow_stats_addr[i] != 0) {
|
||||
reply_len += ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length);
|
||||
}
|
||||
}
|
||||
reply_len += sizeof(struct ofp_header) + sizeof(struct ofp_multipart);
|
||||
// 计算长度
|
||||
for (; i < FAST_RULE_CNT; i++) {
|
||||
if (flow_stats_addr[i] != NULL) {
|
||||
reply_len += ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length);
|
||||
}
|
||||
}
|
||||
reply_len += sizeof(struct ofp_header) + sizeof(struct ofp_multipart);
|
||||
|
||||
// 构造响应包
|
||||
reply_buffer = (struct ofp_buffer *)build_opfmsg_reply_ofpbuf(OFPT_MULTIPART_REPLY, ofpbuf->header.xid, reply_len);
|
||||
multipart_reply = (struct ofp_multipart *)reply_buffer->data;
|
||||
multipart_reply->type = htons(OFPMP_FLOW); // 标识信息
|
||||
multipart_reply->flags = htonl(OFPMP_REPLY_MORE_NO); //这条不用回
|
||||
// 构造响应包
|
||||
reply_buffer = (struct ofp_buffer *)build_reply_ofpbuf(OFPT_MULTIPART_REPLY, ofpbuf->header.xid, reply_len);
|
||||
multipart_reply = (struct ofp_multipart *)reply_buffer->data;
|
||||
multipart_reply->type = htons(OFPMP_FLOW); // 标识信息
|
||||
multipart_reply->flags = htonl(OFPMP_REPLY_MORE_NO); //这条不用回
|
||||
|
||||
// 填充包体
|
||||
flow_stats_offset = sizeof(struct ofp_multipart);
|
||||
current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
// 填充包体
|
||||
flow_stats_offset = sizeof(struct ofp_multipart);
|
||||
current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
|
||||
for (i = 0; i < FAST_RULE_CNT; i++) {
|
||||
if (flow_stats_addr[i] != 0) {
|
||||
memcpy(current_flow_stats, (void *)flow_stats_addr[i], ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length));
|
||||
flow_stats_offset += ntohs(current_flow_stats->length);
|
||||
current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < FAST_RULE_CNT; i++) {
|
||||
if (flow_stats_addr[i] != NULL) {
|
||||
memcpy(current_flow_stats, flow_stats_addr[i], ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length));
|
||||
flow_stats_offset += ntohs(current_flow_stats->length);
|
||||
current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
}
|
||||
}
|
||||
|
||||
send_openflow_message(reply_buffer, reply_len);
|
||||
send_openflow_message(reply_buffer, reply_len);
|
||||
|
||||
return HANDLE;
|
||||
return HANDLE;
|
||||
}
|
||||
// handle_ofpmsg_flow_stats(struct ofp_buffer *ofpbuf)
|
||||
// {
|
||||
// int i = 0, reply_len = 0, flow_stats_offset;
|
||||
// struct ofp_flow_stats *current_flow_stats = NULL;
|
||||
// struct ofp_buffer *reply_buffer = NULL;
|
||||
// struct ofp_multipart *multipart_reply = NULL;
|
||||
//
|
||||
// // 计算长度
|
||||
// for (; i < FAST_RULE_CNT; i++) {
|
||||
// if (flow_stats_addr[i] != NULL) {
|
||||
// reply_len += ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length);
|
||||
// }
|
||||
// }
|
||||
// reply_len += sizeof(struct ofp_header) + sizeof(struct ofp_multipart);
|
||||
//
|
||||
// // 构造响应包
|
||||
// reply_buffer = (struct ofp_buffer *)build_reply_ofpbuf(OFPT_MULTIPART_REPLY, ofpbuf->header.xid, reply_len);
|
||||
// multipart_reply = (struct ofp_multipart *)reply_buffer->data;
|
||||
// multipart_reply->type = htons(OFPMP_FLOW); // 标识信息
|
||||
// multipart_reply->flags = htonl(OFPMP_REPLY_MORE_NO); //这条不用回
|
||||
//
|
||||
// // 填充包体
|
||||
// flow_stats_offset = sizeof(struct ofp_multipart);
|
||||
// current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
//
|
||||
// for (i = 0; i < FAST_RULE_CNT; i++) {
|
||||
// if (flow_stats_addr[i] != NULL) {
|
||||
// memcpy(current_flow_stats, flow_stats_addr[i], ntohs(((struct ofp_flow_stats *)flow_stats_addr[i])->length));
|
||||
// flow_stats_offset += ntohs(current_flow_stats->length);
|
||||
// current_flow_stats = (struct ofp_flow_stats *)&reply_buffer->data[flow_stats_offset];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// send_openflow_message(reply_buffer, reply_len);
|
||||
//
|
||||
// return HANDLE;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 处理OpenFlow Aggregate Stats Request消息
|
||||
@@ -390,7 +361,7 @@ handle_ofpmsg_table(struct ofp_buffer *ofpbuf)
|
||||
|
||||
ofpmp_reply->type = htons(OFPMP_TABLE);
|
||||
ofpmp_reply->flags = htonl(OFPMP_REPLY_MORE_NO);
|
||||
for(i=0;i<1;i++) // 关于为什么写成1,见line 114
|
||||
for(i=0;i<1;i++)
|
||||
{
|
||||
ofpmp_reply->table_stats[i].matched_count = htonll(0);
|
||||
ofpmp_reply->table_stats[i].table_id = i;
|
||||
|
||||
Reference in New Issue
Block a user