connect proto changes

This commit is contained in:
Jeff Hill
1997-06-13 09:16:17 +00:00
parent ccb8a554ab
commit 951d97e7ff
35 changed files with 543 additions and 341 deletions

View File

@@ -11,7 +11,7 @@ include $(TOP)/config/CONFIG_BASE
CXXCMPLR = STRICT
# sometimes it's good to have different C/C++ flags, not now:
USR_CFLAGS = -I$(SRC) -I$(IOSRC) -I$(STSRC) -I$(CA)
USR_CFLAGS = -I$(SRC) -I$(IOSRC) -I$(STSRC) -I$(CA) -DcaNetAddrSock
USR_CXXFLAGS = $(USR_CFLAGS)
LIBSRCS += caServer.cc
@@ -38,7 +38,6 @@ LIBSRCS += casAsyncPVCIOI.cc
LIBSRCS += casEventSys.cc
LIBSRCS += casMonitor.cc
LIBSRCS += casMonEvent.cc
LIBSRCS += casOpaqueAddr.cc
LIBSRCS += inBuf.o
LIBSRCS += outBuf.cc
LIBSRCS += dgInBuf.o

View File

@@ -3,7 +3,7 @@ TOP=../../..
include $(TOP)/config/CONFIG_BASE
DIRS = simple
DIRS = simple directoryService
include $(TOP)/config/RULES_DIRS

View File

@@ -86,7 +86,8 @@ caStatus exPV::update(gdd &valueIn)
return cas;
}
cur.get (t.tv_sec, t.tv_nsec);
t.tv_sec = (time_t) cur.getSecTruncToLong ();
t.tv_nsec = cur.getNSecTruncToLong ();
this->pValue->setTimeStamp(&t);
this->pValue->setStat (epicsAlarmNone);
this->pValue->setSevr (epicsSevNone);
@@ -242,7 +243,8 @@ inline aitTimeStamp exPV::getTS()
}
else {
osiTime cur(osiTime::getCurrent());
cur.get(ts.tv_sec, ts.tv_nsec);
ts.tv_sec = (time_t) cur.getSecTruncToLong ();
ts.tv_nsec = cur.getNSecTruncToLong ();
}
return ts;
}

View File

@@ -140,7 +140,8 @@ void exServer::installAliasName(pvInfo &info, const char *pAliasName)
//
// exServer::pvExistTest()
//
pvExistReturn exServer::pvExistTest(const casCtx& ctxIn, const char *pPVName)
pvExistReturn exServer::pvExistTest
(const casCtx& ctxIn, const char *pPVName)
{
//
// lifetime of id is shorter than lifetime of pName
@@ -185,7 +186,8 @@ pvExistReturn exServer::pvExistTest(const casCtx& ctxIn, const char *pPVName)
//
// exServer::createPV()
//
pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
pvCreateReturn exServer::createPV
(const casCtx &ctx, const char *pName)
{
//
// lifetime of id is shorter than lifetime of pName
@@ -196,7 +198,7 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return pvCreateReturn(S_casApp_pvNotFound);
return S_casApp_pvNotFound;
}
pvInfo &pvi = pPVE->getInfo();
@@ -206,17 +208,20 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
//
if (pvi.getIOType() == excasIoSync) {
pPV = pvi.createPV(*this, aitFalse);
if (!pPV) {
pvCreateReturn(S_casApp_noMemory);
if (pPV) {
return *pPV;
}
return pvCreateReturn(*pPV);
else {
return S_casApp_noMemory;
}
}
//
// Initiate async IO if this is an async PV
//
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return pvCreateReturn(S_casApp_postponeAsyncIO);
return S_casApp_postponeAsyncIO;
}
this->simultAsychIOCount++;
@@ -224,10 +229,10 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
exAsyncCreateIO *pIO =
new exAsyncCreateIO(pvi, *this, ctx);
if (pIO) {
return pvCreateReturn(S_casApp_asyncCompletion);
return S_casApp_asyncCompletion;
}
else {
return pvCreateReturn(S_casApp_noMemory);
return S_casApp_noMemory;
}
}
}

View File

