00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #include <DOS.H>
00094 #include <STDLIB.H>
00095 #include "CLIB/TCPIPAPI.H"
00096 #include "CLIB/TCPIP.H"
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 int tcp_connect(char *DestIPStr, unsigned int ClientPort, unsigned int HostPort, int *error)
00114 {
00115 struct sockaddr_in addr;
00116 unsigned long DestIPAddr;
00117 int sd;
00118 int dummyerror;
00119
00120
00121 sd = opensocket(SOCK_STREAM,error);
00122 if (sd==-1 || *error!=0)
00123 {
00124 return -1;
00125 }
00126
00127 addr.sin_family = PF_INET;
00128 addr.sin_port = htons(ClientPort);
00129 addr.sin_addr.s_addr = 0;
00130 if (ClientPort!=0)
00131 {
00132 bind(sd, (struct sockaddr *)&addr, error);
00133 if (*error!=0)
00134 {
00135 closesocket(sd, &dummyerror);
00136 return -1;
00137 }
00138 }
00139 addr.sin_port = htons(HostPort);
00140
00141
00142 *error = inet_addr(DestIPStr,&DestIPAddr);
00143 if (*error!=0)
00144 {
00145 closesocket(sd, &dummyerror);
00146 return -1;
00147 }
00148 addr.sin_addr.s_addr = DestIPAddr;
00149
00150
00151 connect(sd, (struct sockaddr *) &addr, error);
00152 if (*error!=0)
00153 {
00154 closesocket(sd, &dummyerror);
00155 return -1;
00156 };
00157
00158 *error = 0;
00159 return sd;
00160
00161 }
00162
00163
00164
00165
00166
00167
00168 int accept(int sd, struct sockaddr * addressPtr, int *error)
00169 {
00170
00171 union REGS inregs;
00172 union REGS outregs;
00173
00174 *error = 0;
00175
00176 inregs.h.ah = API_ACCEPT;
00177 inregs.x.bx = sd;
00178
00179 inregs.x.dx = FP_SEG(addressPtr);
00180 inregs.x.si = FP_OFF(addressPtr);
00181
00182 int86(TCPIPVECT,&inregs,&outregs);
00183
00184 if(outregs.x.dx == (unsigned int)API_ERROR)
00185 {
00186 *error = outregs.x.ax;
00187 return API_ERROR;
00188 }
00189
00190 *error = 0;
00191 return outregs.x.ax;
00192 }
00193
00194
00195
00196
00197 void api_sleep(unsigned int howlong)
00198 {
00199 union REGS inregs;
00200 union REGS outregs;
00201
00202 inregs.h.ah = API_SLEEP;
00203 inregs.x.bx = howlong;
00204 int86(TCPIPVECT,&inregs,&outregs);
00205 }
00206
00207
00208
00209 int bind(int sd, struct sockaddr * addressPtr, int *error)
00210 {
00211
00212 union REGS inregs;
00213 union REGS outregs;
00214
00215 *error = 0;
00216 inregs.h.ah = API_BIND;
00217 inregs.x.bx = sd;
00218 inregs.x.dx = FP_SEG(addressPtr);
00219 inregs.x.si = FP_OFF(addressPtr);
00220 int86(TCPIPVECT,&inregs,&outregs);
00221
00222 if(outregs.x.dx == (unsigned int)API_ERROR)
00223 {
00224 *error = outregs.x.ax;
00225 }
00226 return outregs.x.dx;
00227 }
00228
00229
00230
00231 int connect(int sd, struct sockaddr * addressPtr, int *error)
00232 {
00233
00234 union REGS inregs;
00235 union REGS outregs;
00236
00237
00238 *error = 0;
00239
00240 inregs.h.ah = API_CONNECT;
00241 inregs.x.bx = sd;
00242 inregs.x.dx = FP_SEG(addressPtr);
00243 inregs.x.si = FP_OFF(addressPtr);
00244 int86(TCPIPVECT,&inregs,&outregs);
00245
00246 if(outregs.x.dx == (unsigned int)API_ERROR)
00247 {
00248 *error = outregs.x.ax;
00249
00250 }
00251 return outregs.x.dx;
00252 }
00253
00254
00255
00256
00257
00258 int closesocket(int sd, int *error)
00259 {
00260
00261 union REGS inregs;
00262 union REGS outregs;
00263
00264 inregs.h.ah = API_CLOSESOCKET;
00265 inregs.x.bx = sd;
00266 int86(TCPIPVECT,&inregs,&outregs);
00267
00268 if(outregs.x.dx==(unsigned int)API_ERROR)
00269 {
00270 *error = outregs.x.ax;
00271 return API_ERROR;
00272 }
00273 *error = 0;
00274 return outregs.x.dx;
00275 }
00276
00277
00278
00279
00280 int GetWaitingBytes(int sd, int *error)
00281 {
00282 union REGS inregs;
00283 union REGS outregs;
00284
00285 inregs.h.ah = API_GETRCV_BYTES;
00286 inregs.x.bx = sd;
00287 int86(TCPIPVECT,&inregs,&outregs);
00288
00289 if(outregs.x.dx==(unsigned int)API_ERROR)
00290 {
00291 *error = outregs.x.ax;
00292 return API_ERROR;
00293 }
00294 *error = 0;
00295 return outregs.x.ax;
00296 }
00297
00298
00299
00300 unsigned int htons(unsigned int value)
00301 {
00302
00303 asm
00304 {
00305 mov ax,value
00306 ror ax, 8
00307 }
00308 return (unsigned short)_AX;
00309 }
00310
00311
00312
00313
00314 int listen(int sd,int backlog, int *error)
00315 {
00316 union REGS inregs;
00317 union REGS outregs;
00318
00319 inregs.h.ah = API_LISTEN;
00320 inregs.x.bx = sd;
00321 inregs.x.cx = backlog;
00322
00323 int86(TCPIPVECT,&inregs,&outregs);
00324
00325 if(outregs.x.dx == (unsigned int)API_ERROR)
00326 {
00327 *error = outregs.x.ax;
00328 return API_ERROR;
00329 }
00330 *error = 0;
00331 return 0;
00332 }
00333
00334
00335
00336 int inet_addr(char * IPAddressStringPtr, unsigned long * IPAddress)
00337 {
00338 union REGS inregs;
00339 union REGS outregs;
00340 struct SREGS sregs;
00341
00342 inregs.h.ah = API_INETADDR;
00343 inregs.x.bx = FP_SEG(IPAddressStringPtr);
00344 inregs.x.si = FP_OFF(IPAddressStringPtr);
00345 sregs.es = FP_SEG(IPAddress);
00346 inregs.x.di = FP_OFF(IPAddress);
00347 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00348 return outregs.x.dx;
00349 }
00350
00351
00352
00353 int InetToAscii(unsigned long * IPAddress, char * IPAddressStringPtr)
00354 {
00355
00356 union REGS inregs;
00357 union REGS outregs;
00358 struct SREGS sregs;
00359
00360 inregs.h.ah = API_INETTOASCII;
00361 inregs.x.bx = FP_SEG(IPAddress);
00362 inregs.x.si = FP_OFF(IPAddress);
00363 sregs.es = FP_SEG(IPAddressStringPtr);
00364 inregs.x.di = FP_OFF(IPAddressStringPtr);
00365 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00366 return 0;
00367 }
00368
00369
00370
00371 int recvfrom(int sd, char * bufptr, int bufLen, int flags,
00372 unsigned long timeout,struct sockaddr * fromPtr, int *error)
00373 {
00374 int fromLen;
00375 struct recv_params R;
00376 union REGS inregs;
00377 union REGS outregs;
00378
00379
00380 fromLen = sizeof(struct sockaddr_in);
00381 R.bufferPtr = bufptr;
00382 R.bufferLength = bufLen;
00383 R.flags = flags;
00384 R.fromPtr = (struct sockaddr *)fromPtr;
00385 R.fromlengthPtr = &fromLen;
00386 R.timeout = timeout;
00387
00388
00389 inregs.h.ah = API_RECVFROM;
00390 inregs.x.bx = sd;
00391 inregs.x.dx = FP_SEG(&R);
00392 inregs.x.si = FP_OFF(&R);
00393 int86(TCPIPVECT,&inregs,&outregs);
00394
00395 if(outregs.x.dx == (unsigned int)API_ERROR)
00396 {
00397 *error = outregs.x.ax;
00398 return API_ERROR;
00399 }
00400
00401 *error = 0;
00402 return outregs.x.ax;
00403 }
00404
00405
00406
00407 int recv(int sd, char * bufptr, int bufLen, int flags, unsigned long timeout,
00408 int *error)
00409 {
00410
00411 struct recv_params R;
00412 union REGS inregs;
00413 union REGS outregs;
00414
00415
00416 R.bufferPtr = bufptr;
00417 R.bufferLength = bufLen;
00418 R.flags = flags;
00419 R.timeout = timeout;
00420 R.fromPtr = NULL;
00421 R.fromlengthPtr = NULL;
00422
00423 inregs.h.ah = API_RECV;
00424 inregs.x.bx = sd;
00425 inregs.x.dx = FP_SEG(&R);
00426 inregs.x.si = FP_OFF(&R);
00427 int86(TCPIPVECT,&inregs,&outregs);
00428
00429 if(outregs.x.dx == (unsigned int)API_ERROR)
00430 {
00431 *error = outregs.x.ax;
00432 return API_ERROR;
00433 }
00434 *error = 0;
00435 return outregs.x.ax;
00436 }
00437
00438
00439
00440 int ResetConnection(int sd, int *error)
00441 {
00442 union REGS inregs;
00443 union REGS outregs;
00444
00445 inregs.h.ah = API_RESETCONNECTION;
00446 inregs.x.bx = sd;
00447 int86(TCPIPVECT,&inregs,&outregs);
00448 if(outregs.x.dx == (unsigned int)API_ERROR)
00449 {
00450 *error = outregs.x.ax;
00451 return API_ERROR;
00452 }
00453 *error = 0;
00454 return 0;
00455 }
00456
00457
00458
00459 int sendto(int sd, char * bufptr, int bufLen, int flags,
00460 const struct sockaddr * toPtr, int *error)
00461 {
00462
00463 int toLen;
00464 struct send_params S;
00465 union REGS inregs;
00466 union REGS outregs;
00467
00468
00469 toLen = sizeof(struct sockaddr_in);
00470 S.bufferPtr = bufptr;
00471 S.bufferLength = bufLen;
00472 S.flags = flags;
00473 S.toPtr = (struct sockaddr *)toPtr;
00474 S.tolengthPtr = &toLen;
00475
00476 inregs.h.ah = API_SENDTO;
00477 inregs.x.bx = sd;
00478 inregs.x.dx = FP_SEG(&S);
00479 inregs.x.si = FP_OFF(&S);
00480 int86(TCPIPVECT,&inregs,&outregs);
00481
00482 if(outregs.x.dx == (unsigned int)API_ERROR)
00483 {
00484 *error = outregs.x.ax;
00485 return API_ERROR;
00486 }
00487 *error = 0;
00488 return outregs.x.ax;
00489 }
00490
00491
00492
00493
00494 int send(int sd, char * bufptr, int bufLen, int flags, int *error)
00495 {
00496 struct send_params S;
00497 union REGS inregs;
00498 union REGS outregs;
00499
00500
00501 S.bufferPtr = bufptr;
00502 S.bufferLength = bufLen;
00503 S.flags = flags;
00504 S.toPtr = NULL;
00505 S.tolengthPtr = NULL;
00506
00507 inregs.h.ah = API_SEND;
00508 inregs.x.bx = sd;
00509 inregs.x.dx = FP_SEG(&S);
00510 inregs.x.si = FP_OFF(&S);
00511 int86(TCPIPVECT,&inregs,&outregs);
00512
00513 if(outregs.x.dx == (unsigned int)API_ERROR)
00514 {
00515 *error = outregs.x.ax;
00516 return API_ERROR;
00517 }
00518 *error = 0;
00519 return outregs.x.ax;
00520 }
00521
00522
00523
00524 int setlinger(int sd, int seconds, int *error)
00525 {
00526 union REGS inregs;
00527 union REGS outregs;
00528 inregs.h.ah = API_SETLINGER;
00529 inregs.x.bx = sd;
00530 inregs.x.cx = seconds;
00531
00532 int86(TCPIPVECT,&inregs,&outregs);
00533
00534 if(outregs.x.dx == (unsigned int)API_ERROR)
00535 {
00536 *error = outregs.x.ax;
00537 return API_ERROR;
00538 }
00539 *error = 0;
00540 return outregs.x.ax;
00541 }
00542
00543
00544
00545 int setreuse(int sd,int *error)
00546 {
00547 union REGS inregs;
00548 union REGS outregs;
00549 inregs.h.ah = API_SETREUSE;
00550 inregs.x.bx = sd;
00551
00552 int86(TCPIPVECT,&inregs,&outregs);
00553
00554 if(outregs.x.dx == (unsigned int)API_ERROR)
00555 {
00556 *error = outregs.x.ax;
00557 return API_ERROR;
00558 }
00559 *error = 0;
00560 return outregs.x.ax;
00561 }
00562
00563
00564
00565
00566
00567
00568 unsigned char Get_TCP_Socket_State(unsigned int localPort, unsigned long * remoteIP, unsigned int * remotePort)
00569 {
00570
00571 union REGS inregs;
00572 union REGS outregs;
00573 struct SREGS sregs;
00574
00575 inregs.h.ah = API_GET_TCP_STATE;
00576 inregs.x.bx = localPort;
00577 sregs.es = FP_SEG(remoteIP);
00578 inregs.x.di = FP_OFF(remoteIP);
00579 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00580 *remotePort = outregs.x.cx;
00581 return outregs.h.al;
00582 }
00583
00584
00585
00586 int get_socketerror(int sd)
00587 {
00588 union REGS inregs;
00589 union REGS outregs;
00590
00591 inregs.h.ah = API_GET_SOCKETERROR;
00592 inregs.x.bx = sd;
00593
00594 int86(TCPIPVECT,&inregs,&outregs);
00595
00596 return outregs.x.ax;
00597 }
00598
00599
00600
00601
00602 int Set_IP_Type_Of_Service(int sd, unsigned char TOS, int *error)
00603 {
00604
00605 union REGS inregs;
00606 union REGS outregs;
00607
00608 *error=0;
00609 inregs.h.ah = API_SETIPTOS;
00610 inregs.h.al = TOS;
00611 inregs.x.bx = sd;
00612 int86(TCPIPVECT,&inregs,&outregs);
00613 if((int)outregs.x.ax==-1)
00614 {
00615 *error = outregs.x.dx;
00616 }
00617 return outregs.x.ax;
00618
00619 }
00620
00621
00622
00623
00624
00625 int setsockopt(int sd, SetSocketOption *sockoptptr, int *error)
00626 {
00627 union REGS inregs;
00628 union REGS outregs;
00629 struct SREGS sregs;
00630
00631 *error=0;
00632 inregs.h.ah = API_SETSOCKOPT;
00633 inregs.x.bx = sd;
00634 sregs.es = FP_SEG(sockoptptr);
00635 inregs.x.di = FP_OFF(sockoptptr);
00636 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00637
00638 if((int)outregs.x.dx==-1)
00639 {
00640 *error = outregs.x.ax;
00641 }
00642 return outregs.x.dx;
00643 }
00644
00645 int getsockopt(int sd, GetSocketOption *sockoptptr, int *error)
00646 {
00647 union REGS inregs;
00648 union REGS outregs;
00649 struct SREGS sregs;
00650
00651 *error=0;
00652 inregs.h.ah = API_GETSOCKOPT;
00653 inregs.x.bx = sd;
00654 sregs.es = FP_SEG(sockoptptr);
00655 inregs.x.di = FP_OFF(sockoptptr);
00656 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00657
00658 if((int)outregs.x.dx==-1)
00659 {
00660 *error = outregs.x.ax;
00661 }
00662 return outregs.x.dx;
00663 }
00664
00665
00666
00667
00668
00669 int Set_Blocking_Mode(int sd, unsigned char mode, int *error)
00670 {
00671
00672 union REGS inregs;
00673 union REGS outregs;
00674
00675 *error=0;
00676 inregs.h.ah = API_SETBLOCKINGMODE;
00677 inregs.h.al = mode;
00678 inregs.x.bx = sd;
00679 int86(TCPIPVECT,&inregs,&outregs);
00680 if((int)outregs.x.dx==-1)
00681 {
00682 *error = outregs.x.ax;
00683 }
00684 return outregs.x.dx;
00685 }
00686
00687
00688
00689
00690 int opensocket(unsigned char type, int *error)
00691 {
00692
00693 union REGS inregs;
00694 union REGS outregs;
00695
00696 inregs.h.ah = API_OPENSOCKET;
00697 inregs.h.al = type;
00698
00699
00700 int86(TCPIPVECT,&inregs,&outregs);
00701
00702 if(outregs.x.dx == (unsigned int)API_ERROR)
00703 {
00704 *error = outregs.x.ax;
00705 return API_ERROR;
00706 }
00707 *error = 0;
00708 return outregs.x.ax;
00709 }
00710
00711
00712
00713
00714
00715 int RegisterCallbackFunction(int sd, void * funcptr, int eventflagmask ,int *error)
00716 {
00717
00718 union REGS inregs;
00719 union REGS outregs;
00720 struct SREGS sregs;
00721
00722 *error=0;
00723 inregs.h.ah = API_REGISTERCALLBACK;
00724 inregs.x.bx = sd;
00725 inregs.x.cx = eventflagmask;
00726 sregs.es = FP_SEG(funcptr);
00727 inregs.x.di = FP_OFF(funcptr);
00728 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00729
00730 if((int)outregs.x.dx==-1)
00731 {
00732 *error = outregs.x.ax;
00733 }
00734 return outregs.x.dx;
00735 }
00736
00737
00738
00739
00740
00741
00742 int PPP_Client_Installed(void)
00743 {
00744
00745 union REGS inregs;
00746 union REGS outregs;
00747
00748 inregs.h.ah = PPPCLIENT_INSTALLED;
00749 int86(TCPIPVECT,&inregs,&outregs);
00750
00751 return outregs.x.ax;
00752 }
00753
00754
00755
00756
00757
00758 int PPP_Client_Open(PPPClient_Init * ptr, int *error)
00759 {
00760
00761 union REGS inregs;
00762 union REGS outregs;
00763 struct SREGS sregs;
00764
00765 *error=0;
00766
00767 inregs.h.ah = PPPCLIENT_OPEN;
00768 sregs.es = FP_SEG(ptr);
00769 inregs.x.di = FP_OFF(ptr);
00770 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00771
00772 if((int)outregs.x.dx==-1)
00773 {
00774 *error = outregs.x.ax;
00775 }
00776
00777 return outregs.x.dx;
00778 }
00779
00780
00781
00782
00783
00784
00785 int PPP_Client_Close(int *error)
00786 {
00787
00788 union REGS inregs;
00789 union REGS outregs;
00790
00791 *error=0;
00792 inregs.h.ah = PPPCLIENT_CLOSE;
00793 int86(TCPIPVECT,&inregs,&outregs);
00794
00795 if((int)outregs.x.dx==-1)
00796 {
00797 *error = outregs.x.ax;
00798 }
00799 return outregs.x.ax;
00800 }
00801
00802
00803
00804
00805 int PPP_Client_GetStatus(int *error)
00806 {
00807
00808 union REGS inregs;
00809 union REGS outregs;
00810
00811 inregs.h.ah = PPPCLIENT_GET_STATUS;
00812 int86(TCPIPVECT,&inregs,&outregs);
00813
00814 if((int)outregs.x.ax==-1)
00815 {
00816 *error = outregs.x.dx;
00817 }
00818 return outregs.x.ax;
00819 }
00820
00821
00822
00823
00824
00825 int PPP_Client_SetOptions(PPP_Option *ptr)
00826 {
00827
00828 union REGS inregs;
00829 union REGS outregs;
00830 struct SREGS segregs;
00831
00832 inregs.h.ah = PPPCLIENT_SET_OPTIONS;
00833 segregs.es = FP_SEG(ptr);
00834 inregs.x.di = FP_OFF(ptr);
00835 int86x(TCPIPVECT,&inregs,&outregs,&segregs);
00836
00837 return outregs.x.ax;
00838 }
00839
00840
00841
00842
00843
00844 int PPP_Client_Get_DNSIP(unsigned long * IPaddress, int primary_sec, int *error)
00845 {
00846
00847 union REGS inregs;
00848 union REGS outregs;
00849 struct SREGS sregs;
00850
00851 *error=0;
00852
00853 inregs.h.ah = PPPCLIE_GET_DNSIP;
00854 inregs.x.bx = primary_sec;
00855 sregs.es = FP_SEG(IPaddress);
00856 inregs.x.di = FP_OFF(IPaddress);
00857 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00858
00859 if((int)outregs.x.ax==-1)
00860 {
00861 *error = outregs.x.dx;
00862 }
00863
00864 return outregs.x.dx;
00865 }
00866
00867
00868
00869
00870
00871 int PPP_Server_Installed(void)
00872 {
00873 union REGS inregs;
00874 union REGS outregs;
00875
00876 inregs.h.ah = PPPSERVER_INSTALLED;
00877 int86(TCPIPVECT,&inregs,&outregs);
00878 return outregs.x.ax;
00879 }
00880
00881
00882
00883
00884
00885 int PPP_Server_Suspend(int timeoutsecs, int *error)
00886 {
00887
00888 union REGS inregs;
00889 union REGS outregs;
00890
00891 *error=0;
00892 inregs.h.ah = PPPSERVER_SUSPEND;
00893 inregs.x.bx = timeoutsecs;
00894 int86(TCPIPVECT,&inregs,&outregs);
00895 if((int)outregs.x.ax==-1)
00896 {
00897 *error = outregs.x.dx;
00898 }
00899 return outregs.x.ax;
00900
00901 }
00902
00903
00904
00905
00906 int PPP_Server_Activate(int timeoutsecs,int *error)
00907 {
00908 union REGS inregs;
00909 union REGS outregs;
00910
00911 *error=0;
00912 inregs.h.ah = PPPSERVER_ACTIVATE;
00913 inregs.x.bx = timeoutsecs;
00914 int86(TCPIPVECT,&inregs,&outregs);
00915 if((int)outregs.x.ax==-1)
00916 {
00917 *error = outregs.x.dx;
00918 }
00919 return outregs.x.ax;
00920 }
00921
00922
00923
00924
00925
00926 int PPP_Server_Get_Cfg(PPP_IPCfg_Data *ptr , int *error)
00927 {
00928 union REGS inregs;
00929 union REGS outregs;
00930 struct SREGS sregs;
00931
00932 *error=0;
00933
00934 inregs.h.ah = PPPSERVER_GET_CFG;
00935 sregs.es = FP_SEG(ptr);
00936 inregs.x.di = FP_OFF(ptr);
00937 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00938
00939 if((int)outregs.x.ax==-1)
00940 {
00941 *error = outregs.x.dx;
00942 }
00943 return outregs.x.ax;
00944 }
00945
00946
00947
00948 int PPP_Server_GetStatus(void)
00949 {
00950
00951 union REGS inregs;
00952 union REGS outregs;
00953
00954
00955 inregs.h.ah = PPPSERVER_GET_STATUS;
00956
00957 int86(TCPIPVECT,&inregs,&outregs);
00958 return outregs.x.ax;
00959 }
00960
00961
00962
00963
00964 int PPP_Server_SetOptions(PPP_Option *ptr)
00965 {
00966
00967 union REGS inregs;
00968 union REGS outregs;
00969 struct SREGS segregs;
00970
00971 inregs.h.ah = PPPSERVER_SET_OPTIONS;
00972 segregs.es = FP_SEG(ptr);
00973 inregs.x.di = FP_OFF(ptr);
00974 int86x(TCPIPVECT,&inregs,&outregs,&segregs);
00975
00976 return outregs.x.ax;
00977 }
00978
00979
00980
00981
00982
00983 int Get_SNMP_Data(unsigned char which , void * * snmp_mib_ptr)
00984 {
00985 union REGS inregs;
00986 union REGS outregs;
00987 struct SREGS sregs;
00988
00989
00990 inregs.h.ah = API_SNMP_GET;
00991 inregs.h.al = which;
00992 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
00993
00994 if((int)outregs.x.ax==0)
00995 {
00996 *snmp_mib_ptr = (void *)MK_FP(sregs.es,outregs.x.di);
00997 return 0;
00998 }
00999 return outregs.x.ax;
01000 }
01001
01002
01003
01004
01005 int Get_FTP_Login_Counters(unsigned long * * FTP_Login_Count,unsigned long * * FTP_Login_failCount)
01006 {
01007 union REGS inregs;
01008 union REGS outregs;
01009 struct SREGS sregs;
01010
01011
01012 inregs.h.ah = API_FTP_GET_LOGIN;
01013 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01014
01015 *FTP_Login_Count = NULL;
01016 *FTP_Login_failCount = NULL;
01017 if(outregs.x.ax==0)
01018 {
01019 *FTP_Login_Count = (unsigned long *)MK_FP(sregs.es,outregs.x.di);
01020 *FTP_Login_failCount = (unsigned long *)MK_FP(sregs.ds,outregs.x.si);
01021 }
01022 return outregs.x.ax;
01023 }
01024
01025
01026
01027
01028 int Get_Telnet_Login_Counters(unsigned long * * Telnet_Login_Count,unsigned long * * Telnet_Login_failCount)
01029 {
01030 union REGS inregs;
01031 union REGS outregs;
01032 struct SREGS sregs;
01033
01034
01035 *Telnet_Login_Count = NULL;
01036 *Telnet_Login_failCount = NULL;
01037
01038 inregs.h.ah = API_TELNET_GET_LOGIN;
01039 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01040
01041 if(outregs.x.ax==0)
01042 {
01043 *Telnet_Login_Count = (unsigned long *)MK_FP(sregs.es,outregs.x.di);
01044 *Telnet_Login_failCount = (unsigned long *)MK_FP(sregs.ds,outregs.x.si);
01045 }
01046 return outregs.x.ax;
01047 }
01048
01049
01050
01051
01052 int Set_FTPServer_Idle_Timeout( unsigned timeout )
01053 {
01054 union REGS inregs;
01055 union REGS outregs;
01056
01057 inregs.h.ah = SET_SERVER_IDLE_TIMEOUT;
01058 inregs.h.al = 0x00;
01059 inregs.x.bx = 0x00;
01060 inregs.x.dx = timeout;
01061 int86( TCPIPVECT, &inregs, &outregs );
01062
01063 return outregs.x.ax;
01064 }
01065
01066
01067
01068
01069 int Set_TelnetServer_Idle_Timeout( unsigned timeout )
01070 {
01071 union REGS inregs;
01072 union REGS outregs;
01073
01074 inregs.h.ah = SET_SERVER_IDLE_TIMEOUT;
01075 inregs.h.al = 0x00;
01076 inregs.x.bx = 0x01;
01077 inregs.x.dx = timeout;
01078 int86( TCPIPVECT, &inregs, &outregs );
01079
01080 return outregs.x.ax;
01081 }
01082
01083
01084
01085
01086 unsigned Get_FTPServer_Idle_Timeout(void)
01087 {
01088 union REGS inregs;
01089 union REGS outregs;
01090
01091 inregs.h.ah = SET_SERVER_IDLE_TIMEOUT;
01092 inregs.h.al = 0x01;
01093 inregs.x.bx = 0x00;
01094 int86( TCPIPVECT, &inregs, &outregs );
01095
01096 return outregs.x.dx;
01097 }
01098
01099
01100
01101
01102
01103 unsigned Get_TelnetServer_Idle_Timeout(void)
01104 {
01105 union REGS inregs;
01106 union REGS outregs;
01107
01108 inregs.h.ah = SET_SERVER_IDLE_TIMEOUT;
01109 inregs.h.al = 0x01;
01110 inregs.x.bx = 0x01;
01111 int86( TCPIPVECT, &inregs, &outregs );
01112
01113 return outregs.x.dx;
01114 }
01115
01116
01117
01118
01119 int Get_Telnet_State(int *error)
01120 {
01121 union REGS inregs;
01122 union REGS outregs;
01123
01124 *error=0;
01125 inregs.h.ah = API_GET_TELNET_STATE;
01126 int86(TCPIPVECT,&inregs,&outregs);
01127 if((int)outregs.x.dx==-1)
01128 {
01129 *error = outregs.x.dx;
01130 }
01131 return outregs.x.ax;
01132 }
01133
01134
01135
01136
01137
01138 void Get_Installed_Servers(unsigned int * AX, unsigned int *DX)
01139 {
01140 union REGS inregs;
01141 union REGS outregs;
01142
01143 inregs.h.ah = GET_INSTALLED_SERVERS;
01144 int86(TCPIPVECT,&inregs,&outregs);
01145 *AX = outregs.x.ax;
01146 *DX = outregs.x.dx;
01147 }
01148
01149
01150
01151
01152
01153
01154 int Reconfigure_ethernet(void)
01155 {
01156 union REGS inregs;
01157 union REGS outregs;
01158 inregs.h.ah = REINIT_ETHERNET;
01159 int86(TCPIPVECT,&inregs,&outregs);
01160 return outregs.x.ax;
01161 }
01162
01163
01164
01165
01166 int DHCP_use(unsigned char dhcp_use)
01167 {
01168 union REGS inregs;
01169 union REGS outregs;
01170 inregs.h.ah = DHCP_USE;
01171 inregs.h.al = dhcp_use;
01172 int86(TCPIPVECT,&inregs,&outregs);
01173 return outregs.x.ax;
01174 }
01175
01176
01177
01178
01179 void Get_DHCP_Status(unsigned int * dhcp_use, unsigned int *dhcp_stat)
01180 {
01181 union REGS inregs;
01182 union REGS outregs;
01183 inregs.h.ah = DHCP_STAT;
01184 int86(TCPIPVECT,&inregs,&outregs);
01185 *dhcp_use = outregs.x.ax;
01186 *dhcp_stat = outregs.x.dx;
01187 }
01188
01189
01190
01191
01192
01193 void Get_DHCP_Status_Ext(unsigned int * dhcp_use, unsigned int *dhcp_stat, UserEthDhcp_Entry * * dhcpptr)
01194 {
01195 union REGS inregs;
01196 union REGS outregs;
01197 struct SREGS sregs;
01198 inregs.h.ah = DHCP_STAT;
01199 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01200 *dhcp_use = outregs.x.ax;
01201 *dhcp_stat = outregs.x.dx;
01202 if(outregs.x.dx==1)
01203 *dhcpptr = (tag_UserDhcpEthEntry*)MK_FP(sregs.es,outregs.x.di);
01204 else
01205 *dhcpptr = NULL;
01206 }
01207
01208
01209
01210 void Get_IPConfig(char *IP, char * Mask, char *Gateway)
01211 {
01212 union REGS inregs;
01213 union REGS outregs;
01214 struct SREGS sregs;
01215
01216 inregs.h.ah = 0x01;
01217 sregs.es = FP_SEG(IP);
01218 inregs.x.dx = FP_OFF(IP);
01219 int86x(0xA0,&inregs,&outregs,&sregs);
01220
01221 inregs.h.ah = 0x03;
01222 sregs.es = FP_SEG(Mask);
01223 inregs.x.dx = FP_OFF(Mask);
01224 int86x(0xA0,&inregs,&outregs,&sregs);
01225
01226
01227 inregs.h.ah = 0x05;
01228 sregs.es = FP_SEG(Gateway);
01229 inregs.x.dx = FP_OFF(Gateway);
01230 int86x(0xA0,&inregs,&outregs,&sregs);
01231 }
01232
01233
01234
01235
01236 void Set_IPConfig(char *IP, char * Mask, char *Gateway)
01237 {
01238 union REGS inregs;
01239 union REGS outregs;
01240 struct SREGS sregs;
01241
01242 inregs.h.ah = 0x02;
01243 sregs.es = FP_SEG(IP);
01244 inregs.x.dx = FP_OFF(IP);
01245 int86x(0xA0,&inregs,&outregs,&sregs);
01246
01247 inregs.h.ah = 0x04;
01248 sregs.es = FP_SEG(Mask);
01249 inregs.x.dx = FP_OFF(Mask);
01250 int86x(0xA0,&inregs,&outregs,&sregs);
01251
01252 inregs.h.ah = 0x06;
01253 sregs.es = FP_SEG(Gateway);
01254 inregs.x.dx = FP_OFF(Gateway);
01255 int86x(0xA0,&inregs,&outregs,&sregs);
01256 }
01257
01258
01259
01260
01261 void Get_TCPIP_Statistics(Packet_Count * * Packet_Count_Pointer)
01262 {
01263 union REGS inregs;
01264 union REGS outregs;
01265 struct SREGS sregs;
01266
01267 inregs.h.ah = TCPIP_STATISTICS;
01268 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01269
01270 *Packet_Count_Pointer = (Packet_Count *)MK_FP(sregs.es,outregs.x.di);
01271
01272 }
01273
01274
01275
01276
01277 int Ping_Open(Ping * pingptr, int * errorcode)
01278 {
01279 union REGS inregs;
01280 union REGS outregs;
01281 struct SREGS sregs;
01282
01283
01284 inregs.h.ah = PING_OPEN;
01285 sregs.es = FP_SEG(pingptr);
01286 inregs.x.di = FP_OFF(pingptr);
01287 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01288 *errorcode=outregs.x.ax;
01289 return outregs.x.dx;
01290 }
01291
01292
01293
01294
01295
01296 int Ping_Close(int sd)
01297 {
01298 union REGS inregs;
01299 union REGS outregs;
01300
01301 inregs.h.ah = PING_CLOSE;
01302 inregs.x.bx = sd;
01303 int86(TCPIPVECT,&inregs,&outregs);
01304 return outregs.x.dx;
01305 }
01306
01307
01308
01309 int Ping_Statistics(Ping * pingptr)
01310 {
01311 union REGS inregs;
01312 union REGS outregs;
01313 struct SREGS sregs;
01314
01315
01316
01317 inregs.h.ah = PING_STATISTICS;
01318 sregs.es = FP_SEG(pingptr);
01319 inregs.x.di = FP_OFF(pingptr);
01320 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01321 return outregs.x.dx;
01322 }
01323
01324
01325
01326
01327 void Get_TCPIP_Memory_Status(unsigned long * total, unsigned long * used)
01328 {
01329 union REGS inregs;
01330 union REGS outregs;
01331 struct SREGS sregs;
01332
01333 inregs.h.ah = GET_MEMORY_INFO;
01334 sregs.es = FP_SEG(total);
01335 inregs.x.di = FP_OFF(total);
01336 sregs.ds = FP_SEG(used);
01337 inregs.x.si = FP_OFF(used);
01338 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01339 }
01340
01341
01342
01343
01344 int AddDefaultGateway( int interface , unsigned long * Gateway, int * errorcode)
01345 {
01346 union REGS inregs;
01347 union REGS outregs;
01348 struct SREGS sregs;
01349
01350 inregs.h.ah = ADD_DEFAULT_GATEWAY;
01351 inregs.x.bx = interface;
01352 sregs.es = FP_SEG(Gateway);
01353 inregs.x.di = FP_OFF(Gateway);
01354
01355 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01356 *errorcode=outregs.x.ax;
01357 return outregs.x.dx;
01358 }
01359
01360
01361
01362
01363 int DelDefaultGateway(unsigned long * Gateway, int * errorcode)
01364 {
01365 union REGS inregs;
01366 union REGS outregs;
01367 struct SREGS sregs;
01368
01369 inregs.h.ah = DEL_DEFAULT_GATEWAY;
01370 sregs.es = FP_SEG(Gateway);
01371 inregs.x.di = FP_OFF(Gateway);
01372
01373 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01374 *errorcode=outregs.x.ax;
01375 return outregs.x.dx;
01376 }
01377
01378
01379
01380
01381 int GetDefaultGateway(unsigned long * Gateway, int * errorcode)
01382 {
01383 union REGS inregs;
01384 union REGS outregs;
01385 struct SREGS sregs;
01386
01387 inregs.h.ah = GET_DEFAULT_GATEWAY;
01388 sregs.es = FP_SEG(Gateway);
01389 inregs.x.di = FP_OFF(Gateway);
01390
01391 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01392 *errorcode=outregs.x.ax;
01393 return outregs.x.dx;
01394 }
01395
01396
01397
01398
01399
01400 int AddStaticRoute(int interface, Route_Entry * route, int * errorcode)
01401 {
01402 union REGS inregs;
01403 union REGS outregs;
01404 struct SREGS sregs;
01405
01406 inregs.h.ah = ADD_STATIC_ROUTE;
01407 inregs.x.bx = interface;
01408 sregs.es = FP_SEG(route);
01409 inregs.x.di = FP_OFF(route);
01410
01411 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01412 *errorcode=outregs.x.ax;
01413 return outregs.x.dx;
01414 }
01415
01416
01417
01418
01419
01420 int DelStaticRoute(int interface, Route_Entry * route, int * errorcode)
01421 {
01422 union REGS inregs;
01423 union REGS outregs;
01424 struct SREGS sregs;
01425
01426 inregs.h.ah = DEL_STATIC_ROUTE;
01427 inregs.x.bx = interface;
01428 sregs.es = FP_SEG(route);
01429 inregs.x.di = FP_OFF(route);
01430
01431 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01432 *errorcode=outregs.x.ax;
01433 return outregs.x.dx;
01434 }
01435
01436
01437
01438
01439
01440 int Add_IGMP_Membership(unsigned long * MulticastIP, unsigned char * MacAddress, int * errorcode)
01441 {
01442 union REGS inregs;
01443 union REGS outregs;
01444 struct SREGS sregs;
01445
01446 inregs.h.ah = ADD_IGMP_MEMBERSHIP;
01447
01448 sregs.es = FP_SEG(MulticastIP);
01449 inregs.x.di = FP_OFF(MulticastIP);
01450 sregs.ds = FP_SEG(MacAddress);
01451 inregs.x.si = FP_OFF(MacAddress);
01452
01453 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01454 *errorcode=outregs.x.ax;
01455 return outregs.x.dx;
01456 }
01457
01458
01459
01460 int Drop_IGMP_Membership(unsigned long * MulticastIP, int * errorcode)
01461 {
01462 union REGS inregs;
01463 union REGS outregs;
01464 struct SREGS sregs;
01465
01466 inregs.h.ah = DROP_IGMP_MEMBERSHIP;
01467 sregs.es = FP_SEG(MulticastIP);
01468 inregs.x.di = FP_OFF(MulticastIP);
01469
01470 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01471 *errorcode=outregs.x.ax;
01472 return outregs.x.dx;
01473 }
01474
01475
01476
01477
01478
01479 int IPMulticast_to_MacAddr(unsigned long * MulticastIP, unsigned char * MacAddress, int * errorcode)
01480 {
01481 union REGS inregs;
01482 union REGS outregs;
01483 struct SREGS sregs;
01484
01485 inregs.h.ah = MCASTIP_TO_MACADDR;
01486 sregs.es = FP_SEG(MulticastIP);
01487 inregs.x.di = FP_OFF(MulticastIP);
01488 sregs.ds = FP_SEG(MacAddress);
01489 inregs.x.si = FP_OFF(MacAddress);
01490
01491 int86x(TCPIPVECT,&inregs,&outregs,&sregs);
01492 *errorcode=outregs.x.ax;
01493 return outregs.x.dx;
01494 }
01495
01496
01497
01498
01499
01500
01501
01502
01503