<!-- Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for feature requests.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If you submit a feature request (or enhancement) add the description of what you would like to be added.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment). -->
### Description
<!-- Explain what you did, what you expected to happen, and what actually happened. -->
Sometimes need to add rport on outbound uac reg, but seems it's not possible in the current uac module. Would be good to an an extra param to do it, or is it possible to trigger a KEMI event route so a script can add whatever it need before sending the register msg?
Thanks.
### Expected behavior
#### Actual observed behavior
#### Debugging Data
``` (paste your debugging data here) ```
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your log messages here) ```
#### SIP Traffic
<!-- If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your sip traffic here) ```
### Possible Solutions
<!-- If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a improvement. -->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` (paste your output here) ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) -->
``` (paste your output here) ```
In the master brach should work by setting global `local_rport=yes` -- it is in core because the Via header is generated independent of uac module.
The event_route[tm:local-request] should be called for local generated requests, including the REGISTER requests from uac module. You can try to use add_local_rport() there, not sure it works for it, but worth testing.
with docker image image: kamailio/kamailio-ci:5.4.4-alpine
added the following config I get err
local_rport=yes
``` xcc-kamailio | 0(9) CRITICAL: <core> [core/cfg.y:3592]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 128, column 12: syntax error xcc-kamailio | 0(9) CRITICAL: <core> [core/cfg.y:3592]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 128, column 12: unknown config variable xcc-kamailio | 0(9) CRITICAL: <core> [core/cfg.y:3589]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 128, column 13-15: xcc-kamailio | ERROR: bad config file (3 errors) ```
with lua routing, I'm sure the following code is touched, but no rport in the request
``` function ksr_tm_event(evname) KSR.info("===== tm module triggered event: " .. evname .. "\n"); if evname == "tm:local-request" then KSR.info("===== add local rport =====\n"); KSR.add_local_rport(); end return 1; end ```
``` REGISTER sip:x.y.z SIP/2.0. Via: SIP/2.0/UDP 192.168.7.7:17070;branch=z9hG4bK2474.c07cb8d4000000000000000000000000.0. To: sip:xxxx@x.y.z. ... ```
maybe I can build master code and try.
The `local_rport` is in the master branch.
built master and local_rport is in but seems has no effect.
the lua event callback get called, but as soon as it hit `KSR.add_local_rport();` it crashes. comment out that line doesn't crash.
some bt:
``` Core was generated by `/usr/local/sbin/kamailio -S -DD -dd -E -e -m 32 -M 2 -A KAM_SIP_PORT=9060 -A KA'. Program terminated with signal SIGSEGV, Segmentation fault. #0 t_run_local_req (buf=0x7ffca69c35c8, buf_len=0x7ffca69c35c4, uac_r=0x7ffca69c4a10, new_cell=0x7f3a74d20dd8, request=0x7f3a74d21078) at uac.c:346 346 request->dst.proto = lreq.force_send_socket->proto; (gdb) bt #0 t_run_local_req (buf=0x7ffca69c35c8, buf_len=0x7ffca69c35c4, uac_r=0x7ffca69c4a10, new_cell=0x7f3a74d20dd8, request=0x7f3a74d21078) at uac.c:346 #1 0x00007f3a76fe2cec in t_uac_prepare (uac_r=0x7ffca69c4a10, dst_req=0x7ffca69c3730, dst_cell=0x7ffca69c3728) at uac.c:543 #2 0x00007f3a76fe6058 in t_uac_with_ids (uac_r=0x7ffca69c4a10, ret_index=0x0, ret_label=0x0) at uac.c:749 #3 0x00007f3a76fe6024 in t_uac (uac_r=0x7ffca69c4a10) at uac.c:731 #4 0x00007f3a76fe95c6 in request (uac_r=0x7ffca69c4a10, ruri=0x7ffca69c45f0, to=0x7ffca69c41e0, from=0x7ffca69c41e0, next_hop=0x7f3a74d20768) at uac.c:1099 #5 0x00007f3a7461a40d in uac_reg_send (reg=0x7f3a74d20700, tn=1613489050) at uac_reg.c:1152 #6 0x00007f3a7461ae4d in uac_reg_update (reg=0x7f3a74d20700, tn=1613489050) at uac_reg.c:1211 #7 0x00007f3a7461aef5 in uac_reg_timer (ticks=84554152) at uac_reg.c:1234 #8 0x00007f3a745df4e8 in child_init (rank=0) at uac.c:420 #9 0x000055d3e80e3e45 in init_mod_child (m=0x7f3a77fbca18, rank=0) at core/sr_module.c:861 #10 0x000055d3e80e46e4 in init_child (rank=0) at core/sr_module.c:906 #11 0x000055d3e7f9ffa5 in main_loop () at main.c:1772 #12 0x000055d3e7faa5b9 in main (argc=20, argv=0x7ffca69c5478) at main.c:2895 (gdb) f 0 #0 t_run_local_req (buf=0x7ffca69c35c8, buf_len=0x7ffca69c35c4, uac_r=0x7ffca69c4a10, new_cell=0x7f3a74d20dd8, request=0x7f3a74d21078) at uac.c:346 346 request->dst.proto = lreq.force_send_socket->proto; (gdb) print lreq $1 = {id = 1, pid = 27033, tval = {tv_sec = 0, tv_usec = 0}, fwd_send_flags = {f = 0, blst_imask = 0}, rpl_send_flags = {f = 0, blst_imask = 0}, first_line = {type = 1, flags = 1, len = 37, u = {request = { method = { s = 0x7f3a74d22fa8 "REGISTER sip:xyt.xswitch.cn SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8"..., len = 8}, uri = { s = 0x7f3a74d22fb1 "sip:xyt.xswitch.cn SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab47"..., len = 18}, version = { s = 0x7f3a74d22fc4 "SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab4756667432d70505cb2e-"..., len = 7}, method_value = 32}, reply = {version = { s = 0x7f3a74d22fa8 "REGISTER sip:xyt.xswitch.cn SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8"..., len = 8}, status = { s = 0x7f3a74d22fb1 "sip:xyt.xswitch.cn SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab47"..., len = 18}, reason = { s = 0x7f3a74d22fc4 "SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab4756667432d70505cb2e-"..., len = 7}, statuscode = 32}}}, via1 = 0x7f3a77fdc5d8, via2 = 0x0, headers = 0x7f3a77fdc530, last_header = 0x7f3a77fdc530, parsed_flag = 2, h_via1 = 0x7f3a77fdc530, h_via2 = 0x0, callid = 0x0, to = 0x0, --Type <RET> for more, q to quit, c to continue without paging-- cseq = 0x0, from = 0x0, contact = 0x0, maxforwards = 0x0, route = 0x0, record_route = 0x0, content_type = 0x0, content_length = 0x0, authorization = 0x0, expires = 0x0, proxy_auth = 0x0, supported = 0x0, require = 0x0, proxy_require = 0x0, unsupported = 0x0, allow = 0x0, event = 0x0, accept = 0x0, accept_language = 0x0, organization = 0x0, priority = 0x0, subject = 0x0, user_agent = 0x0, server = 0x0, content_disposition = 0x0, diversion = 0x0, rpid = 0x0, refer_to = 0x0, session_expires = 0x0, min_se = 0x0, sipifmatch = 0x0, subscription_state = 0x0, date = 0x0, identity = 0x0, identity_info = 0x0, pai = 0x0, ppi = 0x0, path = 0x0, privacy = 0x0, min_expires = 0x0, body = 0x0, eoh = 0x0, unparsed = 0x7f3a74d23028 "To: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab4756667432d70505cb2e-62ccedaf\r\nCSeq: 10 REGISTER\r\nCall-ID: 6c7081af46269ed1-27033@172.18.0.4\r\nMax-Forwards: 70\r\nContent-L"..., rcv = {src_ip = {af = 2, len = 4, u = {addrl = {67113644, 0}, addr32 = {67113644, 0, 0, 0}, addr16 = {4780, 1024, 0, 0, 0, 0, 0, 0}, addr = "\254\022\000\004", '\000' <repeats 11 times>}}, dst_ip = {af = 2, len = 4, u = {addrl = {1621362842, 0}, addr32 = {1621362842, 0, 0, 0}, addr16 = {2202, 24740, 0, 0, 0, 0, 0, 0}, addr = "\232\b\244`", '\000' <repeats 11 times>}}, src_port = 9060, dst_port = 18860, proto_reserved1 = 0, proto_reserved2 = 0, src_su = {s = {sa_family = 2, sa_data = "#d\254\022\000\004\000\000\000\000\000\000\000"}, sin = {sin_family = 2, sin_port = 25635, sin_addr = {s_addr = 67113644}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 2, sin6_port = 25635, sin6_flowinfo = 67113644, sin6_addr = {__in6_u = { __u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sas = {ss_family = 2, __ss_padding = "#d\254\022\000\004", '\000' <repeats 111 times>, __ss_align = 0}}, bind_address = 0x7f3a77f8c740, rflags = (unknown: 0), proto = 1 '\001', proto_pad0 = 0 '\000', proto_pad1 = 0}, --Type <RET> for more, q to quit, c to continue without paging-- buf = 0x7f3a74d22fa8 "REGISTER sip:xyt.xswitch.cn SIP/2.0\r\nVia: SIP/2.0/UDP 172.16.131.200:9060;branch=z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0\r\nTo: sip:6077@xyt.xswitch.cn\r\nFrom: sip:6077@xyt.xswitch.cn;tag=313d8"..., len = 442, new_uri = {s = 0x0, len = 0}, dst_uri = {s = 0x7f3a77fdc7d0 "sip:xyt.xswitch.cn:18860", len = 24}, parsed_uri_ok = 0, parsed_uri = {user = {s = 0x0, len = 0}, passwd = {s = 0x0, len = 0}, host = { s = 0x0, len = 0}, port = {s = 0x0, len = 0}, params = {s = 0x0, len = 0}, sip_params = {s = 0x0, len = 0}, headers = {s = 0x0, len = 0}, port_no = 0, proto = 0, type = ERROR_URI_T, flags = (unknown: 0), transport = {s = 0x0, len = 0}, ttl = {s = 0x0, len = 0}, user_param = {s = 0x0, len = 0}, maddr = { s = 0x0, len = 0}, method = {s = 0x0, len = 0}, lr = {s = 0x0, len = 0}, r2 = {s = 0x0, len = 0}, gr = { s = 0x0, len = 0}, transport_val = {s = 0x0, len = 0}, ttl_val = {s = 0x0, len = 0}, user_param_val = { s = 0x0, len = 0}, maddr_val = {s = 0x0, len = 0}, method_val = {s = 0x0, len = 0}, lr_val = {s = 0x0, len = 0}, r2_val = {s = 0x0, len = 0}, gr_val = {s = 0x0, len = 0}}, parsed_orig_ruri_ok = 0, parsed_orig_ruri = {user = {s = 0x0, len = 0}, passwd = {s = 0x0, len = 0}, host = {s = 0x0, len = 0}, port = {s = 0x0, len = 0}, params = {s = 0x0, len = 0}, sip_params = {s = 0x0, len = 0}, headers = { s = 0x0, len = 0}, port_no = 0, proto = 0, type = ERROR_URI_T, flags = (unknown: 0), transport = { s = 0x0, len = 0}, ttl = {s = 0x0, len = 0}, user_param = {s = 0x0, len = 0}, maddr = {s = 0x0, len = 0}, method = {s = 0x0, len = 0}, lr = {s = 0x0, len = 0}, r2 = {s = 0x0, len = 0}, gr = {s = 0x0, len = 0}, transport_val = {s = 0x0, len = 0}, ttl_val = {s = 0x0, len = 0}, user_param_val = {s = 0x0, len = 0}, maddr_val = {s = 0x0, len = 0}, method_val = {s = 0x0, len = 0}, lr_val = {s = 0x0, len = 0}, r2_val = { s = 0x0, len = 0}, gr_val = {s = 0x0, len = 0}}, add_rm = 0x7f3a77fdc8c8, body_lumps = 0x0, reply_lump = 0x0, add_to_branch_s = "z9hG4bKae8.2f46aa8", '0' <repeats 25 times>, ".0", '\000' <repeats 12 times>, add_to_branch_len = 45, hash_index = 0, msg_flags = 2048, flags = 0, xflags = {0, 0}, set_global_address = { --Type <RET> for more, q to quit, c to continue without paging-- s = 0x0, len = 0}, set_global_port = {s = 0x0, len = 0}, force_send_socket = 0x0, path_vec = {s = 0x0, len = 0}, instance = {s = 0x0, len = 0}, reg_id = 0, ruid = {s = 0x0, len = 0}, location_ua = {s = 0x0, len = 0}, otcpid = 0, ldv = {flow = {decoded = 0, rcv = {src_ip = {af = 0, len = 0, u = {addrl = {0, 0}, addr32 = {0, 0, 0, 0}, addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, addr = '\000' <repeats 15 times>}}, dst_ip = {af = 0, len = 0, u = {addrl = {0, 0}, addr32 = {0, 0, 0, 0}, addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, addr = '\000' <repeats 15 times>}}, src_port = 0, dst_port = 0, proto_reserved1 = 0, proto_reserved2 = 0, src_su = {s = {sa_family = 0, sa_data = '\000' <repeats 13 times>}, sin = { sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 0, sin6_port = 0, sin6_flowinfo = 0, sin6_addr = {__in6_u = { __u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = { 0, 0, 0, 0}}}, sin6_scope_id = 0}, sas = {ss_family = 0, __ss_padding = '\000' <repeats 117 times>, __ss_align = 0}}, bind_address = 0x0, rflags = (unknown: 0), proto = 0 '\000', proto_pad0 = 0 '\000', proto_pad1 = 0}}, vdata = 0x0}} (gdb) print *request $2 = {rbtype = 0, flags = 0, t_active = 0, branch = 0, buffer_len = 0, buffer = 0x0, my_T = 0x7f3a74d20dd8, timer = {next = 0x0, prev = 0x0, expire = 0, initial_timeout = 0, data = 0x0, f = 0x7f3a7700bf14 <retr_buf_handler>, flags = 0, slow_idx = 0}, dst = {send_sock = 0x0, to = {s = { sa_family = 2, sa_data = "I\254\232\b\244`\000\000\000\000\000\000\000"}, sin = {sin_family = 2, sin_port = 44105, sin_addr = {s_addr = 1621362842}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = { sin6_family = 2, sin6_port = 44105, sin6_flowinfo = 1621362842, sin6_addr = {__in6_u = { __u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sas = {ss_family = 2, __ss_padding = "I\254\232\b\244`", '\000' <repeats 111 times>, __ss_align = 0}}, id = 0, send_flags = { f = 0, blst_imask = 0}, proto = 1 '\001', proto_pad0 = 0 '\000', proto_pad1 = 0}, retr_expire = 0, fr_expire = 0} (gdb) ```
on the master
``` commit fd8d0f66c80f0ab296bcaff08713a2eb578dd886 (HEAD -> master, origin/master, origin/HEAD) Author: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Feb 15 12:11:33 2021 +0100
Makefile.groups: added secsipid_proc to secsipid group ```
Can you try with a fresh master branch? I just pushed a fix for an issue introduced when adding the support for add_local_rport() in the event route, which was caused by not setting an explicit send socket.
updated and now hit another problem. again, comment out the `add_rport` function removes the err.
``` 11(37206) INFO: <core> [core/kemi.c:105]: sr_kemi_core_info(): ===== tm module triggered event: tm:local-request 11(37206) INFO: <core> [core/kemi.c:105]: sr_kemi_core_info(): ===== add local rport ===== 11(37206) ERROR: <core> [core/parser/parse_hname2.c:235]: parse_sip_header_name(): invalid start of header name for [;received=172.18.0.4To: sip:6077@xyt.xswitch.cn From: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab4756667432d70505cb2e-432aedaf CSeq: 10 REGISTER Call-ID: 61936a7e322da704-37206@172.18.0.4 Max-Forwards: 70 Content-Length: 0 User-Agent: kamailio (5.5.0-dev4 (x86_64/linux)) Contact: sip:a@172.16.131.200:9060 Expires: 300
] 11(37206) ERROR: <core> [core/parser/msg_parser.c:98]: get_hdr_field(): bad header 11(37206) ERROR: <core> [core/parser/msg_parser.c:339]: parse_headers(): bad header field [;received=172.18.0.4To: sip:6077@xyt.xswitch.cn From: sip:6077@xyt.xswitch.cn;tag=313d8852a4ab4] 11(37206) ERROR: tm [uac.c:175]: uac_refresh_hdr_shortcuts(): failed to parse headers in new message 11(37206) ERROR: tm [uac.c:579]: t_uac_prepare(): failed to refresh header shortcuts 11(37206) ERROR: uac [uac_reg.c:1163]: uac_reg_send(): failed to send request for [a] ```
Try now with a fresh master, I pushed some commits trying to fix what I thought can be the issue based on log messages, otherwise I was not able to test myself so far.
thanks a lot, it's working. gloal `local_rport=yes` has no effect. and the event callback works for me.
Closed #2639.
Regarding `local_rport=yes`, it is somehow strange, because the code has the condition:
``` if((ksr_local_rport) || (msg && (msg->msg_flags&FL_ADD_LOCAL_RPORT))) { ```
`ksr_local_rport` corresponds to `local_rport` parameter and `FL_ADD_LOCAL_RPORT` is set by `add_local_rport()`. The cfg value `yes` it is an alias to integer `1`.
Can you double check using `local_rport=yes` and no `event_route[tm:local-request]`? It would be good to sort it out now, when we are on it.
I added some debug log, the `create_via_hf` func is not been called when `FL_ADD_LOCAL_RPORT` is not set, so in the following line it's going to the `else` branch unless force send socket is set.
https://github.com/kamailio/kamailio/blob/master/src/modules/tm/uac.c#L315
The Via header was first time created before execution of `event_route[tm:local-request]`, the condition there is to figure out if it needs updates.
Starting from this, I just looked back into the code and discovered that the tm module does not create Via header first time using create_via_hf(), but another function in the module. I will try to fix it soon.
One more try with a fresh master and let's see if `local_rport=yes` works ... thanks for assistance!
cool. it's working now.