Пример #1
0
        public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
            : base(sipStack)
        {
            this.mCallback = new MyMsrpCallback(this);
            base.mMediaType = mediaType;
            base.remotePartyUri = remoteUri;

            if (session == null)
            {
                base.outgoing = true;
            #if WINDOWS_PHONE
                mSession = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMsrpSessionNew(sipStack.WrappedStack, mCallback);
            #else
                mSession = new MsrpSession(sipStack.WrappedStack, mCallback);
            #endif
            }
            else
            {
                base.outgoing = false;
                mSession = session;
                mSession.setCallback(mCallback);
            }

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;
            mSession.addHeader("Subject", "FIXME");
        }
Пример #2
0
        public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
            : base(sipStack)
        {
            this.callback = new MyMsrpCallback(this);
            base.mediaType = mediaType;
            base.remotePartyUri = remoteUri;

            if (session == null)
            {
                base.outgoing = true;
                this.session = new MsrpSession(sipStack, this.callback);
            }
            else
            {
                base.outgoing = false;
                this.session = session;
                this.session.setCallback(this.callback);
            }

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #3
0
        public MyAVSession(MySipStack sipStack, CallSession session, MediaType mediaType, InviteState callState)
            : base(sipStack)
        {
            this.session = (session == null) ? new CallSession(sipStack) : session;
            base.mediaType = mediaType;
            this.state = callState;

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            // 100rel
            this.session.set100rel(true); // will add "Supported: 100rel"

            /* 3GPP TS 24.173
            *
            * 5.1 IMS communication service identifier
            * URN used to define the ICSI for the IMS Multimedia Telephony Communication Service: urn:urn-7:3gpp-service.ims.icsi.mmtel.
            * The URN is registered at http://www.3gpp.com/Uniform-Resource-Name-URN-list.html.
            * Summary of the URN: This URN indicates that the device supports the IMS Multimedia Telephony Communication Service.
            *
            * Contact: <sip:[email protected];gr=urn:uuid:xxx;comp=sigcomp>;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
            * Accept-Contact: *;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
            * P-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel
            */
            this.session.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            this.session.addHeader("Accept-Contact", "*;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            this.session.addHeader("P-Preferred-Service", "urn:urn-7:3gpp-service.ims.icsi.mmtel");
        }
Пример #4
0
        public static MyAVSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType)
        {
            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, null, mediaType, InviteState.INPROGRESS);
                MyAVSession.sessions.Add(avSession.Id, avSession);

                return(avSession);
            }
        }
Пример #5
0
        public static MyMsrpSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType, String remoteUri)
        {
            if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat)
            {
                MyMsrpSession msrpSession = new MyMsrpSession(sipStack, null, mediaType, remoteUri);
                sSessions.Add(msrpSession.Id, msrpSession);

                return(msrpSession);
            }
            return(null);
        }
Пример #6
0
        public MyMessagingSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
            this.session = new MessagingSession(sipStack);

            // commons
            base.init();

            base.ToUri = toUri;

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #7
0
        public MyMessagingSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
            this.session = new MessagingSession(sipStack);

            // commons
            base.init();

            base.ToUri = toUri;

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #8
0
        public MyMessagingSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
#if WINDOWS_PHONE
            this.session = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMessagingSessionNew(sipStack.WrappedStack);
#else
            this.session = new MessagingSession(sipStack.WrappedStack);
#endif

            // commons
            base.init();

            base.ToUri = toUri;

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #9
0
        public MyMessagingSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
            #if WINDOWS_PHONE
            this.session = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMessagingSessionNew(sipStack.WrappedStack);
            #else
            this.session = new MessagingSession(sipStack.WrappedStack);
            #endif

            // commons
            base.init();

            base.ToUri = toUri;

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #10
0
        public static MyAVSession TakeOutgoingTranferSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);

            if (media == MediaType.None)
            {
                return(null);
            }

            MyAVSession avSession = MyAVSession.CreateOutgoingSession(sipStack, session, media);

            if (sipMessage != null)
            {
                avSession.RemotePartyUri = sipMessage.getSipHeaderValue("refer-to");
            }
            return(avSession);
        }
