[sr-dev] alias_contact()/handle_alias() ready for testing

Juha Heinanen jh at tutpro.com
Mon Nov 9 06:52:48 CET 2009


i now have alias_contact()/handle_alias() ready for testing.  a new
modules_k/nathelper/nathelper.c for sr_3.0 that includes those functions
is available for limited time as:

http://box.tutpro.com/tmp/nathelper.c

/*
 * Adds ;alias=ip:port param to cotact uri containing received ip:port
 * if contact uri ip:port does not match received ip:port.
 */
static int
alias_contact_f(struct sip_msg* msg, char* str1, char* str2)

/*
 * Checks if r-uri has alias param and if so, removes it and sets $du
 * based on its value.
 */
static int
handle_alias_f(struct sip_msg* msg, char* str1, char* str2)

usage instructions:

- call alias_contact() for all other incoming requests except register
  and for all incoming replies, for example:

route [OTHER_REQUESTS] { # handle other than REGISTER requests
    if (!alias_contact()) {
        xlog("L_ERR", "Error in aliasing contact <$ct>\n");
        send_reply("400", "Bad request");
        exit;
    };
    ...

onreply_route [REPLY] { # handle all replies
    if (!alias_contact()) {
        xlog("L_ERR", "Error in aliasing contact <$ct>\n");
        send_reply("400", "Bad reply");
        exit;
    };
    ...

- call handle_alias() for all in-dialog requests before t_relaying them,
  for example:

route [IN_DIALOG_REQUESTS] { # handle all in-dialog requests
    ...
    handle_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;
    }
    if (!t_relay()) {
    ...

- do NOT call fix_nated_contact() on anything.

- call fix_nated_register() on register requests, if registering ua is
  behind nat OR is using tcp, for example:

    if (isflagset(FROM_NATED) || (proto == TCP)) {
        fix_nated_register();
	if (isflagset(FROM_NATED)) {
	    setbflag("TO_NATED");
	};
    };
    save("location");

that is it.  my config got much simper than what is was before.

i'm on the road and have been able to test this only using twinkle and
sems.  so more testing with different UAs is very welcome.

i consider these two functions a bug fix and would like to include them
into sr3.0.  but fix, because using current means, some in-dialog
requests will have wrong contact uri, i.e., not the one the ua
advertised.

-- juha



More information about the sr-dev mailing list