diff --git a/pvAccessApp/Makefile b/pvAccessApp/Makefile index bd26f53..687ee94 100644 --- a/pvAccessApp/Makefile +++ b/pvAccessApp/Makefile @@ -68,6 +68,11 @@ LIBSRCS += blockingServerTCPTransport.cpp LIBSRCS += blockingTCPAcceptor.cpp LIBSRCS += channelSearchManager.cpp + +SRC_DIRS += $(PVACCESS)/remoteClient +INC += clientContextImpl.h + + LIBRARY = pvAccess pvAccess_LIBS += Com diff --git a/pvAccessApp/remote/beaconHandler.h b/pvAccessApp/remote/beaconHandler.h index 2a033a6..ed9b93a 100644 --- a/pvAccessApp/remote/beaconHandler.h +++ b/pvAccessApp/remote/beaconHandler.h @@ -18,8 +18,9 @@ using namespace epics::pvData; namespace epics { namespace pvAccess { - //TODO delete this + class ClientContextImpl; + /** * BeaconHandler */ diff --git a/pvAccessApp/remote/blockingClientTCPTransport.cpp b/pvAccessApp/remote/blockingClientTCPTransport.cpp index a18f7a5..b793374 100644 --- a/pvAccessApp/remote/blockingClientTCPTransport.cpp +++ b/pvAccessApp/remote/blockingClientTCPTransport.cpp @@ -97,7 +97,7 @@ namespace epics { if(_closed) return false; char ipAddrStr[48]; - ipAddrToA(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); errlogSevPrintf(errlogInfo, "Acquiring transport to %s.", ipAddrStr); _ownersMutex->lock(); @@ -127,7 +127,7 @@ namespace epics { int refs = _owners->size(); if(refs>0) { char ipAddrStr[48]; - ipAddrToA(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); errlogSevPrintf( errlogInfo, "Transport to %s still has %d client(s) active and closing...", @@ -145,7 +145,7 @@ namespace epics { if(_closed) return; char ipAddrStr[48]; - ipAddrToA(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&_socketAddress->ia, ipAddrStr, sizeof(ipAddrStr)); errlogSevPrintf(errlogInfo, "Releasing transport to %s.", ipAddrStr); diff --git a/pvAccessApp/remote/blockingTCPConnector.cpp b/pvAccessApp/remote/blockingTCPConnector.cpp index 4a066b6..1bd09d4 100644 --- a/pvAccessApp/remote/blockingTCPConnector.cpp +++ b/pvAccessApp/remote/blockingTCPConnector.cpp @@ -38,7 +38,7 @@ namespace epics { if(tryCount>0) epicsThreadSleep(0.1); char strBuffer[64]; - ipAddrToA(&address.ia, strBuffer, sizeof(strBuffer)); + ipAddrToDottedIP(&address.ia, strBuffer, sizeof(strBuffer)); errlogSevPrintf(errlogInfo, "Opening socket to CA server %s, attempt %d.", @@ -73,7 +73,7 @@ namespace epics { SOCKET socket = INVALID_SOCKET; char ipAddrStr[64]; - ipAddrToA(&address.ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&address.ia, ipAddrStr, sizeof(ipAddrStr)); // first try to check cache w/o named lock... BlockingClientTCPTransport @@ -106,6 +106,8 @@ namespace epics { ipAddrStr); socket = tryConnect(address, 3); + if (socket == INVALID_SOCKET) + return 0; // use blocking channel // socket is blocking bya default diff --git a/pvAccessApp/remote/channelSearchManager.cpp b/pvAccessApp/remote/channelSearchManager.cpp index 992af77..0e93554 100644 --- a/pvAccessApp/remote/channelSearchManager.cpp +++ b/pvAccessApp/remote/channelSearchManager.cpp @@ -60,7 +60,7 @@ bool BaseSearchInstance::generateSearchRequestMessage(ByteBuffer* requestMessage return false; } - const string name = getChannelName(); + const String name = getSearchInstanceName(); // not nice... const int addedPayloadSize = sizeof(int32)/sizeof(int8) + (1 + sizeof(int32)/sizeof(int8) + name.length()); @@ -69,7 +69,7 @@ bool BaseSearchInstance::generateSearchRequestMessage(ByteBuffer* requestMessage return false; } - requestMessage->putInt(getChannelID()); + requestMessage->putInt(getSearchInstanceID()); SerializeHelper::serializeString(name, requestMessage, control); requestMessage->putInt(PAYLOAD_POSITION, requestMessage->getPosition() - CA_MESSAGE_HEADER_SIZE); @@ -484,17 +484,17 @@ void ChannelSearchManager::registerChannel(SearchInstance* channel) if(_canceled) return; //overrides if already registered - _channels[channel->getChannelID()] = channel; + _channels[channel->getSearchInstanceID()] = channel; _timers[0]->installChannel(channel); } void ChannelSearchManager::unregisterChannel(SearchInstance* channel) { Lock guard(&_mutex); - _channelsIter = _channels.find(channel->getChannelID()); + _channelsIter = _channels.find(channel->getSearchInstanceID()); if(_channelsIter != _channels.end()) { - _channels.erase(channel->getChannelID()); + _channels.erase(channel->getSearchInstanceID()); } channel->removeAndUnsetListOwnership(); @@ -508,7 +508,7 @@ void ChannelSearchManager::searchResponse(int32 cid, int32 seqNo, int8 minorRevi _channelsIter = _channels.find(cid); if(_channelsIter != _channels.end()) { - SearchInstance* si = _channelsIter->second; + si = _channelsIter->second; _channels.erase(_channelsIter); si->removeAndUnsetListOwnership(); } diff --git a/pvAccessApp/remote/channelSearchManager.h b/pvAccessApp/remote/channelSearchManager.h index c36f19e..5479825 100644 --- a/pvAccessApp/remote/channelSearchManager.h +++ b/pvAccessApp/remote/channelSearchManager.h @@ -40,13 +40,13 @@ public: * * @return channel ID. */ - virtual pvAccessID getChannelID() = 0; + virtual pvAccessID getSearchInstanceID() = 0; /** - * Return channel name. + * Return search instance, e.g. channel, name. * * @return channel channel name. */ - virtual String getChannelName() = 0; + virtual String getSearchInstanceName() = 0; /** * Removes the owner of this search instance. */ @@ -93,8 +93,8 @@ class BaseSearchInstance : public SearchInstance { public: virtual ~BaseSearchInstance() {}; - virtual pvAccessID getChannelID() = 0; - virtual string getChannelName() = 0; + virtual pvAccessID getSearchInstanceID() = 0; + virtual String getSearchInstanceName() = 0; virtual void unsetListOwnership(); virtual void addAndSetListOwnership(ArrayFIFO* newOwner, Mutex* ownerMutex, int32 index); virtual void removeAndUnsetListOwnership(); diff --git a/pvAccessApp/remoteClient/clientContextImpl.h b/pvAccessApp/remoteClient/clientContextImpl.h new file mode 100644 index 0000000..bf5bf1e --- /dev/null +++ b/pvAccessApp/remoteClient/clientContextImpl.h @@ -0,0 +1,50 @@ +/* + * clientContext.h + * + * Created on: Dec 21, 2010 + * Author: msekoran + */ + +#ifndef CLIENTCONTEXTIMPL_H_ +#define CLIENTCONTEXTIMPL_H_ + +#include +#include +#include + +namespace epics { + namespace pvAccess { + + class ChannelImpl : + public Channel , + public TransportClient, + public TransportSender, + public BaseSearchInstance + { + public: + virtual pvAccessID getChannelID() = 0; + virtual void destroyChannel(bool force) = 0; + + }; + + class ClientContextImpl : public ClientContext, public Context + { + public: + virtual ChannelSearchManager* getChannelSearchManager() = 0; + virtual void checkChannelName(String& name) = 0; + + virtual void registerChannel(ChannelImpl* channel) = 0; + virtual void unregisterChannel(ChannelImpl* channel) = 0; + + virtual void destroyChannel(ChannelImpl* channel, bool force) = 0; + virtual ChannelImpl* createChannelInternal(String name, ChannelRequester* requester, short priority, InetAddrVector* addresses) = 0; + + virtual Transport* getTransport(TransportClient* client, osiSockAddr* serverAddress, int16 minorRevision, int16 priority) = 0; + + + }; + + } +} + +#endif /* CLIENTCONTEXTIMPL_H_ */ diff --git a/pvAccessApp/server/responseHandlers.cpp b/pvAccessApp/server/responseHandlers.cpp index e3bbad5..f191c32 100644 --- a/pvAccessApp/server/responseHandlers.cpp +++ b/pvAccessApp/server/responseHandlers.cpp @@ -29,7 +29,7 @@ namespace epics { int payloadSize, ByteBuffer* payloadBuffer) { if(_debug) { char ipAddrStr[48]; - ipAddrToA(&responseFrom->ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&responseFrom->ia, ipAddrStr, sizeof(ipAddrStr)); ostringstream prologue; prologue<<"Message [0x"<ia, ipAddrStr, sizeof(ipAddrStr)); + ipAddrToDottedIP(&responseFrom->ia, ipAddrStr, sizeof(ipAddrStr)); errlogSevPrintf(errlogInfo, "Undecipherable message (bad response type %d) from %s.", diff --git a/pvAccessApp/utils/arrayFIFO.h b/pvAccessApp/utils/arrayFIFO.h index d449c56..6de4bdb 100644 --- a/pvAccessApp/utils/arrayFIFO.h +++ b/pvAccessApp/utils/arrayFIFO.h @@ -243,7 +243,7 @@ namespace epics { T ArrayFIFO::pollFirst() { Lock lock(&_mutex); - if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); + if(isEmpty()) return 0; T result = _elements[_head]; // Element is null if deque empty _head = (_head+1)&(_size-1); @@ -254,7 +254,7 @@ namespace epics { T ArrayFIFO::pollLast() { Lock lock(&_mutex); - if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); + if(isEmpty()) return 0; _tail = (_tail-1)&(_size-1); return _elements[_tail]; @@ -264,7 +264,7 @@ namespace epics { T ArrayFIFO::peekFirst() { Lock lock(&_mutex); - if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); + if(isEmpty()) return 0; return _elements[_head]; } @@ -273,7 +273,7 @@ namespace epics { T ArrayFIFO::peekLast() { Lock lock(&_mutex); - if(isEmpty()) THROW_BASE_EXCEPTION("ArrayFIFO empty"); + if(isEmpty()) return 0; return _elements[(_tail-1)&(_size-1)]; } diff --git a/pvAccessApp/utils/inetAddressUtil.cpp b/pvAccessApp/utils/inetAddressUtil.cpp index 77eac47..e9ab30f 100644 --- a/pvAccessApp/utils/inetAddressUtil.cpp +++ b/pvAccessApp/utils/inetAddressUtil.cpp @@ -60,6 +60,7 @@ namespace epics { // get number of interfaces ifconf.ifc_len = nelem*sizeof(ifreq); ifconf.ifc_req = pIfreqList; + memset(ifconf.ifc_req,0,ifconf.ifc_len); status = ioctl(sock, SIOCGIFCONF, &ifconf); if(status<0||ifconf.ifc_len==0) { errlogSevPrintf( @@ -69,32 +70,46 @@ namespace epics { return retVector; } - errlogPrintf("Found %d interfaces\n", ifconf.ifc_len); + struct ifreq* p = pIfreqList; + int maxNodes = ifconf.ifc_len/sizeof(ifreq); + for(int i = 0; iifr_name)) break; + //printf("[%i] plen %d name %s\n", i,p->ifr_addr.sa_len, p->ifr_name); + + + size_t n = p->ifr_addr.sa_len + sizeof(p->ifr_name); + if (n < sizeof(*p)) + p++; + else + p = (struct ifreq *)((char *)p + n); + - for(int i = 0; i<=ifconf.ifc_len; i++) { /* * If its not an internet interface then dont use it */ - if(pIfreqList[i].ifr_addr.sa_family!=AF_INET) continue; + if(p->ifr_addr.sa_family!=AF_INET) continue; - status = ioctl(sock, SIOCGIFFLAGS, &pIfreqList[i]); + struct ifreq ifrflags; + strncpy(ifrflags.ifr_name, p->ifr_name, + sizeof(ifrflags.ifr_name)); + status = ioctl(sock, SIOCGIFFLAGS, (char*)&ifrflags); if(status) { errlogSevPrintf( errlogMinor, "getBroadcastAddresses(): net intf flags fetch for \"%s\" failed", - pIfreqList[i].ifr_name); + p->ifr_name); continue; } /* * dont bother with interfaces that have been disabled */ - if(!(pIfreqList[i].ifr_flags&IFF_UP)) continue; + if(!(ifrflags.ifr_flags&IFF_UP)) continue; /* * dont use the loop back interface */ - if(pIfreqList[i].ifr_flags&IFF_LOOPBACK) continue; + if(ifrflags.ifr_flags&IFF_LOOPBACK) continue; pNewNode = new osiSockAddr; if(pNewNode==NULL) { @@ -114,37 +129,43 @@ namespace epics { * Otherwise CA will not query through the * interface. */ - if(pIfreqList[i].ifr_flags&IFF_BROADCAST) { - status = ioctl(sock, SIOCGIFBRDADDR, &pIfreqList[i]); + if(ifrflags.ifr_flags&IFF_BROADCAST) { + struct ifreq ifrflags; + strncpy(ifrflags.ifr_name, p->ifr_name, + sizeof(ifrflags.ifr_name)); + status = ioctl(sock, SIOCGIFBRDADDR, (char*)&ifrflags); if(status) { errlogSevPrintf( errlogMinor, "getBroadcastAddresses(): net intf \"%s\": bcast addr fetch fail", - pIfreqList->ifr_name); + p->ifr_name); delete pNewNode; continue; } - pNewNode->sa = pIfreqList[i].ifr_broadaddr; + pNewNode->sa = ifrflags.ifr_broadaddr; } #ifdef IFF_POINTOPOINT - else if(pIfreqList->ifr_flags&IFF_POINTOPOINT) { - status = ioctl(sock, SIOCGIFDSTADDR, &pIfreqList[i]); + else if(ifrflags.ifr_flags&IFF_POINTOPOINT) { + struct ifreq ifrflags; + strncpy(ifrflags.ifr_name, p->ifr_name, + sizeof(ifrflags.ifr_name)); + status = ioctl(sock, SIOCGIFDSTADDR, (char*)&ifrflags); if(status) { errlogSevPrintf( errlogMinor, "getBroadcastAddresses(): net intf \"%s\": pt to pt addr fetch fail", - pIfreqList[i].ifr_name); + p->ifr_name); delete pNewNode; continue; } - pNewNode->sa = pIfreqList[i].ifr_dstaddr; + pNewNode->sa = ifrflags.ifr_dstaddr; } #endif else { errlogSevPrintf( errlogMinor, "getBroadcastAddresses(): net intf \"%s\": not point to point or bcast?", - pIfreqList[i].ifr_name); + p->ifr_name); delete pNewNode; continue; } @@ -164,12 +185,16 @@ namespace epics { buffer->putShort(0); // next 16-bits are 1 buffer->putShort(0xFFFF); + buffer->putInt(ntohl(address->ia.sin_addr.s_addr)); + + /* // following IPv4 address in big-endian (network) byte order in_addr_t ipv4Addr = ntohl(address->ia.sin_addr.s_addr); buffer->putByte((int8)((ipv4Addr>>24)&0xFF)); buffer->putByte((int8)((ipv4Addr>>16)&0xFF)); buffer->putByte((int8)((ipv4Addr>>8)&0xFF)); buffer->putByte((int8)(ipv4Addr&0xFF)); + */ } osiSockAddr* intToIPv4Address(int32 addr) { diff --git a/testApp/remote/testChannelSearchManager.cpp b/testApp/remote/testChannelSearchManager.cpp index 5861a11..a459db2 100644 --- a/testApp/remote/testChannelSearchManager.cpp +++ b/testApp/remote/testChannelSearchManager.cpp @@ -9,8 +9,8 @@ class TestSearcInstance : public BaseSearchInstance { public: TestSearcInstance(string channelName, pvAccessID channelID): _channelID(channelID), _channelName(channelName) {} - pvAccessID getChannelID() { return _channelID;}; - string getChannelName() {return _channelName;}; + pvAccessID getSearchInstanceID() { return _channelID;}; + string getSearchInstanceName() {return _channelName;}; void searchResponse(int8 minorRevision, osiSockAddr* serverAddress) {}; private: pvAccessID _channelID; diff --git a/testApp/remote/testRemoteClientImpl.cpp b/testApp/remote/testRemoteClientImpl.cpp index 4b0f311..de251df 100644 --- a/testApp/remote/testRemoteClientImpl.cpp +++ b/testApp/remote/testRemoteClientImpl.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace epics::pvData; using namespace epics::pvAccess; @@ -388,7 +389,6 @@ typedef std::map IOIDResponseRequestMap; #define CALLBACK_GUARD(code) try { code } catch(...) { } -class ClientContextImpl; class DebugResponse : public ResponseHandler, private epics::pvData::NoDefaultMethods { public: @@ -406,14 +406,13 @@ class ClientContextImpl; Transport* transport, int8 version, int8 command, int payloadSize, epics::pvData::ByteBuffer* payloadBuffer) { + char ipAddrStr[48]; - std::cout << "ole" << std::endl; - ipAddrToA(&responseFrom->ia, ipAddrStr, sizeof(ipAddrStr)); - std::cout << "ole2" << std::endl; - + ipAddrToDottedIP(&responseFrom->ia, ipAddrStr, sizeof(ipAddrStr)); + ostringstream prologue; prologue<<"Message [0x"<ensureData(5); + int32 searchSequenceId = payloadBuffer->getInt(); + bool found = payloadBuffer->getByte() != 0; + if (!found) + return; + + transport->ensureData((128+2*16)/8); + + osiSockAddr serverAddress; + serverAddress.ia.sin_family = AF_INET; + + // 128-bit IPv6 address + /* + int8* byteAddress = new int8[16]; + for (int i = 0; i < 16; i++) + byteAddress[i] = payloadBuffer->getByte(); }; + */ + + // IPv4 compatible IPv6 address expected + // first 80-bit are 0 + if (payloadBuffer->getLong() != 0) return; + if (payloadBuffer->getShort() != 0) return; + if (payloadBuffer->getShort() != (int16)0xFFFF) return; + + // accept given address if explicitly specified by sender + serverAddress.ia.sin_addr.s_addr = htonl(payloadBuffer->getInt()); + if (serverAddress.ia.sin_addr.s_addr == INADDR_ANY) + serverAddress.ia.sin_addr = responseFrom->ia.sin_addr; + + serverAddress.ia.sin_port = htons(payloadBuffer->getShort()); + + // reads CIDs + ChannelSearchManager* csm = m_context->getChannelSearchManager(); + int16 count = payloadBuffer->getShort(); + for (int i = 0; i < count; i++) + { + transport->ensureData(4); + pvAccessID cid = payloadBuffer->getInt(); + csm->searchResponse(cid, searchSequenceId, version & 0x0F, &serverAddress); + } + + + } + }; + + /** * CA response handler - main handler which dispatches responses to appripriate handlers. * @author Matej Sekoranja @@ -460,7 +522,7 @@ class ClientResponseHandler : public ResponseHandler, private epics::pvData::NoD m_handlerTable[ 1] = badResponse; // TODO new ConnectionValidationHandler(context), /* 1 */ m_handlerTable[ 2] = badResponse; // TODO new NoopResponse(context, "Echo"), /* 2 */ m_handlerTable[ 3] = badResponse; // TODO new NoopResponse(context, "Search"), /* 3 */ - m_handlerTable[ 4] = badResponse; // TODO new SearchResponseHandler(context), /* 4 */ + m_handlerTable[ 4] = new SearchResponseHandler(context), /* 4 */ m_handlerTable[ 5] = badResponse; // TODO new NoopResponse(context, "Introspection search"), /* 5 */ m_handlerTable[ 6] = dataResponse; /* 6 - introspection search */ m_handlerTable[ 7] = badResponse; // TODO new CreateChannelHandler(context), /* 7 */ @@ -528,7 +590,6 @@ class ClientResponseHandler : public ResponseHandler, private epics::pvData::NoD -class BeaconHandlerImpl; @@ -558,8 +619,7 @@ enum ContextState { }; -class ClientContextImpl : public ClientContext, -public Context /* TODO */ +class TestClientContextImpl : public ClientContextImpl { @@ -571,11 +631,7 @@ public Context /* TODO */ * Implementation of CAJ JCA Channel. * @author Matej Sekoranja */ -class ChannelImpl : - public Channel , - public TransportClient, - public TransportSender, - public BaseSearchInstance { +class TestChannelImpl : public ChannelImpl { private: /** @@ -658,7 +714,7 @@ class ChannelImpl : PVStructure* m_pvStructure; private: - ~ChannelImpl() + ~TestChannelImpl() { PVDATA_REFCOUNT_MONITOR_DESTRUCT(channel); } @@ -672,7 +728,7 @@ class ChannelImpl : * @param listener * @throws CAException */ - ChannelImpl( + TestChannelImpl( ClientContextImpl* context, pvAccessID channelID, String name, @@ -700,25 +756,6 @@ class ChannelImpl : // connect connect(); - - - // - // mock - // - ScalarType stype = pvDouble; - String allProperties("alarm,timeStamp,display,control,valueAlarm"); - - m_pvStructure = getStandardPVField()->scalar( - 0,name,stype,allProperties); - PVDouble *pvField = m_pvStructure->getDoubleField(String("value")); - pvField->put(1.123); - - - // already connected, report state - m_requester->channelStateChange(this, CONNECTED); - - - } virtual void destroy() @@ -791,6 +828,14 @@ class ChannelImpl : return m_channelID; } + virtual pvAccessID getSearchInstanceID() { + return m_channelID; + } + + virtual String getSearchInstanceName() { + return m_name; + } + void connect() { Lock guard(&m_channelMutex); // if not destroyed... @@ -1027,8 +1072,7 @@ class ChannelImpl : if (transport) { // multiple defined PV or reconnect request (same server address) - // TOD !!!! if (!(*(transport->getRemoteAddress()) == *serverAddress)) - if (false) + if (sockAddrAreIdentical(transport->getRemoteAddress(), serverAddress)) { m_requester->message("More than one channel with name '" + m_name + "' detected, additional response from: " + inetAddressToString(serverAddress), warningMessage); @@ -1346,7 +1390,7 @@ class ChannelImpl : public: - ClientContextImpl() : + TestClientContextImpl() : m_addressList(""), m_autoAddressList(true), m_connectionTimeout(30.0f), m_beaconPeriod(15.0f), m_broadcastPort(CA_BROADCAST_PORT), m_receiveBufferSize(MAX_TCP_RECV), m_timer(0), m_broadcastTransport(0), m_searchTransport(0), m_connector(0), m_transportRegistry(0), @@ -1457,7 +1501,7 @@ class ChannelImpl : } private: - ~ClientContextImpl() {}; + ~TestClientContextImpl() {}; void loadConfiguration() { // TODO @@ -1499,8 +1543,15 @@ class ChannelImpl : listenLocalAddress.ia.sin_addr.s_addr = htonl(INADDR_ANY); // where to send address - InetAddrVector* broadcastAddresses = getSocketAddressList("192.168.1.255", m_broadcastPort); - // TODO getBroadcastAddresses(broadcastPort) + SOCKET socket = epicsSocketCreate(AF_INET, SOCK_DGRAM, 0); + InetAddrVector* broadcastAddresses = getBroadcastAddresses(socket); + cout<<"Broadcast addresses: "<size()<size(); i++) { + broadcastAddresses->at(i)->ia.sin_port = htons(m_broadcastPort); + cout<<"Broadcast address: "; + cout<at(i))<connect(client, new ClientResponseHandler(this), serverAddress, minorRevision, priority); + return m_connector->connect(client, new ClientResponseHandler(this), *serverAddress, minorRevision, priority); } - catch (ConnectionException cex) + catch (...) { - logger.log(Level.SEVERE, "Failed to create transport for: " + serverAddress, cex); + // TODO log + printf("failed to get transport\n"); + return 0; } - */ - return 0; - } /** @@ -1694,7 +1742,7 @@ class ChannelImpl : */ // TODO no minor version with the addresses // TODO what if there is an channel with the same name, but on different host! - Channel* createChannelInternal(String name, ChannelRequester* requester, short priority, + ChannelImpl* createChannelInternal(String name, ChannelRequester* requester, short priority, InetAddrVector* addresses) { // TODO addresses checkState(); @@ -1712,7 +1760,7 @@ class ChannelImpl : try { pvAccessID cid = generateCID(); - return new ChannelImpl(this, cid, name, requester, priority, addresses); + return new TestChannelImpl(this, cid, name, requester, priority, addresses); } catch(...) { // TODO @@ -1873,8 +1921,8 @@ class ChannelImpl : * Beacon handler map. */ // TODO consider std::unordered_map - typedef std::map AddressBeaconHandlerMap; - AddressBeaconHandlerMap m_beaconHandlers; +// typedef std::map AddressBeaconHandlerMap; +// AddressBeaconHandlerMap m_beaconHandlers; /** * Version. @@ -2123,7 +2171,7 @@ class ChannelProcessRequesterImpl : public ChannelProcessRequester int main(int argc,char *argv[]) { - ClientContextImpl* context = new ClientContextImpl(); + TestClientContextImpl* context = new TestClientContextImpl(); context->printInfo(); context->initialize(); @@ -2174,7 +2222,7 @@ int main(int argc,char *argv[]) monitor->destroy(); */ - epicsThreadSleep ( 10.0 ); + epicsThreadSleep ( 100.0 ); channel->destroy(); context->destroy(); diff --git a/testApp/utils/inetAddressUtilsTest.cpp b/testApp/utils/inetAddressUtilsTest.cpp index 5a594b7..0ff8f93 100644 --- a/testApp/utils/inetAddressUtilsTest.cpp +++ b/testApp/utils/inetAddressUtilsTest.cpp @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) { assert(strncmp(buff->getArray(), src, 16)==0); cout<<"\nPASSED!\n"; - SOCKET socket = epicsSocketCreate(AF_INET, SOCK_STREAM, IPPROTO_TCP); + SOCKET socket = epicsSocketCreate(AF_INET, SOCK_DGRAM, 0); InetAddrVector* broadcasts = getBroadcastAddresses(socket); cout<<"Broadcast addresses: "<size()<size(); i++) {