This is Unofficial EPICS BASE Doxygen Site
nciu Class Reference

#include "nciu.h"

+ Inheritance diagram for nciu:
+ Collaboration diagram for nciu:

Public Member Functions

 nciu (cac &, netiiu &, cacChannelNotify &, const char *pNameIn, cacChannel::priLev)
 
 ~nciu ()
 
void connect (unsigned nativeType, unsigned nativeCount, unsigned sid, epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void connect (epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void unresponsiveCircuitNotify (epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void circuitHangupNotify (class udpiiu &, epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void setServerAddressUnknown (netiiu &newiiu, epicsGuard< epicsMutex > &guard)
 
bool searchMsg (epicsGuard< epicsMutex > &)
 
void serviceShutdownNotify (epicsGuard< epicsMutex > &callbackControlGuard, epicsGuard< epicsMutex > &mutualExclusionGuard)
 
void accessRightsStateChange (const caAccessRights &, epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
ca_uint32_t getSID (epicsGuard< epicsMutex > &) const
 
ca_uint32_t getCID (epicsGuard< epicsMutex > &) const
 
netiiugetPIIU (epicsGuard< epicsMutex > &)
 
const netiiugetConstPIIU (epicsGuard< epicsMutex > &) const
 
cacgetClient ()
 
void searchReplySetUp (netiiu &iiu, unsigned sidIn, ca_uint16_t typeIn, arrayElementCount countIn, epicsGuard< epicsMutex > &)
 
void show (unsigned level) const
 
void show (epicsGuard< epicsMutex > &, unsigned level) const
 
unsigned getName (epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLen) const throw ()
 
const char * pName (epicsGuard< epicsMutex > &) const throw ()
 
unsigned nameLen (epicsGuard< epicsMutex > &) const
 
unsigned getHostName (epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLen) const throw ()
 
void writeException (epicsGuard< epicsMutex > &, epicsGuard< epicsMutex > &, int status, const char *pContext, unsigned type, arrayElementCount count)
 
cacChannel::priLev getPriority (epicsGuard< epicsMutex > &) const
 
void * operator new (size_t size, tsFreeList< class nciu, 1024, epicsMutexNOOP > &)
 
 epicsPlacementDeleteOperator ((void *, tsFreeList< class nciu, 1024, epicsMutexNOOP > &)) void resubscribe(epicsGuard< epicsMutex > &)
 
void sendSubscriptionUpdateRequests (epicsGuard< epicsMutex > &)
 
void disconnectAllIO (epicsGuard< epicsMutex > &, epicsGuard< epicsMutex > &)
 
bool connected (epicsGuard< epicsMutex > &) const
 
unsigned getcount () const
 
- Public Member Functions inherited from cacChannel
 cacChannel (cacChannelNotify &)
 
cacChannelNotifynotify () const
 
- Public Member Functions inherited from chronIntIdRes< nciu >
 chronIntIdRes ()
 
- Public Member Functions inherited from chronIntId
 chronIntId (const unsigned &idIn)
 
- Public Member Functions inherited from intId< unsigned, 8u, sizeof(unsigned)*CHAR_BIT >
 intId (const unsigned &idIn)
 
bool operator== (const intId &idIn) const
 
resTableIndex hash () const
 
const unsigned getId () const
 
- Public Member Functions inherited from tsSLNode< nciu >
 tsSLNode ()
 
tsSLNode< nciu > & operator= (const tsSLNode< nciu > &)
 
- Public Member Functions inherited from tsDLNode< class nciu >
 tsDLNode ()
 
 tsDLNode (const tsDLNode< class nciu > &)
 
const tsDLNode< class nciu > & operator= (const tsDLNode< class nciu > &)
 

Additional Inherited Members

- Public Types inherited from cacChannel
enum  ioStatus { iosSynch, iosAsynch }
 
typedef unsigned priLev
 
typedef unsigned ioid
 
- Static Public Member Functions inherited from channelNode
static unsigned getMaxSearchTimerCount ()
 
- Static Public Attributes inherited from cacChannel
static const priLev priorityMax = 99u
 
static const priLev priorityMin = 0u
 
static const priLev priorityDefault = priorityMin
 
static const priLev priorityLinksDB = priorityMax
 
static const priLev priorityArchive = ( priorityMax - priorityMin ) / 2
 
static const priLev priorityOPI = priorityMin
 
- Protected Member Functions inherited from cacChannel
virtual ~cacChannel ()=0
 
- Protected Member Functions inherited from channelNode
 channelNode ()
 
bool isInstalledInServer (epicsGuard< epicsMutex > &) const
 
bool isConnected (epicsGuard< epicsMutex > &) const
 
- Protected Attributes inherited from intId< unsigned, 8u, sizeof(unsigned)*CHAR_BIT >
unsigned id
 

Detailed Description

Definition at line 127 of file nciu.h.

Constructor & Destructor Documentation

nciu::nciu ( cac cacIn,
netiiu iiuIn,
cacChannelNotify chanIn,
const char *  pNameIn,
cacChannel::priLev  pri 
)

Definition at line 40 of file nciu.cpp.

41  :
42  cacChannel ( chanIn ),
43  cacCtx ( cacIn ),
44  piiu ( & iiuIn ),
45  sid ( UINT_MAX ),
46  count ( 0 ),
47  retry ( 0u ),
48  nameLength ( 0u ),
49  typeCode ( USHRT_MAX ),
50  priority ( static_cast <ca_uint8_t> ( pri ) )
51 {
52  size_t nameLengthTmp = strlen ( pNameIn ) + 1;
53 
54  // second constraint is imposed by size field in protocol header
55  if ( nameLengthTmp > MAX_UDP_SEND - sizeof ( caHdr ) || nameLengthTmp > USHRT_MAX ) {
56  throw cacChannel::badString ();
57  }
58 
59  if ( pri > 0xff ) {
60  throw cacChannel::badPriority ();
61  }
62 
63  this->nameLength = static_cast <unsigned short> ( nameLengthTmp );
64 
65  this->pNameStr = new char [ this->nameLength ];
66  strcpy ( this->pNameStr, pNameIn );
67 }
cacChannel(cacChannelNotify &)
Definition: cacIO.h:323
#define MAX_UDP_SEND
Definition: caProto.h:62
nciu::~nciu ( )

Definition at line 69 of file nciu.cpp.

70 {
71  delete [] this->pNameStr;
72 }

Member Function Documentation

void nciu::accessRightsStateChange ( const caAccessRights arIn,
epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 196 of file nciu.cpp.

199 {
200  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
201  this->accessRightState = arIn;
202 
203  //
204  // the channel delete routine takes the call back lock so
205  // that this will not be called when the channel is being
206  // deleted.
207  //
208  this->notify().accessRightsNotify ( guard, this->accessRightState );
209 }
virtual void accessRightsNotify(epicsGuard< epicsMutex > &, const caAccessRights &)=0
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
epicsMutex & mutexRef()
Definition: cac.h:358
cacChannelNotify & notify() const
Definition: cacIO.h:328
void nciu::circuitHangupNotify ( class udpiiu ,
epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)
void nciu::connect ( unsigned  nativeType,
unsigned  nativeCount,
unsigned  sid,
epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 114 of file nciu.cpp.

118 {
119  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
120  if ( ! dbf_type_is_valid ( nativeType ) ) {
121  throw std::logic_error ( "Ignored conn resp with bad native data type" );
122  }
123 
124  this->typeCode = static_cast < unsigned short > ( nativeType );
125  this->count = nativeCount;
126  this->sid = sidIn;
127 
128  /*
129  * if less than v4.1 then the server will never
130  * send access rights and there will always be access
131  */
132  bool v41Ok = this->piiu->ca_v41_ok ( guard );
133  if ( ! v41Ok ) {
134  this->accessRightState.setReadPermit();
135  this->accessRightState.setWritePermit();
136  }
137 
138  /*
139  * if less than v4.1 then the server will never
140  * send access rights and we know that there
141  * will always be access and also need to call
142  * their call back here
143  */
144  if ( ! v41Ok ) {
145  this->notify().accessRightsNotify (
146  guard, this->accessRightState );
147  }
148 
149  // channel uninstal routine grabs the callback lock so
150  // a channel will not be deleted while a call back is
151  // in progress
152  //
153  // the callback lock is also taken when a channel
154  // disconnects to prevent a race condition with the
155  // code below - ie we hold the callback lock here
156  // so a chanel cant be destroyed out from under us.
157  this->notify().connectNotify ( guard );
158 }
virtual void connectNotify(epicsGuard< epicsMutex > &)=0
void setReadPermit()
Definition: cacIO.h:338
virtual void accessRightsNotify(epicsGuard< epicsMutex > &, const caAccessRights &)=0
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
virtual bool ca_v41_ok(epicsGuard< epicsMutex > &) const =0
Definition: netiiu.cpp:43
void setWritePermit()
Definition: cacIO.h:343
#define dbf_type_is_valid(type)
Definition: db_access.h:643
epicsMutex & mutexRef()
Definition: cac.h:358
cacChannelNotify & notify() const
Definition: cacIO.h:328
void nciu::connect ( epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)
inline

Definition at line 304 of file nciu.h.

306 {
307  this->connect ( this->typeCode, this->count,
308  this->sid, cbGuard, guard );
309 }
void connect(unsigned nativeType, unsigned nativeCount, unsigned sid, epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
Definition: nciu.cpp:114
bool nciu::connected ( epicsGuard< epicsMutex > &  guard) const
virtual

Reimplemented from cacChannel.

Definition at line 466 of file nciu.cpp.

467 {
468  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
469  return this->channelNode::isConnected ( guard );
470 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
bool isConnected(epicsGuard< epicsMutex > &) const
Definition: nciu.h:359
epicsMutex & mutexRef()
Definition: cac.h:358
void nciu::disconnectAllIO ( epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 558 of file nciu.cpp.

561 {
562  this->cacCtx.disconnectAllIO ( cbGuard, guard,
563  *this, this->eventq );
564 }
void disconnectAllIO(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard, nciu &, tsDLList< baseNMIU > &ioList)
Definition: cac.cpp:674
nciu::epicsPlacementDeleteOperator ( (void *, tsFreeList< class nciu, 1024, epicsMutexNOOP > &)  )
ca_uint32_t nciu::getCID ( epicsGuard< epicsMutex > &  ) const
inline

Definition at line 297 of file nciu.h.

299 {
300  return this->id;
301 }
cac & nciu::getClient ( )
inline

Definition at line 343 of file nciu.h.

344 {
345  return this->cacCtx;
346 }
const netiiu * nciu::getConstPIIU ( epicsGuard< epicsMutex > &  ) const
inline

Definition at line 337 of file nciu.h.

339 {
340  return this->piiu;
341 }
unsigned nciu::getcount ( ) const
inline

Definition at line 200 of file nciu.h.

200 { return count; }
unsigned nciu::getHostName ( epicsGuard< epicsMutex > &  guard,
char *  pBuf,
unsigned  bufLen 
) const
throw (
)
virtual

Reimplemented from cacChannel.

Definition at line 398 of file nciu.cpp.

401 {
402  return this->piiu->getHostName (
403  guard, pBuf, bufLength );
404 }
virtual unsigned getHostName(epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLength) const =0
Definition: netiiu.cpp:93
unsigned nciu::getName ( epicsGuard< epicsMutex > &  ,
char *  pBuf,
unsigned  bufLen 
) const
throw (
)
virtual

Implements cacChannel.

Definition at line 233 of file nciu.cpp.

236 {
237  if ( bufLen == 0u ) {
238  return 0u;
239  }
240  if ( this->nameLength < bufLen ) {
241  strcpy ( pBuf, this->pNameStr );
242  return this->nameLength;
243  }
244  else {
245  unsigned reducedSize = bufLen - 1u;
246  strncpy ( pBuf, this->pNameStr, bufLen );
247  pBuf[reducedSize] = '\0';
248  return reducedSize;
249  }
250 }
netiiu * nciu::getPIIU ( epicsGuard< epicsMutex > &  )
inline

Definition at line 321 of file nciu.h.

323 {
324  return this->piiu;
325 }
cacChannel::priLev nciu::getPriority ( epicsGuard< epicsMutex > &  ) const
inline

Definition at line 348 of file nciu.h.

350 {
351  return this->priority;
352 }
ca_uint32_t nciu::getSID ( epicsGuard< epicsMutex > &  ) const
inline

Definition at line 291 of file nciu.h.

293 {
294  return this->sid;
295 }
unsigned nciu::nameLen ( epicsGuard< epicsMutex > &  guard) const

Definition at line 252 of file nciu.cpp.

254 {
255  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
256  return this->nameLength;
257 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
epicsMutex & mutexRef()
Definition: cac.h:358
void * nciu::operator new ( size_t  size,
tsFreeList< class nciu, 1024, epicsMutexNOOP > &  freeList 
)
inline

Definition at line 277 of file nciu.h.

279 {
280  return freeList.allocate ( size );
281 }
void * allocate(size_t size)
Definition: tsFreeList.h:126
const char * nciu::pName ( epicsGuard< epicsMutex > &  guard) const
throw (
)
virtual

Implements cacChannel.

Definition at line 226 of file nciu.cpp.

228 {
229  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
230  return this->pNameStr;
231 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
epicsMutex & mutexRef()
Definition: cac.h:358
bool nciu::searchMsg ( epicsGuard< epicsMutex > &  guard)

Definition at line 214 of file nciu.cpp.

215 {
216  bool success = this->piiu->searchMsg (
217  guard, this->getId (), this->pNameStr, this->nameLength );
218  if ( success ) {
219  if ( this->retry < UINT_MAX ) {
220  this->retry++;
221  }
222  }
223  return success;
224 }
virtual bool searchMsg(epicsGuard< epicsMutex > &, ca_uint32_t id, const char *pName, unsigned nameLength)=0
Definition: netiiu.cpp:166
void nciu::searchReplySetUp ( netiiu iiu,
unsigned  sidIn,
ca_uint16_t  typeIn,
arrayElementCount  countIn,
epicsGuard< epicsMutex > &   
)
inline

Definition at line 311 of file nciu.h.

314 {
315  this->piiu = & iiu;
316  this->typeCode = typeIn;
317  this->count = countIn;
318  this->sid = sidIn;
319 }
void nciu::sendSubscriptionUpdateRequests ( epicsGuard< epicsMutex > &  guard)

Definition at line 539 of file nciu.cpp.

540 {
541  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
542  tsDLIter < baseNMIU > pNetIO = this->eventq.firstIter ();
543  while ( pNetIO.valid () ) {
544  tsDLIter < baseNMIU > next = pNetIO;
545  next++;
546  try {
547  pNetIO->forceSubscriptionUpdate ( guard, *this );
548  }
549  catch ( ... ) {
550  errlogPrintf (
551  "CAC: failed to send subscription update request "
552  "during channel connect\n" );
553  }
554  pNetIO = next;
555  }
556 }
tsDLIterConst< T > firstIter() const
Definition: tsDLList.h:459
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
bool valid() const
Definition: tsDLList.h:607
virtual void forceSubscriptionUpdate(epicsGuard< epicsMutex > &guard, nciu &chan)=0
Definition: baseNMIU.cpp:31
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
epicsMutex & mutexRef()
Definition: cac.h:358
void nciu::serviceShutdownNotify ( epicsGuard< epicsMutex > &  callbackControlGuard,
epicsGuard< epicsMutex > &  mutualExclusionGuard 
)

Definition at line 566 of file nciu.cpp.

569 {
570  this->setServerAddressUnknown ( noopIIU, mutualExclusionGuard );
571  this->notify().serviceShutdownNotify ( mutualExclusionGuard );
572 }
void setServerAddressUnknown(netiiu &newiiu, epicsGuard< epicsMutex > &guard)
Definition: nciu.cpp:183
virtual void serviceShutdownNotify(epicsGuard< epicsMutex > &mutualExclusionGuard)=0
noopiiu noopIIU
Definition: noopiiu.cpp:28
cacChannelNotify & notify() const
Definition: cacIO.h:328
void nciu::setServerAddressUnknown ( netiiu newiiu,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 183 of file nciu.cpp.

185 {
186  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
187  this->piiu = & newiiu;
188  this->retry = 0;
189  this->typeCode = USHRT_MAX;
190  this->count = 0u;
191  this->sid = UINT_MAX;
192  this->accessRightState.clrReadPermit();
193  this->accessRightState.clrWritePermit();
194 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
void clrWritePermit()
Definition: cacIO.h:358
void clrReadPermit()
Definition: cacIO.h:353
epicsMutex & mutexRef()
Definition: cac.h:358
void nciu::show ( unsigned  level) const

Definition at line 472 of file nciu.cpp.

473 {
474  epicsGuard < epicsMutex > guard ( this->cacCtx.mutexRef() );
475  this->show ( guard, level );
476 }
void show(unsigned level) const
Definition: nciu.cpp:472
epicsMutex & mutexRef()
Definition: cac.h:358
void nciu::show ( epicsGuard< epicsMutex > &  guard,
unsigned  level 
) const
virtual

Implements cacChannel.

Definition at line 478 of file nciu.cpp.

480 {
481  if ( this->connected ( guard ) ) {
482  char hostNameTmp [256];
483  this->getHostName ( guard, hostNameTmp, sizeof ( hostNameTmp ) );
484  ::printf ( "Channel \"%s\", connected to server %s",
485  this->pNameStr, hostNameTmp );
486  if ( level > 1u ) {
487  int tmpTypeCode = static_cast < int > ( this->typeCode );
488  ::printf ( ", native type %s, native element count %u",
489  dbf_type_to_text ( tmpTypeCode ), this->count );
490  ::printf ( ", %sread access, %swrite access",
491  this->accessRightState.readPermit() ? "" : "no ",
492  this->accessRightState.writePermit() ? "" : "no ");
493  }
494  ::printf ( "\n" );
495  }
496  else {
497  ::printf ( "Channel \"%s\" is disconnected\n", this->pNameStr );
498  }
499 
500  if ( level > 2u ) {
501  ::printf ( "\tnetwork IO pointer = %p\n",
502  static_cast <void *> ( this->piiu ) );
503  ::printf ( "\tserver identifier %u\n", this->sid );
504  ::printf ( "\tsearch retry number=%u\n", this->retry );
505  ::printf ( "\tname length=%u\n", this->nameLength );
506  }
507 }
#define dbf_type_to_text(type)
Definition: db_access.h:677
bool connected(epicsGuard< epicsMutex > &) const
Definition: nciu.cpp:466
unsigned getHostName(epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLen) const
Definition: nciu.cpp:398
#define printf
Definition: epicsStdio.h:41
bool writePermit() const
Definition: cacIO.h:373
bool readPermit() const
Definition: cacIO.h:368
void nciu::unresponsiveCircuitNotify ( epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 160 of file nciu.cpp.

163 {
164  ioid tmpId = this->getId ();
165  cac & caRefTmp = this->cacCtx;
166  guard.assertIdenticalMutex ( this->cacCtx.mutexRef () );
167  this->cacCtx.disconnectAllIO ( cbGuard, guard,
168  *this, this->eventq );
169  this->notify().disconnectNotify ( guard );
170  // if they destroy the channel in their disconnect
171  // handler then we have to be very careful to not
172  // touch this object if it has been destroyed
173  nciu * pChan = caRefTmp.lookupChannel ( guard, tmpId );
174  if ( pChan ) {
175  caAccessRights noRights;
176  pChan->notify().accessRightsNotify ( guard, noRights );
177  // likewise, they might destroy the channel in their access rights
178  // handler so we have to be very careful to not touch this
179  // object from here on down
180  }
181 }
Definition: cac.h:97
virtual void disconnectNotify(epicsGuard< epicsMutex > &)=0
virtual void accessRightsNotify(epicsGuard< epicsMutex > &, const caAccessRights &)=0
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
nciu * lookupChannel(epicsGuard< epicsMutex > &, const cacChannel::ioid &)
Definition: cac.h:400
unsigned ioid
Definition: cacIO.h:173
void disconnectAllIO(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard, nciu &, tsDLList< baseNMIU > &ioList)
Definition: cac.cpp:674
epicsMutex & mutexRef()
Definition: cac.h:358
Definition: nciu.h:127
cacChannelNotify & notify() const
Definition: cacIO.h:328
void nciu::writeException ( epicsGuard< epicsMutex > &  ,
epicsGuard< epicsMutex > &  guard,
int  status,
const char *  pContext,
unsigned  type,
arrayElementCount  count 
)
inline

Definition at line 327 of file nciu.h.

332 {
333  this->notify().writeException ( guard,
334  status, pContext, typeIn, countIn );
335 }
virtual void writeException(epicsGuard< epicsMutex > &, int status, const char *pContext, unsigned type, arrayElementCount count)=0
pvd::Status status
cacChannelNotify & notify() const
Definition: cacIO.h:328

The documentation for this class was generated from the following files: