[SR-Users] Extracting and Handling Via Headers in failure_route

2024-07-02 Thread sadik.oualla.mohamed--- via sr-users
Hello,

I am currently working on a scenario where I need to use Kamailio in the 
failure_route to process SIP responses, specifically handling negative SIP 
replies (e.g., 486 Busy Here) that Kamailio may receive.
Here is the topology:
##B2BUA (acts as a UAC with the Kamailio, because it sends the INVITE) -> 
Kamailio -> Callee##

In my setup, Kamailio needs to extract all Via headers from the received SIP 
response in the failure_route, focusing particularly on the bottom Via header 
(from the B2BUA' UAC part). However, I am encountering difficulties in 
achieving this. Here is what I have tried so far:

1. To extract the Via headers, I used the following line of code in the 
failure_route:
  ```$var(viaHeaderValues) = $T_rpl($hdr(Via));```
However, this only returns the topmost Via header.

2. I attempted to get the first and last Via headers values with:
  ```$var(viaHeaderValueFirst) = $T_rpl($hdr(Via)[0]);
 $var(viaHeaderValueLast) = $T_rpl($hdr(Via)[1]);```
   Unfortunately, this also only returns the topmost Via header, which contains 
the address of Kamailio.


My goal is to make sure that when Kamailio sends the SIP reply to the UAC with 
send_reply method on the failure_route, it uses the extracted *Via header* of 
the incoming SIP response (only the bottom one). Here is an example scenario:
- Received SIP Response in kamailio:
  ```
 SIP/2.0 486 Busy Here
 Via: SIP/2.0/UDP 
200.200.200.4;branch=z9hG4bK9157.090080a91105c0ec6279bb56882d1dc8.0
 Via: SIP/2.0/UDP 
200.200.200.3;received=200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m
 From: ;tag=22
 To: ;tag=4545454
 Call-ID: 65695DSQ@200.200.200.3
 CSeq: 1 INVITE
 Content-Length: 0
  ```
- Desired SIP Response from kamailio:
  ```
 SIP/2.0 486 Busy Here
 Via: SIP/2.0/UDP 
200.200.200.3;received=200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m
 From: ;tag=22
 To: ;tag=4545454
 Call-ID: 65695DSQ@200.200.200.3
 CSeq: 1 INVITE
 Content-Length: 0
  ```

The current issue is that Kamailio modifies the Via header when sending the 
reply with send_reply method, resulting in:
  ```
 SIP/2.0 486 Busy Here
 Via: SIP/2.0/UDP 
200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m;received=200.200.200.3
 From: ;tag=22
 To: ;tag=4545454
 Call-ID: 65695DSQ@200.200.200.3
 CSeq: 1 INVITE
 Content-Length: 0
  ```

Due to this change, the UAC does not correctly react to or understand the SIP 
response "SIP Reply follows the RFC standards, but my current UAC waits for a 
Via that looks like Via of the previous SIP messages in the structure of 
parameters.". It is crucial for the Via header to maintain the same important 
order such as the branch, received, and rport values as the previous exchanged 
SIP messages.

Could you please provide guidance on how to force Kamailio to send the SIP 
reply using send_reply method with the extracted bottom Via header from the 
incoming SIP response? Any advice or examples on handling this situation would 
be greatly appreciated.


Thank you for your time and assistance.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Possibility to print values of Core Keywords in Kamailio configuration file

2024-06-20 Thread sadik.oualla.mohamed--- via sr-users
Hello Henning,

Thank you for your reply.

I am using sipsak for testing purposes and learn more about Kamailio, I was 
using SIPp fine before. My goal is to identify the source port from the User 
Agent Client (UAC). Here is the command I use in sipsak to send an OPTIONS ping 
request:
```sipsak -s sip:proxy_server@33.33.33.4:5060 -l 5060```
the -l flag to identify the source port.

In my Kamailio configuration file, I perform a basic check like this:
```
if ($sp != 5040 && $sp != 5060) {
sl_send_reply(403, "Forbidden");
xlog("this $rm received, is forbidden\n");
exit;
}
```
When my Kamailio server receives the OPTIONS request from sipsak, it sends a 
403 error response.
Using sngrep, I observed the following:
```
SIP From= sipsak@33.33.33.99:5060 
SIP To= proxy_server@33.33.33.4:5060
Source: 33.33.33.99:36593
Destination: 33.33.33.4:5060
```

However, the source port appears to be random (36593 in this case) rather than 
the expected 5060. This leads me to believe that Kamailio checks the source 
port from the transport layer (I am not certain about this). The $sp value in 
this case is 36593, not 5060.

I tried several ways to force sipsak to send the packet from port 5060, but I 
couldn't achieve this. While sipsak correctly sets the number port 5060 in the 
From and Via headers, it seems to use a random source port at the transport 
layer.

Cheers,
Mohamed.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Possibility to print values of Core Keywords in Kamailio configuration file

2024-06-20 Thread sadik.oualla.mohamed--- via sr-users
Yes, the pv module has many useful pseudovariables, and many of the core 
keywords can be accessed through pv.

However, I am facing an issue with the source port of the SIP message. When I 
use $sp, it shows the source port of the transport layer, not the SIP 
application layer.

I want to explore other keywords to find the exact SIP application layer source 
port.

Regards,
Mohamed.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Possibility to print values of Core Keywords in Kamailio configuration file

2024-06-20 Thread sadik.oualla.mohamed--- via sr-users
Hello Victor,

I am impressed by how useful and helpful this module is. Thank you very much, I 
have tried it. It is very important to check the status of variables before and 
after a given route, as well as the SIP_IN and SIP_OUT messages.

I have configured the mask parameter with a value of 32. However, I still 
haven't received the core keyword values.

Thank you again, I really needed to know about this module.

Mohamed.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Possibility to print values of Core Keywords in Kamailio configuration file

2024-06-19 Thread sadik.oualla.mohamed--- via sr-users
Hello everyone,

I have a question regarding the usage of core keywords, specifically the 
possibility of printing their values in log messages. While I understand that 
core keywords such as 'dst_port' and 'af' etc... can be accessed directly in if 
conditions, I am interested to know if there is a way to print the values of 
these core keywords for logging purposes.

Thank you.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] How to Check Source Port in Application Layer with Kamailio

