--
-- Defines simple protocol servers (e.g., certificate authorities)
--
-- The server inherits the node interface from the network nodes, and 
-- checks whether a message is a request for service, in which case it deals with it.

module newIntegrity_Service(address_ : Address) 
    return Integrity_Service is
        
        network_address : Address is address_;
        action start_Integrity_Server(Net : NetID; Node : NodeID); 
        
    initial
        start_Integrity_Server(network_address.net_no, network_address.node_no);
    parallel
        when (?message : Message; ?destination : Address)
            net_conn.to_node(?message,network_address)
                where (message_is_integrity_request(?message))
        declare
        -- The message is an integrity request
            retAddr : Address is ?message.request.requestor;
            operation : ?message.request.to_do.Integrity;
        do
        -- decide whether it is a wrap or a check
        case operation of
        	Wrap => 
        -- Simply return the information as validated (at this point)
            net_conn.to_net
                (Message'(response,
                          (status is (Integrity, (Wrap, operation.wrap)))),
                retAddr);
        or
        	Check => 
        -- Simply return the information as validated (at this point)
            net_conn.to_net
                (Message'(response,
                          (status is (Integrity, (Check, true)))),
                retAddr);
        end case;
        end;
end;