Пример #11
0
        protected MyAVSession(MySipStack sipStack, CallSession session, MediaType mediaType, InviteState callState)
            : base(sipStack)
        {
            mSession = (session == null) ?
            #if WINDOWS_PHONE
            org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtCallSessionNew(sipStack.WrappedStack)
            #else
            new CallSession(sipStack.WrappedStack)
            #endif
                : session;
            base.mMediaType = mediaType;
            this.mState = callState;
            mMute = false;

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            // 100rel
            // mSession.set100rel(true); // See defaults

            // T.140 callback
            if ((mediaType & MediaType.T140) == MediaType.T140)
            {
                mT140Callback = new MyT140Callback(this);
                // do not set the callback as it requires a media session manager (only available when session is connected)
            }

            /* 3GPP TS 24.173
            *
            * 5.1 IMS communication service identifier
            * URN used to define the ICSI for the IMS Multimedia Telephony Communication Service: urn:urn-7:3gpp-service.ims.icsi.mmtel.
            * The URN is registered at http://www.3gpp.com/Uniform-Resource-Name-URN-list.html.
            * Summary of the URN: This URN indicates that the device supports the IMS Multimedia Telephony Communication Service.
            *
            * Contact: <sip:[email protected];gr=urn:uuid:xxx;comp=sigcomp>;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
            * Accept-Contact: *;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
            * P-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel
            */
            mSession.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            mSession.addHeader("Accept-Contact", "*;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            mSession.addHeader("P-Preferred-Service", "urn:urn-7:3gpp-service.ims.icsi.mmtel");
        }
Пример #12
0
        protected MyAVSession(MySipStack sipStack, CallSession session, MediaType mediaType, InviteState callState)
            : base(sipStack)
        {
            mSession = (session == null) ?
#if WINDOWS_PHONE
                       org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtCallSessionNew(sipStack.WrappedStack)
#else
                       new CallSession(sipStack.WrappedStack)
#endif
                : session;
            base.mMediaType = mediaType;
            this.mState     = callState;
            mMute           = false;

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            // 100rel
            // mSession.set100rel(true); // See defaults

            // T.140 callback
            if ((mediaType & MediaType.T140) == MediaType.T140)
            {
                mT140Callback = new MyT140Callback(this);
                // do not set the callback as it requires a media session manager (only available when session is connected)
            }

            /* 3GPP TS 24.173
             *
             * 5.1 IMS communication service identifier
             * URN used to define the ICSI for the IMS Multimedia Telephony Communication Service: urn:urn-7:3gpp-service.ims.icsi.mmtel.
             * The URN is registered at http://www.3gpp.com/Uniform-Resource-Name-URN-list.html.
             * Summary of the URN: This URN indicates that the device supports the IMS Multimedia Telephony Communication Service.
             *
             * Contact: <sip:[email protected];gr=urn:uuid:xxx;comp=sigcomp>;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
             * Accept-Contact: *;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"
             * P-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel
             */
            mSession.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            mSession.addHeader("Accept-Contact", "*;+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            mSession.addHeader("P-Preferred-Service", "urn:urn-7:3gpp-service.ims.icsi.mmtel");
        }
Пример #13
0
        public MyPublicationSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
            this.session = new PublicationSession(sipStack.WrappedStack);

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            // headers
            this.session.addHeader("Event", "presence");
            this.session.addHeader("Content-Type", ContentType.PIDF);

            this.ToUri   = toUri;
            this.FromUri = toUri;
        }
Пример #14
0
        public MyPublicationSession(MySipStack sipStack, String toUri)
            : base(sipStack)
        {
            this.session = new PublicationSession(sipStack.WrappedStack);

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            // headers
            this.session.addHeader("Event", "presence");
            this.session.addHeader("Content-Type", ContentType.PIDF);

            this.ToUri = toUri;
            this.FromUri = toUri;
        }
Пример #15
0
        public static MyAVSession TakeIncomingSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);

            if (media == MediaType.None)
            {
                return(null);
            }

            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, session, media, InviteState.INCOMING);
                if (sipMessage != null)
                {
                    avSession.RemotePartyUri = sipMessage.getSipHeaderValue("f");
                }
                MyAVSession.sessions.Add(avSession.Id, avSession);
                return(avSession);
            }
        }
Пример #16
0
        public MyRegistrationSession(MySipStack sipStack)
            : base(sipStack)
        {
            #if WINDOWS_PHONE
            this.session = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtRegistrationSessionNew(sipStack.WrappedStack);
            #else
            this.session = new RegistrationSession(sipStack.WrappedStack);
            #endif

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            /* support for 3GPP SMS over IP */
            this.session.addCaps("+g.3gpp.smsip", BogheCore.Utils.StringUtils.nullptr);

            /* support for OMA Large message (as per OMA SIMPLE IM v1) */
            this.session.addCaps("+g.oma.sip-im.large-message", BogheCore.Utils.StringUtils.nullptr);

            /* 3GPP TS 24.173
            *
            * 5.1 IMS communication service identifier
            * URN used to define the ICSI for the IMS Multimedia Telephony Communication Service: urn:urn-7:3gpp-service.ims.icsi.mmtel.
            * The URN is registered at http://www.3gpp.com/Uniform-Resource-Name-URN-list.html.
            * Summary of the URN: This URN indicates that the device supports the IMS Multimedia Telephony Communication Service.
            *
            * 5.2 Session control procedures
            * The multimedia telephony participant shall include the g.3gpp. icsi-ref feature tag equal to the ICSI value defined
            * in subclause 5.1 in the Contact header field in initial requests and responses as described in 3GPP TS 24.229 [13].
            */
            /* GSMA RCS phase 3 - 3.2 Registration */
            this.session.addCaps("audio", BogheCore.Utils.StringUtils.nullptr);
            this.session.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            this.session.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\"");
            // In addition, in RCS Release 3 the BA Client when used as a primary device will indicate the capability to receive SMS
            // messages over IMS by registering the SMS over IP feature tag in accordance with [24.341]:
            this.session.addCaps("+g.3gpp.cs-voice", BogheCore.Utils.StringUtils.nullptr);
        }
