mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-21 22:23:05 +00:00
afk.epic: Support sending v2 EPIC subheader
Default to version=4 as to not break DCP Signed-off-by: Eileen Yoon <eyn@gmx.com>
This commit is contained in:
parent
71c59d9894
commit
e76fc526e9
1 changed files with 35 additions and 1 deletions
|
@ -53,6 +53,17 @@ EPICSubHeader = Struct(
|
|||
"inline_len" / Hex(Int32ul),
|
||||
)
|
||||
|
||||
EPICSubHeaderV2 = Struct(
|
||||
"length" / Int32ul,
|
||||
"version" / Default(Int8ul, 2),
|
||||
"category" / EPICCategory,
|
||||
"type" / EPICSubtype,
|
||||
"seq" / Int16ul,
|
||||
"unk" / Default(Hex(Int16ul), 0),
|
||||
"pad" / Default(Hex(Int64ul), 0),
|
||||
"inline_len" / Hex(Int32ul),
|
||||
)
|
||||
|
||||
# dcp's announce
|
||||
EPICAnnounce = Struct(
|
||||
"name" / Padded(32, CString("utf8")),
|
||||
|
@ -377,7 +388,7 @@ class EPICEndpoint(AFKRingBufEndpoint):
|
|||
def send_notify(self, chan, call, **kwargs):
|
||||
return self.serv_map[chan].send_notify(call.TYPE, call.ARGS.build(call.args), **kwargs)
|
||||
|
||||
def send_epic(self, chan, ptype, category, type, seq, data, inline_len=0):
|
||||
def send_epicv4(self, chan, ptype, category, type, seq, data, inline_len=0, **kwargs):
|
||||
hdr = Container()
|
||||
hdr.channel = chan
|
||||
hdr.type = ptype
|
||||
|
@ -393,6 +404,29 @@ class EPICEndpoint(AFKRingBufEndpoint):
|
|||
pkt = EPICHeader.build(hdr) + EPICSubHeader.build(sub) + data
|
||||
super().send_ipc(pkt)
|
||||
|
||||
def send_epicv2(self, chan, ptype, category, type, seq, data, inline_len=0, **kwargs):
|
||||
hdr = Container()
|
||||
hdr.channel = chan
|
||||
hdr.type = ptype
|
||||
hdr.seq = self.hseq
|
||||
self.hseq += 1
|
||||
|
||||
sub = Container()
|
||||
sub.length = len(data)
|
||||
sub.category = category
|
||||
sub.type = type
|
||||
sub.seq = seq
|
||||
sub.inline_len = inline_len
|
||||
pkt = EPICHeader.build(hdr) + EPICSubHeaderV2.build(sub) + data
|
||||
super().send_ipc(pkt)
|
||||
|
||||
def send_epic(self, chan, ptype, category, type, seq, data, inline_len=0, version=4, **kwargs):
|
||||
if (version == 2):
|
||||
return self.send_epicv2(chan, ptype, category, type, seq, data, inline_len, **kwargs)
|
||||
if (version == 4):
|
||||
return self.send_epicv4(chan, ptype, category, type, seq, data, inline_len, **kwargs)
|
||||
raise EPICError(f"unknown epic sub version: {version}")
|
||||
|
||||
class AFKSystemEndpoint(EPICEndpoint):
|
||||
SHORT = "system"
|
||||
|
||||
|
|
Loading…
Reference in a new issue