NT changes and (long) cast problem fixed

This commit is contained in:
Jeff Hill
1995-02-16 22:34:06 +00:00
parent 1ea57db276
commit 35b0e4aaba
8 changed files with 243 additions and 38 deletions

View File

@@ -52,10 +52,9 @@ IF_DEPEN, -
VMS_DEPEN, -
ELLLIB, -
BUCKETLIB, -
NEXTFIELDSUBR, -
ENVSUBR, -
TSSUBR, -
GENSUBR, -
NEXTFIELDSUBR, -
CATIME, -
ACCTST
$ endif
@@ -76,10 +75,9 @@ IF_DEPEN, -
VMS_DEPEN, -
BSD_DEPEN, -
BUCKETLIB, -
NEXTFIELDSUBR, -
TSSUBR, -
ENVSUBR, -
GENSUBR, -
NEXTFIELDSUBR, -
ELLLIB
$! Link the test programs
$ call link acctst

View File

@@ -559,7 +559,7 @@ int ca_os_independent_init (void)
sec = (unsigned) CA_RECAST_DELAY;
ca_static->ca_conn_retry_delay.tv_sec = sec;
ca_static->ca_conn_retry_delay.tv_usec =
(long) (CA_RECAST_DELAY-sec)*USEC_PER_SEC;
(long) ((CA_RECAST_DELAY-sec)*USEC_PER_SEC);
ellInit(&ca_static->ca_iiuList);
ellInit(&ca_static->ca_ioeventlist);
@@ -1109,7 +1109,7 @@ int APIENTRY ca_search_and_connect
sec = (int) CA_RECAST_DELAY;
ca_static->ca_conn_retry_delay.tv_sec = sec;
ca_static->ca_conn_retry_delay.tv_usec =
(long) (CA_RECAST_DELAY-sec)*USEC_PER_SEC;
(long) ((CA_RECAST_DELAY-sec)*USEC_PER_SEC);
UNLOCK;
@@ -2722,11 +2722,11 @@ int APIENTRY ca_pend(ca_real timeout, int early)
/*
* Allow for CA background labor
*/
remaining = (long) min(SELECT_POLL, remaining);
remaining = min(SELECT_POLL, remaining);
}
tmo.tv_sec = (long) remaining;
tmo.tv_usec = (long) (remaining-tmo.tv_sec)*USEC_PER_SEC;
tmo.tv_usec = (long) ((remaining-tmo.tv_sec)*USEC_PER_SEC);
cac_block_for_io_completion(&tmo);
}
}

View File

@@ -469,7 +469,7 @@ void mark_server_available(struct in_addr *pnet_addr)
delay += CA_RECAST_DELAY;
idelay = (long) delay;
ca_delay.tv_sec = idelay;
ca_delay.tv_usec = (long) (delay-idelay) * USEC_PER_SEC;
ca_delay.tv_usec = (long) ((delay-idelay) * USEC_PER_SEC);
next = cac_time_sum(&currentTime, &ca_delay);
diff = cac_time_diff(

View File

@@ -1592,7 +1592,7 @@ void ntohf(float *pNet, float *pHost)
#endif /*CA_FLOAT_MIT*/
#if !defined(CA_FLOAT_MIT)
#if defined(CA_FLOAT_IEEE) && 0
/*
* htond ()
@@ -1600,6 +1600,7 @@ void ntohf(float *pNet, float *pHost)
*/
void htond (double *IEEEhost, double *IEEEnet)
{
#ifdef CA_LITTLE_ENDIAN
ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost;
ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet;
ca_uint32_t tmp;
@@ -1612,6 +1613,9 @@ void htond (double *IEEEhost, double *IEEEnet)
tmp = pHost[0];
pNet[0] = htonl (pHost[1]);
pNet[1] = htonl (tmp);
#else
*IEEEnet = *IEEEhost;
#endif
}
/*
@@ -1620,6 +1624,7 @@ void htond (double *IEEEhost, double *IEEEnet)
*/
void ntohd (double *IEEEnet, double *IEEEhost)
{
#ifdef CA_LITTLE_ENDIAN
ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost;
ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet;
ca_uint32_t tmp;
@@ -1632,6 +1637,9 @@ void ntohd (double *IEEEnet, double *IEEEhost)
tmp = pNet[0];
pHost[0] = ntohl (pNet[1]);
pHost[1] = htonl (tmp);
#else
*IEEEhost = *IEEEnet;
#endif
}
/*
@@ -1658,7 +1666,7 @@ void htonf (float *IEEEhost, float *IEEEnet)
*pNet = htonl (*pHost);
}
#endif /* not CA_MIT_FLOAT*/
#endif /* IEEE float and little endian */

View File

@@ -219,7 +219,7 @@ int net_proto
IPPROTO_TCP,
TCP_NODELAY,
(char *)&true,
sizeof true);
sizeof(true));
if(status < 0){
free(piiu);
status = socket_close(sock);
@@ -443,7 +443,6 @@ int net_proto
piiu->host_name_str,
"<<unknown host>>",
sizeof(piiu->host_name_str)-1);
break;
default:

