Skip to content

Commit 1eb2ee4

Browse files
authored
Merge pull request #83 from xmm7360/split_dbus_library
Split dbus functionality into library file
2 parents f181398 + 0739771 commit 1eb2ee4

File tree

11 files changed

+444
-173
lines changed

11 files changed

+444
-173
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
ignore = E501

.github/workflows/lint.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.py"
7+
8+
pull_request:
9+
paths:
10+
- "**.py"
11+
12+
jobs:
13+
flake8_py3:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.8.5
20+
architecture: x64
21+
22+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
23+
- uses: actions/checkout@v2
24+
25+
- name: Install flake8
26+
run: pip install flake8
27+
28+
- name: Run flake8
29+
uses: suo/flake8-github-action@releases/v1
30+
with:
31+
checkName: "flake8_py3" # NOTE: this needs to be the same as the job name
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
pull_request:
8+
branches: [master]
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
# This workflow contains a single job called "build"
13+
build:
14+
# The type of runner that the job will run on
15+
runs-on: ubuntu-latest
16+
17+
# Steps represent a sequence of tasks that will be executed as part of the job
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
20+
- uses: actions/checkout@v2
21+
22+
# Runs a single command using the runners shell
23+
- name: compile kernel module
24+
run: make
25+
26+
# Runs a single command using the runners shell
27+
- name: test python module
28+
run: python3 rpc/test_rpc.py

.github/workflows/main.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

rpc/mux.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import os
44
import binascii
5-
import time
65
import struct
7-
import itertools
86
import pytap2
97
import selectors
108

9+
1110
class MuxPacket(object):
1211
def __init__(self, seq=0):
1312
self.seq = seq
@@ -16,7 +15,8 @@ def __init__(self, seq=0):
1615

1716
def get_packet(self):
1817
# put the final length in
19-
self.packet = self.packet[:8] + struct.pack('<L', len(self.packet)) + self.packet[8+4:]
18+
self.packet = self.packet[:8] + \
19+
struct.pack('<L', len(self.packet)) + self.packet[8 + 4:]
2020
return self.packet
2121

2222
def append_tag(self, tag, data=b'', extra=0):
@@ -27,15 +27,17 @@ def append_tag(self, tag, data=b'', extra=0):
2727
else:
2828
while len(self.packet) & 3:
2929
self.packet += b'\0'
30-
self.packet = self.packet[:self.fwd_pointer] + struct.pack('<L', len(self.packet)) + self.packet[self.fwd_pointer+4:]
30+
self.packet = self.packet[:self.fwd_pointer] + struct.pack(
31+
'<L', len(self.packet)) + self.packet[self.fwd_pointer + 4:]
3132

3233
hdr_len = len(hdr) + 8
33-
hdr += struct.pack('<HHL', hdr_len+len(data), extra, 0)
34+
hdr += struct.pack('<HHL', hdr_len + len(data), extra, 0)
3435
# that last field is the next-tag pointer
3536
self.fwd_pointer = len(self.packet) + len(hdr) - 4
3637

3738
self.packet += hdr + data
3839

40+
3941
class XMMMux(object):
4042
def package(self, packet_data):
4143
self.seq = (self.seq + 1) & 0xff
@@ -52,11 +54,10 @@ def __init__(self, path='/dev/xmm0/mux'):
5254

5355
self.seq = 0
5456

55-
raw = binascii.unhexlify('6000000000383AFFFE800000000000000000000000000001FE80000000000000D438C1FD077C00C38600248840005550000000000000000005010000000005DC03044040FFFFFFFFFFFFFFFF0000000020018004142021F50000000000000000')
56-
pak = self.package(raw)
5757
pkd = binascii.unhexlify('414442480000010088000000700000006000000000383AFFFE800000000000000000000000000001FE80000000000000D438C1FD077C00C38600248840005550000000000000000005010000000005DC03044040FFFFFFFFFFFFFFFF0000000020018004142021F50000000000000000414454481800000000000000000000001000000060000000')
5858
p = MuxPacket(seq=1)
59-
p.append_tag(b'ADBH', binascii.unhexlify('6000000000383AFFFE800000000000000000000000000001FE80000000000000D438C1FD077C00C38600248840005550000000000000000005010000000005DC03044040FFFFFFFFFFFFFFFF0000000020018004142021F50000000000000000'))
59+
p.append_tag(b'ADBH', binascii.unhexlify(
60+
'6000000000383AFFFE800000000000000000000000000001FE80000000000000D438C1FD077C00C38600248840005550000000000000000005010000000005DC03044040FFFFFFFFFFFFFFFF0000000020018004142021F50000000000000000'))
6061
p.append_tag(b'ADTH', struct.pack('<LLL', 0, 0x10, 0x60))
6162

6263
print(binascii.hexlify(p.get_packet()))
@@ -76,7 +77,6 @@ def __init__(self, path='/dev/xmm0/mux'):
7677
p.append_tag(b'CMDH', struct.pack('<LLLL', 1, 0, 0, 0))
7778
os.write(self.fp, p.get_packet())
7879

79-
8080
while True:
8181
events = sel.select()
8282
for key, mask in events:
@@ -99,7 +99,7 @@ def read_mux(self):
9999
tail = tail[16:]
100100
while len(tail) >= 8:
101101
offset, length = struct.unpack('<LL', tail[:8])
102-
puk = data[offset:offset+length]
102+
puk = data[offset:offset + length]
103103
# print('ai>', binascii.hexlify(puk))
104104
self.tun.write(puk)
105105
tail = tail[8:]

0 commit comments

Comments
 (0)