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

Juha Heinanen jh at tutpro.com
Mon Nov 9 11:29:59 CET 2009


here is my current example config.  it works for both initial and
in-dial requests and replies from proxies or UAs with one catch:

if initial request goes to a proxy, the example does not detect it and
alias_contact() gets called on reply from the proxy.  it might be
possible to detect it as follows:

store in an avp the number of rr headers the request has when it is sent
out.  when reply comes back, count rr headers again.  if there is more
than what was stored, don't call alias_contact().  by looking at the
messages of example

3.2.  Session Establishment Through Two Proxies

of rfc3665, i think that this is the only possible way to figure this
thing out.

this example does not introduce any changes to the current
implementation of the functions and gives klaus the flexibility he
wants.

-- juha

--------------------------------------------------------

simple scenario usage instructions:

- call alias_contact() for all non-register initial requests, which
  don't come from another proxy, for example:

route [NON_REGISTER_INITIAL_REQUESTS] {
    if (!is_present_hf("Record-Route") && !alias_contact()) {
        xlog("L_ERR", "Error in aliasing contact <$ct>\n");
        send_reply("400", "Bad request");
        exit;
    };
    ...
    t_on_reply("REPLY");
    if (!t_relay()) ...

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

route [REGISTER_REQUESTS] {
    ...
    if (isflagset(FROM_NATED) || (proto == TCP)) {
        fix_nated_register();
	if (isflagset(FROM_NATED)) {
	    setbflag("TO_NATED");
	};
    };
    save("location");
    ...

- call handle_alias() for all in-dialog requests before t_relaying them,
  provided that loose_route() didn't set $du, which it does if next hop
  is another proxy.  in the latter case set TO_PROXY fags to be tested
  in onreply_route.  for example:

route [IN_DIALOG_REQUESTS] {
    loose_route();
    ...
    if ($du == "") {
        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;
         };
    } else {
        setflag(TO_PROXY);
    }
    t_on_reply("REPLY");
    if (!t_relay()) {
        ...

- call alias_contact() on all replies except the ones that come from
  another proxy:

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

- do NOT call fix_nated_contact() on anything.



More information about the sr-dev mailing list