MayamaTakeshi / sip-lab

A node module that helps to write SIP functional tests
3 stars 2 forks source link

Remove default header Supported #109

Closed MayamaTakeshi closed 2 weeks ago

MayamaTakeshi commented 2 weeks ago

Currently, we have this by default:

Supported:replaces

However some users want to set timer support so they add headers and end up with something like this:

Supported:replaces
Supported:timer
Session-Expires: 300
Min-SE: 300

This should be OK but some SIP UAS have problem with more than one header Supported. So we should remove this default header.

MayamaTakeshi commented 2 weeks ago

I have removed the header Supported from INVITE requests but it was not possible to do the same for 183/200 replies due to an issue with pjsip itself (I'm checking with devs).

MayamaTakeshi commented 2 weeks ago

The problem is that module 100rel adds:

Support:100rel

to the request. I tried to not load it but as mentioned in pjsip/pjproject issues 4082 this module is mandatory.

I tried anyway to comment the assertion line but then a test failed with:

node: ../src/pjsip/sip_dialog.c:1082: pjsip_dlg_add_usage: Assertion `mod->id >= 0 && mod->id < 32' failed.

Thread 1 "node" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737352521728) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737352521728) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737352521728) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737352521728, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff7842476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff78287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff782871b in __assert_fail_base (fmt=0x7ffff79dd130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff443fc62 "mod->id >= 0 && mod->id < 32", file=0x7ffff443fb01 "../src/pjsip/sip_dialog.c", line=1082, 
    function=<optimized out>) at ./assert/assert.c:92
#6  0x00007ffff7839e96 in __GI___assert_fail (assertion=assertion@entry=0x7ffff443fc62 "mod->id >= 0 && mod->id < 32", file=file@entry=0x7ffff443fb01 "../src/pjsip/sip_dialog.c", line=line@entry=1082, 
    function=function@entry=0x7ffff4440520 <__PRETTY_FUNCTION__.17> "pjsip_dlg_add_usage") at ./assert/assert.c:101
#7  0x00007ffff430d335 in pjsip_dlg_add_usage (dlg=0x5c65b78, mod=<optimized out>, mod@entry=0x7ffff44e2e80 <mod_100rel>, mod_data=mod_data@entry=0x5c82ba0) at ../src/pjsip/sip_dialog.c:1082
#8  0x00007ffff432136d in pjsip_100rel_attach (inv=inv@entry=0x5c81dd8) at ../src/pjsip-ua/sip_100rel.c:204
#9  0x00007ffff431561d in pjsip_inv_create_uac (dlg=0x5c65b78, local_sdp=<optimized out>, options=0, p_inv=0x7fffffffb410) at ../src/pjsip-ua/sip_inv.c:1063
#10 0x00007ffff428c19c in call_create (document=..., proxy_uri=<optimized out>, dlg=<optimized out>, flags=<optimized out>, t=<optimized out>) at ../src/sip.cpp:3223
#11 pjw_call_create (t_id=t_id@entry=0, json=<optimized out>, out_call_id=out_call_id@entry=0x7fffffffc6d8, out_sip_call_id=out_sip_call_id@entry=0x7fffffffc750 "") at ../src/sip.cpp:2950
#12 0x00007ffff429d98d in call_create (info=...) at /usr/include/c++/11/bits/basic_string.h:194
#13 0x00007ffff42a4de5 in Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::{lambda()#1}::operator()() const (__closure=<synthetic pointer>, 
    __closure=<synthetic pointer>) at /home/takeshi/src/git/MayamaTakeshi/sip-lab/node_modules/node-addon-api/napi-inl.h:111
#14 Napi::details::WrapCallback<Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::{lambda()#1}>(Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::{lambda()#1}) (callback=...) at /home/takeshi/src/git/MayamaTakeshi/sip-lab/node_modules/node-addon-api/napi-inl.h:73
#15 Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper (env=0x5b00b30, info=0x7fffffffc950) at /home/takeshi/src/git/MayamaTakeshi/sip-lab/node_modules/node-addon-api/napi-inl.h:106
#16 0x0000000000d7c3a9 in v8impl::(anonymous namespace)::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo<v8::Value> const&) ()
#17 0x00007fffefc0eadd in ?? ()
#18 0x00007fffffffca10 in ?? ()
#19 0x00007fffffffca48 in ?? ()
#20 0x0000000000000002 in ?? ()
#21 0x0000000000000060 in ?? ()
#22 0x0000119e69b68681 in ?? ()
#23 0x00007fffffffc9b0 in ?? ()
MayamaTakeshi commented 2 weeks ago

If we do:

    sip.call.respond(ic.id, {code: 200, reason: 'OK'})

we get this:

SIP/2.0 200 OK
Via: SIP/2.0/UDP 127.0.0.1:5060;rport=5060;received=127.0.0.1;branch=z9hG4bKPjc01d551f-072c-42a9-aa81-22c867e29ee5
Call-ID: 11651fb5-8bcc-4c04-899a-f424b94ee35d
From: <sip:alice@test.com>;tag=77a7afb8-6f2a-42ed-a930-63f538baa746
To: <sip:bob@127.0.0.1>;tag=d5886833-e89b-4284-abe2-2e530dde413b
CSeq: 22333 INVITE
Contact: <sip:sip-lab@127.0.0.1:5061>
Allow: MESSAGE, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE
Supported: 100rel
Content-Type: application/sdp
Content-Length:   245

Notice the 'Supported: 100rel'

However, if I do:

    sip.call.respond(ic.id, {code: 200, reason: 'OK',
       headers: {
           Supported: 'timer',
           'Min-SE': '300',
           'Session-Expires': '350',
       },
    })

I get:

SIP/2.0 200 OK
Via: SIP/2.0/UDP 127.0.0.1:5060;rport=5060;received=127.0.0.1;branch=z9hG4bKPj0dbcf158-4e5f-4b45-bd27-58ee15b475c3
Call-ID: 11651fb5-8bcc-4c04-899a-f424b94ee35d
From: <sip:alice@test.com>;tag=77a7afb8-6f2a-42ed-a930-63f538baa746
To: <sip:bob@127.0.0.1>;tag=d5886833-e89b-4284-abe2-2e530dde413b
CSeq: 22332 INVITE
Contact: <sip:sip-lab@127.0.0.1:5061>
Allow: MESSAGE, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE
Supported: timer
Min-SE: 300
Session-Expires: 350
Content-Type: application/sdp
Content-Length:   245

Notice that the 100rel disappeared. So i think there will be no issues with Supported. So I am closing this ticket. It will continue on #110.