Пример #17
0
        public MyRegistrationSession(MySipStack sipStack)
            : base(sipStack)
        {
#if WINDOWS_PHONE
            this.session = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtRegistrationSessionNew(sipStack.WrappedStack);
#else
            this.session = new RegistrationSession(sipStack.WrappedStack);
#endif

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            /* support for 3GPP SMS over IP */
            this.session.addCaps("+g.3gpp.smsip", BogheCore.Utils.StringUtils.nullptr);

            /* support for OMA Large message (as per OMA SIMPLE IM v1) */
            this.session.addCaps("+g.oma.sip-im.large-message", BogheCore.Utils.StringUtils.nullptr);

            /* 3GPP TS 24.173
             *
             * 5.1 IMS communication service identifier
             * URN used to define the ICSI for the IMS Multimedia Telephony Communication Service: urn:urn-7:3gpp-service.ims.icsi.mmtel.
             * The URN is registered at http://www.3gpp.com/Uniform-Resource-Name-URN-list.html.
             * Summary of the URN: This URN indicates that the device supports the IMS Multimedia Telephony Communication Service.
             *
             * 5.2 Session control procedures
             * The multimedia telephony participant shall include the g.3gpp. icsi-ref feature tag equal to the ICSI value defined
             * in subclause 5.1 in the Contact header field in initial requests and responses as described in 3GPP TS 24.229 [13].
             */
            /* GSMA RCS phase 3 - 3.2 Registration */
            this.session.addCaps("audio", BogheCore.Utils.StringUtils.nullptr);
            this.session.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"");
            this.session.addCaps("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3A3gpp-application.ims.iari.gsma-vs\"");
            // In addition, in RCS Release 3 the BA Client when used as a primary device will indicate the capability to receive SMS
            // messages over IMS by registering the SMS over IP feature tag in accordance with [24.341]:
            this.session.addCaps("+g.3gpp.cs-voice", BogheCore.Utils.StringUtils.nullptr);
        }
Пример #18
0
        public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri) : base(sipStack)
        {
            this.callback       = new MyMsrpCallback(this);
            base.mediaType      = mediaType;
            base.remotePartyUri = remoteUri;

            if (session == null)
            {
                base.outgoing = true;
                this.session  = new MsrpSession(sipStack, this.callback);
            }
            else
            {
                base.outgoing = false;
                this.session  = session;
                this.session.setCallback(this.callback);
            }

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;
        }
Пример #19
0
        public MySubscriptionSession(MySipStack sipStack, String toUri, EVENT_PACKAGE_TYPE eventPackage)
            : base(sipStack)
        {
            this.session = new SubscriptionSession(sipStack);
            this.eventPackage = eventPackage;

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            switch (eventPackage)
            {
                case EVENT_PACKAGE_TYPE.CONFERENCE:
                    this.session.addHeader("Event", "conference");
                    this.session.addHeader("Accept", ContentType.CONFERENCE_INFO);
                    break;
                case EVENT_PACKAGE_TYPE.DIALOG:
                    this.session.addHeader("Event", "dialog");
                    this.session.addHeader("Accept", ContentType.DIALOG_INFO);
                    break;
                case EVENT_PACKAGE_TYPE.MESSAGE_SUMMARY:
                    this.session.addHeader("Event", "message-summary");
                    this.session.addHeader("Accept", ContentType.MESSAGE_SUMMARY);
                    break;
                case EVENT_PACKAGE_TYPE.PRESENCE:
                case EVENT_PACKAGE_TYPE.PRESENCE_LIST:
                    this.session.addHeader("Event", "presence");
                    if (eventPackage == EVENT_PACKAGE_TYPE.PRESENCE_LIST)
                    {
                        this.session.addHeader("Supported", "eventlist");
                    }
                    this.session.addHeader("Accept",
                            String.Format("{0}, {1}, {2}, {3}",
                                    ContentType.MULTIPART_RELATED,
                                    ContentType.PIDF,
                                    ContentType.RLMI,
                                    ContentType.RPID
                                    ));
                    break;
                case EVENT_PACKAGE_TYPE.REG:
                    this.session.addHeader("Event", "reg");
                    this.session.addHeader("Accept", ContentType.REG_INFO);
                    // 3GPP TS 24.229 5.1.1.6 User-initiated deregistration
                    this.session.setSilentHangup(true);
                    break;
                case EVENT_PACKAGE_TYPE.SIP_PROFILE:
                    this.session.addHeader("Event", "sip-profile");
                    this.session.addHeader("Accept", ContentType.OMA_DEFERRED_LIST);
                    break;
                case EVENT_PACKAGE_TYPE.UA_PROFILE:
                    this.session.addHeader("Event", "ua-profile");
                    this.session.addHeader("Accept", ContentType.XCAP_DIFF);
                    break;
                case EVENT_PACKAGE_TYPE.WINFO:
                    this.session.addHeader("Event", "presence.winfo");
                    this.session.addHeader("Accept", ContentType.WATCHER_INFO);
                    break;
                case EVENT_PACKAGE_TYPE.XCAP_DIFF:
                    this.session.addHeader("Event", "xcap-diff");
                    this.session.addHeader("Accept", ContentType.XCAP_DIFF);
                    break;
            }

            this.ToUri = toUri;
            // common to all subscription sessions
            this.session.addHeader("Allow-Events", "refer, presence, presence.winfo, xcap-diff, conference");
        }
Пример #20
0
 public static MyAVSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType)
 {
     return(MyAVSession.CreateOutgoingSession(sipStack, null, mediaType));
 }
Пример #21
0
 public static MyAVSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType)
 {
     return MyAVSession.CreateOutgoingSession(sipStack, null, mediaType);
 }
Пример #22
0
 protected MyInviteSession(MySipStack sipStack)
     : base(sipStack)
 {
     this.state = InviteState.NONE;
 }
Пример #23
0
        public static MyAVSession TakeIncomingSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);
            if (media == MediaType.None)
            {
                return null;
            }

            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, session, media, InviteState.INCOMING);
                if (sipMessage != null)
                {
                    avSession.RemotePartyUri = sipMessage.getSipHeaderValue("f");
                }
                MyAVSession.sessions.Add(avSession.Id, avSession);
                return avSession;
            }
        }
