Describes the types of events that can be sent by the different SIP Servers to SIP Monitor clients.
コード例 #1
0
 private void LogMonitorEvent(SIPMonitorEvent monitorEvent)
 {
     if (monitorEvent is SIPMonitorConsoleEvent)
     {
         SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;
         if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace && consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction)
         {
             logger.Debug(monitorEvent.Message);
         }
     }
 }
コード例 #2
0
        /*private SIPRequest GetInviteRequest(SIPURI dstURI, string callerIdName, string callerIdUser, string callerIdHost)
         * {
         *  SIPRequest inviteRequest = new SIPRequest(SIPMethodsEnum.INVITE, dstURI);
         *
         *  IPEndPoint localEndPoint = m_sipTransport.GetTransportContact(null);
         *  string localAddressStr = localEndPoint.Address.ToString();
         *
         *  SIPToHeader toHeader = SIPToHeader.ParseToHeader("<" + dstURI.ToString() + ">");
         *
         *  SIPFromHeader fromHeader = SIPFromHeader.ParseFromHeader(callerIdName + " <sip:" + callerIdUser + "@" + callerIdHost + ">");
         *  fromHeader.FromTag = CallProperties.CreateNewTag();
         *  SIPContactHeader contact = SIPContactHeader.ParseContactHeader("sip:" + IPSocket.GetSocketString(localEndPoint))[0];
         *
         *  SIPHeader inviteHeader = new SIPHeader(contact, fromHeader, toHeader, 1, CallProperties.CreateNewCallId());
         *  inviteHeader.CSeqMethod = SIPMethodsEnum.INVITE;
         *  inviteRequest.Header = inviteHeader;
         *
         *  SIPViaHeader viaHeader = new SIPViaHeader(localEndPoint.Address.ToString(), localEndPoint.Port, CallProperties.CreateBranchId());
         *  inviteRequest.Header.Via.PushViaHeader(viaHeader);
         *
         *  inviteRequest.Body =
         *      "v=0" + m_CRLF +
         *      "o=" + SERVER_STRING + " 613 888 IN IP4 " + localAddressStr + m_CRLF +
         *      "s=SIP Call" + m_CRLF +
         *      "c=IN IP4 " + localAddressStr + m_CRLF +
         *      "t=0 0" + m_CRLF +
         *      "m=audio 10000 RTP/AVP 0" + m_CRLF +
         *      "a=rtpmap:0 PCMU/8000" + m_CRLF;
         *
         *  inviteRequest.Header.ContentLength = inviteRequest.Body.Length;
         *  inviteRequest.Header.ContentType = "application/sdp";
         *
         *  return inviteRequest;
         * }*/

        private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent)
        {
            if (SIPMonitorLogEvent != null)
            {
                try
                {
                    SIPMonitorLogEvent(monitorEvent);
                }
                catch (Exception excp)
                {
                    logger.Error("Exception FireProxyLogEvent SIPProxyWebService. " + excp.Message);
                }
            }
        }
コード例 #3
0
		public void Send(SIPMonitorEvent monitorEvent)
		{
			try
			{
                if (monitorEvent != null && m_sendEvents)
				{
                    string monitorEventStr = monitorEvent.ToCSV();

                    //if (monitorEvent.Message != null && monitorEvent.Message.Length > 0)
                    //{
                    //    monitorEventStr = monitorEvent.ToCSV();
                    //}

                    if (monitorEventStr != null)
                    {
                        m_monitorClient.Send(Encoding.ASCII.GetBytes(monitorEventStr), monitorEventStr.Length, m_monitorEndPoint);
                    }
				}
			}
			catch(Exception excp)
			{
				logger.Error("Exception SIPMonitorEventWriter Send (SIPMonitorEvent). " + excp.Message);
			}
		}
コード例 #4
0
        private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                if (sipMonitorEvent != null && m_monitorEventWriter != null)
                {
                    if (sipMonitorEvent is SIPMonitorConsoleEvent)
                    {
                        SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent;

                        if (consoleEvent.ServerType == SIPMonitorServerTypesEnum.RegisterAgent ||
                            (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.ContactRegisterInProgress &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.Monitor))
                        {
                            string eventUsername = (sipMonitorEvent.Username.IsNullOrBlank()) ? null : " " + sipMonitorEvent.Username;
                            dialPlanLogger.Debug("as (" + DateTime.Now.ToString("mm:ss:fff") + eventUsername + "): " + sipMonitorEvent.Message);
                        }

                        if (consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction)
                        {
                            m_monitorEventWriter.Send(sipMonitorEvent);
                        }
                    }
                    else
                    {
                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
            }
        }
