コード例 #1
0
        private SipDialogMessage ParseDialog(KamailioData kamailioData)
        {
            DialogStatus dialogStatus;

            if (!Enum.TryParse(kamailioData.GetField("dstat"), true, out dialogStatus))
            {
                log.Warn("Unable to parse dstat field of Kamailio dialog message");
                return(null);
            }

            var dialog = new SipDialogMessage
            {
                Status          = dialogStatus,
                CallId          = kamailioData.GetField("ci"),
                HashId          = kamailioData.GetField("hashid"),
                HashEntry       = kamailioData.GetField("hashent"),
                FromDisplayName = ParseDisplayName(kamailioData.GetField("fn")),
                ToDisplayName   = ParseDisplayName(kamailioData.GetField("tn")),
                FromSipUri      = new SipUri(kamailioData.GetField("fu")),
                ToSipUri        = new SipUri(kamailioData.GetField("ru")),
                FromTag         = kamailioData.GetField("fot"),
                ToTag           = kamailioData.GetField("tot"),
                Sdp             = kamailioData.GetField("sdp"),
                HangupReason    = kamailioData.GetField("hr")
            };

            // Fix for empty ru-field in Kamailio data
            if (dialog.ToSipUri == null || string.IsNullOrEmpty(dialog.ToSipUri.User))
            {
                dialog.ToSipUri = new SipUri(kamailioData.GetField("tu"));
            }

            return(dialog);
        }
コード例 #2
0
        private SipRegistrationExpireMessage ParseRegExpire(KamailioData kamailioData)
        {
            // TODO: Is this one ever called?
            var expire = new SipRegistrationExpireMessage()
            {
                SipAddress = new SipUri(kamailioData.GetField("aor")),
                ReceivedIp = kamailioData.GetField("ip"),
            };

            return(expire);
        }
コード例 #3
0
        private SipRegistrationMessage ParseRegistration(KamailioData kamailioData)
        {
            var registration = new SipRegistrationMessage()
            {
                Ip              = kamailioData.GetField("si"),
                Port            = ParseInt(kamailioData.GetField("sp")),
                UnixTimeStamp   = ParseLong(kamailioData.GetField("TS")),
                Sip             = new SipUri(kamailioData.GetField("fu")),
                FromDisplayName = ParseDisplayName(kamailioData.GetField("fn")),
                UserAgent       = kamailioData.GetField("ua"),
                Username        = kamailioData.GetField("Au"),
                ToDisplayName   = ParseDisplayName(kamailioData.GetField("tn")),
                Expires         = ParseInt(kamailioData.GetField("Expires"), DefaultExpireValue),

                // Not in use
                //ToUsername = kamailioData.GetField("rU"),
                //RequestedSip = new SipUri(kamailioData.GetField("ru")),
                //ReceivedIp = kamailioData.GetField("Ri"),
                //ReceivedPort = ParseInt(kamailioData.GetField("Rp")),
                //CallId = kamailioData.GetField("ci"),
            };

            return(registration);
        }