diff --git a/Hash2Pub/FediChord.asn1 b/Hash2Pub/FediChord.asn1 index 486089e..7e32875 100644 --- a/Hash2Pub/FediChord.asn1 +++ b/Hash2Pub/FediChord.asn1 @@ -16,7 +16,8 @@ Request ::= SEQUENCE { queryIDSendPayload QueryIDSendPayload, joinSendPayload JoinSendPayload, leaveSendPayload LeaveSendPayload, - stabiliseSendPayload StabiliseSendPayload + stabiliseSendPayload StabiliseSendPayload, + pingSendPayload PingSendPayload } } @@ -30,7 +31,8 @@ Response ::= SEQUENCE { queryIDReceivePayload QueryIDReceivePayload, joinReceivePayload JoinReceivePayload, leaveReceivePayload LeaveReceivePayload, - stabiliseReceivePayload StabiliseReceivePayload + stabiliseReceivePayload StabiliseReceivePayload, + pingReceivePayload PingReceivePayload } } @@ -87,5 +89,11 @@ LeaveSendPayload ::= SEQUENCE { LeaveReceivePayload ::= NULL -- just a confirmation +PingSendPayload ::= NULL -- do not include a node/ vserver ID, so that + -- the node has to respond with all active ones + +-- learning all active vserver IDs handled by the server at once +PingReceivePayload ::= SEQUENCE OF NodeState + END diff --git a/Hash2Pub/src/Hash2Pub/ASN1Coding.hs b/Hash2Pub/src/Hash2Pub/ASN1Coding.hs index ca6d8e4..3c0c5fb 100644 --- a/Hash2Pub/src/Hash2Pub/ASN1Coding.hs +++ b/Hash2Pub/src/Hash2Pub/ASN1Coding.hs @@ -28,6 +28,8 @@ data Action = -- probably should be taken care of by the callers of this, as the ASN.1 -- encoding functions are layer-4 agnostic +-- ===== encoding functions ===== + encodeNodeState :: NodeState -> [ASN1] encodeNodeState ns = [ Start Sequence @@ -82,7 +84,7 @@ encodeQueryIDReceivePayload resp = FOUND _ -> [] FORWARD entrySet -> Start Sequence - : mconcat (map encodeCacheEntry . Set.elems $ entrySet) + : concatMap encodeCacheEntry . Set.elems $ entrySet ++ [End Sequence] ++ [End Sequence] @@ -105,7 +107,7 @@ encodeJoinReceivePayload succ' pred' ncache = ++ map (IntVal . getNodeID) pred' ++ [End Sequence , Start Sequence] - ++ mconcat (map encodeCacheEntry ncache) + ++ concatMap encodeCacheEntry ncache ++ [End Sequence , End Sequence] @@ -131,3 +133,12 @@ encodeResponse responseTo senderID parts part action payload = [ , IntVal part , Enumerated . fromIntegral . fromEnum $ action] ++ payload + +encodePingSendPayload :: [ASN1] +encodePingSendPayload = Null + +encodePingReceivePayload :: [NodeState] -> [ASN1] +encodePingReceivePayload nss = + Start Sequence + : concatMap encodeNodeState nss + ++ [End Sequence]