/*=========================================================================*/ void SLPDDatabaseDump(void) /* Dumps currently valid service registrations present with slpd */ /*=========================================================================*/ { SLPMessage msg; SLPBuffer buf; void* eh; eh = SLPDDatabaseEnumStart(); if ( eh ) { SLPDLog("\n========================================================================\n"); SLPDLog("Dumping Registrations\n"); SLPDLog("========================================================================\n"); while ( SLPDDatabaseEnum(eh, &msg, &buf) ) { SLPDLogMessageInternals(msg); SLPDLog("\n"); } SLPDDatabaseEnumEnd(eh); } }
/*=========================================================================*/ void SLPDLogMessage(int msglogflags, struct sockaddr_storage* peerinfo, struct sockaddr_storage* localaddr, SLPBuffer buf) /* Log record of receiving or sending an SLP Message. Logging will only */ /* occur if message logging is enabled G_SlpProperty.traceMsg != 0 */ /* */ /* msglogflags (IN) What type of message to log */ /* */ /* peerinfo (IN) the source or destination peer */ /* */ /* peerinfo (IN) the local address */ /* */ /* msg (IN) the message to log */ /* */ /* Returns: none */ /*=========================================================================*/ { SLPMessage msg; char addr_str[INET6_ADDRSTRLEN]; if (peerinfo == NULL || buf == NULL) { return; } if ((G_SlpdProperty.traceMsg && (msglogflags & SLPDLOG_TRACEMSG)) || (G_SlpdProperty.traceDrop && (msglogflags & SLPDLOG_TRACEDROP)) ) { /* Don't log localhost traffic since it is probably IPC */ /* and don't log empty messages */ if (!SLPNetIsLocal(peerinfo) && buf->end != buf->start) { msg = SLPMessageAlloc(); if (msg) { SLPDLog("\n"); SLPDLogTime(); SLPDLog("MESSAGE - "); if (msglogflags == SLPDLOG_TRACEMSG_OUT) { SLPDLog("Trace message (OUT)\n"); } else if (msglogflags == SLPDLOG_TRACEMSG_IN) { SLPDLog("Trace message (IN)\n"); } else if (msglogflags == SLPDLOG_TRACEDROP) { SLPDLog("Dropped message (following message silently ignored)\n"); } else { SLPDLog("\n"); } if (SLPMessageParseBuffer(peerinfo,localaddr,buf,msg) == 0) { SLPDLogMessageInternals(msg); } else { SLPDLog("Message parsing failed\n"); SLPDLog("Peer: \n"); SLPDLog(" IP address: %s\n", SLPNetSockAddrStorageToString(&(msg->peer), addr_str, sizeof(addr_str))); } SLPMessageFree(msg); } } } }