diff --git a/src/ca/access.c b/src/ca/access.c index b0586444b..c406d27b8 100644 --- a/src/ca/access.c +++ b/src/ca/access.c @@ -99,6 +99,9 @@ /************************************************************************/ /* * $Log$ + * Revision 1.100 1998/02/05 21:55:49 jhill + * detect attempts by user to clear bogus channel + * * Revision 1.98 1997/08/04 22:54:28 jhill * mutex clean up * @@ -253,7 +256,7 @@ static char *sccsId = "@(#) $Id$"; #define CHIXCHK(CHIX) \ { \ - if( (CHIX)->state != cs_conn || INVALID_DB_REQ((CHIX)->type) ){ \ + if( (CHIX)->state != cs_conn || INVALID_DB_REQ((CHIX)->privType) ){ \ return ECA_BADCHID; \ } \ } @@ -264,7 +267,7 @@ static char *sccsId = "@(#) $Id$"; /* allow them to add monitors to a disconnected channel */ #define LOOSECHIXCHK(CHIX) \ { \ - if( (CHIX)->type==TYPENOTINUSE ){ \ + if( (CHIX)->privType==TYPENOTINUSE ){ \ return ECA_BADCHID; \ } \ } @@ -1090,8 +1093,8 @@ int epicsShareAPI ca_search_and_connect *chix->id.paddr = tmp_paddr; chix->puser = puser; chix->pConnFunc = conn_func; - chix->type = chix->id.paddr->dbr_field_type; - chix->count = chix->id.paddr->no_elements; + chix->privType = chix->id.paddr->dbr_field_type; + chix->privCount = chix->id.paddr->no_elements; chix->piiu = NULL; /* none */ chix->state = cs_conn; chix->ar.read_access = TRUE; @@ -1156,8 +1159,8 @@ int epicsShareAPI ca_search_and_connect chix->puser = (void *) puser; chix->pConnFunc = conn_func; - chix->type = TYPENOTCONN; /* invalid initial type */ - chix->count = 0; /* invalid initial count */ + chix->privType = TYPENOTCONN; /* invalid initial type */ + chix->privCount = 0; /* invalid initial count */ chix->id.sid = ~0U; /* invalid initial server id */ chix->ar.read_access = FALSE; chix->ar.write_access = FALSE; @@ -1282,7 +1285,7 @@ void *pvalue return ECA_NORDACCESS; } - if (count > chix->count) { + if (count > chix->privCount) { return ECA_BADCOUNT; } @@ -1363,7 +1366,7 @@ const void *arg if (INVALID_DB_REQ(type)) return ECA_BADTYPE; - if (count > chix->count) + if (count > chix->privCount) return ECA_BADCOUNT; if(!chix->ar.read_access){ @@ -1537,8 +1540,8 @@ LOCAL int issue_get_callback(evid monix, unsigned cmmd) /* * set to the native count if they specify zero */ - if (monix->count == 0 || monix->count > chix->count){ - count = chix->count; + if (monix->count == 0 || monix->count > chix->privCount){ + count = chix->privCount; } else{ count = monix->count; @@ -1595,7 +1598,7 @@ const void *usrarg /* * check for valid count */ - if(count > chix->count || count == 0) + if(count > chix->privCount || count == 0) return ECA_BADCOUNT; piiu = chix->piiu; @@ -1811,7 +1814,7 @@ int epicsShareAPI ca_array_put ( /* * check for valid count */ - if(count > chix->count || count == 0) + if(count > chix->privCount || count == 0) return ECA_BADCOUNT; if (type==DBR_STRING) { @@ -2296,8 +2299,8 @@ int ca_request_event(evid monix) * clip to the native count and set to the native count if they * specify zero */ - if (monix->count > chix->count || monix->count == 0){ - count = chix->count; + if (monix->count > chix->privCount || monix->count == 0){ + count = chix->privCount; } else{ count = monix->count; @@ -2357,8 +2360,8 @@ db_field_log *pfl * clip to the native count * and set to the native count if they specify zero */ - if(monix->count > monix->chan->count || monix->count == 0){ - count = monix->chan->count; + if(monix->count > monix->chan->privCount || monix->count == 0){ + count = monix->chan->privCount; } else{ count = monix->count; @@ -2547,8 +2550,8 @@ int epicsShareAPI ca_clear_event (evid monix) /* msg header */ hdr.m_cmmd = htons(CA_PROTO_EVENT_CANCEL); hdr.m_available = pMon->id; - hdr.m_type = htons(chix->type); - hdr.m_count = htons(chix->count); + hdr.m_type = htons(chix->privType); + hdr.m_count = htons(chix->privCount); hdr.m_cid = chix->id.sid; hdr.m_postsize = 0; @@ -2604,7 +2607,7 @@ int epicsShareAPI ca_clear_channel (chid pChan) LOOSECHIXCHK(pChan); /* disable their further use of deallocated channel */ - pChan->type = TYPENOTINUSE; + pChan->privType = TYPENOTINUSE; old_chan_state = pChan->state; pChan->state = cs_closed; pChan->pAccessRightsFunc = NULL; @@ -3472,7 +3475,7 @@ int issue_claim_channel (chid pchan) ellAdd (&piiu->chidlist, &pchan->node); if (!CA_V42(CA_PROTOCOL_VERSION, piiu->minor_version_number)) { - cac_reconnect_channel(pchan->cid); + cac_reconnect_channel(pchan->cid, TYPENOTCONN, 0); } } else { @@ -3706,3 +3709,28 @@ int epicsShareAPI ca_printf(char *pformat, ...) return status; } +/* + * ca_get_field_type() + */ +short epicsShareAPI ca_get_field_type (chid chan) +{ + if (chan->state==cs_conn) { + return chan->privType; + } + else { + return TYPENOTCONN; + } +} + +/* + * ca_get_element_count() + */ +unsigned short epicsShareAPI ca_get_element_count (chid chan) +{ + if (chan->state==cs_conn) { + return chan->privCount; + } + else { + return 0; + } +} diff --git a/src/ca/acctst.c b/src/ca/acctst.c index 24b0acbb1..cf79bec1d 100644 --- a/src/ca/acctst.c +++ b/src/ca/acctst.c @@ -7,6 +7,9 @@ static char *sccsId = "@(#) $Id$"; /* * $Log$ + * Revision 1.49 1998/02/05 21:56:46 jhill + * added no pend event in event call back test + * * Revision 1.48 1997/07/10 19:33:11 jhill * improved CPU consumption by select() under vxWorks * @@ -243,10 +246,10 @@ int doacctst(char *pname) SEVCHK(status, NULL); if (ca_test_io() == ECA_IOINPROGRESS) { - assert(INVALID_DB_REQ(chix1->type) == TRUE); - assert(INVALID_DB_REQ(chix2->type) == TRUE); - assert(INVALID_DB_REQ(chix3->type) == TRUE); - assert(INVALID_DB_REQ(chix4->type) == TRUE); + assert(INVALID_DB_REQ(ca_field_type(chix1)) == TRUE); + assert(INVALID_DB_REQ(ca_field_type(chix2)) == TRUE); + assert(INVALID_DB_REQ(ca_field_type(chix3)) == TRUE); + assert(INVALID_DB_REQ(ca_field_type(chix4)) == TRUE); assert(ca_state(chix1) == cs_never_conn); assert(ca_state(chix2) == cs_never_conn); @@ -331,10 +334,10 @@ int doacctst(char *pname) assert (ca_state(chix3) == cs_conn); assert (ca_state(chix4) == cs_conn); - assert (INVALID_DB_REQ(chix1->type) == FALSE); - assert (INVALID_DB_REQ(chix2->type) == FALSE); - assert (INVALID_DB_REQ(chix3->type) == FALSE); - assert (INVALID_DB_REQ(chix4->type) == FALSE); + assert (INVALID_DB_REQ(ca_field_type(chix1)) == FALSE); + assert (INVALID_DB_REQ(ca_field_type(chix2)) == FALSE); + assert (INVALID_DB_REQ(ca_field_type(chix3)) == FALSE); + assert (INVALID_DB_REQ(ca_field_type(chix4)) == FALSE); /* * clear chans before starting another test @@ -765,7 +768,7 @@ int doacctst(char *pname) } printf("done.\n"); - if (VALID_DB_REQ(chix4->type)) { + if (VALID_DB_REQ(ca_field_type(chix4))) { status = ca_add_event( DBR_FLOAT, chix4, @@ -782,7 +785,7 @@ int doacctst(char *pname) &monix); SEVCHK(status, NULL); } - if (VALID_DB_REQ(chix4->type)) { + if (VALID_DB_REQ(ca_field_type(chix4))) { status = ca_add_event( DBR_FLOAT, chix4, @@ -792,7 +795,7 @@ int doacctst(char *pname) SEVCHK(status, NULL); SEVCHK(ca_clear_event(monix), NULL); } - if (VALID_DB_REQ(chix3->type)) { + if (VALID_DB_REQ(ca_field_type(chix3))) { status = ca_add_event( DBR_FLOAT, chix3, @@ -813,7 +816,7 @@ int doacctst(char *pname) pdouble = (dbr_double_t *) calloc(sizeof(*pdouble),NUM); pgrfloat = (struct dbr_gr_float *) calloc(sizeof(*pgrfloat),NUM); - if (VALID_DB_REQ(chix1->type)) + if (VALID_DB_REQ(ca_field_type(chix1))) if (pfloat) for (i = 0; i < NUM; i++) { for (j = 0; j < NUM; j++) @@ -853,7 +856,7 @@ int doacctst(char *pname) * o verifies that we can at least write and read back the same array * if multiple elements are present */ - if (VALID_DB_REQ(chix1->type)) { + if (VALID_DB_REQ(ca_field_type(chix1))) { if (ca_element_count(chix1)>1u && ca_read_access(chix1)) { dbr_float_t *pRF, *pWF, *pEF, *pT1, *pT2; diff --git a/src/ca/cadef.h b/src/ca/cadef.h index 6d069ba68..ef4726ebf 100644 --- a/src/ca/cadef.h +++ b/src/ca/cadef.h @@ -131,8 +131,8 @@ HDRVERSIONID(cadefh, "@(#) $Id$") * recommended that the following MACROS be used to access them. * */ -#define ca_field_type(CHID) ((CHID)->type) -#define ca_element_count(CHID) ((CHID)->count) +#define ca_field_type(CHID) (ca_get_field_type(CHID)) +#define ca_element_count(CHID) (ca_get_element_count(CHID)) #define ca_name(CHID) ((READONLY char *)((CHID)+1)) /* * the odd cast here removes const (and allows past practice @@ -196,9 +196,9 @@ typedef void caArh(); */ struct channel_in_use{ ELLNODE node; /* list ptrs */ - short type; /* database field type */ + short privType; /* database field type */ #define TYPENOTCONN (-1) /* the type when disconnected */ - unsigned short count; /* array element count */ + unsigned short privCount; /* array element count */ union{ unsigned sid; /* server id */ struct dbAddr *paddr; /* database address */ @@ -308,6 +308,9 @@ struct exception_handler_args{ #ifdef CAC_ANSI_FUNC_PROTO +epicsShareFunc short epicsShareAPI ca_get_field_type (chid chan); +epicsShareFunc unsigned short epicsShareAPI ca_get_element_count (chid chan); + /************************************************************************/ /* Perform Library Initialization */ /* */ @@ -1064,7 +1067,8 @@ epicsShareFunc int epicsShareAPI ca_replace_printf_handler ( #endif /*CA_DONT_INCLUDE_STDARGH*/ #else /* CAC_ANSI_FUNC_PROTO */ - +epicsShareFunc short epicsShareAPI ca_get_field_type (); +epicsShareFunc unsigned short epicsShareAPI ca_get_element_count (); epicsShareFunc int epicsShareAPI ca_task_initialize (); epicsShareFunc int epicsShareAPI ca_task_exit (); epicsShareFunc int epicsShareAPI ca_search_and_connect (); diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index 452238799..d0dfbf29d 100644 --- a/src/ca/iocinf.c +++ b/src/ca/iocinf.c @@ -47,6 +47,9 @@ /* address in use so that test works on UNIX */ /* kernels that support multicast */ /* $Log$ + * Revision 1.74 1998/02/05 22:29:42 jhill + * use osiSock macros + * * Revision 1.73 1997/08/04 23:37:09 jhill * added beacon anomaly flag init/allow ip 255.255.255.255 * @@ -1440,8 +1443,8 @@ void cacDisconnectChannel(ciu chix, enum channel_state state) { LOCK; - chix->type = TYPENOTCONN; - chix->count = 0u; + chix->privType = TYPENOTCONN; + chix->privCount = 0u; chix->id.sid = ~0u; chix->ar.read_access = FALSE; chix->ar.write_access = FALSE; diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 8be6bf80c..00960f234 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -32,6 +32,11 @@ /************************************************************************/ /* $Log$ + * Revision 1.68 1998/02/20 21:52:21 evans + * Added an explicit include of tsDefs.h before cadef.h to avoid the + * functions in it being declared as export and also to avoid its + * allocating space when it should be declaring a reference. + * * Revision 1.67 1998/02/05 22:30:34 jhill * fixed dll export problems * @@ -736,7 +741,7 @@ void genLocalExcepWFL(long stat, char *ctx, char *pFile, unsigned line); #define genLocalExcep(STAT, PCTX) \ genLocalExcepWFL (STAT, PCTX, __FILE__, __LINE__) -void cac_reconnect_channel(caResId id); +void cac_reconnect_channel(caResId id, short type, unsigned short count); void retryPendingClaims(IIU *piiu); void cacSetRetryInterval(unsigned retryNo); void addToChanList(ciu chan, IIU *piiu); diff --git a/src/ca/service.c b/src/ca/service.c index 1ebd85bb6..812fd5ef4 100644 --- a/src/ca/service.c +++ b/src/ca/service.c @@ -717,7 +717,7 @@ const struct in_addr *pnet_addr break; } case CA_PROTO_CLAIM_CIU: - cac_reconnect_channel(piiu->curMsg.m_cid); + cac_reconnect_channel(piiu->curMsg.m_cid, piiu->curMsg.m_type, piiu->curMsg.m_count); break; case CA_PROTO_CLAIM_CIU_FAILED: @@ -972,6 +972,11 @@ const struct in_addr *pnet_addr */ chan->id.sid = piiu->curMsg.m_cid; + if (!CA_V42(CA_PROTOCOL_VERSION, minorVersion)) { + chan->privType = piiu->curMsg.m_type; + chan->privCount = piiu->curMsg.m_count; + } + issue_claim_channel(chan); UNLOCK } @@ -980,7 +985,7 @@ const struct in_addr *pnet_addr /* * cac_reconnect_channel() */ -void cac_reconnect_channel(caResId cid) +void cac_reconnect_channel(caResId cid, short type, unsigned short count) { IIU *piiu; evid pevent; @@ -1015,9 +1020,14 @@ void cac_reconnect_channel(caResId cid) chan->id.sid = piiu->curMsg.m_available; } - /* Update rmt chid fields from caHdr fields */ - chan->type = piiu->curMsg.m_type; - chan->count = piiu->curMsg.m_count; + /* + * Update rmt chid fields from caHdr fields + * if they are valid + */ + if (type != TYPENOTCONN) { + chan->privType = type; + chan->privCount = count; + } /* * set state to cs_conn before caling diff --git a/src/ca/test_event.c b/src/ca/test_event.c index b1f4176c5..591cf651f 100644 --- a/src/ca/test_event.c +++ b/src/ca/test_event.c @@ -23,7 +23,7 @@ void epicsShareAPI ca_test_event(struct event_handler_args args) { ca_printf("CAC: ~~~### in test event for [%s] ###~~~\n",args.chid+1); ca_printf("CAC: User argument\t%x\n", args.usr); - ca_printf("CAC: Native channel data type\t%d\n", args.chid->type); + ca_printf("CAC: Native channel data type\t%d\n", ca_field_type(args.chid)); ca_printf("CAC: Monitor data type\t%d\n", args.type); ca_printf("CAC: CA Status \"%s\"\n", ca_message(args.status)); diff --git a/src/ca/windows_depen.c b/src/ca/windows_depen.c index 35f8b352f..6aa0f823a 100644 --- a/src/ca/windows_depen.c +++ b/src/ca/windows_depen.c @@ -32,6 +32,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.32 1998/02/27 01:05:04 jhill + * integrated Timossi's win sock II changes + * * Revision 1.1.1.3 1996/11/15 17:45:01 timossi * Interim release from jeff hill * @@ -49,6 +52,9 @@ * * Revision 1.19 1995/11/29 19:15:42 jhill * added $Log$ + * added Revision 1.32 1998/02/27 01:05:04 jhill + * added integrated Timossi's win sock II changes + * added * Revision 1.1.1.3 1996/11/15 17:45:01 timossi * Interim release from jeff hill * @@ -459,18 +465,14 @@ BOOL epicsShareAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) fprintf(stderr, "Process attached to ca.dll version %s\n", EPICS_VERSION_STRING); #endif /* init. winsock */ if ((status = WSAStartup(MAKEWORD(/*major*/2,/*minor*/2), &WsaData)) != 0) { - /* - * The winsock I & II doc indicate that these steps are not required, - * but experience at some sites proves otherwise. Perhaps some vendors - * do not follow the protocol described in the doc. - */ - if ((status = WSAStartup(MAKEWORD(/*major*/1,/*minor*/1), &WsaData)) != 0) { - if ((status = WSAStartup(MAKEWORD(/*major*/1,/*minor*/0), &WsaData)) != 0) { - WSACleanup(); - fprintf(stderr,"Unable to attach to winsock version 2.2 or lower\n"); - return FALSE; - } - } + WSACleanup(); + fprintf(stderr, + "Unable to attach to windows sockets version 2. error=%d\n", status); + fprintf(stderr, + "A Windows Sockets II update for windows 95 is available at\n"); + fprintf(stderr, + "http://www.microsoft.com/win32dev/netwrk/winsock2/ws295sdk.html"); + return FALSE; } #if _DEBUG diff --git a/src/include/cadef.h b/src/include/cadef.h index 6d069ba68..ef4726ebf 100644 --- a/src/include/cadef.h +++ b/src/include/cadef.h @@ -131,8 +131,8 @@ HDRVERSIONID(cadefh, "@(#) $Id$") * recommended that the following MACROS be used to access them. * */ -#define ca_field_type(CHID) ((CHID)->type) -#define ca_element_count(CHID) ((CHID)->count) +#define ca_field_type(CHID) (ca_get_field_type(CHID)) +#define ca_element_count(CHID) (ca_get_element_count(CHID)) #define ca_name(CHID) ((READONLY char *)((CHID)+1)) /* * the odd cast here removes const (and allows past practice @@ -196,9 +196,9 @@ typedef void caArh(); */ struct channel_in_use{ ELLNODE node; /* list ptrs */ - short type; /* database field type */ + short privType; /* database field type */ #define TYPENOTCONN (-1) /* the type when disconnected */ - unsigned short count; /* array element count */ + unsigned short privCount; /* array element count */ union{ unsigned sid; /* server id */ struct dbAddr *paddr; /* database address */ @@ -308,6 +308,9 @@ struct exception_handler_args{ #ifdef CAC_ANSI_FUNC_PROTO +epicsShareFunc short epicsShareAPI ca_get_field_type (chid chan); +epicsShareFunc unsigned short epicsShareAPI ca_get_element_count (chid chan); + /************************************************************************/ /* Perform Library Initialization */ /* */ @@ -1064,7 +1067,8 @@ epicsShareFunc int epicsShareAPI ca_replace_printf_handler ( #endif /*CA_DONT_INCLUDE_STDARGH*/ #else /* CAC_ANSI_FUNC_PROTO */ - +epicsShareFunc short epicsShareAPI ca_get_field_type (); +epicsShareFunc unsigned short epicsShareAPI ca_get_element_count (); epicsShareFunc int epicsShareAPI ca_task_initialize (); epicsShareFunc int epicsShareAPI ca_task_exit (); epicsShareFunc int epicsShareAPI ca_search_and_connect ();