コード例 #1
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
static void HandleOldRequest(RPC2_PacketBuffer *pb, struct CEntry *ce)
{
    say(1, RPC2_DebugLevel, "HandleOldRequest()\n");

    rpc2_Recvd.Requests++;

    if (ce->HeldPacket) {
        ce->HeldPacket->Header.TimeStamp = htonl(pb->Header.TimeStamp);
        rpc2_XmitPacket(ce->HeldPacket, ce->HostInfo->Addr, 1);
    }
    RPC2_FreeBuffer(&pb);
}
コード例 #2
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
static void HandleRetriedBind(RPC2_PacketBuffer *pb, struct CEntry *ce)
{
    say(1, RPC2_DebugLevel, "HandleRetriedBind()\n");

    if (!TestRole(ce, SERVER)) {
        BOGUS(pb, "HandleRetriedBind: not server\n");
        return;
    }

    /* The original bind request could be:
         (1) in the hold queue,
         (2) in RPC2_GetRequest() on some LWP,
         (3) already completed.
    */
    ce->TimeStampEcho = pb->Header.TimeStamp;
    /* if we're modifying the TimeStampEcho, we also have
     * to reset the RequestTime */
    TVTOTS(&pb->Prefix.RecvStamp, ce->RequestTime);

    say(15, RPC2_DebugLevel, "handleinit1 TS %u RQ %u\n", ce->TimeStampEcho,
        ce->RequestTime);

    if (TestState(ce, SERVER, S_STARTBIND)) {
        /* Cases (1) and (2) */
        say(1, RPC2_DebugLevel, "Busying Init1 on %#x\n", ce->UniqueCID);

        SendBusy(ce, FALSE);
        RPC2_FreeBuffer(&pb);
        return;
    }
    if (ce->SecurityLevel == RPC2_OPENKIMONO && ce->HeldPacket) {
        /* Case (3): The Init2 must have been dropped; resend it */
        say(1, RPC2_DebugLevel, "Resending Init2 %#x\n", ce->UniqueCID);
        ce->HeldPacket->Header.TimeStamp = htonl(ce->TimeStampEcho);
        rpc2_XmitPacket(ce->HeldPacket, ce->HostInfo->Addr, 1);
        RPC2_FreeBuffer(&pb);
        return;
    }
    /* This retry is totally bogus */
    BOGUS(pb, "HandleRetriedBind: anything else\n");
    return;
}
コード例 #3
0
ファイル: sftp4.c プロジェクト: krichter722/coda
int sftp_XmitPacket(struct SFTP_Entry *sEntry, RPC2_PacketBuffer *pb,
		    int confirm)
{
#ifdef RPC2DEBUG
    struct TraceEntry *te;

    te = (struct TraceEntry *)CBUF_NextSlot(TraceBuf);
    te->tcode = SENT;
    te->ph = pb->Header;	/* structure assignment */
#endif

    rpc2_XmitPacket(pb, sEntry->HostInfo->Addr, confirm);

    rpc2_Sent.Total--;
    rpc2_Sent.Bytes -= pb->Prefix.LengthOfPacket;
    sftp_Sent.Total++;
    sftp_Sent.Bytes += pb->Prefix.LengthOfPacket;

    return(RPC2_SUCCESS);
}
コード例 #4
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
static void SendBusy(struct CEntry *ce, int doEncrypt)
{
    RPC2_PacketBuffer *pb;
    unsigned int delta;

    rpc2_Sent.Busies++;

    RPC2_AllocBuffer(0, &pb);
    rpc2_InitPacket(pb, ce, 0);

    delta                = TSDELTA(rpc2_MakeTimeStamp(), ce->RequestTime);
    pb->Header.TimeStamp = (unsigned int)ce->TimeStampEcho + delta;
    pb->Header.SeqNumber = ce->NextSeqNumber - 1;
    pb->Header.Opcode    = RPC2_BUSY;

    rpc2_htonp(pb);
    if (doEncrypt)
        rpc2_ApplyE(pb, ce);

    rpc2_XmitPacket(pb, ce->HostInfo->Addr, 1);
    RPC2_FreeBuffer(&pb);
}
コード例 #5
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
static void HandleInit3(RPC2_PacketBuffer *pb, struct CEntry *ce)
{
    struct SL_Entry *sl;

    say(1, RPC2_DebugLevel, "HandleInit3()\n");

    rpc2_Recvd.Requests++;

    /* Am I expecting this packet? */
    if (!TestState(ce, SERVER, S_AWAITINIT3)) {
        if (ce->HeldPacket) {
            /* My Init4 must have got lost; resend it */
            ce->HeldPacket->Header.TimeStamp = htonl(pb->Header.TimeStamp);
            rpc2_XmitPacket(ce->HeldPacket, ce->HostInfo->Addr, 1);
        } else
            say(1, RPC2_DebugLevel, "Bogus Init3\n");
        /* Throw packet away anyway */
        RPC2_FreeBuffer(&pb);
        return;
    }

    /* Expected Init3 */
    if (BogusSl(ce, pb))
        return;
    pb = ShrinkPacket(pb);

    ce->TimeStampEcho = pb->Header.TimeStamp;
    TVTOTS(&pb->Prefix.RecvStamp, ce->RequestTime);

    say(15, RPC2_DebugLevel, "handleinit3 TS %u RQ %u\n", ce->TimeStampEcho,
        ce->RequestTime);

    sl       = ce->MySl;
    sl->data = pb;
    SetState(ce, S_FINISHBIND);
    rpc2_DeactivateSle(sl, ARRIVED);
    LWP_NoYieldSignal((char *)sl);
}
コード例 #6
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
/* Sends a NAK packet for remoteHandle on (whichHost, whichPort) pair */
static void SendNak(RPC2_PacketBuffer *pb)
{
    RPC2_PacketBuffer *nakpb;
    RPC2_Handle remoteHandle = pb->Header.LocalHandle;

    if (pb->Header.Opcode == RPC2_NAKED)
        return;

    say(1, RPC2_DebugLevel, "Sending NAK\n");
    RPC2_AllocBuffer(0, &nakpb);
    rpc2_InitPacket(nakpb, NULL, 0);
    nakpb->Prefix.sa           = pb->Prefix.sa;
    nakpb->Header.RemoteHandle = remoteHandle;
    nakpb->Header.LocalHandle  = -1; /* "from SocketListener" */
    nakpb->Header.Opcode       = RPC2_NAKED;

    rpc2_htonp(nakpb);
    /* use the same security association on which we received the packet
     * we're currently nak-ing */
    rpc2_XmitPacket(nakpb, pb->Prefix.PeerAddr, 1);
    RPC2_FreeBuffer(&nakpb);
    rpc2_Sent.Naks++;
}
コード例 #7
0
ファイル: sl.c プロジェクト: cmusatyalab/coda
static void HandleInit1(RPC2_PacketBuffer *pb)
{
    struct CEntry *ce;
    struct SL_Entry *sl;

    rpc2_ntohp(pb);

    if (pb->Header.Opcode != RPC2_INIT1OPENKIMONO &&
        pb->Header.Opcode != RPC2_INIT1AUTHONLY &&
        pb->Header.Opcode != RPC2_INIT1HEADERSONLY &&
        pb->Header.Opcode != RPC2_INIT1SECURE) {
        NAKIT(pb);
        return;
    }

    say(1, RPC2_DebugLevel, "HandleInit1()\n");

    rpc2_Recvd.Requests++;

    /* Have we seen this bind request before? */
    ce = rpc2_ConnFromBindInfo(pb->Prefix.PeerAddr, pb->Header.LocalHandle,
                               pb->Header.Uniquefier);
    if (ce) {
        HandleRetriedBind(pb, ce);
        return;
    }

    /* Find a willing LWP in RPC2_GetRequest() */
    sl = FindRecipient(pb);
    if (!sl) {
        /* no threads are ready, send a busy to the other side so that it
         * will back off and try again later */
        say(1, RPC2_DebugLevel,
            "HandleInit1: No available threads, busying peer\n");

        /* SendBusy(ce, FALSE);
         * -- we don't have a CEntry yet, but we can reuse most of the
         * INIT1 packet we just got... */
        pb->Header.RemoteHandle ^= pb->Header.LocalHandle;
        pb->Header.LocalHandle ^= pb->Header.RemoteHandle;
        pb->Header.RemoteHandle ^= pb->Header.LocalHandle;
        pb->Header.Opcode         = RPC2_BUSY;
        pb->Header.Lamport        = RPC2_LamportTime();
        pb->Header.SeqNumber      = -1;
        pb->Header.BodyLength     = 0;
        pb->Prefix.LengthOfPacket = sizeof(struct RPC2_PacketHeader);

        rpc2_htonp(pb);

        rpc2_XmitPacket(pb, pb->Prefix.PeerAddr, 1);
        RPC2_FreeBuffer(&pb);
        return;
    }

    /* Create a connection entry */
    ce = MakeConn(pb);
    if (!ce) {
        /* Packet must have been bogus in some way */
        BOGUS(pb, "HandleInit1: MakeConn failed\n");
        return;
    }

    /* Now fix packet header so that it has a real RemoteHandle */
    pb->Header.RemoteHandle = ce->UniqueCID;

    rpc2_DeactivateSle(sl, ARRIVED);
    sl->data            = pb;
    ce->Filter          = sl->Filter; /* struct assignment */
    ce->Filter.OldOrNew = OLDORNEW;
    LWP_NoYieldSignal((char *)sl);
}