Cisco visual message waiting indicator ( VMWI or MVI )

百般思念 提交于 2019-12-23 02:56:14

问题


How can I programatically illuminate Cisco IP Phones Visual message waiting indicator (VMWI or MWI) ?

For sipwiz Answer:

IP Adress 10.1.1.2 => is local IP in which I will send SIP Notify Message

IP Address 10.1.1.9 => is IP Address of Cisco Phone that I will send SIP Message

The Cisco Phone that I send SIP Message does "care" my messages, and I got exception while i try to get response messge from Cisco Phone :"An existing connection was forcibly closed by the remote host".

Actully it does not seem to right to directly send an SIP message to Cisco Phone to change its behaviour.Because it is open to many security violations.And I think Cisco will not allow this.

"sipwiz" do I need to do extra configuration on Cisco Phone to make this feature work? Do you actually able to make it work on a real Cisco Phone? If so, what kind of extra config yo do on the Phone?


回答1:


Below is some crude code that constructs a dummy SIP NOTIFY request that can be sent to a Cisco IP Phone (only tested with a Cisco 7960) that will allow the visual Message Waiting Indicator to be set and unset.

You will need to change the sip:user@server.com to a SIP URI that your Cisco phone recognises. And also of course adjust the IP addresses and ports as required.

Update: Updated the code sample to make it a bit clearer where the IP addresses need to go in the SIP request.

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Cisco MWI Test Console:");

        string setMWIRequest =
            "NOTIFY {0} SIP/2.0\r\n" +
            "Via: SIP/2.0/UDP {1}:{2};branch=z9hG4bK{3}\r\n" +
            "To: <{0}>\r\n" +
            "From: <{0}>\r\n" +
            "Call-ID: {4}\r\n" +
            "CSeq: 1 NOTIFY\r\n" +
            "Max-Forwards: 70\r\n" +
            "Contact: {1}:{2}\r\n" +
            "Content-Length: {5}\r\n" +
            "Content-Type: application/simple-message-summary\r\n" +
            "Event: message-summary\r\n" +
            "\r\n" +
            "{6}";

        string mwiBody = "Messages-Waiting: no"; // Change to no to unset MWI.

        var localSIPEP = new IPEndPoint(IPAddress.Parse("192.168.33.116"), 5091);
        Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        udpSocket.Bind(localSIPEP);

        setMWIRequest = String.Format(setMWIRequest, "sip:user@server.com", localSIPEP.Address.ToString(), localSIPEP.Port, Guid.NewGuid().ToString().Replace("-", ""), Guid.NewGuid().ToString().Replace("-", ""), mwiBody.Length, mwiBody);

        byte[] buffer = Encoding.UTF8.GetBytes(setMWIRequest);

        Console.WriteLine("Sending to Cisco:");
        Console.WriteLine(setMWIRequest);

        udpSocket.SendTo(buffer, new IPEndPoint(IPAddress.Parse("192.168.33.155"), 5060));

        byte[] recvBuffer = new byte[4096];
        int bytesRead = udpSocket.Receive(recvBuffer);

        Console.WriteLine(Encoding.UTF8.GetString(recvBuffer.Take(bytesRead).ToArray()));

        Console.ReadLine();
    }
}


来源:https://stackoverflow.com/questions/21260123/cisco-visual-message-waiting-indicator-vmwi-or-mvi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!