Files
unison/src/openflow/wscript

164 lines
6.1 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
2011-09-13 13:47:17 +01:00
from waflib.Errors import WafError
2011-03-11 15:21:50 -05:00
2011-09-12 14:54:27 +01:00
def options(opt):
2011-03-11 15:21:50 -05:00
opt.add_option('--with-openflow',
help=('Path to OFSID source for NS-3 OpenFlow Integration support'),
default='', dest='with_openflow')
2011-09-08 16:13:40 +01:00
opt.tool_options('boost', tooldir=["waf-tools"])
2011-03-11 15:21:50 -05:00
def configure(conf):
2011-09-13 13:47:17 +01:00
try:
conf.check_tool('boost')
2011-09-15 14:52:24 +01:00
conf.check_boost(lib='signals filesystem')
if not conf.env.LIB_BOOST:
conf.check_boost(lib='signals filesystem', libpath="/usr/lib64")
2011-09-13 13:47:17 +01:00
except WafError:
2011-09-15 14:52:24 +01:00
conf.env['LIB_BOOST'] = []
2011-03-11 15:21:50 -05:00
2011-09-15 14:52:24 +01:00
if not conf.env.LIB_BOOST:
2011-03-11 15:21:50 -05:00
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):
2011-09-15 14:52:24 +01:00
conf.msg("Checking for OpenFlow location", ("%s (given)" % Options.options.with_openflow))
2011-03-11 15:21:50 -05:00
conf.env['WITH_OPENFLOW'] = os.path.abspath(Options.options.with_openflow)
else:
openflow_dir = os.path.join('..','openflow')
if os.path.isdir(openflow_dir):
2011-09-15 14:52:24 +01:00
conf.msg("Checking for OpenFlow location", ("%s (guessed)" % openflow_dir))
2011-03-11 15:21:50 -05:00
conf.env['WITH_OPENFLOW'] = os.path.abspath(openflow_dir)
del openflow_dir
if not conf.env['WITH_OPENFLOW']:
2011-09-15 14:52:24 +01:00
conf.msg("Checking for OpenFlow location", False)
2011-03-11 15:21:50 -05:00
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_store='DL')
conf.env['XML2'] = conf.check(mandatory=True, lib='xml2', define_name='XML2', uselib_store='XML2')
2011-03-11 15:21:50 -05:00
conf.env.append_value('NS3_MODULE_PATH',os.path.abspath(os.path.join(conf.env['WITH_OPENFLOW'],'build','default')))
2011-09-15 14:52:24 +01:00
conf.env['INCLUDES_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
2012-08-27 00:19:20 -07:00
conf.env['DEFINES_OPENFLOW'] = ['NS3_OPENFLOW']
2011-09-15 14:52:24 +01:00
conf.env['OPENFLOW'] = conf.check_nonfatal(fragment=test_code, lib='openflow',
libpath=conf.env['LIBPATH_OPENFLOW'],
use='OPENFLOW DL XML2')
2012-09-23 21:32:12 -07:00
conf.env.append_value('LIB_OPENFLOW', 'dl')
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
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.use.extend('OPENFLOW DL XML2'.split())
obj_test.use.extend('OPENFLOW DL XML2'.split())
2011-03-11 15:21:50 -05:00
2011-09-08 16:13:40 +01:00
headers = bld.new_task_gen(features=['ns3header'])
2011-03-11 15:21:50 -05:00
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')
2011-09-15 14:52:24 +01:00
obj.env.append_value('DEFINES', 'NS3_OPENFLOW')
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')