View File

@@ -40,13 +40,14 @@ static char *sccsId = "@(#) $Id$";
#include <assert.h>
#ifdef _WINDOWS
#include <winsock.h>
# include <winsock.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
/*

View File

@@ -134,11 +134,8 @@ static char *os_depenhSccsId = "$Id$";
#endif
/*
* Big endin architecture is assumed. Otherwise set "CA_LITTLE_ENDIAN".
*
* IEEE floating point architecture assumed. Set "CA_FLOAT_MIT" if
* appropriate. No other floating point formats currently
* supported.
* Here are the definitions for architecture dependent byte ordering
* and floating point format
*/
#if defined(VAX)
# define CA_FLOAT_MIT

View File

@@ -2,6 +2,7 @@
* $Id$
* Author: Jeffrey O. Hill, Chris Timossi
* hill@luke.lanl.gov
* CATimossi@lbl.gov
* (505) 665 1831
* Date: 9-93
*
@@ -31,12 +32,24 @@
*
*/
/*
* Windows includes
*/
#include <process.h>
#define ENV_PRIVATE_DATA
#include "iocinf.h"
#ifndef _WINDOWS
#error This source is specific to DOS/WINDOS
#endif
static int get_subnet_mask ( char SubNetMaskStr[256]);
static int RegTcpParams (char IpAddr[256], char SubNetMask[256]);
static int RegKeyData (CHAR *RegPath, HANDLE hKeyRoot, LPSTR lpzValueName,
LPDWORD lpdwType, LPBYTE lpbData, LPDWORD lpcbData );
/*
* cac_gettimeval
@@ -135,7 +148,8 @@ void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV)
*/
int cac_os_depen_init(struct ca_static *pcas)
{
int status;
int status;
WSADATA WsaData;
ca_static = pcas;
@@ -146,16 +160,17 @@ int cac_os_depen_init(struct ca_static *pcas)
* allow error to be returned to sendto()
* instead of handling disconnect at interrupt
*/
signal(SIGPIPE,SIG_IGN);
/* signal(SIGPIPE,SIG_IGN); */
# ifdef _WINSOCKAPI_
status = WSAStartup(MAKEWORD(1,1), &WsaData));
status = WSAStartup(MAKEWORD(1,1), &WsaData);
assert (status==0);
# endif
status = ca_os_independent_init ();
return status;
return status;
}
@@ -180,12 +195,12 @@ void cac_os_depen_exit (struct ca_static *pcas)
*/
char *localUserName()
{
int length;
char *pName;
char *pTmp;
int length;
char *pName;
char *pTmp;
pName = "Joe PC";
length = strlen(pName)+1;
pName = getenv("USERNAME");
length = strlen(pName)+1;
pTmp = malloc(length);
if(!pTmp){
@@ -211,8 +226,13 @@ void ca_spawn_repeater()
* running in the repeater process
* if here
*/
pImageName = "caRepeater";
status = system(pImageName);
pImageName = "caRepeater.exe";
//status = system(pImageName);
//Need to check if repeater is already loaded
//For now, start Repeater from a command line, not here
status = 0;
//status = _spawnlp(_P_DETACH,pImageName,"");
if(status<0){
ca_printf("!!WARNING!!\n");
ca_printf("Unable to locate the executable \"%s\".\n",
@@ -235,9 +255,192 @@ void caSetDefaultPrintfHandler ()
/*
* DllMain ()
*
* Network interface routines
*
*/
BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
/*
* local_addr()
*
* return 127.0.0.1
* (the loop back address)
*/
int local_addr (SOCKET s, struct sockaddr_in *plcladdr)
{
ca_uint32_t loopBackAddress = 0x7f000001;
plcladdr->sin_family = AF_INET;
plcladdr->sin_port = 0;
plcladdr->sin_addr.s_addr = ntohl (loopBackAddress);
return OK;
}
/*
* caDiscoverInterfaces()
*
* This routine is provided with the address of an ELLLIST a socket
* and a destination port number. When the routine returns there
* will be one additional inet address (a caAddrNode) in the list
* for each inet interface found that is up and isnt a loop back
* interface. If the interface supports broadcast then I add its
* broadcast address to the list. If the interface is a point to
* point link then I add the destination address of the point to
* point link to the list. In either case I set the port number
* in the address node to the port supplied in the argument
* list.
*
* LOCK should be applied here for (pList)
* (this is also called from the server)
*/
void caDiscoverInterfaces(ELLLIST *pList, SOCKET socket, int port)
{
struct sockaddr_in localAddr;
struct sockaddr_in InetAddr;
struct in_addr bcast_addr;
caAddrNode *pNode;
int status;
pNode = (caAddrNode *) calloc(1,sizeof(*pNode));
if(!pNode){
return;
}
broadcast_addr(&bcast_addr);
pNode->destAddr.inetAddr.sin_addr.s_addr = bcast_addr.s_addr; //broadcast addr
pNode->destAddr.inetAddr.sin_port = htons(port);
pNode->destAddr.inetAddr.sin_family = AF_INET;
//pNode->srcAddr.inetAddr = 0 ;//localAddr;
/*
* LOCK applied externally
*/
ellAdd(pList, &pNode->node);
}
int
broadcast_addr( struct in_addr *pcastaddr )
{
char netmask[256], lhostname[80];
static struct in_addr castaddr;
int status;
static char init = FALSE;
struct hostent *phostent;
unsigned long laddr;
if (init) {
*pcastaddr = castaddr;
return OK;
}
gethostname(lhostname,sizeof(lhostname));
phostent = gethostbyname(lhostname);
if (!phostent) {
return MYERRNO;
}
if (status = get_subnet_mask(netmask))
return ERROR;
laddr = *( (unsigned long *) phostent->h_addr_list[0]);
castaddr.s_addr = (laddr & inet_addr(netmask)) | ~inet_addr(netmask);
if (!init){
init = TRUE;
*pcastaddr = castaddr;
}
return OK;
}
static int get_subnet_mask ( char SubNetMaskStr[256])
{
char localadr[256];
return RegTcpParams (localadr, SubNetMaskStr);
}
static int RegTcpParams (char IpAddrStr[256], char SubNetMaskStr[256])
{
#define MAX_VALUE_NAME 128
static CHAR ValueName[MAX_VALUE_NAME];
static CHAR RegPath[256];
DWORD cbDataLen;
CHAR cbData[256];
DWORD dwType;
int status;
static char IpAddr[256], SubNetMask[256];
cbDataLen = sizeof(cbData);
strcpy(RegPath,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\1");
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "ServiceName", &dwType, cbData, &cbDataLen);
if (status) {
strcpy(RegPath,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\01");
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "ServiceName", &dwType, cbData, &cbDataLen);
if (status)
return status;
}
strcpy(RegPath,"SYSTEM\\CurrentControlSet\\Services\\");
strcat(RegPath,cbData);
strcat(RegPath,"\\Parameters\\Tcpip");
cbDataLen = sizeof(IpAddr);
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "IPAddress", &dwType, IpAddr, &cbDataLen);
if (status)
return status;
strcpy(IpAddrStr,IpAddr);
cbDataLen = sizeof(SubNetMask);
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "SubnetMask", &dwType, SubNetMask, &cbDataLen);
if (status)
return status;
strcpy(SubNetMaskStr,SubNetMask);
return 0;
}
static int RegKeyData (CHAR *RegPath, HANDLE hKeyRoot, LPSTR lpzValueName,
LPDWORD lpdwType, LPBYTE lpbData, LPDWORD lpcbData )
{
HKEY hKey;
DWORD retCode;
DWORD dwcClassLen = MAX_PATH;
// OPEN THE KEY.
retCode = RegOpenKeyEx (hKeyRoot, // Key handle at root level.
RegPath, // Path name of child key.
0, // Reserved.
KEY_QUERY_VALUE, // Requesting read access.
&hKey); // Address of key to be returned.
if (retCode)
{
//wsprintf (Buf, "Error: RegOpenKeyEx = %d", retCode);
return -1;
}
retCode = RegQueryValueEx (hKey, // Key handle returned from RegOpenKeyEx.
lpzValueName, // Name of value.
NULL, // Reserved, dword = NULL.
lpdwType, // Type of data.
lpbData, // Data buffer.
lpcbData); // Size of data buffer.
if (retCode)
{
//wsprintf (Buf, "Error: RegQIK = %d, %d", retCode, __LINE__);
return -2;
}
return 0;
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
int status;
WSADATA WsaData;
@@ -276,4 +479,3 @@ BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
return TRUE;
}