• Martin Hurton's avatar
    Extend ZTP/1.0 protocol · 1bca4f6f
    Martin Hurton authored
    The new protocol adds support for protocol version and  exchanges the
    socket type, so that the library can reject a connection when the
    sockets do not match.
    
    The protocol was designed so that it's possible to detect and fully
    support ZTP/1.0 peers.
    
    When a new connection is set up, peers exchange greeting messages. The
    greeting message encodes both the protocol verion and the socket type.
    The format of the greeting message is as follows:
    
        greeting    = tag1, adaptation, tag2, version, length, socket_type
        tag1        = BYTE / 0xff
        adaptation  = 8 BYTES
        tag2        = BYTE / 0x7f
        version     = BYTE / 1
        length      = BYTE / 1
        socket_type = BYTE
    
    The protocol does not define the value of adaptation field.
    
    When interoperability with ZTP/1.0 peers is required, the adaptaion
    encodes, in network byte order, the length of identity message increased
    by 1. When adaptaion consists of eight zeros, the current
    implementatatio of 0MQ 2.x closes the connection.
    
    This patch supports both ZTP/1.0 and new protocol.
    1bca4f6f
stream_engine.hpp 4.61 KB