Browse Source

could use some more checking and testing around payload and nonce sizes

p2p
mach327 1 year ago
parent
commit
bae33809fc
  1. 1
      .drone.yml
  2. 1
      Dockerfile
  3. 2
      m17/client.py
  4. 3
      m17/frames.py
  5. 7
      m17/test_frames.py

1
.drone.yml

@ -17,6 +17,5 @@ steps:
pull: always
image: registry2.tarxvf.tech/mike/pym17_builder
commands:
- pip install --upgrade pip numpy Cython wheel setuptools
- pip install -r requirements_debian_10.txt
- python -m unittest discover -v

1
Dockerfile

@ -1,3 +1,4 @@
from archlinux
RUN pacman --noconfirm -Syyu base-devel
RUN pacman --noconfirm -S codec2 python python-pip python-setuptools
RUN pip install --upgrade pip numpy Cython wheel setuptools

2
m17/client.py

@ -143,7 +143,7 @@ def m17frame(config,inq,outq):
dst=dst,
src=src,
streamtype=5, #TODO need to set this based on codec2 settings too to support c2.1600
nonce=b"\xbe\xef\xf0\x0d"*4 )
nonce=b"\xbe\xef\xf0\x0d" + b"a"*10 )
while 1:
plen = 16 #TODO grab from the framer itself
#need 16 bytes for M17 payload, each element on q should be 8 bytes if c2.3200

3
m17/frames.py

@ -37,6 +37,7 @@ class initialLICH:
self.dst = dst
self.streamtype = streamtype
self.nonce = nonce
assert len(nonce) == 14
def __eq__(self, other):
return bytes(self) == bytes(other)
@ -73,7 +74,7 @@ class initialLICH:
d["dst"], d["src"], d["streamtype"] = bitstruct.unpack("u48u48u16", data[:14])
d["dst"] = Address(addr=d["dst"])
d["src"] = Address(addr=d["src"])
d["nonce"] = data[14:14+16]
d["nonce"] = data[14:14+14]
return d
@staticmethod

7
m17/test_frames.py

@ -15,7 +15,7 @@ class test_frame_encodings(unittest.TestCase):
src=Address(callsign="W2FBI"),
dst=Address(callsign="SP5WWP"),
streamtype=5,
nonce=bytes(example_bytes(16)),
nonce=bytes(example_bytes(14)),
)
bl = bytes(lich)
lich2 = initialLICH.from_bytes(bl)
@ -25,7 +25,7 @@ class test_frame_encodings(unittest.TestCase):
src=Address(callsign="W2FBI"),
dst=Address(callsign="SP5WWP"),
streamtype=5,
nonce=example_bytes(16),
nonce=example_bytes(14),
)
x = regularFrame(
LICH=lich,
@ -41,7 +41,7 @@ class test_frame_encodings(unittest.TestCase):
src=Address(callsign="W2FBI"),
dst=Address(callsign="SP5WWP"),
streamtype=5,
nonce=example_bytes(16),
nonce=example_bytes(14),
)
x = ipFrame(
streamid=0xf00d,
@ -51,3 +51,4 @@ class test_frame_encodings(unittest.TestCase):
);
y = bytes(x)
z = ipFrame.from_bytes(y)
assert z == x
Loading…
Cancel
Save