2024-06-16 Thread sadik.oualla.mohamed--- via sr-users
Hello kamailio lovers,

I am currently working on a Kamailio configuration where I need to check the 
source port of incoming SIP messages. Initially, I used the $sp pseudo-variable 
to get the source port, which worked perfectly while testing with SIPp.
Here is the snippets code that I use
"
if ($sp != 5080 && $sp != 8080 && $sp != 5060){
sl_send_reply(403, "forbidden");
xlog("this $rm received, is forbidden\n");
exit;
}
"
 However, I encountered an issue when I switched to using sipsak for testing.

It seems that sipsak uses a randomly assigned port for the actual network 
connection, even though it sets the source port in the SIP headers (e.g., Via, 
To and Contact headers) to a specified port using the -l option.
Here is the sipsak command that I use "sipsak -vv -s 
sip:jack@192.168.1.2:5060-l 5080"

My goal is to have Kamailio check the source port as specified in the 
application layer, rather than the transport layer port (i.e., the ephemeral 
port assigned by the OS randomly like 54691, 33017...).

Could anyone guide me on how to properly configure Kamailio to extract and 
check the port from the application layer or SIP headers, or am I doing this in 
the wrong way? Any advice or examples would be greatly appreciated.

"I am not a native english speak, so I use chatGPT to make my questions clear" 

Thank you!
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Kamailio Admin Book email

2024-04-08 Thread sadik.oualla.mohamed--- via sr-users
Hello Daniel,

Following your feedback regarding the incomplete address in my  request, I have 
resubmitted the form with the corrected address format and included "N/A" for 
the VAT number, as I am located outside the EU (in Morocco).

I think that the updated details meet the requirements, but please let me know 
if there's anything further needed from my side to process the purchase 
successfully.

Thank you for your attention to this matter, and I look forward to your 
confirmation.

Sincerely yours, 
Mohamed.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Kamailio Admin Book email

2024-04-07 Thread sadik.oualla.mohamed--- via sr-users
Hello,

Last week, I submitted a request on the Asipto website to purchase the Kamailio 
Admin Book and received an automatic confirmation email. However, I have not 
received any further instructions on how to complete the purchase. I replied to 
the automatic email to follow up, but still, there has been no response. I need 
to get the book as soon as possible.

Please note, I am writing from a different email address than the one I used to 
make the request on Asipto's site. If there are any issues with their contact 
email, or if further verification is needed, please let me know how to proceed 
securely without sharing personal details publicly on this list.

Regards,
Mohamed.
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] failure_route, change_reply_status, and append_hf: Not Working as Expected

2023-09-26 Thread sadik.oualla.mohamed--- via sr-users
Hello Kamailio Community,

I'm currently working on a project that involves complex SIP routing and 
handling. I've encountered some difficulties while using change_reply_status, 
and append_hf functions in  failure_route route in Kamailio. Although the 
documentation does provide guidance, the behaviors I am experiencing aren't 
aligning with the expected outcomes.

Issue 1: failure_route
I've set up a failure_route to handle specific SIP response codes (>4xx). 
However, I've observed that it get trigered and lunched, but I can't use 
change_reply_status or append_hf, I was using this first in onreply_route.

Issue 2: change_reply_status
I tried to use the change_reply_status function to modify the status of SIP 
replies, but it raises an error that this command cannot be executed here.

Issue 3: append_hf
I've also attempted to use append_hf in my failure_route block to add headers 
to replies, but the headers are not being added as expected.

As a workaround, I've been using send_reply and append_to_reply for adding 
custom headers, and they seem to be working as expected. However, I found some 
old messages in kamailio mailing list, I can summerize what I learned like this 
```
#Functions and Context
- append_hf(): Adds a header to the currently processed SIP message. If you are 
in a route {...} block, then this adds the header to the request. If you are in 
an onreply_route, it adds the header to the reply. This function always acts on 
the message currently under scrutiny.

- append_to_reply(): This function is used to add a header to a reply that will 
be generated by Kamailio at a later time. This function only affects replies 
generated by Kamailio itself and is not applicable for messages that are simply 
being forwarded.

#Contexts
- route {...}: This is typically where the incoming SIP request gets processed. 
Here, append_hf() will add headers to that request, and append_to_reply() will 
add headers to any replies that Kamailio might generate for this request.

- onreply_route: This is where incoming SIP replies are processed. Here, 
append_hf() will act on the reply, not the request.
``` I'd like to know if there is a way to handle sip replies in failure_route, 
because send_reply make a new reply from kamailio, instead I want to keep some 
important headers from the original reply.

I'd appreciate any insights or guidance the community can offer.



Best regards,
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe: