예제 #1
0
static char InitServer( void )
{
    putstring( "init server\r\n" );
    ServRespESRAddr = _ESR( ServResp );
    SAPBroadESRAddr = _ESR( SAPBroad );
    SAPWaitESRAddr = _ESR( SAPWait );

    ServECB.fragmentCount = 2;
    ServECB.fragmentDescriptor[1].address = &ServDummy;
    ServECB.fragmentDescriptor[1].size = sizeof( ServDummy );

    ServECB.ESRAddress = ServRespESRAddr;
    _IPXListenForPacket( &ServECB );

    _INITIPXECB( SAP );
    FillArray( SAPHead.destination.node, 0xff );
    SAPHead.destination.socket = SAP_SOCKET;
    SAPHead.infoType = _SWAPINT( 0x2 );
    SAPHead.serverType = DBG_SERVER_TYPE;
    _IPXGetInternetworkAddress( &SAPHead.address.network.a[0] );
    SAPHead.address.socket = SAPECB.socketNumber;
    SAPHead.intermediateNetworks = _SWAPINT( 0x1 );
    SAPECB.immediateAddress = SAPHead.destination.node;
    SAPECB.ESRAddress = SAPBroadESRAddr;
    _IPXSendPacket( &SAPECB );
    return( 1 );
}
예제 #2
0
void ServRespESR( void )
{
    if( Completed( ServECB ) && !InUse( RespECB )
            && (ServHead.length == _SWAPINT( sizeof( IPXHeader ) )
                || ServHead.length == _SWAPINT( sizeof( IPXHeader ) + 1 ) ) ) {
        _DBG_IPX(( "ServRespESR responding\r\n" ));
        RespHead.destination = ServHead.source;
        AssignArray( RespECB.immediateAddress , ServECB.immediateAddress );
        RespECB.fragmentDescriptor[1].address = &SPXSocket;
        CIPXSendPacket( &RespECB );
    }
    CIPXListen( &ServECB );
}
예제 #3
0
void ESRFUNC ServResp( void )
{
    if( ServECB.completionCode == 0
        && (ServHead.length == _SWAPINT( sizeof( IPXHeader ) )
         || ServHead.length == _SWAPINT( sizeof( IPXHeader ) + 1 ) )
        && RespECB.inUseFlag == 0 ) {
        RespHead.destination = ServHead.source;
        RespECB.immediateAddress = ServECB.immediateAddress;
        RespECB.fragmentDescriptor[1].address = &SPXSocket;
        _IPXSendPacket( &RespECB );
    }
    _IPXListenForPacket( &ServECB );
}
예제 #4
0
static trap_retval DoRemotePut( byte *snd, trap_elen len )
{
    WORD        rc;

putstring( "RemotePut\r\n" );
putconnstatus( Connection );
    if( len == 0 ) {
        _INITSPXECB( Send, 1, NULL, 0 );
    } else {
        _INITSPXECB( Send, 2, (char *)snd, len );
    }
    SendECB.hsem = (HSEM) &SendSem;
    SendHead.connectionCtl |= 0x10;
    SendHead.packetLen = _SWAPINT( sizeof( SendHead ) + len );
    DosSemSet( &SendSem );
    rc = SpxSendSequencedPacket( Connection, &SendECB );
    putrc( "SPXSendSequencedPacket", rc );

    for( ;; ) {
        /*
            I don't know what the 0x1001 status is - I can't find it
            in any documentation, but if we don't wait for it to clear,
            things mess up badly.
        */
        if( SendECB.status != SPX_SUCCESSFUL && !InUse( SendECB ) && SendECB.status != 0x1001 )
            break;
        rc = DosSemWait( &SendSem, 1000 );
        if( rc != ERROR_SEM_TIMEOUT ) {
            break;
        }
    }
    SendECB.hsem = 0;
putstring( "Done RemotePut\r\n" );
    return( len );
}
예제 #5
0
static char InitServer( void )
{
    ServECB.fragmentCount = 2;
    ServECB.fragmentDescriptor[1].address = &ServDummy;
    ServECB.fragmentDescriptor[1].size = sizeof( ServDummy );

    ServECB.ESRAddress = &ServRespESR;
    CIPXListen( &ServECB );

    SAPStruct.ASServerIDpacket.serverType = DBG_SERVER_TYPE;
    CIPXGetInternetworkAddress((BYTE*)&SAPStruct.ASServerIDpacket.serverAddress);
    AssignArray( SAPStruct.ASServerIDpacket.serverAddress.socket,
                 ServECB.socketNumber );
    SAPStruct.AS_ECB.ESRAddress = NULL;
    SAPStruct.AS_ECB.socketNumber = SAP_SOCKET_VALUE;
    FillArray( SAPStruct.AS_ECB.immediateAddress, '\xFF' );
    SAPStruct.AS_ECB.fragmentCount = 1;
    SAPStruct.AS_ECB.fragmentDescriptor[0].size = sizeof( IPXHeader ) +
            sizeof( SAPIdPacket );
    SAPStruct.AS_ECB.fragmentDescriptor[0].address = &SAPStruct.ASPacket;

    SAPStruct.ASPacket.packetType = 4;
    FillArray( SAPStruct.ASPacket.destination.network, 0 );
    FillArray( SAPStruct.ASPacket.destination.node, '\xFF' );
    {
        LONG        socket;

        socket = SAP_SOCKET;
        AssignArray( SAPStruct.ASPacket.destination.socket, socket );
    }

    SAPStruct.ASServerIDpacket.SAPPacketType = _SWAPINT( 2 );
    SAPStruct.ASServerIDpacket.interveningNetworks = _SWAPINT( 1 );

    CIPXSendPacket( &SAPStruct.AS_ECB );

    SAPTimer.TCallBackProcedure = (void (*)(LONG))Advertiser;
    SAPTimer.TCallBackEBXParameter = (LONG)&SAPTimer;
    SAPTimer.TCallBackWaitTime = 0;
    SAPTimer.TResourceTag = TimerTag;
    CScheduleInterruptTimeCallBack( &SAPTimer );

    return( 1 );
}
예제 #6
0
static trap_retval DoRemotePut( void *data, trap_elen len )
{
    _DBG_IPX(("RemotePut\r\n"));
    _INITSPXECB( Send, 2, data, len );
    SendHead.connectionControl |= 0x10;
    SendHead.length = _SWAPINT( sizeof( SendHead ) + len );
    CSPXSendSequencedPacket( Connection, &SendECB );
    while( InUse( SendECB ) )
        NothingToDo();
    return( len );
}
예제 #7
0
static trap_retval DoRemotePut( void *data, trap_elen len )
{
    _INITECB( SendECB, SendHead, 2, SPX );
    SendHead.connectControl |= 0x10;
    SendHead.length = _SWAPINT( sizeof( SendHead ) + len );
    SendECB.fragmentDescriptor[1].address = data;
    SendECB.fragmentDescriptor[1].size = len;
    _SPXSendSequencedPacket( Connection, &SendECB );
    WaitOn( SendECB );
    return( len );
}
예제 #8
0
static void far Broadcast( void )
{
    _INITIPXECB( SAP );
    FillArray( SAPHead.destNode, 0xff );
    SAPHead.destSocket = SAP_SOCKET;
    SAPHead.infoType = _SWAPINT( 0x2 );
    SAPHead.serverType = DBG_SERVER_TYPE;
    IpxGetInternetworkAddress( (PUCHAR)&SAPHead.addrNet );
    SAPHead.addrSocket = IPXSocket;
    SAPHead.intermediateNetworks = _SWAPINT( 0x1 );
    AssignArray( SAPECB.immediateAddress, SAPHead.destNode );
    for( ;; ) {
        IpxSend( IPXSocket, &SAPECB );
        DosSemClear( &BroadCastStart );
        DosSemWait( &BroadCastStop, 60000 );
        if( ServerDie ) {
            SAPHead.intermediateNetworks = _SWAPINT( 0x10 );
            IpxSend( IPXSocket, &SAPECB );
            ServerDie |= DIE_BROADCAST;
            DosExit( EXIT_THREAD, 0 );
        }
    }
}
예제 #9
0
void RemoteUnLink( void )
{
    CIPXCloseSocket( IPXSocket );
    CIPXCloseSocket( SPXSocket );

    CIPXCancelECB( &ServECB );
    CIPXCancelECB( &RespECB );

    CCancelInterruptTimeCallBack( &Timer );
    CCancelInterruptTimeCallBack( &SAPTimer );

    if (SAPStruct.AS_ECB.status == 0) {
        SAPStruct.ASServerIDpacket.interveningNetworks = _SWAPINT( 0x10 );
        CIPXSendPacket( &SAPStruct.AS_ECB );
    }
    CIPXCloseSocket( SPXSocket );
    CIPXCloseSocket( IPXSocket );
}
예제 #10
0
void RemoteUnLink( void )
{
    _IPXCloseSocket( SPXSocket );
    _IPXCloseSocket( IPXSocket );
#ifdef SERVER
    _IPXCancelEvent( &ServECB );
    _IPXCancelEvent( &RespECB );
    if( SAPECB.inUseFlag != 0 ) _IPXCancelEvent( &SAPECB );
    /* shutdown notification */
    SAPHead.intermediateNetworks = _SWAPINT( 0x10 );
    SAPECB.ESRAddress = NULL;
    _IPXSendPacket( &SAPECB );
    WaitOn( SAPECB );
#endif
    IPXSPXDeinit();
#ifdef __WINDOWS__
    GlobalPageUnlock( (HGLOBAL)FP_SEG( &SAPECB ) );
#endif
}
예제 #11
0
static trap_retval DoRemoteGet( byte *rec, trap_elen len )
{
    int         i;
    int         p;
    unsigned    recvd;
    unsigned    got;

putstring( "RemoteGet\r\n" );
putconnstatus( Connection );

    len = len;
    recvd = 0;
    for( ;; ) {
        DosSemSet( &RecvSem );
        i = NUM_REC_BUFFS-1;
        p = -1;
        for( ;; ) {
            if( i < 0 ) {
                if( p != -1 ) break;
                DosSemWait( &RecvSem, 1000 );
                i = NUM_REC_BUFFS-1;
            }
            if( !InUse( RecECB[i] ) ) {
                if( p == -1
                 || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) {
                    p = i;
                }
            }
            --i;
        }
        got = _SWAPINT( RecHead[p].packetLen ) - sizeof( RecHead[p] );
        _fmemcpy( rec, Buffer[p], got );
        recvd += got;
        PostAListen( p );
        if( got != MAX_DATA_SIZE ) break;
        rec += got;
    }

putstring( "Done RemoteGet\r\n" );
    return( recvd );
}
예제 #12
0
static trap_retval DoRemoteGet( void *data, trap_elen len )
{
    trap_elen   recvd;
    int         i;
    trap_elen   got;
    int         p;

    len = len;
    _DBG_IPX(("RemoteGet\r\n"));
    recvd = 0;
    for( ;; ) {
        i = NUM_REC_BUFFS-1;
        p = -1;
        for( ;; ) {
            if( i < 0 ) {
                if( p != -1 )
                    break;
                NothingToDo();
                i = NUM_REC_BUFFS-1;
            }
            if( !InUse( RecECB[i] ) ) {
                if( p == -1
                        || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) {
                    p = i;
                }
            }
            --i;
        }
        got = _SWAPINT( RecHead[p].length ) - sizeof( RecHead[p] );
        _DBG_IPX(("Got a packet - size=%d\r\n", got));
        memcpy( data, Buffer[p], got );
        recvd += got;
        PostAListen( p );
        if( got != MAX_DATA_SIZE )
            break;
        data = (char *)data + got;
    }
    return( recvd );
}
예제 #13
0
static trap_retval DoRemoteGet( void *data, trap_elen len )
{
    int         i;
    trap_elen   recvd;
    trap_elen   got;
    int         p;

    len = len;
    recvd = 0;
    for( ;; ) {
        i = NUM_REC_BUFFS - 1;
        p = -1;
        for( ;; ) {
            if( i < 0 ) {
                if( p != -1 )
                    break;
                _IPXRelinquishControl();
                i = NUM_REC_BUFFS-1;
            }
            if( !RecECB[i].inUseFlag ) {
                if( p == -1 || LOWER_SEQ( RecHead[i].sequenceNumber, RecHead[p].sequenceNumber ) ) {
                    p = i;
                }
            }
            --i;
        }
        got = _SWAPINT( RecHead[p].length ) - sizeof( RecHead[p] );
        _fmemcpy( data, Buffer[p], got );
        recvd += got;
        PostAListen( p );
        if( got != MAX_DATA_SIZE )
            break;
        data = (char *)data + got;
    }
    return( recvd );
}