<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [x] Related to issue #3653
#### Description
<!-- Describe your changes in detail -->
- Contacts are now added at the end of the list.
- hfl(Contact)[index] is now returning in the correct order.
Currently, if a sip message contains multiple Contacts or just 2, let's say
```
Contact: <sip:bob0@example.com>;expires=3600,<sip:bob1@example.com>;expires=3600,<sip:bob2@example.com>;expires=3600
Contact: <sip:bob3@example.com>;expires=3600,<sip:bob4@example.com>;expires=3600,<sip:bob5@example.com>;expires=3600
```
contacts are stored in the reversed order, ie bob2, bob1,bob0 and bob5,bob4,bob3.
This can be seen with a simple config file such as:
```
#kamailio.cfg
...
request_route {
...
xlog("L_INFO", "Contact headers: $hfl(Contact)\n");
xlog("L_INFO", "Contact headers 0: $(hfl(Contact)[0])\n");
xlog("L_INFO", "Contact headers 1: $(hfl(Contact)[1])\n");
xlog("L_INFO", "Contact headers 2: $(hfl(Contact)[2])\n");
xlog("L_INFO", "Contact headers 3: $(hfl(Contact)[3])\n");
xlog("L_INFO", "Contact headers 4: $(hfl(Contact)[4])\n");
xlog("L_INFO", "Contact headers 5: $(hfl(Contact)[5])\n");
xlog("L_INFO", "Contact headers 6: $(hfl(Contact)[6])\n");
xlog("L_INFO", "Contact headers 7: $(hfl(Contact)[7])\n");
xlog("L_INFO", "Contact headers -1: $(hfl(Contact)[-1])\n");
xlog("L_INFO", "Contact headers -2: $(hfl(Contact)[-2])\n");
xlog("L_INFO", "Contact headers -3: $(hfl(Contact)[-3])\n");
xlog("L_INFO", "Contact headers -4: $(hfl(Contact)[-4])\n");
xlog("L_INFO", "Contact headers -5: $(hfl(Contact)[-5])\n");
xlog("L_INFO", "Contact headers -6: $(hfl(Contact)[-6])\n");
```
that prints in the log all the contacts reversed:
```
Contact headers: <sip:bob2@example.com>;expires=3600
Contact headers 0: <sip:bob2@example.com>;expires=3600
Contact headers 1: <sip:bob1@example.com>;expires=3600
Contact headers 2: <sip:bob0@example.com>;expires=3600
Contact headers 3: <sip:bob5@example.com>;expires=3600
Contact headers 4: <sip:bob4@example.com>;expires=3600
Contact headers 5: <sip:bob3@example.com>;expires=3600
Contact headers 6: <null>
Contact headers 7: <null>
Contact headers -1: <sip:bob3@example.com>;expires=3600
Contact headers -2: <sip:bob4@example.com>;expires=3600
Contact headers -3: <sip:bob5@example.com>;expires=3600
Contact headers -4: <sip:bob0@example.com>;expires=3600
Contact headers -5: <sip:bob1@example.com>;expires=3600
Contact headers -6: <sip:bob2@example.com>;expires=3600
```
This PR fixes and produces:
```
Contact headers: <sip:bob0@example.com>;expires=3600
Contact headers 0: <sip:bob0@example.com>;expires=3600
Contact headers 1: <sip:bob1@example.com>;expires=3600
Contact headers 2: <sip:bob2@example.com>;expires=3600
Contact headers 3: <sip:bob3@example.com>;expires=3600
Contact headers 4: <sip:bob4@example.com>;expires=3600
Contact headers 5: <sip:bob5@example.com>;expires=3600
Contact headers 6: <null>
Contact headers 7: <null>
Contact headers -1: <null>
Contact headers -2: <sip:bob5@example.com>;expires=3600
Contact headers -3: <sip:bob4@example.com>;expires=3600
Contact headers -4: <sip:bob3@example.com>;expires=3600
Contact headers -5: <sip:bob2@example.com>;expires=3600
Contact headers -6: <sip:bob1@example.com>;expires=3600
```
The `contact headers -1: <null>` if fixed via #3697.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3698
-- Commit Summary --
* parser/contact: Change addition order to the end of list
-- File Changes --
M src/core/parser/contact/contact.c (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3698.patchhttps://github.com/kamailio/kamailio/pull/3698.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3698
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3698(a)github.com>
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.kamailio…
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.kamailio.o…
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
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
I am working on extending $hfl and $hflc to support some more headers.
During some experimentation, I stumbled into some weird behavior regarding $(hfl(Route)[-1]) and negative indexing of $hfl pseudo-variable (also for Via, Contact).
Per the [docs ](https://www.kamailio.org/wikidocs/cookbooks/devel/pseudovariables/#hflname-header-field-with-list-of-bodies ): -1 index should print the last header found and so on (as stated by $hdr $hfl).
Right now, -1 produces null, and from -2 and onwards it prints correctly from the last one to the first one.
### Troubleshooting
#### Reproduction
```
#kamailio.cfg
...
request_route {
xlog("L_INFO", "Route headers hdr: $hdr(Route)\n");
xlog("L_INFO", "Route headers hfl: $hfl(Route)\n");
xlog("L_INFO", "Route headers count: $hflc(Route)\n");
xlog("L_INFO", "Route headers 0: $(hfl(Route)[0])\n");
xlog("L_INFO", "Route headers 1: $(hfl(Route)[1])\n");
xlog("L_INFO", "Route headers 4: $(hfl(Route)[4])\n");
xlog("L_INFO", "Route headers -1: $(hfl(Route)[-1])\n");
xlog("L_INFO", "Route headers -2: $(hfl(Route)[-2])\n");
xlog("L_INFO", "Route headers -3: $(hfl(Route)[-3])\n");
...
}
```
Seng a SIP message containing Route (but also applicable for VIA, Contact headers):
```
OPTIONS_MSG_2CONTACTS="OPTIONS sip:example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK123456789
Max-Forwards: 70
From: <sip:bob@example.com>;tag=123456789
To: <sip:alice@example.com>
Call-ID: 987654321(a)192.168.1.100
CSeq: 1 OPTIONS
Contact: <sip:bob@example.com>;expires=3600,<sip:bob2@example.com>;expires=3600,<sip:bob3@example.com>;expires=3600
Route: <sip:server1.example.com;lr;ftag=1234>, <sip:server2.example.com;lr;ftag=5678>, <sip:server3.example.com;lr;ftag=9012>
Route: <sip:server4.example.com;lr;ftag=1234>, <sip:server5.example.com;lr;ftag=5678>
Content-Length: 0
"
echo -e "$OPTIONS_MSG_2CONTACTS" | nc -u localhost 5060
```
See logs for logging details.
#### 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).
-->
```
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers hdr: <sip:server1.example.com;lr;ftag=1234>, <sip:server2.example.com;lr;ftag=5678>, <sip:server3.example.com;lr;ftag=9012>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers hfl: <sip:server1.example.com;lr;ftag=1234>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers count: 5
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers 0: <sip:server1.example.com;lr;ftag=1234>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers 1: <sip:server2.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers 4: <sip:server5.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers -1: <null>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers -2: <sip:server5.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321(a)192.168.1.100} <script>: Route headers -3: <sip:server4.example.com;lr;ftag=1234>
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
In https://github.com/kamailio/kamailio/blob/e59c4415707f0995a0d5315b5601ae518…, the count should start at 0 ie.
```
n=0; // not n=1;
```
### 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 `lsb_release -a` and `uname -a`)
-->
```
(paste your output here)
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3653
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3653(a)github.com>
Hello to all.
I have tried to install VoLTE Setup with Kamailio IMS on Ubuntu 18.04 from https://open5gs.org/open5gs/docs/tutorial/02-VoLTE-setup/
in step 16, Install RTPEngine, dpkg-checkbuilddeps have dependencies: libbcg729-dev, which is not in the repository of ubuntu 18.04 to install. How can install it?
dpkg-checkbuilddeps: error: Unmet build dependencies: libbcg729-dev
sudo apt install libbcg729-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libbcg729-dev
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3703
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3703(a)github.com>