SIP has been broken and I just noticed

Issue #685 resolved
Anonymous created an issue

Here are my settings:

if failed
                host 38.102.250.40 port 4065 type udp protocol sip
                with target "38.102.250.40:4065" and maxforward 0
                with timeout 5 seconds
                                retry 2
        then alert

However when do capture I get this in the sip messages

09:32:17.507133 IP sbc16n1-la.siptalk.com.41262 > outbound.internetcalls4you.com.7060: UDP, length 371
E...0t@.@...&f.=&f.(.....{B.OPTIONS sip:test@38.102.250.40:7060 SIP/2.0
Via: SIP/2.0/UDP 38.102.250.61:41262;branch=z9hG4bKh229517444;rport
Max-Forwards: 70
To: <sip:test@38.102.250.40:7060>
From: monit <sip:monit@38.102.250.61>;tag=1788031191
Call-ID: 1928261051
CSeq: 63104 OPTIONS
Contact: <sip:38.102.250.61:41262>
Accept: application/sdp
Content-Length: 0
User-Agent: Monit/5.23.0

Notice that Max-Forwards: 70 despite settings. This breaks the monitoring.

Comments (4)

  1. Alexander Litvak

    Hackin it to 0 (not a solution for everyone), make it work for me. Could it be the that somehow

     const char *target = P->parameters.sip.target ? P->parameters.sip.target : "monit@foo.bar";
            int maxforward  = P->parameters.sip.maxforward ? P->parameters.sip.maxforward : 0;
    
        int port = Socket_getLocalPort(socket);
        char *proto = Socket_isSecure(socket) ? "sips" : "sip";
    
        char *transport = "";
        char *rport = "";
        switch (Socket_getType(socket)) {
                case Socket_Udp:
                        transport = "UDP";
                        rport = ";rport";
                        break;
                case Socket_Tcp:
                        transport = "TCP";
                        break;
                default:
                        THROW(IOException, "Unsupported socket type, only TCP and UDP are supported");
                        break;
        }
    
        char buf[STRLEN];
        const char *myip = Socket_getLocalHost(socket, buf, sizeof(buf));
    
        if (Socket_print(socket,
                         "OPTIONS %s:%s SIP/2.0\r\n"
                         "Via: SIP/2.0/%s %s:%d;branch=z9hG4bKh%ld%s\r\n"
                         "Max-Forwards: %d\r\n"
                         "To: <%s:%s>\r\n"
                         "From: monit <%s:monit@%s>;tag=%ld\r\n"
                         "Call-ID: %ld\r\n"
                         "CSeq: 63104 OPTIONS\r\n"
                         "Contact: <%s:%s:%d>\r\n"
                         "Accept: application/sdp\r\n"
                         "Content-Length: 0\r\n"
                         "User-Agent: Monit/%s\r\n\r\n",
                         proto,                        // protocol
                         target,                       // to
                         transport,                    // via transport udp|tcp
                         myip,                         // who its from
                         port,                         // our port
                         random(),                     // branch
                         rport,                        // rport option
                         maxforward,               // maximum number of forwards        
                         proto,                        // protocol
    

    ```

  2. Log in to comment