Browse Source

s/liblora/libsyote/ s/lora_comms/syote_comms/

main
John-Mark Gurney 2 years ago
parent
commit
4a2795a593
3 changed files with 48 additions and 48 deletions
  1. +7
    -7
      Makefile
  2. +40
    -40
      lora.py
  3. +1
    -1
      syote_comms.py

+ 7
- 7
Makefile View File

@@ -72,11 +72,11 @@ WITH_USB_CDC=yes

CFLAGS+= -Werror -Wall

LIBLORA_TEST_SRCS= comms.c strobe.c x25519.c
LIBLORA_TEST_OBJS= $(LIBLORA_TEST_SRCS:C/.c$/.no/)
LIBSYOTE_TEST_SRCS= comms.c strobe.c x25519.c
LIBSYOTE_TEST_OBJS= $(LIBSYOTE_TEST_SRCS:C/.c$/.no/)

LIBLORA_TEST = liblora_test.$(SOEXT)
$(LIBLORA_TEST): $(LIBLORA_TEST_OBJS)
LIBSYOTE_TEST = libsyote_test.$(SOEXT)
$(LIBSYOTE_TEST): $(LIBSYOTE_TEST_OBJS)
$(CC) -shared -o $@ $(.ALLSRC)

.MAIN: all
@@ -102,7 +102,7 @@ rng_save.c: Makefile
.arm_deps:
$(ARMCC) $(ARMTARGET) $(CFLAGS) $(.ALLSRC) -MM > $@ || (rm -f $@ && false)

.test_deps: $(LIBLORA_TEST_SRCS)
.test_deps: $(LIBSYOTE_TEST_SRCS)
$(CC) $(CFLAGS) $(.ALLSRC) -MM | sed -e 's/\.o:/\.no:/' > $@ || (rm -f $@ && false)

