Skip to content

Commit

Permalink
Merge branch 'feature/otafragsupport' into develop
Browse files Browse the repository at this point in the history
See #75
  • Loading branch information
sgalgano committed Aug 18, 2017
2 parents 04abce4 + 8f4998f commit b88fa0a
Show file tree
Hide file tree
Showing 18 changed files with 1,332 additions and 435 deletions.
2 changes: 2 additions & 0 deletions SPONSOR
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
MIT Lincoln Laboratory - TDMA radio model
https://github.com/adjacentlink/emane/wiki/TDMA-Model

MIT Lincoln Laboratory - OTA message fragmentation support and
external transport TCP connection support.

For more information on sponsoring EMANE features contact us at
emane-info at adjacentlink dot com.
68 changes: 39 additions & 29 deletions scripts/emanegentransportxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Copyright (c) 2014 - Adjacent Link LLC, Bridgewater, New Jersey
# Copyright (c) 2014,2017 - Adjacent Link LLC, Bridgewater, New Jersey
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,21 +41,21 @@ usage = "%prog [OPTION].. PLATFORMXML..."

optionParser = OptionParser(usage=usage)

optionParser.add_option("-v",
optionParser.add_option("-v",
"--verbose",
action="store_true",
dest="verbose",
help="Verbose output mode")

optionParser.add_option("",
optionParser.add_option("",
"--dtd",
action="store",
type="string",
dest="dtd",
default='file:///usr/share/emane/dtd/transportdaemon.dtd',
help="Transport Daemon XML DTD [default: %default]")
help="Transport Daemon XML DTD [default: %default]")

optionParser.add_option("-o",
optionParser.add_option("-o",
"--outpath",
action="store",
type="string",
Expand Down Expand Up @@ -103,27 +103,32 @@ try:

if nemTransportLocation == "internal":
continue

if nemId not in instances:
instances[nemId] = {}

platformendpoint = nem.find("param/[@name='platformendpoint']")
transportendpoint = nem.find("param/[@name='transportendpoint']")
protocol = nem.find("param/[@name='protocol']")

if platformendpoint is None:
print >>sys.stderr, "error %s:" % platform," missing 'platformendpoint' for NEM",nemId
exit(1)
exit(1)

if transportendpoint is None:
print >>sys.stderr, "error %s:" % platform," missing 'transportendpoint' for NEM",nemId
exit(1)

exit(1)


# store platform and transport endpoints
metas[nemId] = {
'platformendpoint' : platformendpoint.get('value'),
'transportendpoint' : transportendpoint.get('value')
}


if protocol is not None:
metas[nemId]['protocol'] = protocol.get('value')

# load nem XML
try:
if options.verbose:
Expand All @@ -138,7 +143,7 @@ try:
metas[nemId]['definition'] = transportDefinition
elif metas[nemId]['definition'] != transportDefinition:
print >>sys.stderr, "error %s:" % nemDefinition," inconsistent transport selected for NEM",nemId
exit(1)
exit(1)

# load transport XML
try:
Expand All @@ -155,14 +160,14 @@ try:
for paramlist in transportTree.xpath('/transport/paramlist'):

instances[nemId][paramlist.get('name')] = []

for item in paramlist.xpath('item'):
instances[nemId][paramlist.get('name')].append(item.get('value'))

except etree.XMLSyntaxError, exp:
print >>sys.stderr, "error %s:" % transportDefinition,exp
exit(1)
exit(1)

# process nem XML parameters
for param in nemTree.xpath('/nem/transport/param'):
instances[nemId][param.get('name')] = [param.get('value')]
Expand All @@ -171,7 +176,7 @@ try:
for paramlist in nemTree.xpath('/nem/transport/paramlist'):

instances[nemId][paramlist.get('name')] = []

for item in paramlist.xpath('item'):
instances[nemId][paramlist.get('name')].append(item.get('value'))

Expand All @@ -188,25 +193,25 @@ try:
transportDefinition = transport.get('definition')

group = transport.get("group")

if group is None:
group = str(nemId)

if 'definition' not in metas[nemId]:
metas[nemId]['definition'] = transportDefinition
elif metas[nemId]['definition'] != transportDefinition:
print >>sys.stderr, "error %s:" % platform," inconsistent transport selected for NEM",nemId
exit(1)
exit(1)

# process platform XML nem element transport parameters
for param in transport.xpath('param'):
instances[nemId][param.get('name')] = [param.get('value')]

# process nem XML parameter lists
for paramlist in transport.xpath('paramlist'):

instances[nemId][paramlist.get('name')] = []

for item in paramlist.xpath('item'):
instances[nemId][paramlist.get('name')].append(item.get('value'))

Expand All @@ -215,12 +220,12 @@ try:

# add the nem to a group
groups[group].append(nemId)


except IOError,exp:
print >>sys.stderr, "error:",exp
exit(1)

# create the transport daemon files
for members in sorted(groups.values()):
output="transportdaemon%d.xml" % min(members)
Expand All @@ -242,17 +247,25 @@ for members in sorted(groups.values()):
name='transportendpoint',
value=metas[nemId]['transportendpoint'])

transportElement = etree.SubElement(instanceElement,'transport', definition=metas[nemId]['definition'])
if 'protocol' in metas[nemId]:
etree.SubElement(instanceElement,
'param',
name='protocol',
value=metas[nemId]['protocol'])

transportElement = etree.SubElement(instanceElement,
'transport',
definition=metas[nemId]['definition'])


for name,value in params.items():
if len(value) == 1:
etree.SubElement(transportElement,'param', name=name,value=value[0])
else:
paramlist = etree.SubElement(transportElement,'paramlist', name=name)
paramlist = etree.SubElement(transportElement,'paramlist', name=name)

for item in value:
etree.SubElement(paramlist,'item', value=item)
etree.SubElement(paramlist,'item', value=item)


target = "transportdaemon%d.xml" % min(members)
Expand All @@ -269,9 +282,9 @@ for members in sorted(groups.values()):

if options.verbose:
print "generating XML:",target

output=open(os.path.join(options.outpath,target),'w')

print >>output,xml

output.close()
Expand All @@ -280,6 +293,3 @@ for members in sorted(groups.values()):
print >>sys.stderr, "error %s:" % target, "unable to validate target xml"
print >>sys.stderr, exp
exit(1)



Loading

0 comments on commit b88fa0a

Please sign in to comment.