openflow lab finished maybe

This commit is contained in:
2025-11-12 08:14:29 +08:00
parent 3835809adb
commit 11f2d26fce
7 changed files with 357 additions and 110 deletions

View File

@ -27,6 +27,7 @@
#include <main_libofp.h>
#include <ofp_v4.h>
#include <stdint.h>
#include <openboxS4.h>
extern void nms_exec_action(u32 inport,u32 outport,struct eth_header *eth,int len,int hit_idx);
extern void pkt_print(u8 *data, u16 len);
@ -315,8 +316,9 @@ handle_ofpmsg_aggregate(struct ofp_buffer *ofpbuf)
if (flow_stats_addr[i] != 0) {
((struct ofp_flow_stats *)flow_stats_addr[i])->duration_sec = htonl(tv.tv_sec - flow_stats_time[i].tv_sec);
((struct ofp_flow_stats *)flow_stats_addr[i])->duration_nsec = htonl(tv.tv_usec - flow_stats_time[i].tv_usec);
((struct ofp_flow_stats *)flow_stats_addr[i])->packet_count = ((uint64_t)0x100); // 涉及硬件地址拼尽全力无法找到姑且填充256
((struct ofp_flow_stats *)flow_stats_addr[i])->byte_count = ((uint64_t)0x40000); // 涉及硬件地址拼尽全力无法找到姑且填充262144=256*1024
// Read packet and byte counts from hardware registers
((struct ofp_flow_stats *)flow_stats_addr[i])->packet_count = fast_reg_rd(FAST_OFP_FLOW_STATS_PKTS + i * sizeof(uint64_t));
((struct ofp_flow_stats *)flow_stats_addr[i])->byte_count = fast_reg_rd(FAST_OFP_FLOW_STATS_BYTES + i * sizeof(uint64_t));
packet_count += ((struct ofp_flow_stats *)flow_stats_addr[i])->packet_count;
byte_count += ((struct ofp_flow_stats *)flow_stats_addr[i])->byte_count;