Refactored packet type naming

This commit is contained in:
Mark Qvist 2018-04-16 22:09:23 +02:00
parent 8772db6736
commit dedea6ba11
4 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@ link 11
packet types
-----------------
resource 00
data 00
announce 01
link request 10
proof 11

View File

@ -116,7 +116,7 @@ class Destination:
if packet.packet_type == RNS.Packet.LINKREQUEST:
self.incomingLinkRequest(plaintext, packet)
if packet.packet_type == RNS.Packet.RESOURCE:
if packet.packet_type == RNS.Packet.DATA:
if self.callbacks.packet != None:
self.callbacks.packet(plaintext, packet)

View File

@ -4,11 +4,11 @@ import RNS
class Packet:
# Constants
RESOURCE = 0x00;
DATA = 0x00;
ANNOUNCE = 0x01;
LINKREQUEST = 0x02;
PROOF = 0x03;
types = [RESOURCE, ANNOUNCE, LINKREQUEST, PROOF]
types = [DATA, ANNOUNCE, LINKREQUEST, PROOF]
HEADER_1 = 0x00; # Normal header format
HEADER_2 = 0x01; # Header format used for link packets in transport
@ -16,7 +16,7 @@ class Packet:
HEADER_4 = 0x03; # Reserved
header_types = [HEADER_1, HEADER_2, HEADER_3, HEADER_4]
def __init__(self, destination, data, packet_type = RESOURCE, transport_type = RNS.Transport.BROADCAST, header_type = HEADER_1, transport_id = None):
def __init__(self, destination, data, packet_type = DATA, transport_type = RNS.Transport.BROADCAST, header_type = HEADER_1, transport_id = None):
if destination != None:
if transport_type == None:
transport_type = RNS.Transport.BROADCAST

View File

@ -51,7 +51,7 @@ class Transport:
destination.receive(packet)
Transport.cache(packet)
if packet.packet_type == RNS.Packet.RESOURCE:
if packet.packet_type == RNS.Packet.DATA:
if packet.destination_type == RNS.Destination.LINK:
for link in Transport.active_links:
if link.link_id == packet.destination_hash: