1 Star 0 Fork 0

202108010516-曾蕴焘/oflops

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
context.c 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
haris 提交于 2011-02-08 21:09 . integrating work at t-labs with main code
#include <string.h>
#include <dlfcn.h>
#include "context.h"
#include "timer_event.h"
#include "utils.h"
#include "log.h"
#include <pcap.h>
#include <openflow/openflow.h>
// Create a default context
oflops_context * oflops_default_context(void)
{
oflops_context * ctx = malloc_and_check(sizeof(oflops_context));
bzero(ctx, sizeof(*ctx));
ctx->max_tests = 10 ;
ctx->tests = malloc_and_check(ctx->max_tests * sizeof(test_module *));
ctx->listen_port = OFP_TCP_PORT; // listen on default port
ctx->listen_fd = -1;
ctx->snaplen = 100; //65535;
ctx->n_channels=1;
ctx->max_channels=10;
ctx->channels = malloc_and_check(sizeof(struct channel_info)* ctx->max_channels);
ctx->control_outgoing = msgbuf_new(4096); // dynamically sized
ctx->snmp_channel_info = malloc_and_check(sizeof(struct snmp_channel));
ctx->snmp_channel_info->hostname = NULL;
ctx->snmp_channel_info->community_string = NULL;
ctx->channels[OFLOPS_CONTROL].raw_sock = -1;
// initalize other channels later
ctx->log = malloc(sizeof(DEFAULT_LOG_FILE));
strcpy(ctx->log, DEFAULT_LOG_FILE);
ctx->trafficGen = PKTGEN;
ctx->dump_controller = 0;
ctx->cpuOID_len = MAX_OID_LEN;
return ctx;
}
// Reset any counters in the context
// run me between tests
int reset_context(oflops_context * ctx)
{
// reset any state between experiments
//timer_init(ctx);
// clean up after test (each test does its own cleanup, except for the
// stuff oflops allocated)
if(ctx->curr_test)
dlclose(ctx->curr_test->symbol_handle);
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zeng-yuntao/oflops.git
git@gitee.com:zeng-yuntao/oflops.git
zeng-yuntao
oflops
oflops
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385