Files
unison/src/openflow/wscript

165 lines
6.4 KiB
Plaintext
Raw Normal View History

2011-03-11 15:21:50 -05:00
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import os
import Options
def set_options(opt):
opt.add_option('--with-openflow',
help=('Path to OFSID source for NS-3 OpenFlow Integration support'),
default='', dest='with_openflow')
opt.tool_options('boost')
2011-03-11 15:21:50 -05:00
def configure(conf):
conf.check_tool('boost')
conf.env['BOOST'] = conf.check_boost(lib = 'signals filesystem',
kind = 'STATIC_BOTH',
score_version = (-1000, 1000),
2011-04-06 15:02:54 -04:00
tag_minscore = 1000)
if not conf.env['BOOST']:
conf.env['BOOST'] = conf.check_boost(lib = 'signals filesystem',
kind = 'STATIC_BOTH',
score_version = (-1000, 1000),
tag_minscore = 1000,
libpath="/usr/lib64")
2011-03-11 15:21:50 -05:00
if not conf.env['BOOST']:
conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False,
"Required boost libraries not found")
# Add this module to the list of modules that won't be built
# if they are enabled.
conf.env['MODULES_NOT_BUILT'].append('openflow')
2011-03-11 15:21:50 -05:00
return
if Options.options.with_openflow:
if os.path.isdir(Options.options.with_openflow):
conf.check_message("OpenFlow location", '', True, ("%s (given)" % Options.options.with_openflow))
conf.env['WITH_OPENFLOW'] = os.path.abspath(Options.options.with_openflow)
else:
openflow_dir = os.path.join('..','openflow')
if os.path.isdir(openflow_dir):
conf.check_message("OpenFlow location", '', True, ("%s (guessed)" % openflow_dir))
conf.env['WITH_OPENFLOW'] = os.path.abspath(openflow_dir)
del openflow_dir
if not conf.env['WITH_OPENFLOW']:
conf.check_message("OpenFlow location", '', False)
conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False,
"OpenFlow not enabled (see option --with-openflow)")
# Add this module to the list of modules that won't be built
# if they are enabled.
conf.env['MODULES_NOT_BUILT'].append('openflow')
2011-03-11 15:21:50 -05:00
return
test_code = '''
2011-04-06 15:02:54 -04:00
#include "openflow/openflow.h"
#include "openflow/nicira-ext.h"
#include "openflow/ericsson-ext.h"
2011-03-11 15:21:50 -05:00
extern "C"
{
#define private _private
#define delete _delete
#define list List
2011-04-06 15:02:54 -04:00
#include "openflow/private/csum.h"
#include "openflow/private/poll-loop.h"
#include "openflow/private/rconn.h"
#include "openflow/private/stp.h"
#include "openflow/private/vconn.h"
#include "openflow/private/xtoxll.h"
2011-03-11 15:21:50 -05:00
2011-04-06 15:02:54 -04:00
#include "openflow/private/chain.h"
#include "openflow/private/table.h"
#include "openflow/private/datapath.h" // The functions below are defined in datapath.c
2011-03-11 15:21:50 -05:00
uint32_t save_buffer (ofpbuf *);
ofpbuf * retrieve_buffer (uint32_t id);
void discard_buffer (uint32_t id);
2011-04-06 15:02:54 -04:00
#include "openflow/private/dp_act.h" // The functions below are defined in dp_act.c
2011-03-11 15:21:50 -05:00
void set_vlan_vid (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_vlan_pcp (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void strip_vlan (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_dl_addr (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_nw_addr (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_tp_port (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_mpls_label (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
void set_mpls_exp (ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah);
2011-04-06 15:02:54 -04:00
#include "openflow/private/pt_act.h" // The function below is defined in pt_act.c
2011-03-11 15:21:50 -05:00
void update_checksums (ofpbuf *buffer, const sw_flow_key *key, uint32_t old_word, uint32_t new_word);
#undef list
#undef private
#undef delete
}
int main()
{
return 0;
}
'''
conf.env['DL'] = conf.check(mandatory=True, lib='dl', define_name='DL', uselib='DL')
conf.env['XML2'] = conf.check(mandatory=True, lib='xml2', define_name='XML2', uselib='XML2')
conf.env.append_value('NS3_MODULE_PATH',os.path.abspath(os.path.join(conf.env['WITH_OPENFLOW'],'build','default')))
conf.env['CPPPATH_OPENFLOW'] = [
2011-04-06 15:02:54 -04:00
os.path.abspath(os.path.join(conf.env['WITH_OPENFLOW'],'include'))]
conf.env['LIBPATH_OPENFLOW'] = [
os.path.abspath(os.path.join(conf.env['WITH_OPENFLOW'],'build','default')),
os.path.abspath(os.path.join(conf.env['WITH_OPENFLOW'],'lib'))]
2011-03-11 15:21:50 -05:00
2011-04-06 15:02:54 -04:00
conf.env['OPENFLOW'] = conf.check(fragment=test_code, lib='openflow',
libpath=conf.env['LIBPATH_OPENFLOW'],
uselib='OPENFLOW DL XML2')
2011-03-11 15:21:50 -05:00
conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration",
2011-04-06 15:02:54 -04:00
conf.env['OPENFLOW'], "openflow library not found")
2011-03-11 15:21:50 -05:00
if conf.env['OPENFLOW']:
conf.env['ENABLE_OPENFLOW'] = True
2011-04-06 15:02:54 -04:00
conf.env.append_value('CXXDEFINES', 'NS3_OPENFLOW')
conf.env.append_value('CPPPATH', conf.env['CPPPATH_OPENFLOW'])
conf.env.append_value('LIBPATH', conf.env['LIBPATH_OPENFLOW'])
else:
# Add this module to the list of modules that won't be built
# if they are enabled.
conf.env['MODULES_NOT_BUILT'].append('openflow')
2011-04-06 15:02:54 -04:00
2011-03-11 15:21:50 -05:00
def build(bld):
# Don't do anything for this module if openflow's not enabled.
if 'openflow' in bld.env['MODULES_NOT_BUILT']:
return
2011-03-11 15:21:50 -05:00
# Build the Switch module
obj = bld.create_ns3_module('openflow', ['internet'])
obj.source = [
]
obj_test = bld.create_ns3_module_test_library('openflow')
obj_test.source = [
]
2011-03-11 15:21:50 -05:00
if bld.env['OPENFLOW'] and bld.env['DL'] and bld.env['XML2']:
obj.uselib = 'OPENFLOW DL XML2'
obj_test.uselib = 'OPENFLOW DL XML2'
2011-03-11 15:21:50 -05:00
headers = bld.new_task_gen('ns3header')
headers.module = 'openflow'
headers.source = [
]
if bld.env['ENABLE_OPENFLOW']:
obj.source.append('model/openflow-interface.cc')
obj.source.append('model/openflow-switch-net-device.cc')
obj.source.append('helper/openflow-switch-helper.cc')
obj_test.source.append('test/openflow-switch-test-suite.cc')
2011-03-11 15:21:50 -05:00
headers.source.append('model/openflow-interface.h')
headers.source.append('model/openflow-switch-net-device.h')
headers.source.append('helper/openflow-switch-helper.h')
if bld.env['ENABLE_EXAMPLES'] and bld.env['ENABLE_OPENFLOW']:
bld.add_subdirs('examples')