Commit 8337d8ef authored by Juraj Sloboda's avatar Juraj Sloboda Committed by Matej Feder

Run 'black -t py37 -l 120 .'

parent 73a7abde
......@@ -9,30 +9,30 @@ import pydtn_rest
import app
logging.basicConfig(format='%(asctime)s - [%(name)s] - [%(levelname)-5s] - %(message)s', level=logging.DEBUG)
logging.basicConfig(format="%(asctime)s - [%(name)s] - [%(levelname)-5s] - %(message)s", level=logging.DEBUG)
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser()
parser.add_argument("--yaml", type=str, default='')
parser.add_argument("--json", type=str, default='')
parser.add_argument("--yaml", type=str, default="")
parser.add_argument("--json", type=str, default="")
def load_config():
args = parser.parse_args()
# forbid using both formats at once
assert args.yaml == '' or args.json == ''
assert args.yaml == "" or args.json == ""
if args.yaml != '':
if args.yaml != "":
yaml_config = yaml.safe_load(args.yaml)
logger.debug(f'command line --yaml has value:\n{args.yaml}')
logger.debug(f"command line --yaml has value:\n{args.yaml}")
return yaml_config
if args.json != '':
if args.json != "":
json_config = json.loads(args.json)
logger.debug(f'command line --json has value:\n{args.json}')
logger.debug(f"command line --json has value:\n{args.json}")
return json_config
return {}
......
......@@ -8,8 +8,8 @@ logger = logging.getLogger(__name__)
async def recv_callback(adu, adu_len, app_eid, src_eid):
logger.info(f'BP client "{app_eid}" received ADU from of length {adu_len} from "{src_eid}"')
print(adu.decode('ascii'))
print(adu.decode("ascii"))
def start(config):
bp_agent.register(config['app-eid'], recv_callback)
bp_agent.register(config["app-eid"], recv_callback)
......@@ -12,17 +12,18 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
# -- Project information -----------------------------------------------------
project = 'pyDTN'
copyright = '2019, X-works'
author = 'X-works'
project = "pyDTN"
copyright = "2019, X-works"
author = "X-works"
# The full version, including alpha/beta/rc tags
release = '1.0.0'
release = "1.0.0"
# -- General configuration ---------------------------------------------------
......@@ -30,19 +31,15 @@ release = '1.0.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.napoleon"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
autoclass_content = "both"
autodoc_default_options = {
......@@ -61,9 +58,9 @@ napoleon_use_rtype = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
\ No newline at end of file
html_static_path = ["_static"]
......@@ -62,34 +62,34 @@ class BPAgent:
Returns:
None
"""
self._node_id = node_config['id']
self._date_time_format = node_config['date-time-format']
self._node_id = node_config["id"]
self._date_time_format = node_config["date-time-format"]
if 'routes' in node_config:
for key, value in node_config['routes'].items():
if "routes" in node_config:
for key, value in node_config["routes"].items():
self.add_route(dst_eid=key, via_eid=value)
for cla_name, cla_config in node_config['convergence-layer-adapters'].items():
for cla_name, cla_config in node_config["convergence-layer-adapters"].items():
cla_class = getattr(convergence_layers, cla_name)
# Save the Node ID inside the CLA config
cla_config['node-id'] = node_config['id']
cla_config["node-id"] = node_config["id"]
cla = cla_class(cla_config)
self.register_cl_adapter(cla)
if 'neighbors' in cla_config:
for neighbor_eid, neighbor_config in cla_config['neighbors'].items():
if "neighbors" in cla_config:
for neighbor_eid, neighbor_config in cla_config["neighbors"].items():
# Save the neighbor EID inside the neighbor config
neighbor_config['eid'] = neighbor_eid
neighbor_config["eid"] = neighbor_eid
neighbor_class = cla_class.neighbor_class
self.register_neighbor(neighbor_class(**neighbor_config))
date_time_format = node_config['date-time-format']
date_time_format = node_config["date-time-format"]
if 'contacts' in node_config:
for key, value in node_config['contacts'].items():
if "contacts" in node_config:
for key, value in node_config["contacts"].items():
for contact in value:
start_time = time.mktime(time.strptime(contact['start-time'], date_time_format))
end_time = time.mktime(time.strptime(contact['end-time'], date_time_format))
start_time = time.mktime(time.strptime(contact["start-time"], date_time_format))
end_time = time.mktime(time.strptime(contact["end-time"], date_time_format))
self.add_contact(key, start_time, end_time)
def register_cl_adapter(self, adapter):
......@@ -171,10 +171,10 @@ class BPAgent:
ValueError: If start_time is not less than end_time
"""
if start_time >= end_time:
raise ValueError('start_time should be less than end_time')
raise ValueError("start_time should be less than end_time")
start_time_str = datetime.datetime.fromtimestamp(start_time).strftime('%c')
end_time_str = datetime.datetime.fromtimestamp(end_time).strftime('%c')
start_time_str = datetime.datetime.fromtimestamp(start_time).strftime("%c")
end_time_str = datetime.datetime.fromtimestamp(end_time).strftime("%c")
logger.info(f'BP Agent adding contact for node "{eid}" - start: {start_time_str}, end: {end_time_str}')
contact = (start_time, end_time)
......@@ -254,7 +254,7 @@ class BPAgent:
async def _create_and_send_bundle_msg(self, source, destination, payload):
if isinstance(payload, str):
payload = payload.encode('ascii')
payload = payload.encode("ascii")
data = misc.serialize_bundle(source, destination, payload)
......@@ -271,7 +271,9 @@ class BPAgent:
logger.info(f'BP Agent is scheduling job to send bundle to "{via_eid}"')
self._scheduler.schedule_job(start_time, self._send_bundle(via_eid, data))
else:
logger.warning(f'There is no scheduled contact for node "{via_eid}", removing bundle') # TODO: Try to use different route
logger.warning(
f'There is no scheduled contact for node "{via_eid}", removing bundle'
) # TODO: Try to use different route
raise NoContactError(via_eid)
async def create_and_send_bundle_msg(self, source, destination, payload):
......@@ -310,14 +312,10 @@ class BPAgent:
Returns:
None
"""
logger.info('BP Agent received request to send uPCN config message')
logger.info("BP Agent received request to send uPCN config message")
inner_msg = misc.serialize_upcn_config_message(
eid,
cla_address,
contacts=[
misc.make_contact(start_offset, end_offset, 500),
],
eid, cla_address, contacts=[misc.make_contact(start_offset, end_offset, 500)]
)
await self._create_and_send_bundle_msg(self._node_id, target_eid, inner_msg)
......@@ -330,7 +328,7 @@ class BPAgent:
Returns:
None
"""
logger.info('BP Agent is receiving bundle')
logger.info("BP Agent is receiving bundle")
last_bundle_segment = False
bundle_data = bytearray()
......@@ -344,7 +342,7 @@ class BPAgent:
try:
bundle = decoder.decode()
except CBORDecodeError as e:
logger.warning(f'Error in CBOR format of received bundle: {str(e)}')
logger.warning(f"Error in CBOR format of received bundle: {str(e)}")
return
try:
......@@ -367,7 +365,7 @@ class BPAgent:
bp_client = self._get_client_by_eid(dst_eid)
if bp_client is None:
logger.warning(f'BP Agent received bundle with unknown EID ({dst_eid}) as destination')
logger.warning(f"BP Agent received bundle with unknown EID ({dst_eid}) as destination")
return
payload_block = bundle[-1]
......@@ -380,13 +378,13 @@ class BPAgent:
assert isinstance(payload, bytes)
except AssertionError or ValueError:
logger.warning(f'Error in bundle format of received bundle')
logger.debug(f'Received data:\n{hexdump(bundle_data)}')
logger.warning(f"Error in bundle format of received bundle")
logger.debug(f"Received data:\n{hexdump(bundle_data)}")
return
logger.debug('Calling BP client receive callback')
logger.debug("Calling BP client receive callback")
await bp_client._recv_callback(payload, len(payload), dst_eid, src_eid)
logger.debug('BP client receive callback finished')
logger.debug("BP client receive callback finished")
class BPPrivateAPI:
......
......@@ -69,14 +69,14 @@ class ConnectionManager:
def _add_connection(self, conn):
if conn in self._connections:
return
logger.debug('ConnectionManager: Adding connection to the list of existing connections')
logger.debug("ConnectionManager: Adding connection to the list of existing connections")
self._connections.append(conn)
def _remove_connection(self, conn):
if conn not in self._connections:
logger.warning('ConnectionManager: Trying to remove connection that isn\'t registered')
logger.warning("ConnectionManager: Trying to remove connection that isn't registered")
return
logger.debug('ConnectionManager: Removing connection from the list of existing connections')
logger.debug("ConnectionManager: Removing connection from the list of existing connections")
self._connections.remove(conn)
async def _request_handler(self, conn):
......@@ -84,7 +84,9 @@ class ConnectionManager:
try:
await self._request_handler(conn)
finally:
self._remove_connection(conn) # TODO: Don't automatically close connection after one bundle has been received
self._remove_connection(
conn
) # TODO: Don't automatically close connection after one bundle has been received
async def run_forever(self):
"""Block and process incoming data
......@@ -92,8 +94,12 @@ class ConnectionManager:
Returns:
None
"""
await asyncio.wait([asyncio.create_task(cl_adapter.run_forever(self._request_handler))
for cl_adapter in self._cl_adapter_instances])
await asyncio.wait(
[
asyncio.create_task(cl_adapter.run_forever(self._request_handler))
for cl_adapter in self._cl_adapter_instances
]
)
async def _connect(self, remote_eid):
logger.info(f'ConnectionManager: Connecting to "{remote_eid}" node')
......@@ -139,8 +145,8 @@ class ConnectionManager:
logger.debug(f'ConnectionManager: Trying to send bundle to "{dst_eid}"')
conn = self._pick_a_connection()
if conn is None:
logger.debug('ConnectionManager: No connection exists, creating one')
logger.debug("ConnectionManager: No connection exists, creating one")
conn = await self._connect(dst_eid)
else:
logger.debug('ConnectionManager: Using existing connection')
logger.debug("ConnectionManager: Using existing connection")
await conn.send(bundle)
......@@ -13,6 +13,7 @@ from ...util.exceptions import AlreadyRegisteredError
@dataclass
class ConvergenceLayerNeighbor(ABC):
"""Class representing a protocol specific connection endpoint (e.g. IP address and port)"""
eid: str
......@@ -39,7 +40,7 @@ class ConvergenceLayerAdapter(ABC):
except AttributeError:
neighbor_class.cla_class = cls
else:
raise ValueError(f'{neighbor_class} already has attribute cla_class')
raise ValueError(f"{neighbor_class} already has attribute cla_class")
def __init__(self, cla_config):
"""Initialize CLA from supplied configuration
......@@ -47,7 +48,7 @@ class ConvergenceLayerAdapter(ABC):
Args:
cla_config (dict): CLA configuration
"""
self.node_id = cla_config['node-id']
self.node_id = cla_config["node-id"]
self._neighbors = []
@abstractmethod
......
......@@ -3,6 +3,7 @@
import logging
from .api import ConvergenceLayerConnection
# from ...util.hexdump import hexdump
from ...util.io_util import WritebackReader, read_exact
......
......@@ -20,6 +20,7 @@ logger = logging.getLogger(__name__)
@dataclass
class TCPCLNeighbor(ConvergenceLayerNeighbor):
"""TCP connection endpoint specified by IP address and port"""
host: str
port: int
......@@ -36,8 +37,8 @@ class TCPCL(ConvergenceLayerAdapter):
cla_config (dict): TCPCL configuration
"""
super().__init__(cla_config)
self._host = cla_config['host']
self._port = cla_config['port']
self._host = cla_config["host"]
self._port = cla_config["port"]
self._upper_layer_handler = None
async def connect(self, neighbor):
......@@ -53,7 +54,7 @@ class TCPCL(ConvergenceLayerAdapter):
ConnectFailedError: When connection could not be established
"""
assert isinstance(neighbor, TCPCLNeighbor)
logger.info(f'TCPCL: Connecting to: {neighbor.host}:{neighbor.port}')
logger.info(f"TCPCL: Connecting to: {neighbor.host}:{neighbor.port}")
try:
reader, writer = await uio.open_connection(neighbor.host, neighbor.port)
except ConnectionRefusedError or TimeoutError:
......@@ -69,13 +70,13 @@ class TCPCL(ConvergenceLayerAdapter):
async def _request_handler(self, reader, writer):
# TODO: Don't close the connection, but repeatedly call self._upper_layer_handler for every new bundle prefix
logger.info(f'TCPCL: Accepted connection')
logger.info(f"TCPCL: Accepted connection")
conn = TCPCLConnection(self, reader, writer)
try:
await conn.start()
await self._upper_layer_handler(conn)
except Exception:
logger.exception('Exception occurred inside _request_handler')
logger.exception("Exception occurred inside _request_handler")
finally:
conn.close() # TODO: Don't automatically close connection after one bundle has been received
......@@ -91,9 +92,9 @@ class TCPCL(ConvergenceLayerAdapter):
None
"""
self._upper_layer_handler = upper_layer_handler
logger.info(f'TCPCL: listening on {self._host}:{self._port}')
logger.info(f"TCPCL: listening on {self._host}:{self._port}")
await uio.serve_forever(self._request_handler, self._host, self._port)
logger.info('TCPCL: exited')
logger.info("TCPCL: exited")
class TCPCLConnection(StreamedConvergenceLayerConnection):
......@@ -104,7 +105,7 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
try:
value, bytes_decoded = sdnv_decode(buffer=data)
except ValueError:
logger.info('Error reading SDNV: Unexpected end of input!')
logger.info("Error reading SDNV: Unexpected end of input!")
raise self.ProtocolError
self._unrecv(data[bytes_decoded:])
return value
......@@ -126,7 +127,7 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
async def _recv_contact_msg(self):
data = await self._recv_exact(len(TCPCLObjDef.MAGIC))
if data != TCPCLObjDef.MAGIC:
logger.info('Got wrong MAGIC in contact message!')
logger.info("Got wrong MAGIC in contact message!")
raise self.ContactMessageError
# Skip directly to Node ID
......@@ -137,7 +138,7 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
try:
len_of_payload, bytes_decoded = sdnv_decode(buffer=data)
except ValueError:
logger.info('Unexpected end of contact message!')
logger.info("Unexpected end of contact message!")
raise self.ContactMessageError
self._unrecv(data[bytes_decoded:])
......@@ -146,7 +147,7 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
peer_eid = data.decode("ascii")
except UnicodeDecodeError:
peer_eid = data
logger.debug(f'Received peer EID: {peer_eid}')
logger.debug(f"Received peer EID: {peer_eid}")
# TODO: If connection created by us, compare to EID of registered neighbor
async def _send_segment(self, msg_type, msg_flags, content_bytes):
......@@ -174,9 +175,9 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
"""
header = await self._recv(1)
msg_type = MessageType(header[0] >> 4)
msg_flags = header[0] & 0xf
msg_flags = header[0] & 0xF
logger.debug(f'TCPCL: Received segment of type {msg_type.name}')
logger.debug(f"TCPCL: Received segment of type {msg_type.name}")
if msg_type == MessageType.DATA_SEGMENT:
payload_len = await self._recv_sdnv()
......@@ -218,7 +219,7 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
"""
await self._send_contact_msg()
await self._recv_contact_msg()
logger.info('TCPCL: Contact messages exchanged, connection ready to be used')
logger.info("TCPCL: Contact messages exchanged, connection ready to be used")
async def send(self, data, bundle_start=True, bundle_end=True):
"""Send data as one bundle data segment
......@@ -271,5 +272,5 @@ class TCPCLConnection(StreamedConvergenceLayerConnection):
Returns:
None
"""
logger.info(f'TCPCL: Closing connection')
logger.info(f"TCPCL: Closing connection")
super().close()
......@@ -34,74 +34,56 @@ def dtn2unix(dtn_timestamp):
def make_contact(start_offset, end_offset, bitrate):
cur_time = int(time.time())
return (
unix2dtn(cur_time + start_offset),
unix2dtn(cur_time + end_offset),
bitrate,
)
return (unix2dtn(cur_time + start_offset), unix2dtn(cur_time + end_offset), bitrate)
def serialize_upcn_config_message(eid, cla_address,
reachable_eids=None, contacts=None,
config_type=ROUTER_COMMAND_ADD):
def serialize_upcn_config_message(eid, cla_address, reachable_eids=None, contacts=None, config_type=ROUTER_COMMAND_ADD):
# missing escaping has to be addresses in uPCN
assert "(" not in "".join([eid, cla_address] + (reachable_eids or []))
assert ")" not in "".join([eid, cla_address] + (reachable_eids or []))
eid_list = (
(
"[" +
",".join("(" + eid + ")" for eid in reachable_eids) +
"]"
)
if reachable_eids else ""
)
eid_list = ("[" + ",".join("(" + eid + ")" for eid in reachable_eids) + "]") if reachable_eids else ""
contact_list = (
(
"[" +
",".join(
"{{{},{},{}}}".format(start, end, bitrate)
for start, end, bitrate in contacts
) +
"]"
)
if contacts else ""
("[" + ",".join("{{{},{},{}}}".format(start, end, bitrate) for start, end, bitrate in contacts) + "]")
if contacts
else ""
)
return "{}({}):({}):{}:{};".format(
config_type,
eid,
cla_address,
eid_list,
contact_list,
).encode("ascii")
def serialize_bundle(source_eid, destination_eid, payload,
report_to_eid=NULL_EID,
creation_timestamp=None, sequence_number=0,
lifetime=300, flags=0,
fragment_offset=None,
hop_limit=30, hop_count=0, bundle_age=0,
previous_node_eid=NULL_EID):
return "{}({}):({}):{}:{};".format(config_type, eid, cla_address, eid_list, contact_list).encode("ascii")
def serialize_bundle(
source_eid,
destination_eid,
payload,
report_to_eid=NULL_EID,
creation_timestamp=None,
sequence_number=0,
lifetime=300,
flags=0,
fragment_offset=None,
hop_limit=30,
hop_count=0,
bundle_age=0,
previous_node_eid=NULL_EID,
):
if creation_timestamp is None:
creation_timestamp = time.time()
creation_datetime = datetime.datetime.fromtimestamp(
creation_timestamp,
datetime.timezone.utc,
)
creation_datetime = datetime.datetime.fromtimestamp(creation_timestamp, datetime.timezone.utc)
bundle_array = []
bundle_array.append(PrimaryBlock(
bundle_proc_flags=flags,
destination=destination_eid,
source=source_eid,
report_to=report_to_eid,
creation_time=CreationTimestamp(creation_datetime, sequence_number),
lifetime=lifetime,
fragment_offset=fragment_offset,
))
bundle_array.append(
PrimaryBlock(
bundle_proc_flags=flags,
destination=destination_eid,
source=source_eid,
report_to=report_to_eid,
creation_time=CreationTimestamp(creation_datetime, sequence_number),
lifetime=lifetime,
fragment_offset=fragment_offset,
)
)
if previous_node_eid != NULL_EID:
bundle_array.append(PreviousNodeBlock(previous_node_eid))
......
This diff is collapsed.
......@@ -72,13 +72,13 @@ def make_table(width):
initializer = (0 for _ in range(256))
if width == 8:
return array.array('B', initializer)
return array.array("B", initializer)
elif width == 16:
return array.array('H', initializer)
return array.array("H", initializer)
elif width == 32:
return array.array('L', initializer)
return array.array("L", initializer)
elif width == 64:
return array.array('Q', initializer)
return array.array("Q", initializer)
else:
# Fallback to a generic list
return list(initializer)
......@@ -112,8 +112,7 @@ class CRC(object):
assert crc(b"Hello world!") == 0x1b851995
"""
def __init__(self, width, polynomial, initial_value, final_xor_value,
input_reflected, result_reflected):
def __init__(self, width, polynomial, initial_value, final_xor_value, input_reflected, result_reflected):
self.width = width
self.polynomial = polynomial
self.initial_value = initial_value
......@@ -123,7 +122,7 @@ class CRC(object):
# Initialize casting mask to keep the correct width for dynamic Python
# integers
self.cast_mask = int('1' * self.width, base=2)
self.cast_mask = int("1" * self.width, base=2)
# Mask that can be applied to get the Most Significant Bit (MSB) if the
# number with given width
......@@ -161,7 +160,7 @@ class CRC(object):
crc = (crc ^ (cur_byte << (self.width - 8))) & self.cast_mask
# This MSB byte value is the index into the lookup table
index = (crc >> (self.width - 8)) & 0xff
index = (crc >> (self.width - 8)) & 0xFF
# Shift out the index
crc = (crc << 8) & self.cast_mask
......@@ -193,7 +192,7 @@ class CRC(object):
for cur_byte in value:
# The LSB of the XOR-red remainder and the next byte is the index
# into the lookup table
index = (crc & 0xff) ^ cur_byte
index = (crc & 0xFF) ^ cur_byte
# Shift out the index
crc = (crc >> 8) & self.cast_mask
......@@ -237,73 +236,74 @@ class CRC(object):
cur_byte = reflect(cur_byte, self.width)
table[divident] = (cur_byte & self.cast_mask)
table[divident] = cur_byte & self.cast_mask
return table
# Known CRC algorihtms
crc8 = CRC(8, 0x07, 0x00, 0x00, False, False)
crc8_sae_j1850 = CRC(8, 0x1d, 0xff, 0xff, False, False)
crc8_sae_j1850_zero = CRC(8, 0x1d, 0x00, 0x00, False, False)
crc8_8h2f = CRC(8, 0x2f, 0xff, 0xff, False, False)
crc8_cdma2000 = CRC(8, 0x9b, 0xff, 0x00, False, False)
crc8_sae_j1850 = CRC(8, 0x1D, 0xFF, 0xFF, False, False)
crc8_sae_j1850_zero = CRC(8, 0x1D, 0x00, 0x00, False, False)
crc8_8h2f = CRC(8, 0x2F, 0xFF, 0xFF, False, False)
crc8_cdma2000 = CRC(8, 0x9B, 0xFF, 0x00, False, False)
crc8_darc = CRC(8, 0x39, 0x00, 0x00, True, True)
crc8_dvb_s2 = CRC(8, 0xd5, 0x00, 0x00, False, False)
crc8_ebu = CRC(8, 0x1d, 0xff, 0x00, True, True)
crc8_icode = CRC(8, 0x1d, 0xfd, 0x00, False, False)
crc8_dvb_s2 = CRC(8, 0xD5, 0x00, 0x00, False, False)
crc8_ebu = CRC(8, 0x1D, 0xFF, 0x00, True, True)
crc8_icode = CRC(8, 0x1D, 0xFD, 0x00, False, False)
crc8_itu = CRC(8, 0x07, 0x00, 0x55, False, False)
crc8_maxim = CRC(8, 0x31, 0x00, 0x00, True, True)
crc8_rohc = CRC(8, 0x07, 0xff, 0x00, True, True)
crc8_wcdma = CRC(8, 0x9b, 0x00, 0x00, True, True)
crc8_rohc = CRC(8, 0x07, 0xFF, 0x00, True, True)
crc8_wcdma = CRC(8, 0x9B, 0x00, 0x00, True, True)
crc16_ccit_zero = CRC(16, 0x1021, 0x0000, 0x0000, False, False)
crc16_arc = CRC(16, 0x8005, 0x0000, 0x0000, True, True)
crc16_aug_ccitt = CRC(16, 0x1021, 0x1d0f, 0x0000, False, False)
crc16_aug_ccitt = CRC(16, 0x1021, 0x1D0F, 0x0000, False, False)
crc16_buypass = CRC(16, 0x8005, 0x0000, 0x0000, False, False)
crc16_ccitt_false = CRC(16, 0x1021, 0xffff, 0x0000, False, False)
crc16_cdma2000 = CRC(16, 0xc867, 0xffff, 0x0000, False, False)
crc16_dds_110 = CRC(16, 0x8005, 0x800d, 0x0000, False, False)
crc16_ccitt_false = CRC(16, 0x1021, 0xFFFF, 0x0000, False, False)
crc16_cdma2000 = CRC(16, 0xC867, 0xFFFF, 0x0000, False, False)
crc16_dds_110 = CRC(16, 0x8005, 0x800D, 0x0000, False, False)
crc16_dect_r = CRC(16, 0x0589, 0x0000, 0x0001, False, False)
crc16_dect_x = CRC(16, 0x0589, 0x0000, 0x0000, False, False)
crc16_dnp = CRC(16, 0x3d65, 0x0000, 0xffff, True, True)
crc16_en_13757 = CRC(16, 0x3d65, 0x0000, 0xffff, False, False)
crc16_genibus = CRC(16, 0x1021, 0xffff, 0xffff, False, False)
crc16_maxim = CRC(16, 0x8005, 0x0000, 0xffff, True, True)
crc16_mcrf4xx = CRC(16, 0x1021, 0xffff, 0x0000, True, True)
crc16_riello = CRC(16, 0x1021, 0xb2aa, 0x0000, True, True)
crc16_t10_dif = CRC(16, 0x8bb7, 0x0000, 0x0000, False, False)
crc16_teledisk = CRC(16, 0xa097, 0x0000, 0x0000, False, False)
crc16_tms37157 = CRC(16, 0x1021, 0x89ec, 0x0000, True, True)
crc16_usb = CRC(16, 0x8005, 0xffff, 0xffff, True, True)
crc16_a = CRC(16, 0x1021, 0xc6c6, 0x0000, True, True)
crc16_dnp = CRC(16, 0x3D65, 0x0000, 0xFFFF, True, True)
crc16_en_13757 = CRC(16, 0x3D65, 0x0000, 0xFFFF, False, False)
crc16_genibus = CRC(16, 0x1021, 0xFFFF, 0xFFFF, False, False)
crc16_maxim = CRC(16, 0x8005, 0x0000, 0xFFFF, True, True)
crc16_mcrf4xx = CRC(16, 0x1021, 0xFFFF, 0x0000, True, True)
crc16_riello = CRC(16, 0x1021, 0xB2AA, 0x0000, True, True)
crc16_t10_dif = CRC(16, 0x8BB7, 0x0000, 0x0000, False, False)
crc16_teledisk = CRC(16, 0xA097, 0x0000, 0x0000, False, False)
crc16_tms37157 = CRC(16, 0x1021, 0x89EC, 0x0000, True, True)
crc16_usb = CRC(16, 0x8005, 0xFFFF, 0xFFFF, True, True)
crc16_a = CRC(16, 0x1021, 0xC6C6, 0x0000, True, True)
crc16_kermit = CRC(16, 0x1021, 0x0000, 0x0000, True, True)
crc16_modbus = CRC(16, 0x8005, 0xffff, 0x0000, True, True)
crc16_x25 = CRC(16, 0x1021, 0xffff, 0xffff, True, True)
crc16_modbus = CRC(16, 0x8005, 0xFFFF, 0x0000, True, True)