added host name pointer function

This commit is contained in:
Jeff Hill
2000-06-27 23:08:04 +00:00
parent 69162db301
commit 66b35e578b
6 changed files with 50 additions and 60 deletions

View File

@@ -100,6 +100,16 @@ void cacChannel::hostName ( char *pBuf, unsigned bufLength ) const
}
}
const char * cacChannel::pHostName () const
{
if ( this->pChannelIO ) {
return pChannelIO->pHostName ();
}
else {
return "<not connected>";
}
}
short cacChannel::nativeType () const
{
if ( this->pChannelIO ) {

View File

@@ -89,14 +89,16 @@ unsigned cacChannelIO::readSequence () const
void cacChannelIO::hostName ( char *pBuf, unsigned bufLength ) const
{
if ( bufLength ) {
int status = gethostname ( pBuf, bufLength );
if ( status ) {
strncpy ( pBuf, "<unknown host>", bufLength );
pBuf[ bufLength - 1u ] = '\0';
}
localHostNameAtLoadTime.copy (pBuf, bufLength );
}
}
// deprecated - please do not use
const char * cacChannelIO::pHostName () const
{
return localHostNameAtLoadTime.pointer ();
}
void cacChannelIO::incrementOutstandingIO ()
{
}
@@ -104,3 +106,5 @@ void cacChannelIO::incrementOutstandingIO ()
void cacChannelIO::decrementOutstandingIO ()
{
}

View File

@@ -81,6 +81,8 @@ public:
void decrementOutstandingIO ();
void decrementOutstandingIO ( unsigned seqNumber );
const char * pHostName () const; // deprecated - please do not use
protected:
class cacChannelIO *pChannelIO;
@@ -134,8 +136,10 @@ private:
virtual unsigned readSequence () const; // defaults to always zero
virtual void incrementOutstandingIO ();
virtual void decrementOutstandingIO ();
virtual const char * pHostName () const; // deprecated - please do not use
cacChannel &chan;
friend class cacChannel;
};

View File

@@ -16,45 +16,6 @@
#include "iocinf.h"
#include "addrList.h"
/*
* localHostName()
*
* o Indicates failure by setting ptr to nill
*
* o Calls non posix gethostbyname() so that we get DNS style names
* (gethostbyname() should be available with most BSD sock libs)
*
* vxWorks user will need to configure a DNS format name for the
* host name if they wish to be cnsistent with UNIX and VMS hosts.
*
* this needs to attempt to determine if the process is a remote
* login - hard to do under UNIX
*/
char *localHostName ()
{
int size;
int status;
char pName[MAXHOSTNAMELEN];
char *pTmp;
status = gethostname ( pName, sizeof (pName) );
if(status){
return NULL;
}
size = strlen (pName)+1;
pTmp = (char *) malloc (size);
if (!pTmp) {
return pTmp;
}
strncpy ( pTmp, pName, size-1 );
pTmp[size-1] = '\0';
return pTmp;
}
/*
* getToken()
*/

View File

@@ -58,6 +58,7 @@
#include "osiMutex.h"
#include "osiEvent.h"
#include "resourceLib.h"
#include "localHostName.h"
#if defined(epicsExportSharedSymbols)
#error suspect that libCom was not imported
@@ -179,11 +180,14 @@ private:
unsigned f_connected:1;
unsigned f_fullyConstructed:1;
static tsFreeList < class nciu, 1024 > freeList;
~nciu (); // force pool allocation
int issuePut ( ca_uint16_t cmd, unsigned id, chtype type,
unsigned long count, const void *pvalue );
void lock () const;
void unlock () const;
const char * pHostName () const; // deprecated - please do not use
};
class baseNMIU : public tsDLNode <baseNMIU>,
@@ -355,7 +359,10 @@ public:
virtual void removeFromChanList ( nciu &chan ) = 0;
virtual void disconnect ( nciu &chan ) = 0;
virtual const char * pHostName () const = 0; // deprecated - please do not use
tsDLList <nciu> chidList;
private:
};
class udpiiu;
@@ -444,6 +451,8 @@ public:
private:
SOCKET sock;
bool compareIfTCP (nciu &chan, const sockaddr_in &) const;
const char * pHostName () const; // deprecated - please do not use
};
class tcpRecvWatchdog : public osiTimer {
@@ -562,6 +571,7 @@ private:
static tsFreeList < class tcpiiu, 16 > freeList;
friend void cacSendThreadTCP ( void *pParam );
const char * pHostName () const; // deprecated - please do not use
};
class inetAddrID {
@@ -750,6 +760,7 @@ public:
void installDisconnectedChannel ( nciu &chan );
void notifySearchResponse ( unsigned short retrySeqNo );
void repeaterSubscribeConfirmNotify ();
void replaceErrLogHandler ( caPrintfFunc *ca_printf_func );
osiTimerQueue *pTimerQueue;
ELLLIST activeCASGOP;
@@ -762,7 +773,6 @@ public:
void *ca_exception_arg;
caPrintfFunc *ca_printf_func;
char *ca_pUserName;
char *ca_pHostName;
resTable
< bhe, inetAddrID > beaconTable;
tsDLIterBD <nciu> endOfBCastList;
@@ -814,8 +824,6 @@ int ca_vPrintf (const char *pformat, va_list args);
void manage_conn (cac *pcac);
epicsShareFunc void epicsShareAPI ca_repeater (void);
char *localHostName (void);
bhe *lookupBeaconInetAddr(cac *pcac,
const struct sockaddr_in *pnet_addr);

View File

@@ -15,6 +15,10 @@
#include "inetAddrID_IL.h"
#include "bhe_IL.h"
const caHdr cacnullmsg = {
0,0,0,0,0,0
};
tsFreeList < class tcpiiu, 16 > tcpiiu::freeList;
#ifdef DEBUG
@@ -147,7 +151,7 @@ LOCAL void retryPendingClaims (tcpiiu *piiu)
piiu->pcas->lock ();
tsDLIterBD<nciu> chan ( piiu->chidList.first () );
while ( chan != chan.eol () ) {
while ( chan.valid () ) {
if ( ! chan->claimPending ) {
piiu->claimRequestsPending = false;
piiu->flush ();
@@ -555,7 +559,7 @@ tcpiiu::~tcpiiu ()
}
tsDLIterBD <nciu> iter ( this->chidList.first () );
while ( iter != iter.eol () ) {
while ( iter.valid () ) {
tsDLIterBD<nciu> next = iter.itemAfter ();
iter->disconnect ();
iter = next;
@@ -708,24 +712,17 @@ int tcpiiu::readyRequestMsg ()
*/
void tcpiiu::hostNameSetMsg ()
{
unsigned size;
caHdr hdr;
char *pName;
if ( ! CA_V41(CA_PROTOCOL_VERSION, this->minor_version_number) ) {
if ( ! CA_V41 ( CA_PROTOCOL_VERSION, this->minor_version_number ) ) {
return;
}
/*
* allocate space in the outgoing buffer
*/
pName = this->pcas->ca_pHostName,
size = strlen (pName) + 1;
hdr = cacnullmsg;
hdr.m_cmmd = htons (CA_PROTO_HOST_NAME);
hdr.m_postsize = size;
hdr.m_cmmd = htons ( CA_PROTO_HOST_NAME );
hdr.m_postsize = localHostNameAtLoadTime.stringLength () + 1u;
this->pushStreamMsg (&hdr, pName, true);
this->pushStreamMsg ( &hdr, localHostNameAtLoadTime.pointer (), true );
return;
}
@@ -1328,6 +1325,12 @@ void tcpiiu::hostName ( char *pBuf, unsigned bufLength ) const
}
}
// deprecated - please dont use
const char * tcpiiu::pHostName () const
{
return this->host_name_str;
}
bool tcpiiu::ca_v42_ok () const
{
return CA_V42 (CA_PROTOCOL_VERSION, this->minor_version_number);