version check and port numbers aligned with Java

This commit is contained in:
Matej Sekoranja
2012-06-27 08:25:15 +02:00
parent 4b5bc38835
commit 998fd9e44e
8 changed files with 23 additions and 31 deletions

7
TODO Normal file
View File

@@ -0,0 +1,7 @@
redefine size encoding to be able to carry negative values (to handle negative offsets), i.e. -128 means take larger integer size (same pattern for 32-bit integer). This also bings symmetric integer range (-value ... value).
opt) connection validation message sends max paylaod size
readSize checks if size is in limits of size_t?

View File

@@ -15,26 +15,17 @@ namespace pvAccess {
/** CA protocol magic number */
const epics::pvData::int8 CA_MAGIC = 0xCA;
/** CA protocol major revision (implemented by this library). */
const epics::pvData::int8 CA_MAJOR_PROTOCOL_REVISION = 5;
/** CA protocol minor revision (implemented by this library). */
const epics::pvData::int8 CA_MINOR_PROTOCOL_REVISION = 0;
/** Unknown CA protocol minor revision. */
const epics::pvData::int8 CA_UNKNOWN_MINOR_PROTOCOL_REVISION = 0;
/** CA version signature (e.g. 0x50). */
const epics::pvData::int8 CA_VERSION = ((uint8_t)CA_MAJOR_PROTOCOL_REVISION<<4)|CA_MINOR_PROTOCOL_REVISION;
/** CA protocol port base. */
const epics::pvData::int32 CA_PORT_BASE = 5056;
/** CA protocol revision (implemented by this library). */
const epics::pvData::int8 CA_PROTOCOL_REVISION = 0;
/** CA version signature used to report this implementation version in header. */
const epics::pvData::int8 CA_VERSION = CA_PROTOCOL_REVISION;
/** Default CA server port. */
const epics::pvData::int32 CA_SERVER_PORT = CA_PORT_BASE+2*CA_MAJOR_PROTOCOL_REVISION;
const epics::pvData::int32 CA_SERVER_PORT = 5075;
/** Default CA beacon port. */
const epics::pvData::int32 CA_BROADCAST_PORT = CA_SERVER_PORT+1;
const epics::pvData::int32 CA_BROADCAST_PORT = 5076;
/** CA protocol message header size. */
const epics::pvData::int16 CA_MESSAGE_HEADER_SIZE = 8;

View File

@@ -580,7 +580,7 @@ namespace pvAccess {
// second byte version - major/minor nibble
int8 magic = _socketBuffer->getByte();
_version = _socketBuffer->getByte();
if(unlikely((magic != CA_MAGIC) || (((uint8_t)_version) >> 4)!=CA_MAJOR_PROTOCOL_REVISION))
if(unlikely(magic != CA_MAGIC))
{
// error... disconnect
LOG(

View File

@@ -259,7 +259,7 @@ namespace epics {
// second byte version - major/minor nibble
int8 magic = receiveBuffer->getByte();
int8 version = receiveBuffer->getByte();
if(unlikely((magic != CA_MAGIC) || (((uint8_t)version) >> 4)!=CA_MAJOR_PROTOCOL_REVISION))
if(unlikely(magic != CA_MAGIC))
return false;
// only data for UDP

View File

@@ -164,20 +164,12 @@ namespace epics {
*/
virtual const epics::pvData::String getType() const = 0;
/**
* Transport protocol major revision.
* @return protocol major revision.
*/
virtual epics::pvData::int8 getMajorRevision() const {
return CA_MAJOR_PROTOCOL_REVISION;
}
/**
* Transport protocol minor revision.
* @return protocol minor revision.
*/
virtual epics::pvData::int8 getMinorRevision() const {
return CA_MINOR_PROTOCOL_REVISION;
virtual epics::pvData::int8 getRevision() const {
return CA_PROTOCOL_REVISION;
}
/**

View File

@@ -3943,7 +3943,7 @@ TODO
auto_ptr<BlockingUDPConnector> broadcastConnector(new BlockingUDPConnector(true, true));
m_broadcastTransport = static_pointer_cast<BlockingUDPTransport>(broadcastConnector->connect(
nullTransportClient, clientResponseHandler,
listenLocalAddress, CA_MINOR_PROTOCOL_REVISION,
listenLocalAddress, CA_PROTOCOL_REVISION,
CA_DEFAULT_PRIORITY));
if (!m_broadcastTransport.get())
return false;
@@ -3959,7 +3959,7 @@ TODO
auto_ptr<BlockingUDPConnector> searchConnector(new BlockingUDPConnector(false, true));
m_searchTransport = static_pointer_cast<BlockingUDPTransport>(searchConnector->connect(
nullTransportClient, clientResponseHandler,
undefinedAddress, CA_MINOR_PROTOCOL_REVISION,
undefinedAddress, CA_PROTOCOL_REVISION,
CA_DEFAULT_PRIORITY));
if (!m_searchTransport.get())
return false;

View File

@@ -218,7 +218,7 @@ void ServerContextImpl::initializeBroadcastTransport()
auto_ptr<epics::pvAccess::ResponseHandler> responseHandler = createResponseHandler();
_broadcastTransport = static_pointer_cast<BlockingUDPTransport>(broadcastConnector->connect(
nullTransportClient, responseHandler,
listenLocalAddress, CA_MINOR_PROTOCOL_REVISION,
listenLocalAddress, CA_PROTOCOL_REVISION,
CA_DEFAULT_PRIORITY));
_broadcastTransport->setBroadcastAddresses(broadcastAddresses.get());

View File

@@ -419,6 +419,8 @@ class ChannelGetRequesterImpl : public ChannelGetRequester
}
String str;
str.reserve(16*1024*1024);
// access smart pointers
{