Пример #24
0
        public static MyAVSession TakeIncomingSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media;

            lock (MyAVSession.sessions)
            {
                switch (mediaType)
                {
                    case twrap_media_type_t.twrap_media_audio:
                        media = MediaType.Audio;
                        break;
                    case twrap_media_type_t.twrap_media_video:
                        media = MediaType.Video;
                        break;
                    case twrap_media_type_t.twrap_media_audiovideo:
                        media = MediaType.AudioVideo;
                        break;
                    default:
                        return null;
                }
                MyAVSession avSession = new MyAVSession(sipStack, session, media, InviteState.INCOMING);
                if (sipMessage != null)
                {
                    avSession.RemotePartyUri = sipMessage.getSipHeaderValue("f");
                }
                MyAVSession.sessions.Add(avSession.Id, avSession);
                return avSession;
            }
        }
Пример #25
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType     mediaType;
            SdpMessage    sdp     = message.getSdpMessage();
            String        fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return(null);
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return(null);
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");

            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name           = null;
                String type           = null;
                int    nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return(null);
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return(null);
                }
                name         = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession           = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return(msrpSession);
        }
Пример #26
0
        public static MyMsrpSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType, String remoteUri)
        {
            if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat)
            {
                MyMsrpSession msrpSession = new MyMsrpSession(sipStack, null, mediaType, remoteUri);
                sSessions.Add(msrpSession.Id, msrpSession);

                return msrpSession;
            }
            return null;
        }
Пример #27
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType mediaType;
            SdpMessage sdp = message.getSdpMessage();
            String fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return null;
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return null;
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");
            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name = null;
                String type = null;
                int nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return null;
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return null;
                }
                name = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return msrpSession;
        }
Пример #28
0
        public bool Register()
        {
            mPreferences.realm = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.REALM,
                    Configuration.DEFAULT_NETWORK_REALM);
            mPreferences.impi = this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.IMPI,
                    Configuration.DEFAULT_IDENTITY_IMPI);
            mPreferences.impu = this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.IMPU,
                    Configuration.DEFAULT_IDENTITY_IMPU);
            mPreferences.local_ip = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.LOCAL_IP,
                    Configuration.DEFAULT_NETWORK_LOCAL_IP);
            mPreferences.local_port = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.LOCAL_PORT,
                    Configuration.DEFAULT_NETWORK_LOCAL_PORT);
            tmedia_srtp_type_t srtpType = (tmedia_srtp_type_t)Enum.Parse(typeof(tmedia_srtp_type_t), this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.SRTP_TYPE, Configuration.DEFAULT_SECURITY_SRTP_TYPE), true);
            mPreferences.dtls_srtp = ((srtpType & tmedia_srtp_type_t.tmedia_srtp_type_dtls) == tmedia_srtp_type_t.tmedia_srtp_type_dtls);

            LOG.Info(String.Format(
                    "realm='{0}', impu='{1}', impi='{2}', local_ip='{3}', local_port='{4}'", mPreferences.realm, mPreferences.impu, mPreferences.impi, mPreferences.local_ip, mPreferences.local_port));

            if (mSipCallback == null)
            {
                mSipCallback = new MySipCallback(this);
            }
            if (mDebugCallback == null)
            {
                mDebugCallback = new MySipDebugCallback();
            }

            if (mSipStack == null)
            {
                mSipStack = new MySipStack(this.mSipCallback, mPreferences.realm, mPreferences.impi, mPreferences.impu);
                mSipStack.SipService = this;
                mSipStack.WrappedStack.setDebugCallback(mDebugCallback);
            }
            else
            {
                if (!mSipStack.WrappedStack.setRealm(mPreferences.realm))
                {
                    LOG.Error(String.Format("Failed to set realm: {0}", mPreferences.realm));
                    return false;
                }
                if (!mSipStack.WrappedStack.setIMPI(mPreferences.impi))
                {
                    LOG.Error(String.Format("Failed to set IMPI: {0}", mPreferences.impi));
                    return false;
                }
                if (!mSipStack.WrappedStack.setIMPU(mPreferences.impu))
                {
                    LOG.Error(String.Format("Failed to set IMPU: {0}", mPreferences.impu));
                    return false;
                }
            }

            // Set local IP
            if (!String.IsNullOrEmpty(mPreferences.local_ip))
            {
                if (!mSipStack.WrappedStack.setLocalIP(mPreferences.local_ip))
                {
                    LOG.Error(String.Format("Failed to set Local IP: {0}", mPreferences.local_ip));
                    return false;
                }
            }

            // Set local Port
            if (mPreferences.local_port > 1024 && mPreferences.local_port < 0xFFFF)
            {
                if (!mSipStack.WrappedStack.setLocalPort((ushort)mPreferences.local_port))
                {
                    LOG.Error(String.Format("Failed to set Local Port: {0}", mPreferences.local_port));
                    return false;
                }
            }

            // Set the password
            mSipStack.WrappedStack.setPassword(this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.PASSWORD,
                    BogheCore.Utils.StringUtils.nullptr));

            // Set AMF
            mSipStack.WrappedStack.setAMF(this.configurationService.Get(
                    Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IMSAKA_AMF,
                    Configuration.DEFAULT_IMSAKA_AMF));

            // Set Operator Id
            mSipStack.WrappedStack.setOperatorId(this.configurationService.Get(
                    Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IMSAKA_OPID,
                    Configuration.DEFAULT_IMSAKA_OPID));

            // Check stack validity
            if (!mSipStack.WrappedStack.isValid())
            {
                LOG.Error("Trying to use invalid stack");
                return false;
            }

            // Set STUN information
            if (this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.USE_STUN_FOR_SIP, Configuration.DEFAULT_NATT_USE_STUN_FOR_SIP))
            {
                LOG.Debug("STUN=yes");
                mSipStack.WrappedStack.setSTUNEnabled(true);
                if (this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_DISCO, Configuration.DEFAULT_NATT_STUN_DISCO))
                {
                    String domain = mPreferences.realm.Substring(mPreferences.realm.IndexOf(':') + 1);
                    ushort port = 0;
                    String server;
#if WINRT
#if WINDOWS_PHONE
                    doubango_rt.BackEnd.rtDnsResult dnsResult = mSipStack.WrappedStack.dnsSrv(String.Format("_stun._udp.{0}", domain));
                    server = dnsResult.Address;
                    port = dnsResult.Port;
#else
                    IntPtr _port = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(ushort));
                    server = mSipStack.WrappedStack.dnsSrv(String.Format("_stun._udp.{0}", domain), _port);
                    port = (ushort)System.Runtime.InteropServices.Marshal.ReadInt16(_port);
                    System.Runtime.InteropServices.Marshal.FreeHGlobal(_port);