コード例 #5
0
 private void LogTraceMessage(SIPMonitorEvent monitorEvent)
 {
     if(monitorEvent is SIPMonitorConsoleEvent)
     {
         if (((SIPMonitorConsoleEvent)monitorEvent).EventType != SIPMonitorEventTypesEnum.FullSIPTrace &&
             ((SIPMonitorConsoleEvent)monitorEvent).EventType != SIPMonitorEventTypesEnum.SIPTransaction)
         {
             AppendTraceMessage(monitorEvent.Message + "\n");
         }
         else
         {
             AppendSIPTraceMessage(monitorEvent.Message);
         }
     }
 }
コード例 #6
0
ファイル: SIPProxyCore.cs プロジェクト: sipsorcery/sipsorcery
 private void SendMonitorEvent(SIPMonitorEvent monitorEvent)
 {
     if (m_proxyLogger != null)
     {
         m_proxyLogger(monitorEvent);
     }
 }
コード例 #7
0
 private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent)
 {
     if (SIPMonitorEventLog_External != null)
     {
         SIPMonitorEventLog_External(monitorEvent);
     }
 }
コード例 #8
0
ファイル: RTCCDaemon.cs プロジェクト: sipsorcery/sipsorcery
        private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                if (sipMonitorEvent != null)
                {
                    if (sipMonitorEvent is SIPMonitorConsoleEvent)
                    {
                        SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent;
                        logger.Debug("rtcc: " + sipMonitorEvent.Message);
                    }

                    if (m_monitorEventWriter != null)
                    {
                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
            }
        }
コード例 #9
0
 void statefulProxyCore2_StatefulProxyLogEvent(SIPMonitorEvent logEvent)
 {
     Console.WriteLine("AppServerCore2-" + logEvent.EventType + ": " + logEvent.Message);
 }
