21 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov" 40 static char *getToken (
const char **ppString,
char *pBuf,
unsigned bufSIze )
42 bool tokenFound =
false;
47 while ( isspace (*pToken) && *pToken ){
51 for ( i=0u; i<bufSIze; i++ ) {
52 if ( isspace (pToken[i]) || pToken[i]==
'\0' ) {
54 *ppString = &pToken[
i];
64 pBuf[bufSIze-1] =
'\0';
75 unsigned short port,
int ignoreNonDefaultPort )
80 struct sockaddr_in addr;
89 while ( ( pToken = getToken (&pStr, buf,
sizeof (buf) ) ) ) {
90 status =
aToIPAddr ( pToken, port, &addr );
92 fprintf (
stderr,
"%s: Parsing '%s'\n", __FILE__, pEnv->
name);
93 fprintf (
stderr,
"\tBad internet address or host name: '%s'\n", pToken);
97 if ( ignoreNonDefaultPort && ntohs ( addr.sin_port ) != port ) {
102 if (pNewNode==
NULL) {
103 fprintf (
stderr,
"addAddrToChannelAccessAddressList(): no memory available for configuration\n");
127 while ( (pRawNode =
ellGet ( pSrcList ) ) ) {
132 if ( pNode->
addr.
sa.sa_family == AF_INET ) {
136 if (pTmpNode->addr.sa.sa_family == AF_INET) {
137 if ( pNode->
addr.
ia.sin_addr.s_addr == pTmpNode->addr.ia.sin_addr.s_addr &&
138 pNode->
addr.
ia.sin_port == pTmpNode->addr.ia.sin_port ) {
143 "Warning: Duplicate EPICS CA Address list entry \"%s\" discarded\n", buf );
165 static void forcePort (
ELLLIST *pList,
unsigned short port )
171 if ( pNode->
addr.
sa.sa_family == AF_INET ) {
172 pNode->
addr.
ia.sin_port = htons ( port );
204 sizeof (yesno), yesno );
206 if ( strstr ( pstr,
"no" ) || strstr ( pstr,
"NO" ) ) {
219 addr.
ia.sin_family = AF_UNSPEC;
221 forcePort ( &bcastList, port );
231 pNewNode->
addr.
ia.sin_family = AF_INET;
233 pNewNode->
addr.
ia.sin_port = htons ( port );
237 errlogPrintf (
"configureChannelAccessAddressList(): no memory available for configuration\n" );
254 ::printf (
"Channel Access Address List\n" );
LIBCOM_API void epicsStdCall osiSockDiscoverBroadcastAddresses(ELLLIST *pList, SOCKET socket, const osiSockAddr *pMatchAddr)
LIBCOM_API int epicsStdCall aToIPAddr(const char *pAddrString, unsigned short defaultPort, struct sockaddr_in *pIP)
#define assert(exp)
Declare that a condition should be true.
#define ellCount(PLIST)
Report the number of nodes in a list.
An EPICS-specific replacement for ANSI C's assert.
void epicsStdCall configureChannelAccessAddressList(ELLLIST *pList, SOCKET sock, unsigned short port)
char * name
Name of the parameter.
LIBCOM_API const char *epicsStdCall envGetConfigParamPtr(const ENV_PARAM *pParam)
Get a configuration parameter's value or default string.
void epicsStdCall printChannelAccessAddressList(const ELLLIST *pList)
Routines to get and set EPICS environment parameters.
ELLNODE * ellGet(ELLLIST *pList)
Deletes and returns the first node from a list.
A structure to hold a single environment parameter.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define ellNext(PNODE)
Find the next node in list.
#define STATIC_ASSERT(expr)
Declare a condition that should be true at compile-time.
LIBCOM_API const ENV_PARAM EPICS_CA_ADDR_LIST
int errlogPrintf(const char *pFormat,...)
#define ellInit(PLIST)
Initialize a list type.
unsigned epicsStdCall ipAddrToA(const struct sockaddr_in *paddr, char *pBuf, unsigned bufSize)
int epicsStdCall addAddrToChannelAccessAddressList(ELLLIST *pList, const ENV_PARAM *pEnv, unsigned short port, int ignoreNonDefaultPort)
void epicsStdCall removeDuplicateAddresses(ELLLIST *pDestList, ELLLIST *pSrcList, int silent)
LIBCOM_API char *epicsStdCall envGetConfigParam(const ENV_PARAM *pParam, int bufDim, char *pBuf)
Get value of a configuration parameter.
LIBCOM_API const ENV_PARAM EPICS_CA_AUTO_ADDR_LIST
unsigned epicsStdCall ipAddrToDottedIP(const struct sockaddr_in *paddr, char *pBuf, unsigned bufSize)
#define ellFirst(PLIST)
Find the first node in list.