#endif
#else
                    server = mSipStack.WrappedStack.dnsSrv(String.Format("_stun._udp.{0}", domain), out port);
#endif
                    if (server == null)
                    {
                        LOG.Error("STUN discovery has failed");
                    }
                    LOG.Debug(String.Format("STUN1 - server={0} and port={1}", server, port));
                    mSipStack.WrappedStack.setSTUNServer(server, port);// Needed event if null
                }
                else
                {
                    String server = this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_SERVER, Configuration.DEFAULT_NATT_STUN_SERVER);
                    int port = this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_PORT, Configuration.DEFAULT_NATT_STUN_PORT);
                    LOG.Info(String.Format("STUN2 - server={0} and port={1}", server, port));
                    mSipStack.WrappedStack.setSTUNServer(server, (ushort)port);
                }
            }
            else
            {
                LOG.Debug("STUN=no");
                mSipStack.WrappedStack.setSTUNEnabled(false);
            }

            // Set Proxy-CSCF
            mPreferences.pcscf_host = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_HOST,
                    BogheCore.Utils.StringUtils.nullptr); // null will trigger DNS NAPTR+SRV
            mPreferences.pcscf_port = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_PORT,
                    Configuration.DEFAULT_NETWORK_PCSCF_PORT);
            mPreferences.transport = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.TRANSPORT,
                    Configuration.DEFAULT_NETWORK_TRANSPORT);
            mPreferences.ipversion = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.IP_VERSION,
                    Configuration.DEFAULT_NETWORK_IP_VERSION);

            LOG.Debug(String.Format(
                    "pcscf-host='{0}', pcscf-port='{1}', transport='{2}', ipversion='{3}'",
                    mPreferences.pcscf_host, mPreferences.pcscf_port, mPreferences.transport, mPreferences.ipversion));

            if (!mSipStack.WrappedStack.setProxyCSCF(mPreferences.pcscf_host, (ushort)mPreferences.pcscf_port, mPreferences.transport,
                    mPreferences.ipversion))
            {
                LOG.Error("Failed to set Proxy-CSCF parameters");
                return false;
            }

            // Set TLS parameters (used for both DTLS-SRTP and TLS)
            String privKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_PRIV_KEY_FILE, Configuration.DEFAULT_TLS_PRIV_KEY_FILE);
            String pubKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_PUB_KEY_FILE, Configuration.DEFAULT_TLS_PUB_KEY_FILE);
            String caKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_CA_FILE, Configuration.DEFAULT_TLS_CA_FILE);

            LOG.Debug(String.Format("TLS pubKey={0} privKey={1} caKey={2} dtls-strp={3}", privKey, pubKey, caKey, mPreferences.dtls_srtp));
            if (!mSipStack.WrappedStack.setSSLCertificates(privKey, pubKey, caKey))
            {
                LOG.Error("Failed to set SSL certificates");
            }

            // Set IPSec => only if TLS is disabled
            if (this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_SEC_AGREE, Configuration.DEFAULT_SECURITY_IPSEC_SEC_AGREE))
            {
                mPreferences.ipsec_secagree = true;
                String algo = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_ALGO, Configuration.DEFAULT_SECURITY_IPSEC_ALGO);
                String ealgo = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_EALGO, Configuration.DEFAULT_SECURITY_IPSEC_EALGO);
                String mode = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_MODE, Configuration.DEFAULT_SECURITY_IPSEC_MODE);
                String proto = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_PROTO, Configuration.DEFAULT_SECURITY_IPSEC_PROTO);

                LOG.Debug(String.Format("IPSec secagree enable with algo={0} ealgo={1} mode={2} proto={3}", algo, ealgo, mode, proto));
                if (!mSipStack.WrappedStack.setIPSecParameters(algo, ealgo, mode, proto) || !mSipStack.WrappedStack.setIPSecSecAgree(true))
                {
                    LOG.Error("Failed to set IPSec parameters");
                }
            }
            else if (mPreferences.ipsec_secagree)
            {
                mPreferences.ipsec_secagree = false;
                // Disable IPSec secagree
                mSipStack.WrappedStack.setIPSecSecAgree(false);
            }
           

            // Whether to use DNS NAPTR+SRV for the Proxy-CSCF discovery (even if the DNS requests are sent only when the stack starts,
            // should be done after setProxyCSCF())
            mSipStack.WrappedStack.setDnsDiscovery(this.configurationService.Get(Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_DISCOVERY_DNS, Configuration.DEFAULT_NETWORK_PCSCF_DISCOVERY_DNS));

            // enable/disable 3GPP early IMS
            mSipStack.WrappedStack.setEarlyIMS(this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.EARLY_IMS,
                    Configuration.DEFAULT_NETWORK_EARLY_IMS));

            // SigComp (only update compartment Id if changed)
            if (this.configurationService.Get(Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.SIGCOMP, Configuration.DEFAULT_NETWORK_SIGCOMP))
            {
                String compId = String.Format("urn:uuid:{0}", Guid.NewGuid().ToString());
                this.mSipStack.SigCompId = compId;
                LOG.Debug(String.Format("SigComp enable with uuid={0}", compId));
            }
            else
            {
                this.mSipStack.SigCompId = null;
            }

            // Set Privacy
            this.mSipStack.Privacy = this.configurationService.Get(Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.PRIVACY, Configuration.DEFAULT_IDENTITY_PRIVACY);

            // Start the Stack
            if (!mSipStack.WrappedStack.start())
            {
                LOG.Error("Failed to start the SIP stack");
                return false;
            }

            // Other Preference values
            mPreferences.xcap_enabled = this.configurationService.Get(
                    Configuration.ConfFolder.XCAP, Configuration.ConfEntry.ENABLED,
                    Configuration.DEFAULT_XCAP_ENABLED);
            mPreferences.presence_sub = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.PRESENCE_SUB,
                    Configuration.DEFAULT_RCS_PRESENCE_SUB);
            mPreferences.presence_rls = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.RLS,
                    Configuration.DEFAULT_RCS_RLS);
            mPreferences.presence_pub = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.PRESENCE_PUB,
                    Configuration.DEFAULT_RCS_PRESENCE_PUB);
            mPreferences.mwi = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.MWI,
                    Configuration.DEFAULT_RCS_MWI);

            // Create registration session
            if (mRegSession == null)
            {
                mRegSession = new MyRegistrationSession(this.mSipStack);
            }
            else
            {
                mRegSession.SigCompId = this.mSipStack.SigCompId;
            }

            // Set/update From URI. For Registration ToUri should be equals to realm
            // (done by the stack)
            mRegSession.FromUri = mPreferences.impu;
            /* this.regSession.setToUri(mPreferences.impu); */

            // Update default identity to the current IMPU before registering
            this.DefaultIdentity = mPreferences.impu;

            if (!mRegSession.register())
            {
                LOG.Error("Failed to send REGISTER request");
                return false;
            }

            return true;
        }