.for i in $(PROGS)
@@ -126,8 +126,8 @@ runbuild: $(SRCS) Makefile mk/*.mk
for i in $(.MAKEFILE_LIST) $(.ALLSRC) $$(cat $(DEPENDS) | gsed ':x; /\\$$/ { N; s/\\\n//; tx }' | sed -e 's/^[^:]*://'); do if [ "$$i" != ".." ]; then echo $$i; fi; done | sort -u | entr -d sh -c 'echo starting...; cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) depend && $(MAKE) $(.MAKEFLAGS) all'

.PHONY: runtests
runtests: Makefile lora_comms.py lora.py loraserv.py multicast.py $(LIBLORA_TEST) $(LIBLORA_TEST_SRCS)
ls $(.ALLSRC) | entr sh -c '(cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) $(LIBLORA_TEST)) && ((PYTHONPATH="$(.CURDIR)" python3 -m coverage run -m unittest lora multicast loraserv lora_comms && coverage report --omit=$(.CURDIR)/p/\* -m -i) 2>&1 | head -n 30)'
runtests: Makefile syote_comms.py lora.py loraserv.py multicast.py $(LIBSYOTE_TEST) $(LIBSYOTE_TEST_SRCS)
ls $(.ALLSRC) | entr sh -c '(cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) $(LIBSYOTE_TEST)) && ((PYTHONPATH="$(.CURDIR)" python3 -m coverage run -m unittest lora multicast loraserv syote_comms && coverage report --omit=$(.CURDIR)/p/\* -m -i) 2>&1 | head -n 30)'

.if empty(IRR_KEY) && exists($(.CURDIR)/.irr_key)
IRR_KEY!= cat $(.CURDIR)/.irr_key


+ 40
- 40
lora.py View File

@@ -33,8 +33,8 @@ import unittest
from Strobe.Strobe import Strobe, KeccakF
from Strobe.Strobe import AuthenticationFailed

import lora_comms
from lora_comms import make_pktbuf, X25519
import syote_comms
from syote_comms import make_pktbuf, X25519
import multicast
from util import *

@@ -291,11 +291,11 @@ async def main():

# seed the RNG
prngseed = os.urandom(64)
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

import util_load
client_func = util_load.load_application(args.client)
@@ -310,17 +310,17 @@ async def main():
for i in range(outbuf[0].pktlen):
outbuf[0].pkt[i] = ret[i]

cb = lora_comms.process_msgfunc_t(client_call)
cb = syote_comms.process_msgfunc_t(client_call)

# Initialize everything
lora_comms.comms_init(commstate, cb, make_pktbuf(shared_key))
syote_comms.comms_init(commstate, cb, make_pktbuf(shared_key))

try:
while True:
pkt = await mr.recv()
msg = pkt[0]

out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, msg)

if out:
@@ -917,19 +917,19 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
# seed the RNG
prngseed = b'abc123'
from ctypes import c_uint8
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

cb = lora_comms.process_msgfunc_t(lambda msg, outbuf: None)
cb = syote_comms.process_msgfunc_t(lambda msg, outbuf: None)

# Generate shared key
shared_key = os.urandom(32)

# Initialize everything
lora_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)
syote_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)

# Create test fixture, only use it to init crypto state
tsd = SyncDatagram()
@@ -942,13 +942,13 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
msg = os.urandom(16) + b'othre'
msg = cstate.send_enc(msg) + cstate.send_mac(l.MAC_LEN)

out = lora_comms.comms_process_wrap(commstate, msg)
out = syote_comms.comms_process_wrap(commstate, msg)

self.assertFalse(out)

# that varous short messages don't cause problems
for i in range(10):
out = lora_comms.comms_process_wrap(commstate, b'0' * i)
out = syote_comms.comms_process_wrap(commstate, b'0' * i)

self.assertFalse(out)

@@ -959,7 +959,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
msg = os.urandom(16) + b' eqreset'
msg = cstate.send_enc(msg) + cstate.send_mac(l.MAC_LEN)

out = lora_comms.comms_process_wrap(commstate, msg)
out = syote_comms.comms_process_wrap(commstate, msg)

self.assertFalse(out)

@@ -967,7 +967,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
msg = os.urandom(16) + b'reqreset'
msg = l.st.send_enc(msg) + l.st.send_mac(l.MAC_LEN)

out = lora_comms.comms_process_wrap(commstate, msg)
out = syote_comms.comms_process_wrap(commstate, msg)

l.st.recv_enc(out[:-l.MAC_LEN])
l.st.recv_mac(out[-l.MAC_LEN:])
@@ -981,7 +981,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
msg = b'onfirm'
msg = cstate.send_enc(msg) + cstate.send_mac(l.MAC_LEN)

out = lora_comms.comms_process_wrap(commstate, msg)
out = syote_comms.comms_process_wrap(commstate, msg)

self.assertFalse(out)

@@ -992,7 +992,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
msg = b' onfirm'
msg = cstate.send_enc(msg) + cstate.send_mac(l.MAC_LEN)

out = lora_comms.comms_process_wrap(commstate, msg)
out = syote_comms.comms_process_wrap(commstate, msg)

self.assertFalse(out)

@@ -1003,11 +1003,11 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):

# seed the RNG
prngseed = b'abc123'
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

# These are the expected messages and their arguments
exptmsgs = [
@@ -1031,7 +1031,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
raise RuntimeError('cmd not found')

# wrap the callback function
cb = lora_comms.process_msgfunc_t(procmsg)
cb = syote_comms.process_msgfunc_t(procmsg)

class CCodeSD(MockSyncDatagram):
async def runner(self):
@@ -1040,7 +1040,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
inmsg = await self.get()

# process the test message
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# make sure the reply matches length
@@ -1050,7 +1050,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
origmsg = out

# pretend that the reply didn't make it
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# make sure that the reply matches
@@ -1065,7 +1065,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
respkey = X25519.gen()

# Initialize everything
lora_comms.comms_init(commstate, cb, None, make_pktbuf(respkey.getpriv()), make_pktbuf(initkey.getpub()))
syote_comms.comms_init(commstate, cb, None, make_pktbuf(respkey.getpriv()), make_pktbuf(initkey.getpub()))

# Create test fixture
tsd = CCodeSD()
@@ -1100,11 +1100,11 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):

# seed the RNG
prngseed = b'abc123'
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

# These are the expected messages and their arguments
exptmsgs = [
@@ -1128,7 +1128,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
raise RuntimeError('cmd not found')

# wrap the callback function
cb = lora_comms.process_msgfunc_t(procmsg)
cb = syote_comms.process_msgfunc_t(procmsg)

class CCodeSD(MockSyncDatagram):
async def runner(self):
@@ -1137,7 +1137,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
inmsg = await self.get()

# process the test message
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# make sure the reply matches length
@@ -1147,7 +1147,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
origmsg = out

# pretend that the reply didn't make it
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# make sure that the reply matches
@@ -1161,7 +1161,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
shared_key = os.urandom(32)

# Initialize everything
lora_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)
syote_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)

# Create test fixture
tsd = CCodeSD()
@@ -1203,11 +1203,11 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):

# seed the RNG
prngseed = b'abc123'
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

# These are the expected messages and their arguments
exptmsgs = [
@@ -1231,7 +1231,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
raise RuntimeError('cmd not found: %d' % cmd)

# wrap the callback function
cb = lora_comms.process_msgfunc_t(procmsg)
cb = syote_comms.process_msgfunc_t(procmsg)

class FlipMsg(object):
async def flipmsg(self):
@@ -1239,7 +1239,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
inmsg = await self.get()

# process the test message
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# pass the reply back
@@ -1257,7 +1257,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
inmsg = b'0'*24

# process the bogus message
out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, inmsg)

# make sure there was not a response
@@ -1290,7 +1290,7 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
shared_key = os.urandom(32)

# Initialize everything
lora_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)
syote_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)

# Create test fixture
tsd = CCodeSD1()
@@ -1340,11 +1340,11 @@ class TestLoRaNodeMulticast(unittest.IsolatedAsyncioTestCase):

# seed the RNG
prngseed = b'abc123'
lora_comms.strobe_seed_prng((c_uint8 *
syote_comms.strobe_seed_prng((c_uint8 *
len(prngseed))(*prngseed), len(prngseed))

# Create the state for testing
commstate = lora_comms.CommsState()
commstate = syote_comms.CommsState()

# These are the expected messages and their arguments
exptmsgs = [
@@ -1367,13 +1367,13 @@ class TestLoRaNodeMulticast(unittest.IsolatedAsyncioTestCase):
raise RuntimeError('cmd not found')

# wrap the callback function
cb = lora_comms.process_msgfunc_t(procmsg)
cb = syote_comms.process_msgfunc_t(procmsg)

# Generate shared key
shared_key = os.urandom(32)

# Initialize everything
lora_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)
syote_comms.comms_init(commstate, cb, make_pktbuf(shared_key), None, None)

# create the object we are testing
msd = MulticastSyncDatagram(self.maddr)
@@ -1394,7 +1394,7 @@ class TestLoRaNodeMulticast(unittest.IsolatedAsyncioTestCase):
pkt = await mr.recv()
msg = pkt[0]

out = lora_comms.comms_process_wrap(
out = syote_comms.comms_process_wrap(
commstate, msg)

if out:


lora_comms.py → syote_comms.py View File

@@ -66,7 +66,7 @@ def make_pktbuf(s):
process_msgfunc_t = CFUNCTYPE(None, PktBuf, POINTER(PktBuf))

try:
_lib = CDLL('liblora_test.dylib')
_lib = CDLL('libsyote_test.dylib')
except OSError:
_lib = None


Loading…
Cancel
Save