@@ -66,10 +66,10 @@ public:
// for this class
//
pvInfo (const pvInfo &copyIn) :
scanPeriod(copyIn.scanPeriod), pName(copyIn.pName),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType), elementCount(copyIn.elementCount),
pPV(copyIn.pPV)
scanPeriod(copyIn.scanPeriod), pName(copyIn.pName),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType), elementCount(copyIn.elementCount),
pPV(copyIn.pPV)
{
}
@@ -78,7 +78,8 @@ public:
const double getHopr () const { return this->hopr; }
const double getLopr () const { return this->lopr; }
const excasIoType getIOType () const { return this->ioType; }
const unsigned getElementCount() const { return this->elementCount; }
const unsigned getElementCount() const
{ return this->elementCount; }
void destroyPV() { this->pPV=NULL; }
exPV *createPV (exServer &exCAS, aitBool preCreateFlag);
private:
@@ -103,7 +104,8 @@ private:
//
class pvEntry : public stringId, public tsSLNode<pvEntry> {
public:
pvEntry (pvInfo &infoIn, exServer &casIn, const char *pAliasName) :
pvEntry (pvInfo &infoIn, exServer &casIn,
const char *pAliasName) :
stringId(pAliasName), info(infoIn), cas(casIn)
{
assert(this->stringId::resourceName()!=NULL);
@@ -113,13 +115,8 @@ public:
pvInfo &getInfo() const { return this->info; }
void destroy ()
{
//
// always created with new
//
delete this;
}
inline void destroy ();
private:
pvInfo &info;
exServer &cas;
@@ -252,7 +249,8 @@ protected:
//
class exScalarPV : public exPV {
public:
exScalarPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag) :
exScalarPV (caServer &cas,
pvInfo &setup, aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
void scan();
private:
@@ -264,7 +262,8 @@ private:
//
class exVectorPV : public exPV {
public:
exVectorPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag) :
exVectorPV (caServer &cas, pvInfo &setup,
aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
void scan();
@@ -302,7 +301,8 @@ public:
this->simultAsychIOCount--;
}
else {
fprintf(stderr, "inconsistent simultAsychIOCount?\n");
fprintf(stderr,
"simultAsychIOCount underflow?\n");
}
}
private:
@@ -561,4 +561,15 @@ inline pvEntry::~pvEntry()
{
this->cas.removeAliasName(*this);
}
//
// pvEntry:: destroy()
//
inline void pvEntry::destroy ()
{
//
// always created with new
//
delete this;
}

View File

@@ -1,6 +1,9 @@
// $Id$
// $Log$
// Revision 1.2 1997/03/05 21:16:22 jbk
// Fixes cvs log id at top
//
#include <stdio.h>
#include "pvServ.h"
@@ -80,7 +83,7 @@ int main(int argc, char* argv[])
Debug3("total=%d,rate=%lf,prefix=%s\n",total_pv,rate,name);
server = new serv(total_pv,rate,name,40u,total_pv,total_pv);
server = new serv(total_pv,rate,name,total_pv);
rc=server->Main();
delete server;
return rc;
@@ -100,38 +103,19 @@ int serv::InitDB(void)
int serv::Main(void)
{
unsigned i;
int not_done=1;
double inv=(1.0/event_rate);
double num=(unsigned long)inv;
double fract=inv-num;
unsigned long lfract=fract?(unsigned long)(1.0/fract):0;
unsigned long nsec = lfract?1000000000u/lfract:0;
unsigned long sec = (unsigned long)num;
struct timeval tv_curr,tv_prev;
osiTime delay(sec,nsec);
tv_prev.tv_sec=0;
tv_prev.tv_usec=0;
Debug2("Update every sec=%lu nsec=%lu\n",sec,nsec);
if (event_rate>0) {
Debug1("Update every %f sec\n", inv);
double inv=(1.0/event_rate);
pScanTimer = new scanTimer (inv, *this);
}
while(not_done)
{
osiTime delay(10.0);
fileDescriptorManager.process(delay);
gettimeofday(&tv_curr,NULL);
if(tv_curr.tv_sec-tv_prev.tv_sec >= sec &&
tv_curr.tv_usec-tv_prev.tv_usec >= (nsec/1000))
{
for(i=0;i<pv_total;i++)
db_sync[i].eventReady();
}
tv_prev=tv_curr;
}
return 0;
@@ -139,10 +123,10 @@ int serv::Main(void)
// ------------------------- server stuff ----------------------------
serv::serv(int tot,double rate,char* name,
unsigned max_name_len,unsigned pv_count_est,unsigned max_sim_io):
caServer(max_name_len, pv_count_est, max_sim_io),
db_sync(NULL),pv_total(tot),event_rate(rate),prefix(name)
serv::serv(int tot,double rate,char* name,unsigned pv_count_est):
caServer(pv_count_est),
db_sync(NULL),pv_total(tot),event_rate(rate),prefix(name),
pScanTimer(NULL)
{
event_mask|=(alarmEventMask|valueEventMask|logEventMask);
@@ -159,6 +143,7 @@ serv::serv(int tot,double rate,char* name,
serv::~serv(void)
{
delete [] db_sync;
if (pScanTimer) delete pScanTimer;
}
pvExistReturn serv::pvExistTest(const casCtx&,const char* pvname)
@@ -185,9 +170,9 @@ pvExistReturn serv::pvExistTest(const casCtx&,const char* pvname)
pvExistReturn(rc);
}
casPV* serv::createPV(const casCtx& in,const char* pvname)
pvCreateReturn serv::createPV(const casCtx& in,const char* pvname)
{
casPV* rc=NULL;
casPV* pPV=NULL;
int val;
Debug1("createPV: %s\n",pvname);
@@ -199,30 +184,44 @@ casPV* serv::createPV(const casCtx& in,const char* pvname)
{
Debug("createPV: I am making this PV\n");
if(val>=0 && val<pv_total)
rc=new servPV(in,*this,pvname,db_sync[val]);
pPV=new servPV(*this,pvname,db_sync[val]);
}
}
return rc;
if (pPV) {
return pvCreateReturn(*pPV);
}
else {
return pvCreateReturn(S_casApp_pvNotFound);
}
}
void serv::scan(void)
{
unsigned i;
for(i=0;i<pv_total;i++)
db_sync[i].eventReady();
}
// -----------------------PV stuff -------------------------------
servPV::servPV(const casCtx& c,serv& m,const char* n,dBase& x):
casPV(c,n),db(x),mgr(m),monitored(0)
servPV::servPV(serv& m,const char* n,dBase& x):
casPV(m),db(x),mgr(m),monitored(0)
{
db.node=this;
value=new gddScalar(appValue,aitEnumFloat64);
pName=new char [strlen(n)+1];
assert(pName);
strcpy(pName,n);
}
servPV::~servPV(void)
{
value->unreference();
db.node=NULL;
delete [] pName;
}
unsigned servPV::maxSimultAsyncOps(void) const { return 100000u; }
caStatus servPV::interestRegister()
{
if(!monitored) monitored=1;
@@ -239,6 +238,11 @@ aitEnum servPV::bestExternalType() const
return aitEnumFloat64;
}
const char *servPV::getName() const
{
return pName;
}
caStatus servPV::read(const casCtx&, gdd &dd)
{
Debug1("read: %s\n",db.pvname);
@@ -277,3 +281,27 @@ void servPV::eventReady(void)
postEvent(mgr.event_mask,*value);
}
//
// scanTimer::expire ()
//
void scanTimer::expire ()
{
serv.scan();
}
//
// scanTimer::again()
//
osiBool scanTimer::again() const
{
return osiTrue;
}
//
// scanTimer::delay()
//
const osiTime scanTimer::delay() const
{
return period;
}

View File

@@ -2,6 +2,9 @@
/*
* $Id$
* $Log$
* Revision 1.2 1997/03/05 21:16:23 jbk
* Fixes cvs log id at top
*
*/
#include "casdef.h"
@@ -45,19 +48,38 @@ public:
servPV* node;
};
class serv;
//
// scanTimer
//
class scanTimer : public osiTimer {
public:
scanTimer (double delayIn, serv &servIn) :
osiTimer(delayIn), serv(servIn),
period(delayIn) {}
void expire ();
osiBool again() const;
const osiTime delay() const;
private:
serv &serv;
double period;
};
class serv : public caServer
{
public:
serv(int totpv,double rate,char* prefix,
unsigned maxnamelen,unsigned pvtotalest, unsigned maxsimio);
serv(int totpv,double rate,char* prefix,unsigned pvtotalest);
virtual ~serv(void);
virtual pvExistReturn pvExistTest(const casCtx& c,const char* pvname);
virtual casPV* createPV(const casCtx& c,const char* pvname);
virtual pvCreateReturn createPV(const casCtx& c,const char* pvname);
int InitDB(void);
int Main(void);
void scan();
// sloppy
char* prefix;
int prefix_len;
@@ -65,12 +87,13 @@ public:
double event_rate;
casEventMask event_mask;
dBase* db_sync;
scanTimer *pScanTimer;
};
class servPV : public casPV
{
public:
servPV(const casCtx&,serv&,const char* pvname,dBase&);
servPV(serv&,const char* pvname,dBase&);
virtual ~servPV(void);
virtual caStatus interestRegister(void);
@@ -79,7 +102,7 @@ public:
virtual caStatus read(const casCtx &ctx, gdd &prototype);
virtual caStatus write(const casCtx &ctx, gdd &value);
virtual void destroy(void);
virtual unsigned maxSimultAsyncOps(void) const;
virtual const char *getName() const;
void eventReady(void);
@@ -88,5 +111,7 @@ private:
dBase& db;
gdd* value;
int monitored;
char *pName;
};

View File

@@ -2,7 +2,7 @@
TOP = ../../../..
include $(TOP)/config/CONFIG_BASE
INC := casdef.h casInternal.h casEventMask.h
INC := casdef.h casInternal.h casEventMask.h caNetAddr.h
include $(TOP)/config/RULES.Host

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.5 1997/04/10 19:33:52 jhill
* API changes
*
* Revision 1.4 1996/11/02 00:53:53 jhill
* many improvements
*
@@ -89,6 +92,22 @@ caServer::~caServer()
}
}
//
// caServer::pvExistTest()
//
pvExistReturn caServer::pvExistTest (const casCtx &, const char *)
{
return pverDoesNotExistHere;
}
//
// caServer::createPV()
//
pvCreateReturn caServer::createPV (const casCtx &, const char *)
{
return S_casApp_pvNotFound;
}
//
// caServer::registerEvent()
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.7 1997/04/10 19:33:53 jhill
* API changes
*
* Revision 1.6 1996/11/02 00:53:54 jhill
* many improvements
*
@@ -333,7 +336,7 @@ void serverToolDebugFunc(const char *pFile, unsigned line, const char *pComment)
//
// caServerI::addAddr()
//
caStatus caServerI::addAddr(const caAddr &caAddr, int autoBeaconAddr,
caStatus caServerI::addAddr(const caNetAddr &addr, int autoBeaconAddr,
int addConfigBeaconAddr)
{
caStatus stat;
@@ -341,7 +344,7 @@ caStatus caServerI::addAddr(const caAddr &caAddr, int autoBeaconAddr,
pIntf = new casIntfOS(*this);
if (pIntf) {
stat = pIntf->init(caAddr, this->dgClient,
stat = pIntf->init(addr, this->dgClient,
autoBeaconAddr, addConfigBeaconAddr);
if (stat==S_cas_success) {
this->osiLock();

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1997/04/10 19:33:54 jhill
* API changes
*
* Revision 1.3 1996/11/02 00:53:56 jhill
* many improvements
*
@@ -96,15 +99,6 @@ inline casChannelI *caServerI::resIdToChannel(const caResId &id)
return (casChannelI *) pRes;
}
//
// find the channel associated with a resource id
//
inline casPVExistReturn caServerI::pvExistTest(
const casCtx &ctxIn, const char *pPVName)
{
return casPVExistReturn((*this)->pvExistTest(ctxIn, pPVName));
}
//
// caServerI::installItem()
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1997/04/10 19:33:54 jhill
* API changes
*
* Revision 1.2 1996/11/06 22:15:53 jhill
* allow monitor init read to using rd async io
*
@@ -43,17 +46,17 @@
#include "server.h"
#include "casAsyncIOIIL.h" // casAsyncIOI in line func
#include "casChannelIIL.h" // casChannelI in line func
#include "casOpaqueAddrIL.h" // casOpaqueAddr in line func
#include "casCtxIL.h" // casCtx in line func
#include "casCoreClientIL.h" // casCoreClient in line func
//
// casAsyncExIOI::casAsyncExIOI()
//
casAsyncExIOI::casAsyncExIOI(const casCtx &ctx,
casAsyncPVExistIO &ioIn) :
casAsyncExIOI::casAsyncExIOI(
const casCtx &ctx, casAsyncPVExistIO &ioIn) :
casAsyncIOI(*ctx.getClient(), ioIn),
msg(*ctx.getMsg()),
retVal(pverDoesNotExistHere),
pOutDGIntfIO(ctx.getClient()->fetchOutIntf()),
dgOutAddr(ctx.getClient()->fetchRespAddr())
{
@@ -94,7 +97,7 @@ caStatus casAsyncExIOI::cbFuncAsyncIO()
//
assert(this->pOutDGIntfIO);
status = this->client.asyncSearchResponse(*this->pOutDGIntfIO,
this->dgOutAddr.get(), this->msg, this->retVal);
this->dgOutAddr, this->msg, this->retVal);
break;
default:

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.1 1997/04/10 19:38:14 jhill
* installed
*
* Revision 1.2 1996/11/06 22:15:53 jhill
* allow monitor init read to using rd async io
*
@@ -43,7 +46,6 @@
#include "server.h"
#include "casAsyncIOIIL.h" // casAsyncIOI in line func
#include "casChannelIIL.h" // casChannelI in line func
#include "casOpaqueAddrIL.h" // casOpaqueAddr in line func
#include "casCtxIL.h" // casCtx in line func
#include "casCoreClientIL.h" // casCoreClient in line func
@@ -53,7 +55,8 @@
casAsyncPVCIOI::casAsyncPVCIOI(const casCtx &ctx,
casAsyncPVCreateIO &ioIn) :
casAsyncIOI(*ctx.getClient(), ioIn),
msg(*ctx.getMsg())
msg(*ctx.getMsg()),
retVal(S_cas_badParameter)
{
assert (&this->msg);
this->client.installAsyncIO(*this);

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1997/04/10 19:33:58 jhill
* API changes
*
* Revision 1.2 1996/11/02 00:54:01 jhill
* many improvements
*
@@ -42,6 +45,13 @@
#include "server.h"
#include "casEventSysIL.h" // casEventSys in line func
//
// casChanDelEv()
//
casChanDelEv::~casChanDelEv()
{
}
//
// casChanDelEv()
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.5 1997/04/10 19:34:03 jhill
* API changes
*
* Revision 1.4 1996/11/02 00:54:07 jhill
* many improvements
*
@@ -182,7 +185,7 @@ void casCoreClient::show (unsigned level) const
// asynchronous completion
//
caStatus casCoreClient::asyncSearchResponse(casDGIntfIO &,
const caAddr &, const caHdr &, const pvExistReturn)
const caNetAddr &, const caHdr &, const pvExistReturn &)
{
return S_casApp_noSupport;
}
@@ -239,11 +242,9 @@ void casCoreClient::removeChannel(casChannelI &)
//
// casCoreClient::fetchRespAddr()
//
caAddr casCoreClient::fetchRespAddr()
caNetAddr casCoreClient::fetchRespAddr()
{
caAddr addr;
memset (&addr, '\0', sizeof(addr));
return addr;
return caNetAddr(); // sets addr type to UDF
}
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.9 1997/04/10 19:34:06 jhill
* API changes
*
* Revision 1.8 1997/01/10 21:17:53 jhill
* code around gnu g++ inline bug when -O isnt used
*
@@ -127,7 +130,6 @@ caStatus casDGClient::searchAction()
void *dp = this->ctx.getData();
const char *pChanName = (const char *) dp;
caStatus status;
pvExistReturn pver;
if (this->ctx.getServer()->getDebugLevel()>2u) {
printf("client is searching for \"%s\"\n", pChanName);
@@ -149,38 +151,34 @@ caStatus casDGClient::searchAction()
// ask the server tool if this PV exists
//
this->asyncIOFlag = 0u;
casPVExistReturn retVal =
this->ctx.getServer()->pvExistTest(this->ctx, pChanName);
if (retVal.getStatus()!=S_cas_success) {
return retVal.getStatus();
}
pvExistReturn pver =
(*this->ctx.getServer())->pvExistTest(this->ctx, pChanName);
//
// prevent problems when they initiate
// async IO but dont return status
// indicating so (and vise versa)
//
pver = retVal.getAppStat();
if (this->asyncIOFlag) {
pver = pverAsyncCompletion;
}
else if (pver == pverAsyncCompletion) {
else if (pver.getStatus() == pverAsyncCompletion) {
pver = pverDoesNotExistHere;
errMessage(S_cas_badParameter,
"- expected asynch IO creation from caServer::pvExistTest()");
"- expected asynch IO status from caServer::pvExistTest()");
}
//
// otherwise we assume sync IO operation was initiated
//
switch (pver) {
switch (pver.getStatus()) {
case pverDoesNotExistHere:
case pverAsyncCompletion:
status = S_cas_success;
break;
case pverExistsHere:
status = this->searchResponse(*mp, retVal.getAppStat());
status = this->searchResponse(*mp, pver);
break;
default:
@@ -196,7 +194,7 @@ caStatus casDGClient::searchAction()
// caStatus casDGClient::searchResponse()
//
caStatus casDGClient::searchResponse(const caHdr &msg,
const pvExistReturn retVal)
const pvExistReturn &retVal)
{
caStatus status;
caHdr *search_reply;
@@ -205,11 +203,11 @@ caStatus casDGClient::searchResponse(const caHdr &msg,
//
// normal search failure is ignored
//
if (retVal==pverDoesNotExistHere) {
if (retVal.getStatus()==pverDoesNotExistHere) {
return S_cas_success;
}
if (retVal!=pverExistsHere) {
if (retVal.getStatus()!=pverExistsHere) {
fprintf(stderr,
"async exist completion with invalid return code \"pverAsynchCompletion\"?\n");
return S_cas_success;
@@ -250,16 +248,42 @@ caStatus casDGClient::searchResponse(const caHdr &msg,
return status;
}
*search_reply = msg;
search_reply->m_postsize = sizeof(*pMinorVersion);
/*
* cid field is abused to carry the IP
* address in CA_V48 or higher
* (this allows a CA servers to serve
* as a directory service)
*
* type field is abused to carry the IP
* port number here CA_V44 or higher
* (this allows multiple CA servers on one
* host)
*/
*search_reply = msg;
search_reply->m_postsize = sizeof(*pMinorVersion);
search_reply->m_cid = ~0U;
search_reply->m_type = this->pOutMsgIO->serverPortNumber();
if (CA_V48(CA_PROTOCOL_VERSION,msg.m_count)) {
if (retVal.addrIsValid()) {
caNetAddr addr = retVal.getAddr();
struct sockaddr_in ina = addr.getSockIP();
search_reply->m_cid = ina.sin_addr.s_addr;
if (ina.sin_port==0u) {
search_reply->m_type = this->pOutMsgIO->serverPortNumber();
}
else {
search_reply->m_type = ina.sin_port;
}
}
else {
search_reply->m_cid = ~0U;
search_reply->m_type = this->pOutMsgIO->serverPortNumber();
}
}
else {
search_reply->m_cid = ~0U;
search_reply->m_type = this->pOutMsgIO->serverPortNumber();
}
search_reply->m_count = 0ul;
/*
@@ -322,7 +346,7 @@ void casDGClient::sendBeacon(casDGIntfIO &io)
//
// send it to all addresses on the beacon list
//
io.sendBeacon(buf, sizeof(msg), msg.m_available);
io.sendBeacon(buf, sizeof(msg), msg.m_available, msg.m_count);
}
//
@@ -400,8 +424,9 @@ void casDGClient::processDG(casDGIntfIO &inMsgIO, casDGIntfIO &outMsgIO)
//
// casDGClient::asyncSearchResp()
//
caStatus casDGClient::asyncSearchResponse(casDGIntfIO &outMsgIO, const caAddr &outAddr,
const caHdr &msg, const pvExistReturn retVal)
caStatus casDGClient::asyncSearchResponse(
casDGIntfIO &outMsgIO, const caNetAddr &outAddr,
const caHdr &msg, const pvExistReturn &retVal)
{
caStatus stat;
@@ -425,7 +450,7 @@ caStatus casDGClient::asyncSearchResponse(casDGIntfIO &outMsgIO, const caAddr &o
// casDGClient::xDGSend()
//
xSendStatus casDGClient::xDGSend (char *pBufIn, bufSizeT nBytesNeedToBeSent,
bufSizeT &nBytesSent, const caAddr &recipient)
bufSizeT &nBytesSent, const caNetAddr &recipient)
{
xSendStatus stat;
@@ -447,7 +472,7 @@ xSendStatus casDGClient::xDGSend (char *pBufIn, bufSizeT nBytesNeedToBeSent,
// casDGClient::xDGRecv()
//
xRecvStatus casDGClient::xDGRecv (char *pBufIn, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv, caAddr &sender)
bufSizeT &nByesRecv, caNetAddr &sender)
{
xRecvStatus stat;
@@ -489,7 +514,7 @@ unsigned casDGClient::getDebugLevel() const
//
// casDGClient::fetchRespAddr()
//
caAddr casDGClient::fetchRespAddr()
caNetAddr casDGClient::fetchRespAddr()
{
return this->getRecipient();
}

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.11 1997/04/10 19:34:10 jhill
* API changes
*
* Revision 1.10 1997/01/10 21:17:55 jhill
* code around gnu g++ inline bug when -O isnt used
*
@@ -87,6 +90,7 @@ private:
class casChanDelEv : public casEvent {
public:
casChanDelEv(caResId idIn) : id(idIn) {}
~casChanDelEv();
caStatus cbFunc(casEventSys &);
private:
caResId id;
@@ -114,7 +118,7 @@ class ioBlocked : public tsDLNode<ioBlocked> {
friend class ioBlockedList;
public:
ioBlocked ();
virtual ~ioBlocked ()=0;
virtual ~ioBlocked ();
private:
ioBlockedList *pList;
virtual void ioBlockedSignal ();
@@ -358,51 +362,6 @@ private:
caStatus completionStatus;
};
union ca_addr;
//
// casOpaqueAddr
//
// store address as an opaque array of bytes so that
// we dont drag the socket (or other IO specific)
// headers into the server tool.
//
//
// get() will assert fail if the init flag has not been
// set
//
class casOpaqueAddr
{
public:
//
// casOpaqueAddr()
//
casOpaqueAddr();
//
// clear()
//
void clear();
inline int hasBeenInitialized() const;
inline casOpaqueAddr (const union ca_addr &addr);
inline void set (const union ca_addr &);
inline union ca_addr get () const;
private:
char opaqueAddr[16u]; // large enough for socket addresses
char init;
//
// simple class that will assert fail if
// sizeof(opaqueAddr) < sizeof(caAddr)
//
class checkSize {
public:
checkSize();
};
static checkSize sizeChecker;
};
class casDGIntfIO;
//
@@ -426,7 +385,7 @@ private:
caHdr const msg;
pvExistReturn retVal;
casDGIntfIO * const pOutDGIntfIO;
const casOpaqueAddr dgOutAddr;
const caNetAddr dgOutAddr;
};
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1997/04/10 19:34:13 jhill
* API changes
*
* Revision 1.3 1996/11/02 00:54:19 jhill
* many improvements
*
@@ -41,9 +44,6 @@
*
*/
#include"server.h"
class casMsgIO {
@@ -65,9 +65,9 @@ public:
//
xSendStatus xSend (char *pBuf, bufSizeT nBytesAvailableToSend,
bufSizeT nBytesNeedToBeSent, bufSizeT &nBytesSent,
const caAddr &addr);
const caNetAddr &addr);
xRecvStatus xRecv (char *pBuf, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv, caAddr &addr);
bufSizeT &nByesRecv, caNetAddr &addr);
virtual bufSizeT incommingBytesPresent() const;
virtual casIOState state() const=0;
@@ -93,9 +93,9 @@ private:
xBlockingStatus blockingStatus;
virtual xSendStatus osdSend (const char *pBuf, bufSizeT nBytesReq,
bufSizeT &nBytesActual, const caAddr &addr) =0;
bufSizeT &nBytesActual, const caNetAddr &addr) =0;
virtual xRecvStatus osdRecv (char *pBuf, bufSizeT nBytesReq,
bufSizeT &nBytesActual, caAddr &addr) =0;
bufSizeT &nBytesActual, caNetAddr &addr) =0;
virtual void osdShow (unsigned level) const = 0;
virtual void xSetNonBlocking();
};
@@ -139,7 +139,7 @@ void casMsgIO::show(unsigned level) const
// casMsgIO::xRecv()
//
xRecvStatus casMsgIO::xRecv(char *pBuf, bufSizeT nBytes,
bufSizeT &nActualBytes, caAddr &from)
bufSizeT &nActualBytes, caNetAddr &from)
{
xRecvStatus stat;
@@ -155,7 +155,7 @@ xRecvStatus casMsgIO::xRecv(char *pBuf, bufSizeT nBytes,
//
xSendStatus casMsgIO::xSend(char *pBuf, bufSizeT nBytesAvailableToSend,
bufSizeT nBytesNeedToBeSent, bufSizeT &nActualBytes,
const caAddr &to)
const caNetAddr &to)
{
xSendStatus stat;
bufSizeT nActualBytesDelta;

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.15 1997/04/10 19:34:18 jhill
* API changes
*
* Revision 1.14 1996/12/12 18:56:27 jhill
* doc
*
@@ -84,6 +87,7 @@
#include "inBufIL.h" // inBuf inline functions
#include "outBufIL.h" // outBuf inline functions
#include "gddApps.h"
#include "net_convert.h" // byte order conversion from libca
VERSIONID(casStrmClientcc,"%W% %G%")
@@ -349,6 +353,14 @@ caStatus casStrmClient::readResponse (casChannelI *pChan, const caHdr &msg,
//
gddMapDbr[msg.m_type].conv_dbr((reply+1), pDesc);
#ifdef CONVERSION_REQUIRED
/* use type as index into conversion jumptable */
(* cac_dbr_cvrt[msg.m_type])
( reply + 1,
reply + 1,
TRUE, /* host -> net format */
msg.m_count);
#endif
//
// force string message size to be the true size rounded to even
// boundary
@@ -483,6 +495,14 @@ caStatus casStrmClient::readNotifyResponse (casChannelI *,
memset ((char *)(reply+1), '\0', size);
}
#ifdef CONVERSION_REQUIRED
/* use type as index into conversion jumptable */
(* cac_dbr_cvrt[msg.m_type])
( reply + 1,
reply + 1,
TRUE, /* host -> net format */
msg.m_count);
#endif
//
// force string message size to be the true size rounded to even
// boundary
@@ -579,6 +599,14 @@ caStatus casStrmClient::monitorResponse (casChannelI *pChan,
//
gddMapDbr[msg.m_type].conv_dbr ((pReply+1), pDBRDD);
#ifdef CONVERSION_REQUIRED
/* use type as index into conversion jumptable */
(* cac_dbr_cvrt[msg.m_type])
( pReply + 1,
pReply + 1,
TRUE, /* host -> net format */
msg.m_count);
#endif
//
// force string message size to be the true size
//
@@ -1181,6 +1209,7 @@ caStatus casStrmClient::eventAddAction ()
gdd *pDD;
caStatus status;
casEventMask mask;
unsigned short caProtoMask;
status = casStrmClient::verifyRequest (pciu);
if (status != S_cas_validRequest) {
@@ -1190,22 +1219,23 @@ caStatus casStrmClient::eventAddAction ()
//
// place monitor mask in correct byte order
//
pMonInfo->m_mask = ntohs (pMonInfo->m_mask);
if (pMonInfo->m_mask&DBE_VALUE) {
caProtoMask = ntohs (pMonInfo->m_mask);
if (caProtoMask&DBE_VALUE) {
mask |= this->getCAS().getAdapter()->valueEventMask;
}
if (pMonInfo->m_mask&DBE_LOG) {
if (caProtoMask&DBE_LOG) {
mask |= this->getCAS().getAdapter()->logEventMask;
}
if (pMonInfo->m_mask&DBE_ALARM) {
if (caProtoMask&DBE_ALARM) {
mask |= this->getCAS().getAdapter()->alarmEventMask;
}
if (mask.noEventsSelected()) {
this->sendErr(mp, ECA_BADMASK, "event add request");
char errStr[40];
sprintf(errStr, "event add req with mask=0X%X\n", caProtoMask);
this->sendErr(mp, ECA_BADMASK, errStr);
return S_cas_success;
}
@@ -1513,6 +1543,15 @@ caStatus casStrmClient::write()
return S_cas_badType;
}
#ifdef CONVERSION_REQUIRED
/* use type as index into conversion jumptable */
(* cac_dbr_cvrt[pHdr->m_type])
( this->ctx.getData(),
this->ctx.getData(),
FALSE, /* net -> host format */
pHdr->m_count);
#endif
//
// the PV state must not be modified during a transaction
//

View File

@@ -30,6 +30,9 @@
* Modification Log:
* -----------------
* $Log$
* Revision 1.12 1997/04/10 19:34:19 jhill
* API changes
*
* Revision 1.11 1997/01/09 22:24:46 jhill
* eliminate MSVC++ warning resulting from passing *this to a base
*
@@ -112,7 +115,7 @@
// This eliminates a warning resulting from passing *this
// to a base class during derived class construction.
//
#ifdef WIN32
#if defined(WIN32)
# pragma warning (disable:4355)
#endif
@@ -173,6 +176,8 @@ typedef aitUint32 caStatus;
#define S_casApp_undefined (M_casApp | 9) /*undefined value*/
#define S_casApp_postponeAsyncIO (M_casApp | 10) /*postpone asynchronous IO*/
#include <caNetAddr.h>
//
// pv exist test return
//
@@ -181,19 +186,79 @@ typedef aitUint32 caStatus;
// to do so return pverDoesNotExistHere (and the client will
// retry the request later).
//
enum pvExistReturn {pverExistsHere, pverDoesNotExistHere,
enum pvExistReturnEnum {pverExistsHere, pverDoesNotExistHere,
pverAsyncCompletion};
class pvExistReturn {
public:
//
// most server tools will use this
//
pvExistReturn (pvExistReturnEnum s=pverDoesNotExistHere) :
status(s) {}
//
// directory service server tools
// will use this
//
// (see caNetAddr.h)
//
pvExistReturn (const caNetAddr &addressIn) :
status(pverExistsHere), address(addressIn) {}
const pvExistReturn &operator = (pvExistReturnEnum rhs)
{
this->status = rhs;
this->address.clear();
return *this;
}
const pvExistReturn &operator = (const caNetAddr &rhs)
{
this->status = pverExistsHere;
this->address = rhs;
return *this;
}
pvExistReturnEnum getStatus() const {return this->status;}
int addrIsValid() const {return this->address.isSock();}
caNetAddr getAddr() const {return this->address;}
private:
pvExistReturnEnum status;
caNetAddr address;
};
class casPV;
class pvCreateReturn {
public:
pvCreateReturn()
{ this->pPV = NULL; this->stat = S_cas_badParameter; }
pvCreateReturn(caStatus statIn)
{ this->pPV = NULL; this->stat = statIn; }
pvCreateReturn(casPV &pv)
{ this->pPV = &pv; this->stat = S_casApp_success; }
const pvCreateReturn &operator = (caStatus rhs)
{
this->pPV = NULL;
if (rhs == S_casApp_success) {
rhs = S_cas_badParameter;
}
this->stat = rhs;
return *this;
}
const pvCreateReturn &operator = (casPV &pvIn)
{
this->stat = S_casApp_success;
this->pPV = &pvIn;
return *this;
}
const pvCreateReturn &operator = (casPV *pPVIn)
{
if (pPVIn!=NULL) {
this->stat = S_casApp_success;
}
else {
this->stat = S_casApp_pvNotFound;
}
this->pPV = pPVIn;
return *this;
}
const caStatus getStatus() const { return this->stat; }
casPV *getPV() const { return this->pPV; }
@@ -251,16 +316,14 @@ public:
// return pverExistsHere; // server has PV
// return pverDoesNotExistHere; // server does know of this PV
// return pverAsynchCompletion; // deferred result
// return pverNoMemoryForAsyncOP; // unable to defer result
//
// Return S_casApp_postponeAsyncIO if too many simultaneous
// asynchronous IO operations are pending aginst the server.
// The server library will retry the request whenever an
// asynchronous IO operation (create or exist) completes
// against the server.
// Return pverDoesNotExistHere if too many simultaneous
// asynchronous IO operations are pending against the server.
// The client library will retry the request at some time
// in the future.
//
virtual pvExistReturn pvExistTest (const casCtx &ctx,
const char *pPVAliasName) = 0;
const char *pPVAliasName);
//
// createPV() is called _every_ time that a PV is attached to
@@ -281,19 +344,20 @@ public:
// PV).
//
// example return from this procedure:
// return pvCreateReturn(*pPV); // success
// return pvCreateReturn(S_casApp_pvNotFound); // no PV by that name here
// return pvCreateReturn(S_casApp_noMemory); // no resource to create pv
// return pvCreateReturn(S_casApp_asyncCompletion); // deferred completion
// return pPV; // success (pass by pointer)
// return PV; // success (pass by ref)
// return S_casApp_pvNotFound; // no PV by that name here
// return S_casApp_noMemory; // no resource to create pv
// return S_casApp_asyncCompletion; // deferred completion
//
// Return S_casApp_postponeAsyncIO if too many simultaneous
// asynchronous IO operations are pending aginst the server.
// asynchronous IO operations are pending against the server.
// The server library will retry the request whenever an
// asynchronous IO operation (create or exist) completes
// against the server.
//
virtual pvCreateReturn createPV (const casCtx &ctx,
const char *pPVAliasName) = 0;
const char *pPVAliasName);
//
// common event masks

View File

@@ -1,7 +1,6 @@
#include "server.h"
#include "inBufIL.h"
#include "casOpaqueAddrIL.h"
//
// this needs to be here (and not in dgInBufIL.h) if we
@@ -30,7 +29,7 @@ dgInBuf::~dgInBuf()
//
int dgInBuf::hasAddress() const
{
return this->from.hasBeenInitialized();
return this->from.isSock();
}
//
@@ -39,12 +38,12 @@ int dgInBuf::hasAddress() const
xRecvStatus dgInBuf::xRecv (char *pBufIn, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv)
{
caAddr addr;
caNetAddr addr;
xRecvStatus stat;
stat = this->xDGRecv (pBufIn, nBytesToRecv, nByesRecv, addr);
if (stat == xRecvOK) {
this->from.set(addr);
this->from = addr;
}
return stat;
}
@@ -52,8 +51,8 @@ xRecvStatus dgInBuf::xRecv (char *pBufIn, bufSizeT nBytesToRecv,
//
// dgInBuf::getSender()
//
caAddr dgInBuf::getSender() const
caNetAddr dgInBuf::getSender() const
{
return this->from.get();
return this->from;
}

View File

@@ -2,7 +2,6 @@
#ifndef dgInBufILh
#define dgInBufILh
#include "casOpaqueAddrIL.h"
#include "inBufIL.h"
//

View File

@@ -1,6 +1,5 @@
#include "server.h"
#include "casOpaqueAddrIL.h"
#include "outBufIL.h"
//
@@ -31,8 +30,7 @@ xSendStatus dgOutBuf::xSend (char *pBufIn,
bufSizeT &nBytesSent)
{
assert(nBytesAvailableToSend>=nBytesNeedToBeSent);
return xDGSend(pBufIn, nBytesAvailableToSend, nBytesSent,
this->to.get());
return xDGSend(pBufIn, nBytesAvailableToSend, nBytesSent, this->to);
}
//
@@ -53,9 +51,9 @@ void dgOutBuf::clear()
//
// dgOutBuf::setRecipient()
//
void dgOutBuf::setRecipient(const caAddr &addr)
void dgOutBuf::setRecipient(const caNetAddr &addr)
{
this->to.set(addr);
this->to = addr;
}
//
@@ -64,8 +62,8 @@ void dgOutBuf::setRecipient(const caAddr &addr)
//
// dgOutBuf::getRecipient()
//
caAddr dgOutBuf::getRecipient()
caNetAddr dgOutBuf::getRecipient()
{
return this->to.get();
return this->to;
}

View File

@@ -2,7 +2,6 @@
#ifndef dgOutBufILh
#define dgOutBufILh
#include "casOpaqueAddrIL.h"
#include "outBufIL.h"
//

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.16 1997/04/10 19:34:23 jhill
* API changes
*
* Revision 1.15 1997/01/10 21:18:05 jhill
* code around gnu g++ inline bug when -O isnt used
*
@@ -115,7 +118,6 @@ HDRVERSIONID(serverh, "%W% %G%")
//
// CAS
//
#include "casAddr.h"
#include "osiMutexCAS.h" // NOOP on single threaded OS
void casVerifyFunc(const char *pFile, unsigned line, const char *pExp);
void serverToolDebugFunc(const char *pFile, unsigned line, const char *pComment);
@@ -335,15 +337,15 @@ public:
int hasAddress() const;
caAddr getSender() const;
caNetAddr getSender() const;
xRecvStatus xRecv (char *pBufIn, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv);
virtual xRecvStatus xDGRecv (char *pBuf, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv, caAddr &sender) = 0;
bufSizeT &nByesRecv, caNetAddr &sender) = 0;
private:
casOpaqueAddr from;
caNetAddr from;
};
//
@@ -416,9 +418,9 @@ public:
virtual ~dgOutBuf();
caAddr getRecipient();
caNetAddr getRecipient();
void setRecipient(const caAddr &addr);
void setRecipient(const caNetAddr &addr);
void clear();
@@ -426,9 +428,9 @@ public:
bufSizeT nBytesNeedToBeSent, bufSizeT &nBytesSent);
virtual xSendStatus xDGSend (char *pBuf, bufSizeT nBytesNeedToBeSent,
bufSizeT &nBytesSent, const caAddr &recipient) = 0;
bufSizeT &nBytesSent, const caNetAddr &recipient) = 0;
private:
casOpaqueAddr to;
caNetAddr to;
};
@@ -476,23 +478,27 @@ public:
// one virtual function for each CA request type that has
// asynchronous completion
//
virtual caStatus asyncSearchResponse(casDGIntfIO &outMsgIO,
const caAddr &outAddr, const caHdr &, const pvExistReturn);
virtual caStatus createChanResponse(const caHdr &, const pvCreateReturn &);
virtual caStatus readResponse(casChannelI *, const caHdr &,
gdd *, const caStatus);
virtual caStatus readNotifyResponse(casChannelI *, const caHdr &,
gdd *, const caStatus);
virtual caStatus writeResponse(casChannelI *, const caHdr &,
const caStatus);
virtual caStatus writeNotifyResponse(casChannelI *, const caHdr &,
const caStatus);
virtual caStatus asyncSearchResponse(
casDGIntfIO &outMsgIO, const caNetAddr &outAddr,
const caHdr &, const pvExistReturn &);
virtual caStatus createChanResponse(
const caHdr &, const pvCreateReturn &);
virtual caStatus readResponse(
casChannelI *, const caHdr &,
gdd *, const caStatus);
virtual caStatus readNotifyResponse(
casChannelI *, const caHdr &,
gdd *, const caStatus);
virtual caStatus writeResponse(
casChannelI *, const caHdr &, const caStatus);
virtual caStatus writeNotifyResponse(
casChannelI *, const caHdr &, const caStatus);
//
// The following are only used with async IO for
// DG clients
//
virtual caAddr fetchRespAddr();
virtual caNetAddr fetchRespAddr();
virtual casDGIntfIO* fetchOutIntf();
protected:
casCtx ctx;
@@ -774,12 +780,12 @@ private:
//
caStatus searchFailResponse(const caHdr *pMsg);
caStatus searchResponse(const caHdr &, const pvExistReturn);
caStatus searchResponse(const caHdr &, const pvExistReturn &);
caStatus asyncSearchResponse(casDGIntfIO &outMsgIO,
const caAddr &outAddr, const caHdr &msg,
const pvExistReturn);
caAddr fetchRespAddr();
caStatus asyncSearchResponse(
casDGIntfIO &outMsgIO, const caNetAddr &outAddr,
const caHdr &msg, const pvExistReturn &);
caNetAddr fetchRespAddr();
casDGIntfIO* fetchOutIntf();
@@ -787,9 +793,9 @@ private:
// IO depen
//
xRecvStatus xDGRecv (char *pBuf, bufSizeT nBytesToRecv,
bufSizeT &nByesRecv, caAddr &sender);
bufSizeT &nByesRecv, caNetAddr &sender);
xSendStatus xDGSend (char *pBuf, bufSizeT nBytesNeedToBeSent,
bufSizeT &nBytesSent, const caAddr &recipient);
bufSizeT &nBytesSent, const caNetAddr &recipient);
bufSizeT incommingBytesPresent() const;
};
@@ -813,7 +819,7 @@ private:
// casEventRegistry
//
class casEventRegistry : private resTable <casEventMaskEntry, stringId> {
friend casEventMaskEntry;
friend class casEventMaskEntry;
public:
casEventRegistry(osiMutex &mutexIn) :
mutex(mutexIn), allocator(0), hasBeenInitialized(0) {}
@@ -842,24 +848,6 @@ private:
class casClientMon;
//
// casPVExistReturn
//
// special return code for the server internal version of pvExistTest()
//
class casPVExistReturn {
public:
casPVExistReturn(pvExistReturn appIn)
{app=appIn; stat = S_cas_success; }
casPVExistReturn(caStatus statIn)
{app=pverDoesNotExistHere; stat = statIn; }
caStatus getStatus() const {return stat;}
pvExistReturn getAppStat() const {return app;}
private:
pvExistReturn app;
caStatus stat;
};
//
// caServerI
//
@@ -909,7 +897,6 @@ public:
unsigned getDebugLevel() const { return debugLevel; }
inline void setDebugLevel(unsigned debugLevelIn);
inline casPVExistReturn pvExistTest (const casCtx &ctx, const char *pPVName);
osiTime getBeaconPeriod() const { return this->beaconPeriod; }
@@ -932,7 +919,7 @@ public:
inline aitBool ready();
caStatus addAddr(const caAddr &caAddr, int autoBeaconAddr,
caStatus addAddr(const caNetAddr &addr, int autoBeaconAddr,
int addConfigAddr);
private:
void advanceBeaconPeriod();

View File

@@ -31,7 +31,7 @@ private:
//
// casIntfOS::init()
//
caStatus casIntfOS::init(const caAddr &addrIn, casDGClient &dgClientIn,
caStatus casIntfOS::init(const caNetAddr &addrIn, casDGClient &dgClientIn,
int autoBeaconAddr, int addConfigBeaconAddr)
{
caStatus stat;

View File

@@ -7,6 +7,9 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.2 1997/04/10 19:34:31 jhill
// API changes
//
// Revision 1.1 1996/11/02 01:01:32 jhill
// installed
//
@@ -83,7 +86,7 @@ class casIntfOS : public casIntfIO, public tsDLNode<casIntfOS>
public:
casIntfOS (caServerI &casIn) :
cas (casIn), pRdReg (NULL) {}
caStatus init(const caAddr &addr, casDGClient &dgClientIn,
caStatus init(const caNetAddr &addr, casDGClient &dgClientIn,
int autoBeaconAddr, int addConfigBeaconAddr);
virtual ~casIntfOS();

View File

@@ -7,6 +7,9 @@
// (for single threaded version of the server)
//
// $Log$
// Revision 1.2 1997/04/10 19:34:32 jhill
// API changes
//
// Revision 1.1 1996/11/02 01:01:34 jhill
// installed
//
@@ -19,7 +22,7 @@
//
// ioBlocked::~ioBlocked()
// ioBlocked::ioBlocked()
//
ioBlocked::ioBlocked() :
pList(NULL)

View File

@@ -5,6 +5,9 @@
//
//
// $Log$
// Revision 1.4 1997/04/10 19:40:31 jhill
// API changes
//
// Revision 1.3 1996/11/02 00:54:42 jhill
// many improvements
//
@@ -20,6 +23,7 @@
#include "server.h"
#include "sigPipeIgnore.h"
#include "addrList.h"
static char *getToken(const char **ppString, char *pBuf, unsigned bufSIze);
@@ -52,12 +56,12 @@ inline void caServerIO::staticInit()
//
caStatus caServerIO::init(caServerI &cas)
{
char buf[64u];
const char *pStr;
char buf[64u];
const char *pStr;
char *pToken;
caStatus stat;
unsigned short port;
caAddr addr;
struct sockaddr_in saddr;
int autoBeaconAddr;
caServerIO::staticInit();
@@ -75,9 +79,9 @@ caStatus caServerIO::init(caServerI &cas)
port = caFetchPortConfig(&EPICS_CA_SERVER_PORT, CA_SERVER_PORT);
}
memset((char *)&addr,0,sizeof(addr));
addr.sa.sa_family = AF_INET;
addr.in.sin_port = ntohs (port);
memset((char *)&saddr,0,sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = ntohs (port);
pStr = envGetConfigParam(&EPICS_CA_AUTO_ADDR_LIST, sizeof(buf), buf);
if (pStr) {
@@ -106,8 +110,8 @@ caStatus caServerIO::init(caServerI &cas)
int configAddrOnceFlag = TRUE;
stat = S_cas_noInterface;
while ( (pToken = getToken(&pStr, buf, sizeof(buf))) ) {
addr.in.sin_addr.s_addr = inet_addr(pToken);
if (addr.in.sin_addr.s_addr == ~0ul) {
saddr.sin_addr.s_addr = inet_addr(pToken);
if (saddr.sin_addr.s_addr == ~0ul) {
ca_printf(
"%s: Parsing '%s'\n",
__FILE__,
@@ -117,7 +121,7 @@ caStatus caServerIO::init(caServerI &cas)
pToken);
continue;
}
stat = cas.addAddr(addr, autoBeaconAddr, configAddrOnceFlag);
stat = cas.addAddr(caNetAddr(saddr), autoBeaconAddr, configAddrOnceFlag);
if (stat) {
errMessage(stat, NULL);
break;
@@ -126,8 +130,8 @@ caStatus caServerIO::init(caServerI &cas)
}
}
else {
addr.in.sin_addr.s_addr = INADDR_ANY;
stat = cas.addAddr(addr, autoBeaconAddr, TRUE);
saddr.sin_addr.s_addr = INADDR_ANY;
stat = cas.addAddr(caNetAddr(saddr), autoBeaconAddr, TRUE);
if (stat) {
errMessage(stat, NULL);
}
@@ -175,4 +179,3 @@ static char *getToken(const char **ppString, char *pBuf, unsigned bufSIze)
}
}

View File

@@ -38,8 +38,8 @@
void casDGIO::clientHostName (char *pBufIn, unsigned bufSizeIn) const
{
if (this->hasAddress()) {
const caAddr addr = this->getSender();
ipAddrToA (&addr.in, pBufIn, bufSizeIn);
struct sockaddr_in addr = this->getSender();
ipAddrToA (&addr, pBufIn, bufSizeIn);
}
else {
if (bufSizeIn>=1u) {

View File

@@ -36,6 +36,7 @@
#include "server.h"
#include "ipAddrToA.h"
#include "addrList.h"
//
// casDGIntfIO::casDGIntfIO()
@@ -45,7 +46,8 @@ casDGIntfIO::casDGIntfIO(casDGClient &clientIn) :
client(clientIn),
sock(INVALID_SOCKET),
sockState(casOffLine),
connectWithThisPort(0)
connectWithThisPort(0),
dgPort(0)
{
ellInit(&this->beaconAddrList);
}
@@ -53,16 +55,15 @@ casDGIntfIO::casDGIntfIO(casDGClient &clientIn) :
//
// casDGIntfIO::init()
//
caStatus casDGIntfIO::init(const caAddr &addr, unsigned connectWithThisPortIn,
caStatus casDGIntfIO::init(const caNetAddr &addr, unsigned connectWithThisPortIn,
int autoBeaconAddr, int addConfigBeaconAddr,
int useBroadcastAddr, casDGIntfIO *pAltOutIn)
{
int yes = TRUE;
caAddr serverAddr;
int status;
unsigned short serverPort;
unsigned short beaconPort;
ELLLIST BCastAddrList;
int yes = TRUE;
struct sockaddr_in serverAddr;
int status;
aitInt16 beaconPort;
ELLLIST BCastAddrList;
if (pAltOutIn) {
this->pAltOutIO = pAltOutIn;
@@ -133,11 +134,11 @@ caStatus casDGIntfIO::init(const caAddr &addr, unsigned connectWithThisPortIn,
// Fetch port configuration from EPICS environment variables
//
if (envGetConfigParamPtr(&EPICS_CAS_SERVER_PORT)) {
serverPort = caFetchPortConfig(&EPICS_CAS_SERVER_PORT,
this->dgPort = caFetchPortConfig(&EPICS_CAS_SERVER_PORT,
CA_SERVER_PORT);
}
else {
serverPort = caFetchPortConfig(&EPICS_CA_SERVER_PORT,
this->dgPort = caFetchPortConfig(&EPICS_CA_SERVER_PORT,
CA_SERVER_PORT);
}
beaconPort = caFetchPortConfig(&EPICS_CA_REPEATER_PORT,
@@ -146,21 +147,21 @@ caStatus casDGIntfIO::init(const caAddr &addr, unsigned connectWithThisPortIn,
/*
* discover beacon addresses associated with this interface
*/
serverAddr.in = addr.in;
serverAddr = addr;
if (autoBeaconAddr || useBroadcastAddr) {
ellInit(&BCastAddrList);
caDiscoverInterfaces(
&BCastAddrList,
this->sock,
beaconPort,
serverAddr.in.sin_addr); /* match addr */
serverAddr.sin_addr); /* match addr */
if (useBroadcastAddr) {
caAddrNode *pAddr;
if (ellCount(&BCastAddrList)!=1) {
return S_cas_noInterface;
}
pAddr = (caAddrNode *) ellFirst(&BCastAddrList);
serverAddr.in.sin_addr = pAddr->destAddr.in.sin_addr;
serverAddr.sin_addr = pAddr->destAddr.in.sin_addr;
}
if (autoBeaconAddr) {
ellConcat(&this->beaconAddrList, &BCastAddrList);
@@ -170,17 +171,17 @@ caStatus casDGIntfIO::init(const caAddr &addr, unsigned connectWithThisPortIn,
}
}
serverAddr.in.sin_port = htons (serverPort);
serverAddr.sin_port = htons (this->dgPort);
status = bind(
this->sock,
&serverAddr.sa,
sizeof (serverAddr.sa));
(struct sockaddr *)&serverAddr,
sizeof (serverAddr));
if (status<0) {
errPrintf(S_cas_bindFail,
__FILE__, __LINE__,
"- bind UDP IP addr=%s port=%u failed because %s",
inet_ntoa(serverAddr.in.sin_addr),
(unsigned) serverPort,
inet_ntoa(serverAddr.sin_addr),
(unsigned) this->dgPort,
strerror(SOCKERRNO));
return S_cas_bindFail;
}
@@ -278,18 +279,19 @@ void casDGIntfIO::xSetNonBlocking()
// casDGIntfIO::osdRecv()
//
xRecvStatus casDGIntfIO::osdRecv(char *pBuf, bufSizeT size,
bufSizeT &actualSize, caAddr &from)
bufSizeT &actualSize, caNetAddr &fromOut)
{
int status;
int addrSize;
struct sockaddr from;
if (this->sockState!=casOnLine) {
return xRecvDisconnect;
}
addrSize = sizeof(from.sa);
addrSize = sizeof(from);
status = recvfrom(this->sock, pBuf, size, 0,
&from.sa, &addrSize);
&from, &addrSize);
if (status<0) {
if(SOCKERRNO == EWOULDBLOCK){
actualSize = 0u;
@@ -303,6 +305,7 @@ xRecvStatus casDGIntfIO::osdRecv(char *pBuf, bufSizeT size,
}
}
fromOut = from;
actualSize = (bufSizeT) status;
return xRecvOK;
}
@@ -311,7 +314,7 @@ xRecvStatus casDGIntfIO::osdRecv(char *pBuf, bufSizeT size,
// casDGIntfIO::osdSend()
//
xSendStatus casDGIntfIO::osdSend(const char *pBuf, bufSizeT size,
bufSizeT &actualSize, const caAddr &to)
bufSizeT &actualSize, const caNetAddr &to)
{
int status;
int anerrno;
@@ -328,8 +331,9 @@ xSendStatus casDGIntfIO::osdSend(const char *pBuf, bufSizeT size,
//
// (char *) cast below is for brain dead wrs prototype
//
struct sockaddr dest = to;
status = sendto(this->sock, (char *) pBuf, size, 0,
(sockaddr *) &to.sa, sizeof(to.sa));
&dest, sizeof(dest));
if (status>0) {
if (size != (unsigned) status) {
ca_printf ("CAS: partial UDP msg discarded??\n");
@@ -360,7 +364,7 @@ xSendStatus casDGIntfIO::osdSend(const char *pBuf, bufSizeT size,
//
// casDGIntfIO::sendBeacon()
//
void casDGIntfIO::sendBeacon(char &msg, unsigned length, aitUint32 &m_avail)
void casDGIntfIO::sendBeacon(char &msg, unsigned length, aitUint32 &m_ipa, aitUint16 &m_port)
{
caAddrNode *pAddr;
int status;
@@ -373,8 +377,8 @@ void casDGIntfIO::sendBeacon(char &msg, unsigned length, aitUint32 &m_avail)
pAddr;
pAddr = (caAddrNode *)ellNext(&pAddr->node)) {
m_avail = htonl(pAddr->srcAddr.in.sin_addr.s_addr);
m_ipa = htonl(pAddr->srcAddr.in.sin_addr.s_addr);
m_port = htons(this->dgPort);
status = sendto(
this->sock,
&msg,

View File

@@ -7,6 +7,9 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.7 1997/01/10 21:18:55 jhill
// code around gnu g++ inline bug when -O isnt used
//
// Revision 1.6 1996/11/02 00:54:45 jhill
// many improvements
//
@@ -30,9 +33,10 @@
#ifndef includeCASIODH
#define includeCASIODH
void hostNameFromIPAddr (const caAddr *pAddr,
char *pBuf, unsigned bufSize);
#include "envDefs.h"
void hostNameFromIPAddr (const caNetAddr *pAddr,
char *pBuf, unsigned bufSize);
class casDGClient;
@@ -42,21 +46,21 @@ class casDGClient;
class casDGIntfIO {
public:
casDGIntfIO (casDGClient &clientIn);
caStatus init(const caAddr &addr, unsigned connectWithThisPort,
caStatus init(const caNetAddr &addr, unsigned connectWithThisPort,
int autoBeaconAddr=TRUE, int addConfigBeaconAddr=FALSE,
int useBroadcastAddr=FALSE, casDGIntfIO *pAltOutIn=NULL);
virtual ~casDGIntfIO();
int getFD() const;
void xSetNonBlocking();
void sendBeacon(char &msg, bufSizeT length, aitUint32 &m_avail);
void sendBeacon(char &msg, bufSizeT length, aitUint32 &m_ipa, aitUint16 &m_port);
casIOState state() const;
void clientHostName (char *pBuf, unsigned bufSize) const;
xSendStatus osdSend (const char *pBuf, bufSizeT nBytesReq,
bufSizeT &nBytesActual, const caAddr &addr);
bufSizeT &nBytesActual, const caNetAddr &addr);
xRecvStatus osdRecv (char *pBuf, bufSizeT nBytesReq,
bufSizeT &nBytesActual, caAddr &addr);
bufSizeT &nBytesActual, caNetAddr &addr);
void osdShow (unsigned level) const;
static bufSizeT optimumBufferSize ();
@@ -78,10 +82,11 @@ private:
SOCKET sock;
casIOState sockState;
aitInt16 connectWithThisPort;
aitInt16 dgPort;
};
struct ioArgsToNewStreamIO {
caAddr addr;
caNetAddr addr;
SOCKET sock;
};
@@ -133,14 +138,14 @@ public:
//
unsigned serverPortNumber();
const caAddr &getAddr()
const caNetAddr getAddr()
{
return addr;
return caNetAddr(this->addr);
}
private:
casIOState sockState;
SOCKET sock;
caAddr addr;
struct sockaddr_in addr;
xBlockingStatus blockingFlag;
};
@@ -156,7 +161,7 @@ class casIntfIO {
public:
casIntfIO();
//constructor does not return status
caStatus init(const caAddr &addr, casDGClient &dgClientIn,
caStatus init(const caNetAddr &addr, casDGClient &dgClientIn,
int autoBeaconAddr, int addConfigBeaconAddr);
virtual ~casIntfIO();
void show(unsigned level) const;
@@ -180,7 +185,7 @@ private:
casDGIntfIO *pNormalUDP; // attached to this intf's addr
casDGIntfIO *pBCastUDP; // attached to this intf's broadcast addr
SOCKET sock;
caAddr addr;
struct sockaddr_in addr;
};
//
@@ -208,6 +213,7 @@ private:
static inline void staticInit();
};
// no additions below this line
#endif // includeCASIODH

View File

@@ -6,6 +6,9 @@
//
//
// $Log$
// Revision 1.2 1997/04/10 19:40:33 jhill
// API changes
//
// Revision 1.1 1996/11/02 01:01:41 jhill
// installed
//
@@ -32,7 +35,7 @@ casIntfIO::casIntfIO() :
//
// casIntfIO::init()
//
caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
caStatus casIntfIO::init(const caNetAddr &addrIn, casDGClient &dgClientIn,
int autoBeaconAddr, int addConfigBeaconAddr)
{
int yes = TRUE;
@@ -63,10 +66,10 @@ caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
return S_cas_internal;
}
this->addr = addrIn;
this->addr = addrIn.getSockIP();
status = bind(
this->sock,
(sockaddr *) &this->addr.sa,
(sockaddr *) &this->addr,
sizeof(this->addr));
if (status<0) {
if (SOCKERRNO == EADDRINUSE) {
@@ -75,25 +78,27 @@ caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
// (so the getsockname() call below will
// work correctly)
//
this->addr.in.sin_port = ntohs (0);
this->addr.sin_port = ntohs (0);
status = bind(
this->sock,
&this->addr.sa,
(sockaddr *)&this->addr,
sizeof(this->addr));
}
if (status<0) {
errPrintf(S_cas_bindFail,
__FILE__, __LINE__,
"- bind TCP IP addr=%s port=%u failed because %s",
inet_ntoa(this->addr.in.sin_addr),
ntohs(this->addr.in.sin_port),
inet_ntoa(this->addr.sin_addr),
ntohs(this->addr.sin_port),
strerror(SOCKERRNO));
return S_cas_bindFail;
}
}
addrSize = sizeof(this->addr);
status = getsockname(this->sock, &this->addr.sa, &addrSize);
status = getsockname(this->sock,
(struct sockaddr *)&this->addr, &addrSize);
if (status) {
ca_printf("CAS: getsockname() error %s\n", strerror(SOCKERRNO));
return S_cas_internal;
@@ -103,7 +108,7 @@ caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
// be sure of this now so that we can fetch the IP
// address and port number later
//
assert (this->addr.sa.sa_family == AF_INET);
assert (this->addr.sin_family == AF_INET);
status = listen(this->sock, caServerConnectPendQueueSize);
if(status < 0) {
@@ -119,7 +124,7 @@ caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
if (!this->pNormalUDP) {
return S_cas_noMemory;
}
stat = this->pNormalUDP->init(addr, this->portNumber(),
stat = this->pNormalUDP->init(this->addr, this->portNumber(),
autoBeaconAddr, addConfigBeaconAddr);
if (stat) {
return stat;
@@ -133,7 +138,7 @@ caStatus casIntfIO::init(const caAddr &addrIn, casDGClient &dgClientIn,
// we will also need to bind to the broadcast address
// for that interface (if it has one)
//
if (this->addr.in.sin_addr.s_addr != INADDR_ANY) {
if (this->addr.sin_addr.s_addr != INADDR_ANY) {
this->pBCastUDP = this->newDGIntfIO(dgClientIn);
if (this->pBCastUDP) {
stat = this->pBCastUDP->init(addr, this->portNumber(),
@@ -181,13 +186,13 @@ casIntfIO::~casIntfIO()
//
casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const
{
caAddr newAddr;
struct sockaddr newAddr;
SOCKET newSock;
int length;
casStreamOS *pOS;
length = sizeof(newAddr.sa);
newSock = accept(this->sock, &newAddr.sa, &length);
length = sizeof(newAddr);
newSock = accept(this->sock, &newAddr, &length);
if (newSock==INVALID_SOCKET) {
if (SOCKERRNO!=EWOULDBLOCK) {
ca_printf(
@@ -197,7 +202,7 @@ casStreamOS *casIntfIO::newStreamClient(caServerI &cas) const
}
return NULL;
}
else if (sizeof(newAddr.sa)>(size_t)length) {
else if (sizeof(newAddr)>(size_t)length) {
socket_close(newSock);
ca_printf("CAS: accept returned bad address len?\n");
return NULL;
@@ -252,7 +257,7 @@ void casIntfIO::show(unsigned level) const
//
unsigned casIntfIO::portNumber() const
{
return ntohs(this->addr.in.sin_port);
return ntohs(this->addr.sin_port);
}
//

View File

@@ -5,6 +5,9 @@
//
//
// $Log$
// Revision 1.11 1997/05/01 19:59:09 jhill
// new header file for ipAddrToA()
//
// Revision 1.10 1997/04/23 17:27:01 jhill
// use matching buffer sizes
//
@@ -218,7 +221,7 @@ xRecvStatus casStreamIO::osdRecv(char *pInBuf, bufSizeT nBytes,
break;
default:
ipAddrToA(&this->addr.in, buf, sizeof(buf));
ipAddrToA(&this->addr, buf, sizeof(buf));
ca_printf(
"CAS: client %s disconnected because \"%s\"\n",
buf, strerror(SOCKERRNO));
@@ -240,10 +243,10 @@ void casStreamIO::osdShow (unsigned level) const
printf ("casStreamIO at %x\n", (unsigned) this);
if (level>1u) {
char buf[64];
ipAddrToA(&this->addr.in, buf, sizeof(buf));
ipAddrToA(&this->addr, buf, sizeof(buf));
printf (
"client=%s, port=%x\n",
buf, ntohs(this->addr.in.sin_port));
buf, ntohs(this->addr.sin_port));
}
}
@@ -302,7 +305,7 @@ bufSizeT casStreamIO::incommingBytesPresent() const
break;
default:
ipAddrToA(&this->addr.in, buf, sizeof(buf));
ipAddrToA(&this->addr, buf, sizeof(buf));
ca_printf(
"CAS: FIONREAD for %s failed because \"%s\"\n",
buf, strerror(SOCKERRNO));
@@ -323,7 +326,7 @@ bufSizeT casStreamIO::incommingBytesPresent() const
//
void casStreamIO::clientHostName (char *pInBuf, unsigned bufSizeIn) const
{
ipAddrToA (&this->addr.in, pInBuf, bufSizeIn);
ipAddrToA (&this->addr, pInBuf, bufSizeIn);
}
//

View File

@@ -7,6 +7,9 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.3 1996/11/02 00:55:00 jhill
// many improvements
//
// Revision 1.2 1996/09/16 18:27:10 jhill
// vxWorks port changes
//
@@ -103,7 +106,7 @@ class casIntfOS : public casIntfIO, public tsDLNode<casIntfOS>
public:
casIntfOS (caServerI &casIn) :
cas (casIn), pRdReg (NULL) {}
caStatus init(const caAddr &addr, casDGClient &dgClientIn,
caStatus init(const caNetAddr &addr, casDGClient &dgClientIn,
int autoBeaconAddr, int addConfigBeaconAddr);
~casIntfOS();