Пример #29
0
        public bool Stop()
#endif
        {
            bool ret = true;

#if WINDOWS_PHONE
            if (bEnteringBackground)
            {
                if (mSipStack != null && mSipStack.WrappedStack != null)
                {
                    mSipStack.WrappedStack.setDebugCallback(null);
                }
            }
#endif

            if (mSipStack != null && (mSipStack.State == MySipStack.STACK_STATE.STARTED || mSipStack.State == MySipStack.STACK_STATE.STARTING))
            {
                ret = mSipStack.WrappedStack.stop();
            }
#if !WINRT
            this.xcapService.onXcapEvent -= this.xcapService_onXcapEvent;
#endif
            this.contactService.onContactEvent -= this.contactService_onContactEvent;

#if WINDOWS_PHONE
            if (bEnteringBackground)
            {
                mSipStack = null;
                mSipCallback = null;
                mDebugCallback = null;
                mRegSession = null;
            }
#endif
            return ret;
        }
Пример #30
0
        public static MyAVSession CreateOutgoingSession(MySipStack sipStack, MediaType mediaType)
        {
            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, null, mediaType, InviteState.INPROGRESS);
                MyAVSession.sessions.Add(avSession.Id, avSession);

                return avSession;
            }
        }
Пример #31
0
        public bool Register()
        {
            this.preferences.realm = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.REALM,
                    Configuration.DEFAULT_REALM);
            this.preferences.impi = this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.IMPI,
                    Configuration.DEFAULT_IMPI);
            this.preferences.impu = this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.IMPU,
                    Configuration.DEFAULT_IMPU);

            LOG.Info(String.Format(
                    "realm='{0}', impu='{1}', impi='{2}'", this.preferences.realm, this.preferences.impu, this.preferences.impi));

            if (this.sipStack == null)
            {
                this.sipStack = new MySipStack(this.sipCallback, this.preferences.realm, this.preferences.impi, this.preferences.impu);
                this.sipStack.setDebugCallback(this.debugCallback);
                // Set UserAgent
            }
            else
            {
                if (!this.sipStack.setRealm(this.preferences.realm))
                {
                    LOG.Error(String.Format("Failed to set realm: {0}", this.preferences.realm));
                    return false;
                }
                if (!this.sipStack.setIMPI(this.preferences.impi))
                {
                    LOG.Error(String.Format("Failed to set IMPI: {0}", this.preferences.impi));
                    return false;
                }
                if (!this.sipStack.setIMPU(this.preferences.impu))
                {
                    LOG.Error(String.Format("Failed to set IMPU: {0}", this.preferences.impu));
                    return false;
                }
            }

            // Set the password
            this.sipStack.setPassword(this.configurationService.Get(
                    Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.PASSWORD,
                    null));

            // Set AMF
            this.sipStack.setAMF(this.configurationService.Get(
                    Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IMSAKA_AMF,
                    Configuration.DEFAULT_IMSAKA_AMF));

            // Set Operator Id
            this.sipStack.setOperatorId(this.configurationService.Get(
                    Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IMSAKA_OPID,
                    Configuration.DEFAULT_IMSAKA_OPID));

            // Check stack validity
            if (!this.sipStack.isValid())
            {
                LOG.Error("Trying to use invalid stack");
                return false;
            }

            // Set STUN information
            if (this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.USE_STUN, Configuration.DEFAULT_NATT_USE_STUN))
            {
                LOG.Debug("STUN=yes");
                if (this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_DISCO, Configuration.DEFAULT_NATT_STUN_DISCO))
                {
                    String domain = this.preferences.realm.Substring(this.preferences.realm.IndexOf(':') + 1);
                    ushort port = 0;
                    String server = this.sipStack.dnsSrv(String.Format("_stun._udp.{0}", domain), out port);
                    if (server == null)
                    {
                        LOG.Error("STUN discovery has failed");
                    }
                    LOG.Debug(String.Format("STUN1 - server={0} and port={1}", server, port));
                    this.sipStack.setSTUNServer(server, port);// Needed event if null
                }
                else
                {
                    String server = this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_SERVER, Configuration.DEFAULT_NATT_STUN_SERVER);
                    int port = this.configurationService.Get(Configuration.ConfFolder.NATT, Configuration.ConfEntry.STUN_PORT, Configuration.DEFAULT_NATT_STUN_PORT);
                    LOG.Info(String.Format("STUN2 - server={0} and port={1}", server, port));
                    this.sipStack.setSTUNServer(server, (ushort)port);
                }
            }
            else
            {
                LOG.Debug("STUN=no");
                this.sipStack.setSTUNServer(null, 0);
            }

            // Set Proxy-CSCF
            this.preferences.pcscf_host = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_HOST,
                    null); // null will trigger DNS NAPTR+SRV
            this.preferences.pcscf_port = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_PORT,
                    Configuration.DEFAULT_PCSCF_PORT);
            this.preferences.transport = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.TRANSPORT,
                    Configuration.DEFAULT_TRANSPORT);
            this.preferences.ipversion = this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.IP_VERSION,
                    Configuration.DEFAULT_IP_VERSION);

            LOG.Debug(String.Format(
                    "pcscf-host='{0}', pcscf-port='{1}', transport='{2}', ipversion='{3}'",
                    this.preferences.pcscf_host, this.preferences.pcscf_port, this.preferences.transport, this.preferences.ipversion));

            if (!this.sipStack.setProxyCSCF(this.preferences.pcscf_host, (ushort)this.preferences.pcscf_port, this.preferences.transport,
                    this.preferences.ipversion))
            {
                LOG.Error("Failed to set Proxy-CSCF parameters");
                return false;
            }

            // Set TLS parameters
            if ("tls".Equals(this.preferences.transport, StringComparison.InvariantCultureIgnoreCase))
            {
                String privKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_PRIV_KEY_FILE, Configuration.DEFAULT_TLS_PRIV_KEY_FILE);
                String pubKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_PUB_KEY_FILE, Configuration.DEFAULT_TLS_PUB_KEY_FILE);
                String caKey = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.TLS_CA_FILE, Configuration.DEFAULT_TLS_CA_FILE);
                LOG.Debug(String.Format("TLS pubKey={0} privKey={1} caKey={2}", privKey, pubKey, caKey));
                if (!String.IsNullOrEmpty(privKey) || !String.IsNullOrEmpty(pubKey) || !String.IsNullOrEmpty(caKey))
                {
                    if (!this.sipStack.setSSLCretificates(privKey, pubKey, caKey))
                    {
                        LOG.Error("Failed to set SSL certificates");
                    }
                }
            }

            // Set IPSec => only if TLS is disabled
            if (this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_SEC_AGREE, Configuration.DEFAULT_SECURITY_IPSEC_SEC_AGREE))
            {
                this.preferences.ipsec_secagree = true;
                String algo = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_ALGO, Configuration.DEFAULT_SECURITY_IPSEC_ALGO);
                String ealgo = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_EALGO, Configuration.DEFAULT_SECURITY_IPSEC_EALGO);
                String mode = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_MODE, Configuration.DEFAULT_SECURITY_IPSEC_MODE);
                String proto = this.configurationService.Get(Configuration.ConfFolder.SECURITY, Configuration.ConfEntry.IPSEC_PROTO, Configuration.DEFAULT_SECURITY_IPSEC_PROTO);

                LOG.Debug(String.Format("IPSec secagree enable with algo={0} ealgo={1} mode={2} proto={3}", algo, ealgo, mode, proto));
                if (!this.sipStack.setIPSecParameters(algo, ealgo, mode, mode) || !this.sipStack.setIPSecSecAgree(true))
                {
                    LOG.Error("Failed to set IPSec parameters");
                }
            }
            else if (this.preferences.ipsec_secagree)
            {
                this.preferences.ipsec_secagree = false;
                // Disable IPSec secagree
                this.sipStack.setIPSecSecAgree(false);
            }

            // Whether to use DNS NAPTR+SRV for the Proxy-CSCF discovery (even if the DNS requests are sent only when the stack starts,
            // should be done after setProxyCSCF())
            this.sipStack.setDnsDiscovery(this.configurationService.Get(Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.PCSCF_DISCOVERY_DNS, Configuration.DEFAULT_PCSCF_DISCOVERY_DNS));

            // enable/disable 3GPP early IMS
            this.sipStack.setEarlyIMS(this.configurationService.Get(
                    Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.EARLY_IMS,
                    Configuration.DEFAULT_EARLY_IMS));

            // SigComp (only update compartment Id if changed)
            if (this.configurationService.Get(Configuration.ConfFolder.NETWORK, Configuration.ConfEntry.SIGCOMP, Configuration.DEFAULT_SIGCOMP))
            {
                String compId = String.Format("urn:uuid:%s", Guid.NewGuid().ToString());
                this.sipStack.SigCompId = compId;
                LOG.Debug(String.Format("SigComp enable with uuid={0}", compId));
            }
            else
            {
                this.sipStack.SigCompId = null;
            }

            // Set Privacy
            this.sipStack.Privacy = this.configurationService.Get(Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.PRIVACY, Configuration.DEFAULT_PRIVACY);

            // Start the Stack
            if (!this.sipStack.start())
            {
                LOG.Error("Failed to start the SIP stack");
                return false;
            }

            // Other Preference values
            this.preferences.xcap_enabled = this.configurationService.Get(
                    Configuration.ConfFolder.XCAP, Configuration.ConfEntry.ENABLED,
                    Configuration.DEFAULT_XCAP_ENABLED);
            this.preferences.presence_sub = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.PRESENCE_SUB,
                    Configuration.DEFAULT_RCS_PRESENCE_SUB);
            this.preferences.presence_rls = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.RLS,
                    Configuration.DEFAULT_RCS_RLS);
            this.preferences.presence_pub = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.PRESENCE_PUB,
                    Configuration.DEFAULT_RCS_PRESENCE_PUB);
            this.preferences.mwi = this.configurationService.Get(
                    Configuration.ConfFolder.RCS, Configuration.ConfEntry.MWI,
                    Configuration.DEFAULT_RCS_MWI);

            // Create registration session
            if (this.regSession == null)
            {
                this.regSession = new MyRegistrationSession(this.sipStack);
            }
            else
            {
                this.regSession.SigCompId = this.sipStack.SigCompId;
            }

            // Set/update From URI. For Registration ToUri should be equals to realm
            // (done by the stack)
            this.regSession.FromUri = this.preferences.impu;
            /* this.regSession.setToUri(this.preferences.impu); */

            // Update default identity to the current IMPU before registering
            this.DefaultIdentity = this.preferences.impu;

            if (!this.regSession.register())
            {
                LOG.Error("Failed to send REGISTER request");
                return false;
            }

            return true;
        }
