void rpc2_PrintHostIdent(RPC2_HostIdent *hPtr, FILE *tFile) { char addr[INET_ADDRSTRLEN]; if (tFile == NULL) tFile = rpc2_logfile; /* it's ok, call-by-value */ if (hPtr) { switch (hPtr->Tag) { case RPC2_HOSTBYADDRINFO: rpc2_printaddrinfo(hPtr->Value.AddrInfo, tFile); break; case RPC2_HOSTBYINETADDR: inet_ntop(AF_INET, &hPtr->Value.InetAddress, addr, INET_ADDRSTRLEN); fprintf(tFile, "Host.InetAddr = %s", addr); break; case RPC2_HOSTBYNAME: fprintf(tFile, "Host.Name = \"%s\"", hPtr->Value.Name); break; default: fprintf(tFile, "Host = ??????\n"); } } else fprintf(tFile, "Host = NULL"); (void) fflush(tFile); }
void rpc2_PrintMEntry(struct MEntry *mPtr, FILE *tFile) { if (tFile == NULL) tFile = rpc2_logfile; /* it's ok, call-by-value */ fprintf(tFile, "MyAddr: 0x%lx\n\tNextEntry = 0x%lx PrevEntry = 0x%lx MagicNumber = %s Role = %s State = ", (long)mPtr, (long)mPtr->Next, (long)mPtr->Prev, WhichMagic(mPtr->MagicNumber), TestRole(mPtr,FREE) ? "FREE" :(TestRole(mPtr, CLIENT) ? "CLIENT" : (TestRole(mPtr, SERVER) ? "SERVER" : "?????") )); if (TestRole(mPtr,CLIENT)) switch((int) (mPtr->State & 0x0000ffff)) { case C_THINK: fprintf(tFile, "C_THINK");break; case C_AWAITREPLY: fprintf(tFile, "C_AWAITREPLY");break; case C_HARDERROR: fprintf(tFile, "C_HARDERROR");break; default: fprintf(tFile, "???????"); break; } if (TestRole(mPtr,SERVER)) switch((int) (mPtr->State & 0x0000ffff)) { case S_AWAITREQUEST: fprintf(tFile, "S_AWAITREQUEST");break; case S_PROCESS: fprintf(tFile, "S_PROCESS");break; case S_REQINQUEUE: fprintf(tFile, "S_REQINQUEUE");break; case S_HARDERROR: fprintf(tFile, "S_HARDERROR");break; case S_INSE: fprintf(tFile, "S_INSE");break; case S_AWAITENABLE: fprintf(tFile, "S_AWAITENABLE");break; default: fprintf(tFile, "??????"); break; } fprintf(tFile, "\n\tMgrpID = %#x NextSeqNumber = %d\n", mPtr->MgroupID, mPtr->NextSeqNumber); fprintf(tFile, "Client Host Ident: "); rpc2_printaddrinfo(mPtr->ClientAddr, tFile); fprintf(tFile, "\n"); if (TestRole(mPtr,CLIENT)) { fprintf(tFile, "\n\tMaxlisteners = %ld Listeners = %ld\n", mPtr->me_conns.me_client.mec_maxlisteners, mPtr->me_conns.me_client.mec_howmanylisteners); } else { fprintf(tFile, "Client CEntry:\n"); rpc2_PrintCEntry(mPtr->me_conns.mes_conn, tFile); } fprintf(tFile, "\n"); (void) fflush(tFile); }
static void rpc2_ProcessPacket(int fd) { RPC2_PacketBuffer *pb = NULL; struct timeval tv; int rc; /* We are guaranteed that there is a packet in the socket buffer at this point */ RPC2_AllocBuffer(RPC2_MAXPACKETSIZE - sizeof(RPC2_PacketBuffer), &pb); assert(pb != NULL); assert(pb->Prefix.LE.Queue == &rpc2_PBList); if (rpc2_RecvPacket(fd, pb) < 0) { say(9, RPC2_DebugLevel, "Recv error, ignoring.\n"); RPC2_FreeBuffer(&pb); return; } #ifdef RPC2DEBUG if (RPC2_DebugLevel > 9) { fprintf(rpc2_tracefile, "Packet received from "); rpc2_printaddrinfo(pb->Prefix.PeerAddr, rpc2_tracefile); if (pb->Prefix.sa && pb->Prefix.sa->decrypt) fprintf(rpc2_tracefile, " (secure)"); fprintf(rpc2_tracefile, "\n"); } #endif if (pb->Prefix.LengthOfPacket < (ssize_t)sizeof(struct RPC2_PacketHeader)) { /* avoid memory reference errors */ BOGUS(pb, "Runt packet\n"); return; } rc = LUA_fail_delay(pb->Prefix.PeerAddr, pb, 0, &tv); if (rc == -1) { say(9, RPC2_DebugLevel, "Dropping incoming packet\n"); RPC2_FreeBuffer(&pb); return; } if (rc && rpc2_DelayedRecv(pb, &tv)) { return; } /* delay */ DispatchPacket(pb); }
void rpc2_PrintHEntry(struct HEntry *hPtr, FILE *tFile) { if (tFile == NULL) tFile = rpc2_logfile; /* it's ok, call-by-value */ fprintf(tFile, "\nHost 0x%lx state is...\n\tNextEntry = 0x%lx PrevEntry = 0x%lx MagicNumber = %s\n", (long)hPtr, (long)hPtr->Next, (long)hPtr->Prev, WhichMagic(hPtr->MagicNumber)); rpc2_printaddrinfo(hPtr->Addr, tFile); fprintf(tFile, "\tLastWord = %ld.%06ld\n", hPtr->LastWord.tv_sec, hPtr->LastWord.tv_usec); fprintf(tFile, "\tRTT = %ld.%03ld\n", hPtr->RTT >> RPC2_RTT_SHIFT, hPtr->RTT % ((1 << RPC2_RTT_SHIFT) - 1)); fprintf(tFile, "\tBandwidth = out: %u:%u B/s, in: %u:%u B/s\n", hPtr->BWlo_out, hPtr->BWhi_out, hPtr->BWlo_in, hPtr->BWhi_in); PrintNetLog("RPC2", hPtr->RPC2_NumEntries, hPtr->RPC2_Log, tFile); PrintNetLog("SE", hPtr->SE_NumEntries, hPtr->SE_Log, tFile); (void) fflush(tFile); }
void rpc2_PrintTraceElem(struct TraceElem *whichTE, long whichIndex, FILE *outFile) { long i; fprintf(outFile, "\nTrace Entry %ld: <<<<<< %s: %s", whichIndex, whichTE->ActiveLWP, CallName(whichTE->CallCode)); switch(whichTE->CallCode) { case SLNEWPACKET: case CLOCKTICK: fprintf(outFile, " >>>>>>\n"); break; default: fprintf(outFile, "() >>>>>>\n"); break; } switch(whichTE->CallCode) { case INIT: break; case EXPORT: { struct te_EXPORT *tea; tea = &whichTE->Args.ExportEntry; if (tea->Subsys.Tag == RPC2_SUBSYSBYID) fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYID SubsysId = %ld\n", tea->Subsys.Value.SubsysId); else fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYNAME Name = \"%s\"\n", tea->Subsys.Value.Name); break; /* switch */ } case DEEXPORT: { struct te_DEEXPORT *tea; tea = &whichTE->Args.DeExportEntry; if (tea->Subsys.Tag == RPC2_SUBSYSBYID) fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYID SubsysId = %ld\n", tea->Subsys.Value.SubsysId); else fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYNAME Name = \"%s\"\n", tea->Subsys.Value.Name); break; /* switch */ } case ALLOCBUFFER: { struct te_ALLOCBUFFER *tea; tea = &whichTE->Args.AllocBufferEntry; fprintf(outFile, "MinBodySize: %d\n", tea->MinBodySize); break; /* switch */ } case FREEBUFFER: { struct te_FREEBUFFER *tea; tea = &whichTE->Args.FreeBufferEntry; fprintf(outFile, "*BuffPtr: %p\n", tea->BuffPtr); break; /* switch */ } case SENDRESPONSE: { struct te_SENDRESPONSE *tea; tea = &whichTE->Args.SendResponseEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); break; /* switch */ } case GETREQUEST: { struct te_GETREQUEST *tea; tea = &whichTE->Args.GetRequestEntry; fprintf(outFile, "Filter: "); rpc2_PrintFilter(&tea->Filter, outFile); if (tea->IsNullBreathOfLife) fprintf(outFile, "BreathOfLife: NULL\n"); else fprintf(outFile, "BreathOfLife: %ld.%ld\n", tea->BreathOfLife.tv_sec, tea->BreathOfLife.tv_usec); break; /* switch */ } case MAKERPC: { struct te_MAKERPC *tea; tea = &whichTE->Args.MakeRPCEntry; fprintf(outFile, "Conn: %#x ", tea->ConnHandle); fprintf(outFile, "Enqueue: %d ", tea->EnqueueRequest); if (tea->IsNullBreathOfLife) fprintf(outFile, "BreathOfLife: NULL "); else fprintf(outFile, "BreathOfLife: %ld.%ld ", tea->BreathOfLife.tv_sec, tea->BreathOfLife.tv_usec); if (tea->IsNullSDesc) fprintf(outFile, "SDesc: NULL\n"); else {fprintf(outFile, "\nSDesc: "); rpc2_PrintSEDesc(&tea->SDesc, outFile);} break; /* switch */ } case MULTIRPC: { struct te_MULTIRPC *tea; tea = &whichTE->Args.MultiRPCEntry; fprintf(outFile, "ConnHandle: 0x%lx\n", (unsigned long)tea->ConnHandle); fprintf(outFile, "Request: OriginalAddress = %p ", tea->Request_Address); rpc2_PrintPacketHeader(&tea->Request, outFile); if (tea->IsNullSDesc) fprintf(outFile, "SDesc: NULL\n"); else {fprintf(outFile, "SDesc: "); rpc2_PrintSEDesc(&tea->SDesc, outFile);} fprintf(outFile, "HandleResult: %p\n", tea->HandleResult); if (tea->IsNullBreathOfLife) fprintf(outFile, "BreathOfLife: NULL\n"); else fprintf(outFile, "BreathOfLife: %ld.%ld\n", tea->BreathOfLife.tv_sec, tea->BreathOfLife.tv_usec); break; /* switch */ } case BIND: { struct te_BIND *tea; tea = &whichTE->Args.BindEntry; switch (tea->Host.Tag) { case RPC2_HOSTBYNAME: fprintf(outFile, "Host: Tag = RPC2_HOSTBYNAME Name = \"%s\"\n", tea->Host.Value.Name); break; case RPC2_HOSTBYADDRINFO: { char addr[RPC2_ADDRSTRLEN]; RPC2_formataddrinfo(tea->Host.Value.AddrInfo, addr, RPC2_ADDRSTRLEN); fprintf(outFile, "Host: Tag = RPC2_HOSTBYINETADDR AddrInfo = %s\n", addr); break; } case RPC2_HOSTBYINETADDR: fprintf(outFile, "Host: Tag = RPC2_HOSTBYINETADDR InetAddress = %s\n", inet_ntoa(tea->Host.Value.InetAddress)); break; default: fprintf(outFile, "Host: ?????????\n"); break; } switch (tea->Port.Tag) { case RPC2_PORTBYNAME: fprintf(outFile, "Port: Tag = RPC2_PORTBYNAME Name = \"%s\"\n", tea->Port.Value.Name); break; case RPC2_PORTBYINETNUMBER: fprintf(outFile, "Port: Tag = RPC2_PORTBYINETNUMBER InetNumber = \"%u\"\n", ntohs(tea->Port.Value.InetPortNumber)); break; default: fprintf(outFile, "Port: ??????\n"); break; } switch(tea->Subsys.Tag) { case RPC2_SUBSYSBYNAME: fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYNAME Name = \"%s\"\n", tea->Subsys.Value.Name); break; case RPC2_SUBSYSBYID: fprintf(outFile, "Subsys: Tag = RPC2_SUBSYSBYID Name = %ld\n", tea->Subsys.Value.SubsysId); break; default: fprintf(outFile, "Subsys: ??????\n"); } fprintf(outFile, "SideEffectType = %d\n", tea->SideEffectType); if (tea->IsNullClientIdent) fprintf(outFile, "ClientIdent: NULL\n"); else { long max; fprintf(outFile, "ClientIdent: SeqLen = %u SeqBody\"", tea->ClientIdent.SeqLen); max = (tea->ClientIdent.SeqLen < sizeof(tea->ClientIdent_Value)) ? tea->ClientIdent.SeqLen : sizeof(tea->ClientIdent_Value); for (i = 0; i < max; i++) fprintf(outFile, "%c", (tea->ClientIdent_Value)[i]); if (max < tea->ClientIdent.SeqLen) fprintf(outFile, "....."); fprintf(outFile, "\"\n"); } break; /* switch */ } case INITSIDEEFFECT: { struct te_INITSIDEEFFECT *tea; tea = &whichTE->Args.InitSideEffectEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); if (tea->IsNullSDesc) fprintf(outFile, "SDesc: NULL\n"); else {fprintf(outFile, "SDesc: "); rpc2_PrintSEDesc(&tea->SDesc, outFile); } break; /* switch */ } case CHECKSIDEEFFECT: { struct te_CHECKSIDEEFFECT *tea; tea = &whichTE->Args.CheckSideEffectEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); if (tea->IsNullSDesc) fprintf(outFile, "SDesc: NULL\n"); else {fprintf(outFile, "SDesc: "); rpc2_PrintSEDesc(&tea->SDesc, outFile);} fprintf(outFile, "Flags: { "); if (tea->Flags & SE_AWAITLOCALSTATUS) fprintf(outFile, "SE_AWAITLOCALSTATUS "); if (tea->Flags & SE_AWAITREMOTESTATUS) fprintf(outFile, "SE_AWAITREMOTESTATUS "); fprintf(outFile, "}\n"); break; /* switch */ } case UNBIND: { struct te_UNBIND *tea; tea = &whichTE->Args.UnbindEntry; fprintf(outFile, "whichConn: %#x\n", tea->whichConn); break; /* switch */ } case GETPRIVATEPOINTER: { struct te_GETPRIVATEPOINTER *tea; tea = &whichTE->Args.GetPrivatePointerEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); break; /* switch */ } case SETPRIVATEPOINTER: { struct te_SETPRIVATEPOINTER *tea; tea = &whichTE->Args.SetPrivatePointerEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); fprintf(outFile, "PrivatePtr: %p\n", tea->PrivatePtr); break; /* switch */ } case GETSEPOINTER: { struct te_GETSEPOINTER *tea; tea = &whichTE->Args.GetSEPointerEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); break; /* switch */ } case SETSEPOINTER: { struct te_SETSEPOINTER *tea; tea = &whichTE->Args.SetSEPointerEntry; fprintf(outFile, "ConnHandle: %#x\n", tea->ConnHandle); fprintf(outFile, "SEPtr: %p\n", tea->SEPtr); break; /* switch */ } case GETPEERINFO: { struct te_GETPEERINFO *tea; tea = &whichTE->Args.GetPeerInfoEntry; fprintf(outFile, "ConnHandle: 0x%lx\n", (long)tea->ConnHandle); break; /* switch */ } case SLNEWPACKET: { struct te_SLNEWPACKET *tea; tea = &whichTE->Args.SLNewPacketEntry; rpc2_PrintPacketHeader(&tea->pb, outFile); break; /* switch */ } case SENDRELIABLY: { struct te_SENDRELIABLY *tea; tea = &whichTE->Args.SendReliablyEntry; fprintf(outFile, "Conn.UniqueCID = 0x%x ",tea->Conn_UniqueCID); if (tea->IsNullTimeout) fprintf(outFile, "TimeOut: NULL\n"); else fprintf(outFile, "TimeOut: %ld.%ld\n", tea->Timeout.tv_sec, tea->Timeout.tv_usec); break; /* switch */ } case MSENDPACKETSRELIABLY: { struct te_MSENDPACKETSRELIABLY *tea; tea = &whichTE->Args.MSendPacketsReliablyEntry; fprintf(outFile, "HowMany: %d ConnArray[0]: %p ConnArray[0].UniqueCID = 0x%x\n", tea->HowMany, tea->ConnArray0, tea->ConnArray0_UniqueCID); fprintf(outFile, "PacketArray[0]: OriginalAddress = 0x%lx ", (long)tea->PacketArray0_Address); rpc2_PrintPacketHeader(&tea->PacketArray0, outFile); if (tea->IsNullTimeout) fprintf(outFile, "TimeOut: NULL\n"); else fprintf(outFile, "TimeOut: %ld.%ld\n", tea->Timeout.tv_sec, tea->Timeout.tv_usec); break; /* switch */ } case XMITPACKET: { struct te_XMITPACKET *tea; tea = &whichTE->Args.XmitPacketEntry; fprintf(outFile, "whichSocket = %ld\n", tea->whichSocket); fprintf(outFile, "whichAddr: "); rpc2_printaddrinfo(&tea->whichAddr, outFile); fprintf(outFile,"\n"); rpc2_PrintPacketHeader(&tea->whichPB, outFile); break; /* switch */ } case CLOCKTICK: { struct te_CLOCKTICK *tea; tea = &whichTE->Args.ClockTickEntry; fprintf(outFile, "TimeNow: %d\n", tea->TimeNow); break; /* switch */ } case CREATEMGRP: { struct te_CREATEMGRP *tea; tea = &whichTE->Args.CreateMgrpEntry; fprintf(outFile, "MgroupHandle: %#x\n", tea->MgroupHandle); fprintf(outFile, "McastHost: "); rpc2_PrintHostIdent((RPC2_HostIdent *)&(tea->McastHost), outFile); fprintf(outFile, " "); fprintf(outFile, "McastPort: "); rpc2_PrintPortIdent(&(tea->Port), outFile); fprintf(outFile, " "); fprintf(outFile, "Subsystem: "); rpc2_PrintSubsysIdent(&(tea->Subsys), outFile); fprintf(outFile, "\n"); break; /* switch */ } case ADDTOMGRP: { struct te_ADDTOMGRP *tea; tea = &whichTE->Args.AddToMgrpEntry; fprintf(outFile, "MgroupHandle: %#x ConnHandle: %#x\n", tea->MgroupHandle, tea->ConnHandle); break; /* switch */ } case REMOVEFROMMGRP: { struct te_REMOVEFROMMGRP *tea; tea = &whichTE->Args.RemoveFromMgrpEntry; fprintf(outFile, "MEntry: "); rpc2_PrintMEntry(&tea->me, outFile); fprintf(outFile, " "); fprintf(outFile, "CEntry: "); rpc2_PrintCEntry(&tea->ce, outFile); fprintf(outFile, "\n"); break; /* switch */ } case XLATEMCASTPACKET: { struct te_XLATEMCASTPACKET *tea; tea = &whichTE->Args.XlateMcastPacketEntry; fprintf(outFile, "PacketBuffer Address: 0x%lx PacketHeader: ", tea->pb_address); rpc2_PrintPacketHeader(&tea->pb, outFile); fprintf(outFile, " ClientHost: "); rpc2_printaddrinfo(&tea->ThisAddr, outFile); fprintf(outFile, "\n"); break; /* switch */ } } }