#include "prolog.h"
#include "cprolog.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "servdef.h"
#include "srvip.h"
#include "brdcast.h"
#include "errors.h"
#include "database.h"
Include dependency graph for iplib.c:
Go to the source code of this file.
Defines | |
#define | MTU 1460 |
#define | MAX_RCVBUF 0x10000 |
#define | MAX_SNDBUF (MAX_RCVBUF / 2) |
#define | RDATE_TIMEOUT 1 |
#define | IPPORT_TIMESERVER 37 |
#define | SEVENTY_YEARS 2208988800UL |
Functions | |
void | FD_MERGE (fd_set fdsrc, fd_set *fddst) |
EXPORT int | _SystemAssignBufferSpace (UINT32 rcvBufferSpace, UINT32 sndBufferSpace) |
TCPBCKT * | findBucket (int sck) |
TCPBCKT * | getBucket (int sck) |
void | freeBucket (int sck) |
void | CloseConnectionSocket (int sck) |
int | SendIPData (CLN *cln, BYTE *data) |
int | listenUDP (int *s, unsigned short port) |
UINT16 | GetPortOffset (RPCFecStruct *f) |
UINT32 | getmyipaddr (void) |
int | tUDPCall (int fecindex, BYTE *buf, int timout) |
time_t | getUnixTime (char *tsHost) |
Variables | |
int | gtUDPPort = UDP_PORT |
int | gtTCPPort = TCP_PORT |
int | gtNetSrvPort = NETSRV_PORT |
int | gtGCastPort = GCAST_PORT |
int | gtMCastPort = MCAST_PORT |
int | gtUDPClnPort = UDP_CLN_PORT |
char * | gtNetSrvAddr = NETSRV_ADDR |
char * | gtNetLclBcast = NETBCST_ADDR |
char * | gtMCastAddr = MCAST_ADDR |
char * | gtGCastAddr = GCAST_ADDR |
int | gtMCastTTL = MCAST_TTL |
UINT32 | TCPcount = 0 |
UINT32 | UDPcount = 0 |
UINT32 | SPXcount = 0 |
UINT32 | IPXcount = 0 |
UINT32 | BRDcount = 0 |
char | clientaddr [30] |
int | TCPloaded = 0 |
int | IPXloaded = 0 |
sockaddr_in | prod_name |
fd_set | ext_set |
int | externalFdSets = 0 |
int | maxFdSets = MAX_FDSETS |
int | max_rcvbuf = MAX_RCVBUF |
int | max_sndbuf = MAX_SNDBUF |
TCPBCKT * | bcktList = NULL |
UINT32 | sendtoErrcnt = 0 |
in_addr | tMCastAddr |
in_addr | tGCastAddr |
in_addr | tNetSrvAddr |
sockaddr_in | tMCastAddrSck |
sockaddr_in | tGCastAddrSck |
sockaddr_in | tNetSrvAddrSck |
char | TimeServerHost [64] |
#define IPPORT_TIMESERVER 37 |
#define RDATE_TIMEOUT 1 |
#define SEVENTY_YEARS 2208988800UL |
EXPORT int _SystemAssignBufferSpace | ( | UINT32 | rcvBufferSpace, | |
UINT32 | sndBufferSpace | |||
) |
Definition at line 147 of file iplib.c.
References buffer_too_small.
00148 { 00149 if (rcvBufferSpace > 0) 00150 { 00151 if (rcvBufferSpace < 0x1000) return buffer_too_small; 00152 max_rcvbuf = (int)rcvBufferSpace; 00153 } 00154 if (sndBufferSpace > 0) 00155 { 00156 if (sndBufferSpace < 0x1000) return buffer_too_small; 00157 max_sndbuf = (int)sndBufferSpace; 00158 } 00159 00160 return 0; 00161 }
void CloseConnectionSocket | ( | int | sck | ) |
Definition at line 197 of file iplib.c.
References closeIPConnectionToFec(), connTable, conset, Consumers, freeBucket(), nConnectionTableEntries, nconsumer, nTCPsck, rwset, soclose, TCPsck, and TCPsocket.
Referenced by getConsumerIPAddress(), and SendIPData().
00198 { 00199 int i; 00200 unsigned int usck = (unsigned int)sck; 00201 00202 FD_CLR(usck,&rwset); FD_CLR(usck,&conset); 00203 freeBucket(sck); 00204 00205 for (i=0; i<nTCPsck; i++) /* socket on the server side ? */ 00206 { 00207 if (sck == TCPsck[i]) 00208 { 00209 if (sck != 0) soclose(sck); 00210 TCPsck[i] = 0; 00211 nTCPsck--; 00212 break; 00213 } 00214 } 00215 for (; i<nTCPsck; i++) TCPsck[i] = TCPsck[i+1]; 00216 for (i=0; i<nconsumer; i++) if (Consumers[i]->sck == sck) Consumers[i]->sck = 0; 00217 for (i=0; i<nConnectionTableEntries; i++) 00218 { 00219 if (connTable[i]->TCPsocket == sck) /* socket on the client side ? */ 00220 { 00221 closeIPConnectionToFec(connTable[i]->FECindex); 00222 return; 00223 } 00224 } 00225 }
Here is the call graph for this function:
Here is the caller graph for this function:
void FD_MERGE | ( | fd_set | fdsrc, | |
fd_set * | fddst | |||
) |
Definition at line 96 of file iplib.c.
References BYTE.
Referenced by AcceptIP(), and doUDPConsumer().
00097 { 00098 int i; 00099 for (i=0; i<(int)sizeof(fd_set); i++) 00100 ((BYTE *)fddst)[i] |= ((BYTE *)&fdsrc)[i]; 00101 }
Here is the caller graph for this function:
TCPBCKT* findBucket | ( | int | sck | ) |
Definition at line 165 of file iplib.c.
References bcktList, tcpbckt::nxt, and tcpbckt::sck.
Referenced by freeBucket(), and getConsumerIPAddress().
00166 { 00167 TCPBCKT *bckt=NULL; 00168 for (bckt=bcktList; bckt != NULL && bckt->sck != sck; bckt=bckt->nxt); 00169 return bckt; 00170 }
Here is the caller graph for this function:
void freeBucket | ( | int | sck | ) |
Definition at line 184 of file iplib.c.
References bcktList, findBucket(), tcpbckt::nxt, and SystemFree.
Referenced by CheckConnections(), CloseConnectionSocket(), and SendSubBuffer().
00185 { 00186 TCPBCKT *bckt,*b; 00187 if ((bckt=findBucket(sck)) == NULL) return; 00188 if (bckt == bcktList) bcktList = bckt->nxt; 00189 else 00190 { 00191 for (b=bcktList; b != NULL && b->nxt != bckt; b = b->nxt); 00192 if (b == NULL || b->nxt == NULL) return; 00193 b->nxt = bckt->nxt; 00194 } 00195 SystemFree(bckt); 00196 }
Here is the call graph for this function:
Here is the caller graph for this function:
TCPBCKT* getBucket | ( | int | sck | ) |
Definition at line 171 of file iplib.c.
References bcktList, tcpbckt::nxt, tcpbckt::sck, and SystemCalloc.
Referenced by AcceptIPC(), and AssignConnectionSocket().
00172 { 00173 TCPBCKT *bckt=NULL; 00174 for (bckt=bcktList; bckt != NULL; bckt=bckt->nxt) 00175 if (bckt->sck == sck) return bckt; 00176 if ((bckt=(TCPBCKT *)SystemCalloc(1,sizeof(TCPBCKT))) != NULL) 00177 { 00178 bckt->sck = sck; 00179 bckt->nxt = bcktList; 00180 bcktList = bckt; 00181 } 00182 return bckt; 00183 }
Here is the caller graph for this function:
UINT32 getmyipaddr | ( | void | ) |
Definition at line 472 of file iplib.c.
References IPPORT_ECHO, soclose, TRUE, and UINT32.
Referenced by AcceptIPC(), fixFecProtocol(), listenUDP(), and SendSubBuffer().
00473 { 00474 static char hname[30]; 00475 static struct hostent *hent; 00476 static struct sockaddr_in stlclAddr; 00477 static struct sockaddr_in strmtAddr; 00478 static int done = 0; 00479 static UINT32 myip = 0; 00480 int sck; 00481 unsigned int nRet=sizeof(struct sockaddr); 00482 00483 if (done) return myip; 00484 # if defined(WINNT) 00485 /* do this here, just in case this is called prior to SystemInit() ! */ 00486 if (!WinsockLoaded()) return -1; 00487 # endif 00488 stlclAddr.sin_addr.s_addr = INADDR_ANY; 00489 # if !defined(MSDOS) 00490 if (gethostname(hname,30) != -1) 00491 { 00492 if ((hent=gethostbyname(hname)) != NULL) 00493 { 00494 stlclAddr.sin_addr.s_addr = *((UINT32 *)(hent->h_addr)); 00495 } 00496 } 00497 # endif 00498 if (stlclAddr.sin_addr.s_addr == INADDR_ANY) 00499 { 00500 if ((sck=(int)socket(AF_INET, SOCK_DGRAM, 0)) > 0) 00501 { 00502 strmtAddr.sin_family = AF_INET; 00503 strmtAddr.sin_port = htons(IPPORT_ECHO); 00504 strmtAddr.sin_addr.s_addr = inet_addr("128.127.50.1"); 00505 if (connect(sck,(struct sockaddr *)&strmtAddr,sizeof(struct sockaddr)) != -1) 00506 { 00507 getsockname(sck,(struct sockaddr *)&stlclAddr,(int *)&nRet); 00508 } 00509 soclose(sck); 00510 } 00511 } 00512 myip = stlclAddr.sin_addr.s_addr; 00513 done = TRUE; 00514 return stlclAddr.sin_addr.s_addr; 00515 }
Here is the caller graph for this function:
UINT16 GetPortOffset | ( | RPCFecStruct * | f | ) |
Definition at line 464 of file iplib.c.
References RPCFecStruct::Port, RPCFecStruct::PortOffset, and UINT16.
Referenced by connectTCP(), getIncomingFecIndex(), SendSubBuffer(), and tUDPCall().
00465 { 00466 UINT16 poff; 00467 poff = (f->Port[1] << 8) | f->Port[0]; 00468 if (poff == 0) poff = f->PortOffset; 00469 return poff; 00470 }
Here is the caller graph for this function:
time_t getUnixTime | ( | char * | tsHost | ) |
Definition at line 641 of file iplib.c.
References ccerr, connection_timeout, erlst, feclog(), IPPORT_TIMESERVER, NGdebug, non_existent, RDATE_TIMEOUT, SEVENTY_YEARS, soclose, soerrno, soioctl, soperror, soread, tcp_connect_error, tcp_socket_error, and UINT32.
00642 { 00643 int sockfd=-1; /* socket fd's */ 00644 static struct sockaddr_in serverAddr; 00645 UINT32 tmptime; 00646 static struct hostent *host = NULL; 00647 static int firstCallLogged = 0; 00648 int cc = 0,mode = 1,done = 0; 00649 time_t interim; 00650 00651 if (firstCallLogged == 0) 00652 { 00653 firstCallLogged++; 00654 feclog("using TIME Server %s", tsHost == NULL ? "local host" : tsHost); 00655 } 00656 if (tsHost == NULL) return time(NULL); 00657 if (host == NULL) 00658 { 00659 memset(&serverAddr,0,sizeof(serverAddr)); 00660 serverAddr.sin_family = AF_INET; 00661 serverAddr.sin_port = htons(IPPORT_TIMESERVER); 00662 if ((host=gethostbyname(tsHost)) == NULL && 00663 (host=gethostbyaddr(tsHost,(int)strlen(tsHost),AF_INET)) == NULL) 00664 { 00665 if (NGdebug) soperror("time svr gethost"); 00666 ccerr(non_existent); 00667 } 00668 memcpy(&serverAddr.sin_addr,host->h_addr,sizeof(struct in_addr)); 00669 } 00670 00671 if ((sockfd=(int)socket(AF_INET,SOCK_STREAM,0)) < 0 ) 00672 { 00673 if (NGdebug) soperror("time svr socket"); 00674 ccerr(tcp_socket_error); 00675 } 00676 if (soioctl(sockfd,FIONBIO,(char *)&mode)) 00677 { 00678 if (NGdebug) soperror("time svr soioctl"); 00679 ccerr(tcp_socket_error); 00680 } 00681 for (time(&interim); 00682 (connect(sockfd,(struct sockaddr *)&serverAddr,sizeof(serverAddr))<0);) 00683 { 00684 if (soerrno == EISCONN) break; 00685 if (time(NULL) > interim + RDATE_TIMEOUT) 00686 { 00687 if (NGdebug) soperror("time svr connect"); 00688 ccerr(tcp_connect_error); 00689 } 00690 } 00691 00692 while (time(NULL) < interim + RDATE_TIMEOUT && !done) 00693 { 00694 if (soread(sockfd,(char *)&tmptime,sizeof(UINT32)) == sizeof(UINT32) ) 00695 done = 1; 00696 } 00697 if (!done) 00698 { 00699 if (NGdebug > 1) soperror("soread"); 00700 ccerr(connection_timeout); 00701 } 00702 if (firstCallLogged == 1) 00703 { 00704 firstCallLogged++; 00705 feclog("got time from %s",tsHost); 00706 } 00707 00708 err: 00709 if (sockfd > 0) soclose(sockfd); 00710 if (cc) 00711 { 00712 if (firstCallLogged < 3) 00713 { 00714 firstCallLogged++; 00715 feclog("get time from %s : %s",tsHost,erlst[cc]); 00716 } 00717 return 0; 00718 } 00719 return (ntohl(tmptime) - SEVENTY_YEARS); /* convert to unix time */ 00720 }
Here is the call graph for this function:
int listenUDP | ( | int * | s, | |
unsigned short | port | |||
) |
Definition at line 346 of file iplib.c.
References argument_list_error, ccerr, FALSE, feclog(), getmyipaddr(), gtGCastAddr, gtGCastPort, gtMCastAddr, gtMCastPort, gtNetSrvAddr, gtNetSrvPort, gtUDPClnPort, POLLING, ServerCycleMode, SINT32, soclose, soerr, soioctl, soperror, TRUE, UDP_CLN_RANGE, and UINT16.
Referenced by initIPClient(), initTCP(), and tUDPCall().
00347 { 00348 struct sockaddr_in sck_name; 00349 int mode = 1,optval,optlen = sizeof(int), cc = 0; 00350 char txt[50]; 00351 unsigned short udpport; 00352 static UINT16 nextFreePort = 0; 00353 static int lInitDone = FALSE; 00354 SINT32 ip; 00355 # if defined(MSDOS) || defined(VXWORKS) 00356 int reuseFlg = TRUE; 00357 # else 00358 int reuseFlg = FALSE; 00359 # endif 00360 # ifndef NOT_MULTICASTING 00361 struct ip_mreq mreq; 00362 # endif 00363 00364 if (!lInitDone) /* always fill this in at initialization time for use by server code */ 00365 { 00366 lInitDone = TRUE; 00367 # if !defined(VXWORKS) && !defined(VAX_VMS) && !defined(NIOS) && !defined(MSDOS) 00368 ip = (SINT32)getmyipaddr(); 00369 ip |= 0xff000000; 00370 # else 00371 ip = (SINT32)(0xffffffff); 00372 # endif 00373 # ifdef NOT_MULTICASTING 00374 memcpy(&tNetSrvAddr,&ip,sizeof(struct in_addr)); /* service port */ 00375 # else 00376 ip = inet_addr(gtMCastAddr); 00377 memcpy(&tMCastAddr,&ip,sizeof(struct in_addr)); /* producer-subscriber */ 00378 ip = inet_addr(gtGCastAddr); 00379 memcpy(&tGCastAddr,&ip,sizeof(struct in_addr)); /* producer-consumer */ 00380 ip = inet_addr(gtNetSrvAddr); 00381 memcpy(&tNetSrvAddr,&ip,sizeof(struct in_addr)); /* service port */ 00382 tGCastAddrSck.sin_addr = tGCastAddr; 00383 tGCastAddrSck.sin_family = AF_INET; 00384 tGCastAddrSck.sin_port = htons((UINT16)gtGCastPort); 00385 # endif 00386 } 00387 if (s == NULL) ccerr(argument_list_error); 00388 if (nextFreePort == 0) nextFreePort = gtUDPClnPort; 00389 sprintf(txt,"UDP PORT %d: ",port); 00390 if ((*s=(int)socket(PF_INET,SOCK_DGRAM,0)) < 0) soerr("socket"); 00391 if (port == gtMCastPort || port == gtGCastPort || port == gtNetSrvPort) reuseFlg = TRUE; 00392 if (reuseFlg) 00393 { 00394 optval = 1; 00395 if (setsockopt(*s,SOL_SOCKET,SO_REUSEADDR,(char *)&optval,optlen)) soerr("REUSEADDR"); 00396 } 00397 # if defined(UNIX) || defined(WINNT) 00398 if (max_rcvbuf > 0) 00399 { 00400 optval = max_rcvbuf; 00401 if (setsockopt(*s,SOL_SOCKET,SO_RCVBUF,(char *)&optval,optlen)) soerr("RCVBUF"); 00402 } 00403 if (max_sndbuf) 00404 { 00405 optval = max_sndbuf; 00406 if (setsockopt(*s,SOL_SOCKET,SO_SNDBUF,(char *)&optval,optlen)) soerr("SNDBUF"); 00407 } 00408 # endif 00409 memset(&sck_name,0,sizeof(sck_name)); 00410 sck_name.sin_addr.s_addr = 0; 00411 sck_name.sin_family = AF_INET; 00412 00413 udpport = port ? port : nextFreePort; 00414 if (udpport == 0) goto portbound; 00415 bindport: 00416 sck_name.sin_port = htons(udpport); 00417 if (bind(*s,(struct sockaddr *)&sck_name,sizeof(sck_name))) 00418 { 00419 if (port == 0 && udpport++ < gtUDPClnPort + UDP_CLN_RANGE) goto bindport; 00420 soerr("bind"); 00421 } 00422 if (port == 0) nextFreePort = udpport + 1; 00423 portbound: 00424 # ifndef NOT_MULTICASTING 00425 if (port == gtMCastPort) /* join multicast group */ 00426 { 00427 mreq.imr_multiaddr.s_addr = tMCastAddr.s_addr; 00428 mreq.imr_interface.s_addr = htonl(INADDR_ANY); 00429 cc = setsockopt(*s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)&mreq,sizeof(mreq)); 00430 feclog("joining multicast group : %s",cc ? "failed" : "success"); 00431 } 00432 else if (port == gtGCastPort) /* join multicast group */ 00433 { 00434 mreq.imr_multiaddr.s_addr = tGCastAddr.s_addr; 00435 mreq.imr_interface.s_addr = htonl(INADDR_ANY); 00436 cc = setsockopt(*s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)&mreq,sizeof(mreq)); 00437 feclog("joining globals multicast group : %s",cc ? "failed" : "success"); 00438 } 00439 else if (port == gtNetSrvPort) /* join multicast group */ 00440 { 00441 mreq.imr_multiaddr.s_addr = tNetSrvAddr.s_addr; 00442 mreq.imr_interface.s_addr = htonl(INADDR_ANY); 00443 cc = setsockopt(*s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char *)&mreq,sizeof(mreq)); 00444 feclog("joining net services multicast group : %s",cc ? "failed" : "success"); 00445 } 00446 # endif 00447 if (ServerCycleMode == POLLING && soioctl(*s,FIONBIO,(char *)&mode)) soerr("NONBLOCKING"); 00448 feclog("%s bound to %d (socket %d %sblocking)", 00449 txt,ntohs(sck_name.sin_port),*s,ServerCycleMode == POLLING?" non-":" "); 00450 err: 00451 if (cc != 0) 00452 { 00453 soperror(txt); printf(">"); 00454 if (s != NULL) 00455 { 00456 if (*s != 0) soclose(*s); 00457 *s = 0; 00458 } 00459 feclog("%s socket error",txt); 00460 } 00461 return cc; 00462 }
Here is the call graph for this function:
Here is the caller graph for this function:
int SendIPData | ( | CLN * | cln, | |
BYTE * | data | |||
) |
Definition at line 266 of file iplib.c.
References cannot_select, ccerr, clientaddr, CloseConnectionSocket(), dbglog(), erlst, getProtocolAsString, inet_ntoa_b, CLN::IPaddress, isUnixSocket(), maxFdSets, net_write_error, NGdebug, PeekWord, CLN::sck, soperror, TCP, tcp_not_supported, tcp_socket_error, TCPloaded, CLN::transport, UDP_BUFFER_SIZE, use_stream_transport, CLN::userName, and writeto.
Referenced by SendToPeer(), and tUDPCall().
00267 { 00268 fd_set fdwset; 00269 struct timeval wait_to; 00270 int sck, cc = 0, retry = 0; 00271 char *strprot = getProtocolAsString(cln->transport); 00272 unsigned short msgsize = PeekWord(*(unsigned short *)data); 00273 00274 if (!TCPloaded) return tcp_not_supported; 00275 if (msgsize > UDP_BUFFER_SIZE) return use_stream_transport; 00276 if ((sck=cln->sck) <= 0) return tcp_socket_error; 00277 # if defined(UNIX) && !defined(NO_TINE_PIPE) 00278 if (isUnixSocket(sck)) goto SendIPretry; 00279 # endif 00280 SelectIPretry: 00281 FD_ZERO(&fdwset); FD_SET(sck,&fdwset); 00282 wait_to.tv_sec=0; wait_to.tv_usec=1000; 00283 if (select(maxFdSets,NULL,&fdwset,NULL,&wait_to) != 1) 00284 { 00285 sendtoErrcnt++; 00286 if (retry++ > 3) ccerr(cannot_select); 00287 goto SelectIPretry; 00288 } 00289 SendIPretry: 00290 if (writeto(sck,(char *)data,msgsize,0, 00291 (struct sockaddr *)&cln->IPaddress,sizeof(cln->IPaddress)) < 0) 00292 { 00293 sendtoErrcnt++; 00294 if (retry++ > 3) ccerr(net_write_error); 00295 goto SendIPretry; 00296 } 00297 err: 00298 if (NGdebug) 00299 { 00300 inet_ntoa_b(cln->IPaddress.sin_addr,clientaddr); 00301 if (cc) 00302 { 00303 soperror("sendto"); printf(">"); 00304 dbglog("%s error: %s",strprot,erlst[cc]); 00305 } 00306 else if (NGdebug > 2) 00307 { 00308 dbglog("%s: %d bytes to %s [%s]",strprot,msgsize,cln->userName,clientaddr); 00309 } 00310 } 00311 if (cc && cln->transport == TCP) CloseConnectionSocket(sck); 00312 return cc; 00313 }
Here is the call graph for this function:
Here is the caller graph for this function:
int tUDPCall | ( | int | fecindex, | |
BYTE * | buf, | |||
int | timout | |||
) |
Definition at line 518 of file iplib.c.
References BYTE, curNameServer, GetPortOffset(), gtUDPPort, illegal_protocol, RPCFecStruct::IPh_addr, IPX_BUFFER_SIZE, link_not_open, listenUDP(), maxFdSets, RPCFecStruct::Name, NameServer, NGdebug, non_existent_fec, PeekWord, prod_name, remitted_data_lost, RPCFec, SendIPData(), SINT32, soperror, SyncSocket, tcp_socket_error, udp_socket_error, and UINT16.
00519 { 00520 fd_set tset; 00521 struct timeval t_to; 00522 static struct sockaddr_in IPfec; 00523 static CLN cln; 00524 static UINT16 ltid = 0xffff; 00525 UINT16 tid; 00526 int cc,n,poff; 00527 unsigned int len; 00528 char s[64]; 00529 BYTE lclbuf[IPX_BUFFER_SIZE]; 00530 RPCFecStruct *rpcfec = fecindex ? &RPCFec[fecindex] : &NameServer[curNameServer]; 00531 00532 if (SyncSocket == 0) 00533 { 00534 if (listenUDP(&SyncSocket,0) != 0) 00535 { 00536 soperror("Listen SyncSocket"); 00537 return udp_socket_error; 00538 } 00539 } 00540 /* flush any input bytes that are somehow there ... */ 00541 FD_ZERO(&tset); FD_SET(SyncSocket,&tset); 00542 t_to.tv_sec=0; t_to.tv_usec=0; 00543 while (select(32,&tset,NULL,NULL,&t_to) > 0) 00544 { 00545 len = sizeof(IPfec); 00546 recvfrom(SyncSocket,(char *)lclbuf,IPX_BUFFER_SIZE,0,(struct sockaddr *)&IPfec,(int *)&len); 00547 } 00548 memset(&cln,0,sizeof(CLN)); 00549 strcpy(cln.userName,rpcfec->Name); 00550 if (!rpcfec->IPh_addr) return non_existent_fec; 00551 memset(&prod_name,0,sizeof(prod_name)); 00552 memcpy(&prod_name.sin_addr,&rpcfec->IPh_addr,sizeof(struct in_addr)); 00553 poff = GetPortOffset(rpcfec); 00554 prod_name.sin_family=AF_INET; 00555 prod_name.sin_port = htons((UINT16)(gtUDPPort + poff)); 00556 memcpy(&cln.IPaddress,&prod_name,sizeof(prod_name)); 00557 cln.sck = SyncSocket; 00558 00559 if ((cc=SendIPData(&cln,buf)) != 0) return cc; 00560 00561 lsnForDataGram: 00562 FD_ZERO(&tset); FD_SET(SyncSocket,&tset); 00563 t_to.tv_sec=timout/1000; 00564 # ifndef MSDOS 00565 t_to.tv_usec=((SINT32)timout%1000)*(SINT32)1000; 00566 # else 00567 t_to.tv_usec=((SINT32)timout%1000); 00568 # endif 00569 len = sizeof(IPfec); 00570 switch (select(maxFdSets,&tset,NULL,NULL,&t_to)) 00571 { 00572 case -1: 00573 if (NGdebug) 00574 { 00575 sprintf(s,"SyncSocket (%d) select (to : %d)",SyncSocket,timout); 00576 soperror(s); 00577 } 00578 return tcp_socket_error; 00579 case 0: 00580 return link_not_open; 00581 default: 00582 n = recvfrom(SyncSocket,(char *)buf,IPX_BUFFER_SIZE,0,(struct sockaddr *)&IPfec,(int *)&len); 00583 } 00584 if (n != PeekWord(*(short *)buf)) return remitted_data_lost; 00585 if ((cc=PeekWord(*(short *)&buf[6])) == illegal_protocol) return cc; 00586 if ((tid=PeekWord(*(UINT16 *)&buf[4])) == ltid) /* phantom block ! */ 00587 { 00588 goto lsnForDataGram; 00589 } 00590 ltid = tid; 00591 return 0; 00592 }
Here is the call graph for this function:
UINT32 BRDcount = 0 |
char clientaddr[30] |
Definition at line 86 of file iplib.c.
Referenced by AcceptIPC(), dumpIPNets(), getConsumerIPAddress(), SendIPBroadcast(), and SendIPData().
fd_set ext_set |
Definition at line 89 of file iplib.c.
Referenced by AcceptIP(), doUDPConsumer(), initIPClient(), and initTCP().
int externalFdSets = 0 |
char* gtGCastAddr = GCAST_ADDR |
int gtGCastPort = GCAST_PORT |
Definition at line 36 of file iplib.c.
Referenced by appendRegisteredNetsList(), getIPControlNets(), initIPClient(), ListenForIPNetGlobals(), and listenUDP().
char* gtMCastAddr = MCAST_ADDR |
int gtMCastPort = MCAST_PORT |
Definition at line 42 of file iplib.c.
Referenced by getNetworkClientFromList(), initIPClient(), ListenForIPMulticasts(), and listenUDP().
int gtMCastTTL = MCAST_TTL |
char* gtNetLclBcast = NETBCST_ADDR |
char* gtNetSrvAddr = NETSRV_ADDR |
int gtNetSrvPort = NETSRV_PORT |
int gtTCPPort = TCP_PORT |
int gtUDPClnPort = UDP_CLN_PORT |
int gtUDPPort = UDP_PORT |
Definition at line 18 of file iplib.c.
Referenced by getIncomingFecIndex(), initTCP(), SendSubBuffer(), and tUDPCall().
UINT32 IPXcount = 0 |
int IPXloaded = 0 |
int max_rcvbuf = MAX_RCVBUF |
int max_sndbuf = MAX_SNDBUF |
int maxFdSets = MAX_FDSETS |
Definition at line 95 of file iplib.c.
Referenced by AcceptIP(), doUDPConsumer(), getConsumerIPAddress(), initTCP(), IPDataReady(), IsInForeground(), SendIPBroadcast(), SendIPData(), and tUDPCall().
struct sockaddr_in prod_name |
UINT32 sendtoErrcnt = 0 |
UINT32 SPXcount = 0 |
UINT32 TCPcount = 0 |
Definition at line 83 of file iplib.c.
Referenced by activityQuery(), getConsumerIPAddress(), and outputServerStats().
int TCPloaded = 0 |
Definition at line 87 of file iplib.c.
Referenced by AcceptIP(), closeIPClients(), closeIPConnectionToFec(), closeIPServer(), doUDPConsumer(), initIPClient(), initTCP(), ListenForIPMulticasts(), ListenForIPNetGlobals(), SendIPBroadcast(), SendIPData(), and SendSubBuffer().
struct in_addr tGCastAddr |
struct sockaddr_in tGCastAddrSck |
char TimeServerHost[64] |
struct in_addr tMCastAddr |
struct sockaddr_in tMCastAddrSck |
struct in_addr tNetSrvAddr |
Definition at line 316 of file iplib.c.
Referenced by GetAddressFromNameServer(), and SendSubBuffer().
struct sockaddr_in tNetSrvAddrSck |
UINT32 UDPcount = 0 |
Definition at line 83 of file iplib.c.
Referenced by activityQuery(), getConsumerIPAddress(), and outputServerStats().