コード例 #10
0
        private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent) {
            try {
                if (sipMonitorEvent != null && m_monitorEventWriter != null)
                {
                    if (sipMonitorEvent is SIPMonitorConsoleEvent)
                    {
                        SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent;

                        if (consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAlive)
                        {
                            logger.Debug("re: " + sipMonitorEvent.Message);
                        }

                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                    else
                    {
                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                }
            }
            catch (Exception excp) {
                logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
            }
        }
コード例 #11
0
        /// <summary>
        /// Rules for displaying events.
        ///  1. The event type is checked to see if it matches. If no event type has been specified than all events EXCEPT FullSIPTrace are
        ///     matched,
        ///  2. If the event type is FullSIPTrace then the messages can be filtered on the request type. If the request type is not set all
        ///     SIP trace messages are matched otherwise only those pertaining to the request type specified,
        ///  3. The server type is checked, if it's not set all events are matched,
        ///  4. If the event has matched up until this point a decision is now made as to whether to display or reject it:
        ///     a. If the IPAddress filter is set is checked, if it matches the event is displayed otherwise it's rejected,
        ///     b. If the username AND server IP AND request type AND regex filters all match the vent is displayed otherwise rejected.
        /// </summary>
        /// <param name="proxyEvent"></param>
        /// <returns></returns>
        public bool ShowSIPMonitorEvent(SIPMonitorEvent proxyEvent)
        {
            if (proxyEvent is SIPMonitorMachineEvent)
            {
                #region Machine event filtering.

                if (BaseType == MACHINE_BASE_TYPE)
                {
                    if (EventFilterDescr == WILDCARD)
                    {
                        return(ShowUsername(proxyEvent.Username));
                    }
                    else
                    {
                        SIPMonitorMachineEvent machineEvent = proxyEvent as SIPMonitorMachineEvent;

                        if ((machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueCreated ||
                             machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueRemoved ||
                             machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueUpdated ||
                             machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueTransfer) && SIPEventDialogURI != null)
                        {
                            if (SIPEventDialogURI.User == WILDCARD)
                            {
                                return(ShowUsername(proxyEvent.Username) && ShowMachineEvent(machineEvent.MachineEventType));
                            }
                            else
                            {
                                return(proxyEvent.Username == Username && machineEvent.ResourceURI != null &&
                                       machineEvent.ResourceURI.User == SIPEventDialogURI.User && machineEvent.ResourceURI.Host == SIPEventDialogURI.Host);
                            }
                        }
                        else if ((machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPRegistrarBindingRemoval ||
                                  machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPRegistrarBindingUpdate) && SIPEventPresenceURI != null)
                        {
                            if (SIPEventPresenceURI.User == WILDCARD)
                            {
                                return(ShowUsername(proxyEvent.Username));
                            }
                            else
                            {
                                return(proxyEvent.Username == Username && machineEvent.ResourceURI != null &&
                                       machineEvent.ResourceURI.User == SIPEventPresenceURI.User && machineEvent.ResourceURI.Host == SIPEventPresenceURI.Host);
                            }
                        }
                        else if (SIPEventDialogURI == null && SIPEventPresenceURI == null)
                        {
                            return(ShowUsername(proxyEvent.Username));
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    return(false);
                }

                #endregion
            }
            else if (BaseType == MACHINE_BASE_TYPE && !(proxyEvent is SIPMonitorMachineEvent))
            {
                return(false);
            }
            else
            {
                SIPMonitorConsoleEvent consoleEvent = proxyEvent as SIPMonitorConsoleEvent;

                string serverAddress   = (consoleEvent.ServerEndPoint != null) ? consoleEvent.ServerEndPoint.Address.ToString() : null;
                string remoteIPAddress = (consoleEvent.RemoteEndPoint != null) ? consoleEvent.RemoteEndPoint.Address.ToString() : null;
                string dstIPAddress    = (consoleEvent.DestinationEndPoint != null) ? consoleEvent.DestinationEndPoint.Address.ToString() : null;

                if (SIPRequestFilter != WILDCARD && consoleEvent.Message != null && consoleEvent.EventType == SIPMonitorEventTypesEnum.FullSIPTrace)
                {
                    if (ShowEvent(consoleEvent.EventType, consoleEvent.ServerEndPoint) && ShowServer(consoleEvent.ServerType))
                    {
                        if (SIPRequestFilter == SIPREQUEST_INVITE_VALUE)
                        {
                            // Do a regex to pick out ACKs, BYEs, CANCELs, INVITEs and REFERs.
                            if (Regex.Match(consoleEvent.Message, "(ACK|BYE|CANCEL|INVITE|REFER) +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ (ACK|BYE|CANCEL|INVITE|REFER)(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return(ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress)));
                            }
                        }
                        else if (SIPRequestFilter == SIPREQUEST_REGISTER_VALUE)
                        {
                            // Do a regex to pick out REGISTERs.
                            if (Regex.Match(consoleEvent.Message, "REGISTER +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ REGISTER(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return(ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress)));
                            }
                        }
                        else if (SIPRequestFilter == SIPREQUEST_NOTIFY_VALUE)
                        {
                            // Do a regex to pick out NOTIFYs and SUBSCRIBEs.
                            if (Regex.Match(consoleEvent.Message, "(NOTIFY|SUBSCRIBE) +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ (NOTIFY|SUBSCRIBE)(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return(ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress)));
                            }
                        }

                        return(false);
                    }
                }

                if (ShowEvent(consoleEvent.EventType, consoleEvent.ServerEndPoint))
                {
                    bool showIPAddress = ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress);
                    bool showUsername  = ShowUsername(consoleEvent.Username);
                    bool showServerIP  = ShowServerIPAddress(serverAddress);
                    bool showRegex     = ShowRegex(consoleEvent.Message);
                    bool showServer    = ShowServer(consoleEvent.ServerType);

                    if (showUsername && showServerIP && showRegex && showIPAddress && showServer)
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
コード例 #12
0
        public bool MonitorEventAvailable(SIPMonitorEvent monitorEvent)
        {
            try
            {
                SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;
                if (consoleEvent != null && consoleEvent.SessionID == m_notificationsSessionID)
                {
                    OutStream.Write(Encoding.ASCII.GetBytes(consoleEvent.ToConsoleString(AdminId)));
                    OutStream.Flush();
                    return true;
                }

                return false;
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPSorceryVT100Server NotificationReady. " + excp.Message);
                return false;
            }
        }
コード例 #13
0
        /*private SIPRequest GetInviteRequest(SIPURI dstURI, string callerIdName, string callerIdUser, string callerIdHost)
        {
            SIPRequest inviteRequest = new SIPRequest(SIPMethodsEnum.INVITE, dstURI);

            IPEndPoint localEndPoint = m_sipTransport.GetTransportContact(null);
            string localAddressStr = localEndPoint.Address.ToString();

            SIPToHeader toHeader = SIPToHeader.ParseToHeader("<" + dstURI.ToString() + ">");

            SIPFromHeader fromHeader = SIPFromHeader.ParseFromHeader(callerIdName + " <sip:" + callerIdUser + "@" + callerIdHost + ">");
            fromHeader.FromTag = CallProperties.CreateNewTag();
            SIPContactHeader contact = SIPContactHeader.ParseContactHeader("sip:" + IPSocket.GetSocketString(localEndPoint))[0];

            SIPHeader inviteHeader = new SIPHeader(contact, fromHeader, toHeader, 1, CallProperties.CreateNewCallId());
            inviteHeader.CSeqMethod = SIPMethodsEnum.INVITE;
            inviteRequest.Header = inviteHeader;

            SIPViaHeader viaHeader = new SIPViaHeader(localEndPoint.Address.ToString(), localEndPoint.Port, CallProperties.CreateBranchId());
            inviteRequest.Header.Via.PushViaHeader(viaHeader);

            inviteRequest.Body =
                "v=0" + m_CRLF +
                "o=" + SERVER_STRING + " 613 888 IN IP4 " + localAddressStr + m_CRLF +
                "s=SIP Call" + m_CRLF +
                "c=IN IP4 " + localAddressStr + m_CRLF +
                "t=0 0" + m_CRLF +
                "m=audio 10000 RTP/AVP 0" + m_CRLF +
                "a=rtpmap:0 PCMU/8000" + m_CRLF;

            inviteRequest.Header.ContentLength = inviteRequest.Body.Length;
            inviteRequest.Header.ContentType = "application/sdp";

            return inviteRequest;
        }*/
        
        private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent)
        {                       
            if (SIPMonitorLogEvent != null)
            {
                try
                {
                    SIPMonitorLogEvent(monitorEvent);
                }
                catch (Exception excp)
                {
                    logger.Error("Exception FireProxyLogEvent SIPProxyWebService. " + excp.Message);
                }
            }
        }
コード例 #14
0
        private bool MonitorEventAvailable(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                SIPMonitorMachineEvent machineEvent = sipMonitorEvent as SIPMonitorMachineEvent;

                if (machineEvent != null && !machineEvent.SessionID.IsNullOrBlank() && m_subscriptions.ContainsKey(machineEvent.SessionID))
                {
                    SIPEventSubscription subscription = m_subscriptions[machineEvent.SessionID];

                    lock (subscription)
                    {
                        string resourceURI = (machineEvent.ResourceURI != null) ? machineEvent.ResourceURI.ToString() : null;

                        //logger.Debug("NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".");

                        //MonitorLogEvent_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Notifier, SIPMonitorEventTypesEnum.Monitor, "NotifierSubscriptionsManager received new " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".", subscription.SubscriptionDialogue.Owner));

                        if (subscription.AddMonitorEvent(machineEvent))
                        {
                            SendNotifyRequestForSubscription(subscription);
                        }

                        //logger.Debug("NotifierSubscriptionsManager completed " + machineEvent.MachineEventType + ", resource ID=" + machineEvent.ResourceID + ", resource URI=" + resourceURI + ".");
                    }

                    return true;
                }

                return false;
            }
            catch (Exception excp)
            {
                logger.Error("Exception NotifierSubscriptionsManager MonitorEventAvailable. " + excp.Message);
                return false;
            }
        }
コード例 #15
0
 private void SendMonitorEventViaUDP(SIPMonitorEvent monitorEvent, string destinationSocket)
 {
     try
     {
         byte[] monitorEventBytes = Encoding.UTF8.GetBytes(monitorEvent.ToCSV());
         m_udpEventSender.Send(monitorEventBytes, monitorEventBytes.Length, IPSocket.ParseSocketString(destinationSocket));
     }
     catch (Exception excp)
     {
         logger.Error("Exception SendMonitorEventViaUDP. " + excp.Message);
     }
 }
コード例 #16
0
        public void MonitorEventReceived(SIPMonitorEvent monitorEvent)
        {
            try
            {
                monitorEvent.MonitorServerID = m_monitorServerID;
                //Action<string> notificationReady = null;
                //string notificationAddress = null;

                lock (m_clientSessions)
                {
                    foreach (KeyValuePair<string, List<SIPMonitorClientSession>> sessionEntry in m_clientSessions)
                    {
                        string address = sessionEntry.Key;
                        List<SIPMonitorClientSession> sessions = sessionEntry.Value;

                        bool eventAdded = false;

                        foreach (SIPMonitorClientSession session in sessions)
                        {
                            if (session.Filter.ShowSIPMonitorEvent(monitorEvent))
                            {
                                //logger.Debug("Session accepted event " + monitorEvent.ClientType + " for session " + monitorEvent.SessionID + ".");

                                monitorEvent.SessionID = session.SessionID;

                                if (session.UDPSocket != null)
                                {
                                    SendMonitorEventViaUDP(monitorEvent, session.UDPSocket);
                                }
                                else
                                {
                                    if (MonitorEventReady == null || !MonitorEventReady(monitorEvent))
                                    {
                                        lock (session.Events)
                                        {
                                            if (session.Events.Count > MAX_EVENT_QUEUE_SIZE)
                                            {
                                                // Queue has exceeded max allowed size, pop off the oldest event.
                                                session.Events.Dequeue();
                                            }
                                            session.Events.Enqueue(monitorEvent);
                                        }
                                        eventAdded = true;
                                    }
                                }
                            }
                        }

                        //if (eventAdded && m_clientsWaiting.ContainsKey(session.Address))
                        if (eventAdded)
                        {
                            //notificationAddress = session.Address;
                            //notificationReady = m_clientsWaiting[session.Address];

                            if (NotificationReady != null)
                            {
                                NotificationReady(address);
                            }
                        }
                    }
                }

                /*if (notificationReady != null)
                {
                    //logger.Debug("SIPMonitorClientManager Firing notification available callback for address " + notificationAddress + ".");

                    try
                    {
                        notificationReady(notificationAddress);
                    }
                    catch (Exception callbackExcp)
                    {
                        logger.Error("Exception SIPMonitorClientManager MonitorEventReceived Callback. " + callbackExcp.Message);
                        lock (m_clientsWaiting)
                        {
                            m_clientsWaiting.Remove(notificationAddress);
                        }
                    }
                }*/
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorClientManager MonitorEventReceived. " + excp.Message);
            }
        }
コード例 #17
0
        private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
        {
            try
            {
                if (monitorEvent is SIPMonitorConsoleEvent)
                {
                    SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;

                    if (TraceLog != null)
                    {
                        TraceLog.AppendLine(consoleEvent.EventType + "=> " + monitorEvent.Message);
                    }
                }

                if (Log_External != null)
                {
                    Log_External(monitorEvent);
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireProxyLogEvent DialPlanContext. " + excp.Message);
            }
        }
コード例 #18
0
 private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent)
 {
     try
     {
         if (sipMonitorEvent != null && m_monitorEventWriter != null)
         {
             if (!(sipMonitorEvent is SIPMonitorConsoleEvent &&
                 ((SIPMonitorConsoleEvent)sipMonitorEvent).EventType == SIPMonitorEventTypesEnum.SIPTransaction))
             {
                 m_monitorEventWriter.Send(sipMonitorEvent);
             }
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
     }
 }
コード例 #19
0
        /// <summary>
        /// Rules for displaying events.
        ///  1. The event type is checked to see if it matches. If no event type has been specified than all events EXCEPT FullSIPTrace are
        ///     matched,
        ///  2. If the event type is FullSIPTrace then the messages can be filtered on the request type. If the request type is not set all
        ///     SIP trace messages are matched otherwise only those pertaining to the request type specified,
        ///  3. The server type is checked, if it's not set all events are matched,
        ///  4. If the event has matched up until this point a decision is now made as to whether to display or reject it:
        ///     a. If the IPAddress filter is set is checked, if it matches the event is displayed otherwise it's rejected,
        ///     b. If the username AND server IP AND request type AND regex filters all match the vent is displayed otherwise rejected. 
        /// </summary>
        /// <param name="proxyEvent"></param>
        /// <returns></returns>
        public bool ShowSIPMonitorEvent(SIPMonitorEvent proxyEvent)
        {
            if (proxyEvent is SIPMonitorMachineEvent)
            {
                #region Machine event filtering.

                if (BaseType == MACHINE_BASE_TYPE)
                {
                    if (EventFilterDescr == WILDCARD)
                    {
                        return ShowUsername(proxyEvent.Username);
                    }
                    else
                    {
                        SIPMonitorMachineEvent machineEvent = proxyEvent as SIPMonitorMachineEvent;

                        if ((machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueCreated ||
                            machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueRemoved ||
                            machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueUpdated ||
                            machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPDialogueTransfer) && SIPEventDialogURI != null)
                        {
                            if (SIPEventDialogURI.User == WILDCARD)
                            {
                                return ShowUsername(proxyEvent.Username) && ShowMachineEvent(machineEvent.MachineEventType);
                            }
                            else
                            {
                                return proxyEvent.Username == Username && machineEvent.ResourceURI != null &&
                                    machineEvent.ResourceURI.User == SIPEventDialogURI.User && machineEvent.ResourceURI.Host == SIPEventDialogURI.Host;
                            }
                        }
                        else if ((machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPRegistrarBindingRemoval ||
                            machineEvent.MachineEventType == SIPMonitorMachineEventTypesEnum.SIPRegistrarBindingUpdate) && SIPEventPresenceURI != null)
                        {
                            if (SIPEventPresenceURI.User == WILDCARD)
                            {
                                return ShowUsername(proxyEvent.Username);
                            }
                            else
                            {
                                return proxyEvent.Username == Username && machineEvent.ResourceURI != null &&
                                    machineEvent.ResourceURI.User == SIPEventPresenceURI.User && machineEvent.ResourceURI.Host == SIPEventPresenceURI.Host;
                            }
                        }
                        else if (SIPEventDialogURI == null && SIPEventPresenceURI == null)
                        {
                            return ShowUsername(proxyEvent.Username);
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                else
                {
                    return false;
                }

                #endregion
            }
            else if (BaseType == MACHINE_BASE_TYPE && !(proxyEvent is SIPMonitorMachineEvent))
            {
                return false;
            }
            else
            {
                SIPMonitorConsoleEvent consoleEvent = proxyEvent as SIPMonitorConsoleEvent;

                string serverAddress = (consoleEvent.ServerEndPoint != null) ? consoleEvent.ServerEndPoint.Address.ToString() : null;
                string remoteIPAddress = (consoleEvent.RemoteEndPoint != null) ? consoleEvent.RemoteEndPoint.Address.ToString() : null;
                string dstIPAddress = (consoleEvent.DestinationEndPoint != null) ? consoleEvent.DestinationEndPoint.Address.ToString() : null;

                if (SIPRequestFilter != WILDCARD && consoleEvent.Message != null && consoleEvent.EventType == SIPMonitorEventTypesEnum.FullSIPTrace)
                {
                    if (ShowEvent(consoleEvent.EventType, consoleEvent.ServerEndPoint) && ShowServer(consoleEvent.ServerType))
                    {
                        if (SIPRequestFilter == SIPREQUEST_INVITE_VALUE)
                        {
                            // Do a regex to pick out ACKs, BYEs, CANCELs, INVITEs and REFERs.
                            if (Regex.Match(consoleEvent.Message, "(ACK|BYE|CANCEL|INVITE|REFER) +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ (ACK|BYE|CANCEL|INVITE|REFER)(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress));
                            }
                        }
                        else if (SIPRequestFilter == SIPREQUEST_REGISTER_VALUE)
                        {
                            // Do a regex to pick out REGISTERs.
                            if (Regex.Match(consoleEvent.Message, "REGISTER +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ REGISTER(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress));
                            }
                        }
                        else if (SIPRequestFilter == SIPREQUEST_NOTIFY_VALUE)
                        {
                            // Do a regex to pick out NOTIFYs and SUBSCRIBEs.
                            if (Regex.Match(consoleEvent.Message, "(NOTIFY|SUBSCRIBE) +?sips?:", RegexOptions.IgnoreCase).Success ||
                                Regex.Match(consoleEvent.Message, @"CSeq: \d+ (NOTIFY|SUBSCRIBE)(\r|\n)", RegexOptions.IgnoreCase).Success)
                            {
                                return ShowRegex(consoleEvent.Message) && (ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress));
                            }
                        }

                        return false;
                    }
                }

                if (ShowEvent(consoleEvent.EventType, consoleEvent.ServerEndPoint))
                {
                    bool showIPAddress = ShowIPAddress(remoteIPAddress) || ShowIPAddress(dstIPAddress);
                    bool showUsername = ShowUsername(consoleEvent.Username);
                    bool showServerIP = ShowServerIPAddress(serverAddress);
                    bool showRegex = ShowRegex(consoleEvent.Message);
                    bool showServer = ShowServer(consoleEvent.ServerType);

                    if (showUsername && showServerIP && showRegex && showIPAddress && showServer)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
コード例 #20
0
        public void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                if (sipMonitorEvent != null)
                {
                    if (sipMonitorEvent.GetType() != typeof(SIPMonitorMachineEvent))
                    {
                        logger.Debug("ra: " + sipMonitorEvent.Message);
                    }

                    if (m_monitorEventWriter != null)
                    {
                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: sipsorcery/sipsorcery
        private static void LogTraceMessage(SIPMonitorEvent monitorEvent)
        {
            if (monitorEvent is SIPMonitorConsoleEvent)
            {
                SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;

                if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace &&
                               consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction &&
                               consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing &&
                               consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage &&
                               consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAliveRelay &&
                               consoleEvent.EventType != SIPMonitorEventTypesEnum.BadSIPMessage)
                {
                    logger.Debug("Monitor: " + monitorEvent.Message);
                }
            }
        }
コード例 #22
0
 //public void RegisterListener(string address)
 //{
 //    m_publisher.RegisterListener(address);
 //}
 public void MonitorEventReceived(SIPMonitorEvent monitorEvent)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
 {
     if (SIPMonitorLogEvent_External != null)
     {
         try
         {
             SIPMonitorLogEvent_External(monitorEvent);
         }
         catch (Exception excp)
         {
             logger.Error("Exception FireProxyLogEvent SIPAppServerCore. " + excp.Message);
         }
     }
 }
コード例 #24
0
 private void LogMonitorEvent(SIPMonitorEvent monitorEvent)
 {
     if (monitorEvent is SIPMonitorConsoleEvent)
     {
         SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;
         if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace && consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction)
         {
             logger.Debug(monitorEvent.Message);
         }
     }
 }
コード例 #25
0
 private void FireSIPMonitorLogEvent(SIPMonitorEvent monitorEvent)
 {
     if (SIPMonitorLog_External != null)
     {
         try
         {
             SIPMonitorLog_External(monitorEvent);
         }
         catch (Exception excp)
         {
             logger.Error("Exception FireProxyLogEvent NATKeepAliveRelay. " + excp.Message);
         }
     }
 }
コード例 #26
0
 private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
 {
     try
     {
         if (LogDelegate_External != null)
         {
             LogDelegate_External(monitorEvent);
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception FireProxyLogEvent DialPlanEngine. " + excp.Message);
     }
 }
コード例 #27
0
 private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
 {
     if (m_registrarLogEvent != null)
     {
         try
         {
             m_registrarLogEvent(monitorEvent);
         }
         catch (Exception excp)
         {
             logger.Error("Exception FireProxyLogEvent RegistrarCore. " + excp.Message);
         }
     }
 }
コード例 #28
0
        /// <summary>
        /// Rules for displaying events.
        ///  1. The event type is checked to see if it matches. If no event type has been specified than all events EXCEPT FullSIPTrace are
        ///     matched,
        ///  2. If the event type is FullSIPTrace then the messages can be filtered on the request type. If the request type is not set all
        ///     SIP trace messages are matched otherwise only those pertaining to the request type specified,
        ///  3. The server type is checked, if it's not set all events are matched,
        ///  4. If the event has matched up until this point a decision is now made as to whether to display or reject it:
        ///     a. If the IPAddress filter is set is checked, if it matches the event is displayed otherwise it's rejected,
        ///     b. If the username AND server IP AND request type AND regex filters all match the vent is displayed otherwise rejected. 
        /// </summary>
        /// <param name="proxyEvent"></param>
        /// <returns></returns>
        public bool ShowSIPMonitorEvent(SIPMonitorEvent proxyEvent)
        {
            string serverAddress = (proxyEvent.ServerEndPoint != null) ? proxyEvent.ServerEndPoint.SocketEndPoint.Address.ToString() : null;
            string remoteIPAddress = (proxyEvent.RemoteEndPoint != null) ? proxyEvent.RemoteEndPoint.SocketEndPoint.Address.ToString() : null;
            string dstIPAddress = (proxyEvent.DestinationEndPoint != null) ? proxyEvent.DestinationEndPoint.SocketEndPoint.Address.ToString() : null;
            SIPMethodsEnum sipMethod = SIPMethodsEnum.NONE;

            if (SIPRequestFilter != WILDCARD && proxyEvent.Message != null && proxyEvent.EventType == SIPMonitorEventTypesEnum.FullSIPTrace)
            {
                if(ShowEvent(proxyEvent.EventType, proxyEvent.ServerEndPoint))
                {
                    if (SIPRequestFilter == SIPREQUEST_INVITE_VALUE)
                    {
                        // Do a regex to pick out ACK's, BYE's , CANCEL's and INVITES.
                        if (Regex.Match(proxyEvent.Message, "(ACK|BYE|CANCEL|INVITE) +?sips?:", RegexOptions.IgnoreCase).Success ||
                            Regex.Match(proxyEvent.Message, @"CSeq: \d+ (ACK|BYE|CANCEL|INVITE)(\r|\n)", RegexOptions.IgnoreCase).Success)
                        {
                            return ShowRegex(proxyEvent.Message);
                        }
                        else
                        {
                            string reqPattern = SIPRequestFilter + " +?sips?:";
                            string respPattern = @"CSeq: \d+ " + SIPRequestFilter;

                            if (Regex.Match(proxyEvent.Message, reqPattern, RegexOptions.IgnoreCase).Success ||
                                Regex.Match(proxyEvent.Message, respPattern, RegexOptions.IgnoreCase).Success)
                            {
                                return ShowRegex(proxyEvent.Message);
                            }
                        }
                    }

                    return false;
                }
            }

            if (ShowEvent(proxyEvent.EventType, proxyEvent.ServerEndPoint) && ShowServer(proxyEvent.ServerType))
            {
                if (IPAddress != WILDCARD)
                {
                    if (ShowIPAddress(remoteIPAddress))
                    {
                        return true;
                    }
                    else if (ShowIPAddress(dstIPAddress))
                    {
                         return true;
                    }
                    else
                    {
                        return false;
                    }
                }

                bool showUsername = ShowUsername(proxyEvent.Username);
                bool showServerIP = ShowServerIPAddress(serverAddress);
                bool showRequest = ShowRequest(sipMethod);
                bool showRegex = ShowRegex(proxyEvent.Message);

                if (showUsername && showServerIP && showRequest && showRegex)
                {
                    return true;
                }
            }

            return false;
        }
コード例 #29
0
        private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
        {
            try
            {
                if (monitorEvent is SIPMonitorConsoleEvent)
                {
                    SIPMonitorConsoleEvent consoleEvent = monitorEvent as SIPMonitorConsoleEvent;

                    if (m_dialPlanContext.TraceLog != null)
                    {
                        m_dialPlanContext.TraceLog.AppendLine(consoleEvent.EventType + "=> " + monitorEvent.Message);
                    }
                }

                if (m_dialPlanLogDelegate != null)
                {
                    m_dialPlanLogDelegate(monitorEvent);
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireProxyLogEvent DialPlanScriptFacade. " + excp.Message);
            }
        }
コード例 #30
0
 private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
 {
     if (StatefulProxyLogEvent_External != null)
     {
         try
         {
             StatefulProxyLogEvent_External(monitorEvent);
         }
         catch (Exception excp)
         {
             logger.Error("Exception FireProxyLogEvent SIPRegistrationAgent. " + excp.Message);
         }
     }
 }
コード例 #31
0
ファイル: ForkCall.cs プロジェクト: sipsorcery/sipsorcery
 private void FireProxyLogEvent(SIPMonitorEvent monitorEvent)
 {
     try
     {
         if (m_statefulProxyLogEvent != null)
         {
             m_statefulProxyLogEvent(monitorEvent);
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception FireProxyLogEvent ForkCall. " + excp.Message);
     }
 }
コード例 #32
0
        private void FireSIPMonitorEvent(SIPMonitorEvent sipMonitorEvent)
        {
            try
            {
                if (sipMonitorEvent != null && m_monitorEventWriter != null)
                {
                    if (sipMonitorEvent is SIPMonitorConsoleEvent)
                    {
                        SIPMonitorConsoleEvent consoleEvent = sipMonitorEvent as SIPMonitorConsoleEvent;

                        if (consoleEvent.EventType != SIPMonitorEventTypesEnum.FullSIPTrace &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.Timing &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.UnrecognisedMessage &&
                            consoleEvent.EventType != SIPMonitorEventTypesEnum.NATKeepAliveRelay &&
                           consoleEvent.EventType != SIPMonitorEventTypesEnum.BadSIPMessage)
                        {
                            logger.Debug("pr: " + sipMonitorEvent.Message);
                        }

                        if (consoleEvent.EventType != SIPMonitorEventTypesEnum.SIPTransaction)
                        {
                            m_monitorEventWriter.Send(sipMonitorEvent);
                        }
                    }
                    else
                    {
                        m_monitorEventWriter.Send(sipMonitorEvent);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception FireSIPMonitorEvent. " + excp.Message);
            }
        }