Kamailio module nathelper: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
 
Line 2: Line 2:
Kamailio 모듈 nathelper 내용 정리.
Kamailio 모듈 nathelper 내용 정리.


== Functions ==
=== handle_ruri_alias([mode]) ===
Checks if the Request URI has an "alias" parameter and if so, removes it and sets the "$du" based on its value. Note that this means that routing of request is based on ";alias" parameter value of the Request URI rather than the Request URI itself. If you call handle_ruri_alias() on a request, make sure that you screen the alias parameter value of Request URI the same ways as you would screen the Request URI itself.
The optional parameter mode can be 0 to consume first alias parameter, otherwise it consumes the last alias parameter. If the parameter mode is not provided, it consumes the first parameter.
Returns 1 if ";alias" parameter was found and "$du" was set and the "$ru" rewrite, 2 if the alias parameter was not found and nothing was done, or -1 in case of error.
<pre>
...
    if ($du == "") {
        handle_ruri_alias();
        switch ($rc) {
        case -1:
            xlog("L_ERR", "Failed to handle alias of R-URI $ru\n");
            send_reply("400", "Bad request");
            exit;
        case 1:
            xlog("L_INFO", "Routing in-dialog $rm from $fu to $du\n");
            break;
        case 2:
            xlog("L_INFO", "Routing in-dialog $rm from $fu to $ru\n");
            break;
        };
    };
...
</pre>


== Functions ==
=== set_contact_alias([trim]) ===
=== set_contact_alias([trim]) ===
Adds an ";alias=ip~port~transport" parameter to the contact URI containing the received ip, port, and transport protocol. The new contact URI is immediately visible to other modules in the way the fix_nated_contact() does it.
Adds an ";alias=ip~port~transport" parameter to the contact URI containing the received ip, port, and transport protocol. The new contact URI is immediately visible to other modules in the way the fix_nated_contact() does it.

Latest revision as of 16:33, 15 June 2022

Overview

Kamailio 모듈 nathelper 내용 정리.

Functions

handle_ruri_alias([mode])

Checks if the Request URI has an "alias" parameter and if so, removes it and sets the "$du" based on its value. Note that this means that routing of request is based on ";alias" parameter value of the Request URI rather than the Request URI itself. If you call handle_ruri_alias() on a request, make sure that you screen the alias parameter value of Request URI the same ways as you would screen the Request URI itself.

The optional parameter mode can be 0 to consume first alias parameter, otherwise it consumes the last alias parameter. If the parameter mode is not provided, it consumes the first parameter.

Returns 1 if ";alias" parameter was found and "$du" was set and the "$ru" rewrite, 2 if the alias parameter was not found and nothing was done, or -1 in case of error.

...
    if ($du == "") {
        handle_ruri_alias();
        switch ($rc) {
        case -1:
            xlog("L_ERR", "Failed to handle alias of R-URI $ru\n");
            send_reply("400", "Bad request");
            exit;
        case 1:
            xlog("L_INFO", "Routing in-dialog $rm from $fu to $du\n");
            break;
        case 2:
            xlog("L_INFO", "Routing in-dialog $rm from $fu to $ru\n");
            break;
         };
    };
...

set_contact_alias([trim])

Adds an ";alias=ip~port~transport" parameter to the contact URI containing the received ip, port, and transport protocol. The new contact URI is immediately visible to other modules in the way the fix_nated_contact() does it.

  • trim: by default, set_contact_alias() will not detect and trim an already existing alias parameter. If this optional parameter is set to "1", set_contact_alias() will trim the existing alias before adding a new one.
...
    if (!is_present_hf("Record-Route")) {
        if (!set_contact_alias()) {
            xlog("L_ERR", "Error in aliasing contact $ct\n");
            send_reply("400", "Bad request");
            exit;
        };
    };
...

See also