Пример #32
0
        public static MyAVSession TakeOutgoingTranferSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);
            if (media == MediaType.None)
            {
                return null;
            }

            MyAVSession avSession = MyAVSession.CreateOutgoingSession(sipStack, session, media);
            if (sipMessage != null)
            {
                avSession.RemotePartyUri = sipMessage.getSipHeaderValue("refer-to");
            }
            return avSession;
        }
Пример #33
0
        public MySubscriptionSession(MySipStack sipStack, String toUri, EVENT_PACKAGE_TYPE eventPackage)
            : base(sipStack)
        {
            this.session      = new SubscriptionSession(sipStack);
            this.eventPackage = eventPackage;

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;

            switch (eventPackage)
            {
            case EVENT_PACKAGE_TYPE.CONFERENCE:
                this.session.addHeader("Event", "conference");
                this.session.addHeader("Accept", ContentType.CONFERENCE_INFO);
                break;

            case EVENT_PACKAGE_TYPE.DIALOG:
                this.session.addHeader("Event", "dialog");
                this.session.addHeader("Accept", ContentType.DIALOG_INFO);
                break;

            case EVENT_PACKAGE_TYPE.MESSAGE_SUMMARY:
                this.session.addHeader("Event", "message-summary");
                this.session.addHeader("Accept", ContentType.MESSAGE_SUMMARY);
                break;

            case EVENT_PACKAGE_TYPE.PRESENCE:
            case EVENT_PACKAGE_TYPE.PRESENCE_LIST:
                this.session.addHeader("Event", "presence");
                if (eventPackage == EVENT_PACKAGE_TYPE.PRESENCE_LIST)
                {
                    this.session.addHeader("Supported", "eventlist");
                }
                this.session.addHeader("Accept",
                                       String.Format("{0}, {1}, {2}, {3}",
                                                     ContentType.MULTIPART_RELATED,
                                                     ContentType.PIDF,
                                                     ContentType.RLMI,
                                                     ContentType.RPID
                                                     ));
                break;

            case EVENT_PACKAGE_TYPE.REG:
                this.session.addHeader("Event", "reg");
                this.session.addHeader("Accept", ContentType.REG_INFO);
                // 3GPP TS 24.229 5.1.1.6 User-initiated deregistration
                this.session.setSilentHangup(true);
                break;

            case EVENT_PACKAGE_TYPE.SIP_PROFILE:
                this.session.addHeader("Event", "sip-profile");
                this.session.addHeader("Accept", ContentType.OMA_DEFERRED_LIST);
                break;

            case EVENT_PACKAGE_TYPE.UA_PROFILE:
                this.session.addHeader("Event", "ua-profile");
                this.session.addHeader("Accept", ContentType.XCAP_DIFF);
                break;

            case EVENT_PACKAGE_TYPE.WINFO:
                this.session.addHeader("Event", "presence.winfo");
                this.session.addHeader("Accept", ContentType.WATCHER_INFO);
                break;

            case EVENT_PACKAGE_TYPE.XCAP_DIFF:
                this.session.addHeader("Event", "xcap-diff");
                this.session.addHeader("Accept", ContentType.XCAP_DIFF);
                break;
            }

            this.ToUri = toUri;
            // common to all subscription sessions
            this.session.addHeader("Allow-Events", "refer, presence, presence.winfo, xcap-diff, conference");
        }
Пример #34
0
 protected MyInviteSession(MySipStack sipStack)
     : base(sipStack)
 {
     this.state = InviteState.NONE;
 }